Skip to content

Commit

Permalink
Make reader more generic
Browse files Browse the repository at this point in the history
  • Loading branch information
robjmcgibbon committed Jun 18, 2024
1 parent fda13e2 commit 143d65f
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 117 deletions.
3 changes: 3 additions & 0 deletions swiftsimio/metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
from .particle import particle_types
from .particle import particle_fields

from .fof import fof_types
from .fof import fof_fields

from .unit import unit_types
from .unit import unit_fields

Expand Down
2 changes: 2 additions & 0 deletions swiftsimio/metadata/fof/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .fof_fields import *
from .fof_types import *
67 changes: 67 additions & 0 deletions swiftsimio/metadata/fof/fof_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
"""
Contains the particle fields for the various particle types.
"""

# TODO: Decide what fields are needed here
shared = {
"Coordinates": "coordinates",
"Masses": "masses",
"ParticleIDs": "particle_ids",
"Velocities": "velocities",
"Potential": "potential",
}

baryon = {
"ElementAbundance": "element_abundance",
"Maximal Temperature": "maximal_temperature",
"Maximal Temperature scale-factor": "maximal_temperature_scale_factor",
"Maximal Temperature time": "maximal_temperature_time",
"IronMassFracFromSNIa": "iron_mass_frac_from_sn1a",
"MetalMassFracFromAGB": "metal_mass_frac_from_agb",
"MetalMassFracFromSNII": "metal_mass_frac_from_snii",
"MetalMassFracFromSNIa": "metal_mass_frac_from_sn1a",
"Metallicity": "metallicity",
"SmoothedElementAbundance": "smoothed_element_abundance",
"SmoothedIronMassFracFromSNIa": "smoothed_iron_mass_frac_from_sn1a",
"SmoothedMetallicity": "smoothed_metallicity",
"TotalMassFromAGB": "total_mass_from_agb",
"TotalMassFromSNII": "total_mass_from_snii",
}

gas = {
"Density": "density",
"Entropy": "entropy",
"InternalEnergy": "internal_energy",
"SmoothingLength": "smoothing_length",
"Pressure": "pressure",
"Diffusion": "diffusion",
"SFR": "sfr",
"Temperature": "temperature",
"Viscosity": "viscosity",
"sSFR": "specific_sfr",
"MaterialID": "material_id",
"Diffusion": "diffusion",
"Viscosity": "viscosity",
"RadiatedEnergy": "radiated_energy",
**shared,
**baryon,
}

dark_matter = {**shared}

boundary = {**shared}

sinks = {**shared}

stars = {
"BirthDensity": "birth_density",
"BirthTime": "birth_time",
"InitialMasses": "initial_masses",
"SmoothingLength": "smoothing_length",
**shared,
**baryon,
}

black_holes = {**shared}

neutrinos = {**shared}
10 changes: 10 additions & 0 deletions swiftsimio/metadata/fof/fof_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
Includes the fancy names.
"""

# Describes the conversion of hdf5 group names to swiftsimio names
fof_name_underscores = {"Groups": "fof_groups"}

fof_name_class = {"Groups": "FOFGroups"}

fof_name_text = {"Groups": "FOF Groups"}
1 change: 1 addition & 0 deletions swiftsimio/metadata/metadata/metadata_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"NumPart_ThisFile": "num_part",
"CanHaveTypes": "has_type",
"NumFilesPerSnapshot": "num_files_per_snapshot",
"OutputType": "output_type",
}

# Some of these 'arrays' are really types of mass table, so unpack
Expand Down
42 changes: 21 additions & 21 deletions swiftsimio/metadata/particle/particle_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@

# Describes the conversion of particle types to names
particle_name_underscores = {
0: "gas",
1: "dark_matter",
2: "boundary",
3: "sinks",
4: "stars",
5: "black_holes",
6: "neutrinos",
"PartType0": "gas",
"PartType1": "dark_matter",
"PartType2": "boundary",
"PartType3": "sinks",
"PartType4": "stars",
"PartType5": "black_holes",
"PartType6": "neutrinos",
}

particle_name_class = {
0: "Gas",
1: "DarkMatter",
2: "Boundary",
3: "Sinks",
4: "Stars",
5: "BlackHoles",
6: "Neutrinos",
"PartType0": "Gas",
"PartType1": "DarkMatter",
"PartType2": "Boundary",
"PartType3": "Sinks",
"PartType4": "Stars",
"PartType5": "BlackHoles",
"PartType6": "Neutrinos",
}

particle_name_text = {
0: "Gas",
1: "Dark Matter",
2: "Boundary",
3: "Sinks",
4: "Stars",
5: "Black Holes",
6: "Neutrinos",
"PartType0": "Gas",
"PartType1": "Dark Matter",
"PartType2": "Boundary",
"PartType3": "Sinks",
"PartType4": "Stars",
"PartType5": "Black Holes",
"PartType6": "Neutrinos",
}
Loading

0 comments on commit 143d65f

Please sign in to comment.