How to use the pynbody.load function in pynbody

To help you get started, we’ve selected a few pynbody examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pynbody / pynbody / pynbody / analysis / ramses_util.py View on Github external
"""
    Convert RAMSES file `output` to tipsy format readable by pkdgrav
    and Amiga Halo Finder. Does all unit conversions etc. into the
    pkdgrav unit system. Creates a file called `output_fullbox.tipsy`.

    **Input**: 

    *output*: name of RAMSES output

    **Optional Keywords**:

    *write_param*: whether or not to write the parameter file (default = True)

    """

    s = pynbody.load(output)

    lenunit, massunit, timeunit = get_tipsy_units(s)

#    l_unit = Unit('%f kpc'%lenunit)
#    t_unit = Unit('%f Gyr'%timeunit)
    velunit = lenunit / timeunit

    tipsyfile = "%s_fullbox.tipsy" % (output)

    s['mass'].convert_units(massunit)
    s.g['temp']

    # get the appropriate tform
    get_tform(s)
    s.g['metals'] = s.g['metal']
    s['pos'].convert_units(lenunit)
github pynbody / pynbody / docs / tutorials / example_code / velocity_vectors.py View on Github external
import pynbody
import pynbody.plot.sph as sph
import matplotlib.pylab as plt

# load the snapshot and set to physical units
s = pynbody.load('testdata/g15784.lr.01024.gz')
s.physical_units()

# load the halos
h = s.halos()

# center on the largest halo and align the disk
pynbody.analysis.angmom.sideon(h[1])

# create the subplots
f, axs = plt.subplots(1,2,figsize=(14,6))

#create a simple slice showing the gas temperature, with velocity vectors overlaid
sph.velocity_image(h[1].g, vector_color="cyan", qty="temp",width=50,cmap="YlOrRd", 
                   denoise=True,approximate_fast=False, subplot=axs[0], show_cbar = False)

#you can also make a stream visualization instead of a quiver plot
github pynbody / pynbody / docs / tutorials / example_code / density_integrated.py View on Github external
import pynbody
import pynbody.plot.sph as sph
import matplotlib.pylab as plt

# load the snapshot and set to physical units
s = pynbody.load('testdata/g15784.lr.01024.gz')
s.physical_units()

# load the halos
h = s.halos()

# center on the largest halo and align the disk
pynbody.analysis.angmom.faceon(h[1])

#create an image of gas density integrated down the line of site (z axis)
sph.image(h[1].g,qty="rho",units="g cm^-2",width=100,cmap="Greys")
github pynbody / pynbody / tutorials / example_code / velocity_vectors.py View on Github external
import pynbody
import pynbody.plot.sph as sph
import matplotlib.pylab as plt

# load the snapshot and set to physical units
s = pynbody.load('testdata/g15784.lr.01024.gz')
s.physical_units()

# load the halos
h = s.halos()

# center on the largest halo and align the disk
pynbody.analysis.angmom.sideon(h[1])

# create the subplots
f, axs = plt.subplots(1,2,figsize=(14,6))

#create a simple slice showing the gas temperature, with velocity vectors overlaid
sph.velocity_image(h[1].g, vector_color="cyan", qty="temp",width=50,cmap="YlOrRd", 
                   denoise=True,approximate_fast=False, subplot=axs[0], show_cbar = False)

#you can also make a stream visualization instead of a quiver plot
github pynbody / pynbody / tutorials / example_code / density_slice.py View on Github external
import pynbody
import pynbody.plot.sph as sph
import matplotlib.pylab as plt

# load the snapshot and set to physical units
s = pynbody.load('testdata/g15784.lr.01024.gz')
s.physical_units()

# load the halos
h = s.halos()

# center on the largest halo and align the disk
pynbody.analysis.angmom.faceon(h[1])

#create a simple slice of gas density
sph.image(h[1].g,qty="rho",units="g cm^-3",width=100,cmap="Greys")
github pynbody / pynbody / pynbody / halo / __init__.py View on Github external
def load_copy(self, i):
        """Load the a fresh SimSnap with only the particle in halo i"""
        from .. import load
        return load(self.base.filename, take=self._get_halo_indices(i))
github pynbody / pynbody / pynbody / halo.py View on Github external
def load_copy(self, i):
        """Load a fresh SimSnap with only the particles in halo i"""
        if i>=len(self):
            raise KeyError, "No such halo"

        from . import load
        halo = load(self.base.filename, take=self._get_particles_for_halo(i))
        self._add_halo_id(halo, i)
        return halo
github pynbody / pynbody / docs / tutorials / example_code / density_slice.py View on Github external
import pynbody
import pynbody.plot.sph as sph
import matplotlib.pylab as plt

# load the snapshot and set to physical units
s = pynbody.load('testdata/g15784.lr.01024.gz')
s.physical_units()

# load the halos
h = s.halos()

# center on the largest halo and align the disk
pynbody.analysis.angmom.faceon(h[1])

#create a simple slice of gas density
sph.image(h[1].g,qty="rho",units="g cm^-3",width=100,cmap="Greys")
github pynbody / pynbody / docs / tutorials / example_code / temperature_slice.py View on Github external
import pynbody
import pynbody.plot.sph as sph
import matplotlib.pylab as plt

# load the snapshot and set to physical units
s = pynbody.load('testdata/g15784.lr.01024.gz')
s.physical_units()

# load the halos
h = s.halos()

# center on the largest halo and align the disk
pynbody.analysis.angmom.sideon(h[1])

#create a simple slice showing the gas temperature
sph.image(h[1].g,qty="temp",width=50,cmap="YlOrRd", denoise=True,approximate_fast=False)
github pynbody / pynbody / pynbody / halo / ahf.py View on Github external
"""Load the a fresh SimSnap with only the particle in halo i"""

        from .. import load

        if self._dosort is not None:
            i = self._sorted_indices[i-1]

        f = util.open_(self._ahfBasename + 'particles')

        fpos = self._halos[i].properties['fstart']
        f.seek(fpos,0)
        ids = self._load_ahf_particle_block(f, nparts=self._halos[i].properties['npart'])

        f.close()

        return load(self.base.filename, take=ids)