Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SOAP/core/swift_cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def __call__(self, data, cache):
np.s_[mem_start:mem_end, ...],
)
except OSError as e:
print(f'Error reading {dataset_name}')
print(f"Error reading {dataset_name}")
raise e


Expand Down
73 changes: 39 additions & 34 deletions SOAP/property_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -4938,11 +4938,15 @@ def add_properties(self, halo_property: HaloProperty, halo_type: str):
units = unyt.unyt_quantity(1, units=prop.unit)
if not prop.output_physical:
units = units * unyt.Unit("a") ** prop.a_scale_exponent
prop_unit = units.units.latex_repr.replace(
"\\rm{km} \\cdot \\rm{kpc}", "\\rm{kpc} \\cdot \\rm{km}"
).replace(
"\\frac{\\rm{km}^{2}}{\\rm{s}^{2}}", "\\rm{km}^{2} / \\rm{s}^{2}"
).rstrip()
prop_unit = (
units.units.latex_repr.replace(
"\\rm{km} \\cdot \\rm{kpc}", "\\rm{kpc} \\cdot \\rm{km}"
)
.replace(
"\\frac{\\rm{km}^{2}}{\\rm{s}^{2}}", "\\rm{km}^{2} / \\rm{s}^{2}"
)
.rstrip()
)

prop_dtype = prop.dtype.__name__

Expand Down Expand Up @@ -5336,9 +5340,9 @@ def replace_math(match):
# Map from internal snap_* unit names to human-readable physical equivalents.
# Values are validated against the live unyt registry by _validate_snap_unit_map.
_snap_unit_map = {
"snap_mass": "(1e10*Msun)",
"snap_length": "Mpc",
"snap_time": "(s*Mpc/km)",
"snap_mass": "(1e10*Msun)",
"snap_length": "Mpc",
"snap_time": "(s*Mpc/km)",
"snap_temperature": "K",
}

Expand All @@ -5359,8 +5363,9 @@ def _resolve_snap_units(self, prop_name: str, prop: dict) -> str:

