Skip to content

Instantly share code, notes, and snippets.

@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": [
{

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 / 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)
@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 / 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 / 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
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
@rokroskar
rokroskar / local_bloomberg_sparkgrams.ipynb
Last active August 29, 2015 14:06
example sparkgrams package usage
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rokroskar
rokroskar / example.ipynb
Created October 22, 2014 12:27
example broken notebook/slide render
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.