gizio.spec module

Snapshot format specification.

class gizio.spec.SpecBase[source]

Bases: abc.ABC

Snapshot format specification base class.

HEADER_BLOCK = None
HEADER_N_PART = None
HEADER_PER_FILE = None
HEADER_SPEC = None
UNIT_SPEC = None
PTYPE_SPEC = None
FIELD_SPEC = None
apply_to(snap)[source]

Apply specification to snapshot.

Parameters

snap (Snapshot) – The snapshot to apply to.

Returns

  • header (dict) – Snapshot header.

  • shape (collections.OrderedDict) – Data shape composed of {ptype_name: n_part} entries, in the specification ptypes order.

  • cosmology (astropy.cosmology.LambdaCDM) – An astropy cosmology calculator.

  • unit_registry (unyt.unit_registry.UnitRegistry) – Simulation unit registry.

register_derived_fields(ps, ptype)[source]

Register default derived fields to a field system.

Parameters
  • ps (ParticleSelector) – The particle selector to register fields to.

  • ptype (str) – The particle type to register fields with.

class gizio.spec.GIZMOSpec[source]

Bases: gizio.spec.SpecBase

GIZMO snapshot format specification.

HEADER_BLOCK = 'Header'
HEADER_N_PART = 'n_part'
HEADER_PER_FILE = ['NumPart_ThisFile']
HEADER_SPEC = [('Time', 'time'), ('NumFilesPerSnapshot', 'n_file'), ('MassTable', 'mass_tab'), ('Flag_Sfr', 'f_sfr'), ('Flag_Cooling', 'f_cool'), ('Flag_Feedback', 'f_fb'), ('Flag_StellarAge', 'f_age'), ('Flag_Metals', 'f_met'), ('NumPart_Total', 'n_part'), ('NumPart_ThisFile', 'n_part_pf'), ('BoxSize', 'box_size'), ('Omega0', 'Om0'), ('OmegaLambda', 'OmL'), ('HubbleParam', 'h'), ('Redshift', 'z')]
UNIT_SPEC = {'SolarAbundance': 0.02, 'UnitLength_in_cm': 3.085678e+21, 'UnitMagneticField_in_gauss': 1.0, 'UnitMass_in_g': 1.989e+43, 'UnitVelocity_in_cm_per_s': 100000.0}
PTYPE_SPEC = [('PartType0', 'gas'), ('PartType1', 'hdm'), ('PartType2', 'ldm'), ('PartType3', 'dum'), ('PartType4', 'star'), ('PartType5', 'bh')]
FIELD_SPEC = [('Coordinates', 'p', 'code_length'), ('Velocities', 'v', 'code_velocity'), ('ParticleIDs', 'id', ''), ('Masses', 'm', 'code_mass'), ('InternalEnergy', 'u', 'code_specific_energy'), ('Density', 'rho', 'code_mass / code_length**3'), ('SmoothingLength', 'h', 'code_length'), ('ElectronAbundance', 'ne', ''), ('NeutralHydrogenAbundance', 'nh', ''), ('StarFormationRate', 'sfr', 'Msun / yr'), ('Metallicity', 'z', 'code_metallicity'), ('ArtificialViscosity', 'alpha', ''), ('MagneticField', 'b', 'code_magnetic_field'), ('DivergenceOfMagneticField', 'divb', 'code_magnetic_field / code_length'), ('StellarFormationTime', 'sft', ''), ('BH_Mass', 'mbh', 'code_mass'), ('BH_Mdot', 'mdot', 'code_mass / code_time'), ('BH_Mass_AlphaDisk', 'mad', 'code_mass')]
register_derived_fields(ps, ptype)[source]

Register default derived fields to a field system.

Parameters
  • ps (ParticleSelector) – The particle selector to register fields to.

  • ptype (str) – The particle type to register fields with.

static compute_age(ps)[source]

Compute age from formation time.

Parameters

ps (ParticleSelector) – A particle selector.

Returns

The age array.

Return type

unyt.unyt_array

static compute_temperature(ps)[source]

Compute temperature from internal energy.

Parameters

ps (ParticleSelector) – A particle selector.

Returns

The temperature array.

Return type

unyt.unyt_array