units = unyt.unyt_quantity(1, units=prop_unit)
latex = (
units.units.latex_repr
.replace("\\rm{km} \\cdot \\rm{kpc}", "\\rm{kpc} \\cdot \\rm{km}")
units.units.latex_repr.replace(
"\\rm{km} \\cdot \\rm{kpc}", "\\rm{kpc} \\cdot \\rm{km}"
)
.replace("\\frac{\\rm{km}^{2}}{\\rm{s}^{2}}", "\\rm{km}^{2} / \\rm{s}^{2}")
.replace(r"1.0 \times ", "")
.rstrip()
Expand Down Expand Up @@ -5450,10 +5455,7 @@ def get_footnotes_rst(self, name: str) -> tuple[list[int], str]:
self.footnotes.append(fnote)
footnote_nums.append(i + 1)
if footnote_nums:
refs = " ".join(
f"`[{n}] <footnote-{n}_>`_"
for n in sorted(footnote_nums)
)
refs = " ".join(f"`[{n}] <footnote-{n}_>`_" for n in sorted(footnote_nums))
return footnote_nums, refs
return [], ""

Expand Down Expand Up @@ -5529,7 +5531,9 @@ def enumerate_to_rst(match):
# Convert inline math and non-breaking spaces within the
# item text now, before the block is stashed as a
# placeholder (the main conversion steps run before restore)
item = re.sub(r"\$([^\n\$]+?)\$", lambda m: f":math:`{m.group(1)}`", item)
item = re.sub(
r"\$([^\n\$]+?)\$", lambda m: f":math:`{m.group(1)}`", item
)
item = item.replace("~", " ")
rst_items.append(f"#. {item}")
block = "\n\n" + "\n".join(rst_items) + "\n\n"
Expand Down Expand Up @@ -5640,24 +5644,24 @@ def _build_rst_table(self, prop_names: list, lines: list):

# swiftsimio name
snake_name = ".".join(
self._camel_to_snake(part) for part in prop['name'].split("/")
self._camel_to_snake(part) for part in prop["name"].split("/")
)

# HDF5 output name (prepend InputHalos/ where applicable)
output_name = prop["name"]
if output_name.split("/")[0] in ("HBTplus", "VR", "FOF"):
output_name = "InputHalos/" + output_name
snake_name = 'input_halos_' + snake_name
snake_name = "input_halos_" + snake_name

prop_units_rst = self._resolve_snap_units(prop_name, prop)
prop_comp_rst = self._compression_to_rst(
self.compression_description[prop["compression"]]
)
prop_filter = prop['category']
prop_filter = prop["category"]
output_types = self._get_output_types_rst(prop)
if 'DummyProperties' in prop['types']:
prop_filter = 'basic'
output_types = r'\-'
if "DummyProperties" in prop["types"]:
prop_filter = "basic"
output_types = r"\-"
description = prop["description"].format(
label="satisfying a spherical overdensity criterion.",
core_excision="excised core",
Expand Down Expand Up @@ -5713,9 +5717,11 @@ def generate_rst_files(self, output_dir: str):
prop_names_sorted = sorted(
self.properties.keys(),
key=lambda key: (
category_order.index(self.properties[key]["category"])
if self.properties[key]["category"] in category_order
else len(category_order),
(
category_order.index(self.properties[key]["category"])
if self.properties[key]["category"] in category_order
else len(category_order)
),
self.properties[key]["name"].lower(),
),
)
Expand All @@ -5726,11 +5732,11 @@ def generate_rst_files(self, output_dir: str):
dmo_props = []
hydro_props = []
for n in prop_names_sorted:
if self.properties[n]['category'] == 'InputHalos':
if self.properties[n]["category"] == "InputHalos":
input_basic_props.append(n)
elif 'DummyProperties' in self.properties[n]['types']:
elif "DummyProperties" in self.properties[n]["types"]:
input_copied_props.append(n)
elif self.properties[n]['dmo']:
elif self.properties[n]["dmo"]:
dmo_props.append(n)
else:
hydro_props.append(n)
Expand All @@ -5740,16 +5746,16 @@ def generate_rst_files(self, output_dir: str):
self.footnotes = []

# Introduction
with open(f'documentation/property_table_intro.rst') as file:
with open(f"documentation/property_table_intro.rst") as file:
lines = [line.rstrip() for line in file.readlines()]

# Tables
for props, table_title in [
(input_basic_props, "Input halo properties"),
(dmo_props, "Dark matter only properties"),
(hydro_props, "Hydrodynamical properties"),
(input_copied_props, "Copied properties"),
]:
(input_basic_props, "Input halo properties"),
(dmo_props, "Dark matter only properties"),
(hydro_props, "Hydrodynamical properties"),
(input_copied_props, "Copied properties"),
]:

lines.append(table_title)
lines.append("-" * len(table_title))
Expand Down Expand Up @@ -5778,7 +5784,6 @@ def generate_rst_files(self, output_dir: str):
ofile.write("\n".join(lines))



class DummyProperties:
"""
Dummy HaloProperty object used to include properties which are not computed
Expand Down
2 changes: 1 addition & 1 deletion tests/FLAMINGO/parameters_HYDRO.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ GroupMembership:
filename: "{sim_dir}/{sim_name}/SOAP-HBT/membership_{snap_nr:04d}/membership_{snap_nr:04d}.{file_nr}.hdf5"

ExtraInput:
xrays: "/cosma8/data/dp004/dc-mcgi1/FLAMINGO/Xray/{sim_name}/xray/flamingo_{snap_nr:04}/xray_{snap_nr:04}.{file_nr}.hdf5"
xrays: "/cosma8/data/dp004/dc-mcgi1/SOAP/TEST_DATA/Xray/{sim_name}/xray/flamingo_{snap_nr:04}/xray_{snap_nr:04}.{file_nr}.hdf5"

HaloProperties:
# Where to write the halo properties file
Expand Down
Loading