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.
| { | |
| "metadata": { | |
| "name": "pynbody_demo" | |
| }, | |
| "nbformat": 3, | |
| "nbformat_minor": 0, | |
| "worksheets": [ | |
| { | |
| "cells": [ | |
| { |
| 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) |
| """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 |
| { | |
| "metadata": { | |
| "name": "", | |
| "signature": "sha256:51674423333905e7630a6f70f9aed7a81e31205a98f3620d90a7374eb69f0931" | |
| }, | |
| "nbformat": 3, | |
| "nbformat_minor": 0, | |
| "worksheets": [ | |
| { | |
| "cells": [ |
| 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 |
| import marisa_trie | |
| from sklearn.feature_extraction.text import CountVectorizer, _make_int_array | |
| import numpy as np | |
| import scipy.sparse as sp | |
| from itertools import chain | |
| class MarisaCountVectorizer(CountVectorizer): | |
| """ | |
| Extension of Scikit-learn CountVectorizer class using the | |
| MARISA-trie python wrapper from https://github.com/kmike/marisa-trie |