Skip to content

Commit

Permalink
fix amr parsing for variable columns
Browse files Browse the repository at this point in the history
  • Loading branch information
wtbarnes committed Nov 7, 2024
1 parent 014ced4 commit fa84101
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ site/
docs/api/*
docs/config_tables.rst
docs/generated
docs/sg_execution_times.rst

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
2 changes: 1 addition & 1 deletion examples/configure_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# Mm loop lasting 5000 s heated by a single 200 s nanoflare
# solved on an adaptive grid.
# A complete list of configuration parameters can be found in
# the `configuration-tables`_ page.
# the :ref:`configuration-tables` page.
config_dict = {
'general': {
'loop_length': 80*u.Mm,
Expand Down
2 changes: 1 addition & 1 deletion examples/parse_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
# single time step as a function of field-aligned coordinate.
# The `~pydrad.parse.Profile` object provides a simple quicklook
# method for this,
s[0].peek()
p.peek()

#################################################################
# Similarly, we can call this method on a `~pydrad.parse.Strand` to
Expand Down
16 changes: 11 additions & 5 deletions pydrad/parse/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ def read_amr_file(filename):
'electron_energy_density',
'ion_energy_density',
]
# FIXME: Get actual names for these additional columns
columns += [f'col{i}' for i in range(6,19)]
units = {
'grid_centers': 'cm',
'grid_widths': 'cm',
Expand All @@ -44,13 +42,21 @@ def read_amr_file(filename):
'electron_energy_density': 'erg cm-3',
'ion_energy_density': 'erg cm-3',
}
return astropy.table.QTable.read(
table = astropy.table.QTable.read(
filename,
format='ascii',
data_start=4,
names=columns,
units=units,
)
# NOTE: This is done after creating the table because the
# remaining number of columns can be variable and thus we
# cannot assign all of the column names at once.
table.rename_columns(
table.colnames[:len(columns)],
columns,
)
for column in columns:
table[column].unit = units[column]
return table


def read_phy_file(filename):
Expand Down

0 comments on commit fa84101

Please sign in to comment.