Skip to content

Commit

Permalink
Fix classic 3d model read (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeshingles authored May 9, 2023
1 parent ee4aeff commit fe358ff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions artistools/inputmodel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import artistools.inputmodel.botyanski2017
import artistools.inputmodel.describeinputmodel
import artistools.inputmodel.downscale3dgrid
import artistools.inputmodel.energyinputfiles
import artistools.inputmodel.makeartismodel
import artistools.inputmodel.maketardismodelfromartis
import artistools.inputmodel.modelfromhydro
import artistools.inputmodel.opacityinputfile
import artistools.inputmodel.rprocess_from_trajectory
Expand Down
15 changes: 10 additions & 5 deletions artistools/inputmodel/inputmodel_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def read_modelfile_text(

data_line_even = fmodel.readline().split()
ncols_line_even = len(data_line_even)
ncols_line_odd = len(fmodel.readline().split())

if columns is None:
if modelmeta["dimensions"] == 1:
Expand All @@ -123,7 +124,7 @@ def read_modelfile_text(
"X_Cr48",
"X_Ni57",
"X_Co57",
][:ncols_line_even]
]

elif modelmeta["dimensions"] == 2:
columns = [
Expand All @@ -138,7 +139,7 @@ def read_modelfile_text(
"X_Cr48",
"X_Ni57",
"X_Co57",
][:ncols_line_even]
]

elif modelmeta["dimensions"] == 3:
columns = [
Expand All @@ -154,10 +155,15 @@ def read_modelfile_text(
"X_Cr48",
"X_Ni57",
"X_Co57",
][:ncols_line_even]
]
# last two abundances are optional
assert columns is not None
assert len(columns) == (ncols_line_even + ncols_line_odd) or len(columns) == (
ncols_line_even + ncols_line_odd + 2
)
columns = columns[: ncols_line_even + ncols_line_odd]

assert columns is not None

if ncols_line_even == len(columns):
if not printwarningsonly:
print(" model file is one line per cell")
Expand All @@ -167,7 +173,6 @@ def read_modelfile_text(
if not printwarningsonly:
print(" model file format is two lines per cell")
# columns split over two lines
ncols_line_odd = len(fmodel.readline().split())
assert (ncols_line_even + ncols_line_odd) == len(columns)
onelinepercellformat = False

Expand Down

0 comments on commit fe358ff

Please sign in to comment.