Skip to content

Instantly share code, notes, and snippets.

@rokroskar
rokroskar / ramses_tform.py
Created April 30, 2014 10:14
ramses tform derived quantity using part2birth
import pynbody
part2birth = '/home/itp/roskar/ramses/galaxy_formation/part2birth'
@pynbody.ramses.RamsesSnap.derived_quantity
def tform(self) :
"""Generate a tform array that is compatible with pynbody unit system
and will allow one to get the ages of stars.
make sure the 'part2birth' above corresponds to the location of the executable on your machine
@rokroskar
rokroskar / pynbody_actions
Last active August 29, 2015 14:00
actions notebook
{
"metadata": {
"name": "",
"signature": "sha256:51674423333905e7630a6f70f9aed7a81e31205a98f3620d90a7374eb69f0931"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@rokroskar
rokroskar / test_openmp.py
Created April 9, 2014 13:52
openmp test
"""Check whether the default compiler supports OpenMP.
This routine is adapted from yt, thanks to Nathan
Goldbaum. See https://github.com/pynbody/pynbody/issues/124"""
import tempfile
import os
import sysconfig
import subprocess
import shutil
@rokroskar
rokroskar / ramses_to_AHF.py
Last active August 29, 2015 13:56
Saving ramses outputs in gasoline format to use with AHF
def prepare_for_amiga(outname, write = False, run_amiga=False) :
"""
Takes a RAMSES output and turns it into a 'tipsy' file for use with
tipsy, pkdgrav, or AHF
"""
import os
from pynbody.units import Unit
s = pynbody.load(outname)

Simple class for generating actions for particles in a simulation that can be read using pynbody. The action calculation is done with galpy.

See the notebook for an example.

@rokroskar
rokroskar / pynbody demo session
Last active December 18, 2015 09:19
A python notebook that demonstrates some basic pynbody functionality
{
"metadata": {
"name": "pynbody_demo"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{