Skip to content

Commit

Permalink
Merge pull request #1074 from smangham/issue943-delay-dump-db-creation
Browse files Browse the repository at this point in the history
Fix delay dump database creation from text
  • Loading branch information
smangham authored May 24, 2024
2 parents ea3bf3b + ad9ef7a commit 1047ad5
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions py_progs/py4py/py4py/reverb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1280,17 +1280,23 @@ def open_database(file_root: str, user: str = None, password: str = None, batch_
print("Malformed line: '{}'".format(line))
continue

if len(values) != 12:
# There should be 13 values per line in our base formatting!
if len(values) != 14:
# There should be 14 values per line in our base formatting!
print("Incorrect number of values in line: '{}'".format(line))
continue

# Add the photo using the values. Some must be modified here; ideally, this would be done in Python.
session.add(Photon(Wavelength=values[1], Weight=values[2], X=values[3], Y=values[4], Z=values[5],
ContinuumScatters=int(values[6]-values[7]), ResonantScatters=int(values[7]),
Delay=values[8],
Spectrum=int(values[9]), Origin=int(values[10] % 10), Resonance=int(values[11]),
Origin_matom=(values[10] > 9)))
session.add(
Photon(
Wavelength=values[2], Weight=values[3],
X=values[4], Y=values[5], Z=values[6],
ContinuumScatters=int(values[7]-values[8]), ResonantScatters=int(values[8]),
Delay=values[9],
Spectrum=int(values[10]), Origin=int(values[11] % 10),
Resonance=int(values[12]), LineResonance=int(values[13]),
Origin_matom=(values[11] > 9)
)
)
added += 1
if added > batch_size:
# We commit in batches in order to avoid out-of-memory errors
Expand Down Expand Up @@ -1355,6 +1361,7 @@ class Photon(Base):
Spectrum = sqlalchemy.Column(sqlalchemy.Integer)
Origin = sqlalchemy.Column(sqlalchemy.Integer)
Resonance = sqlalchemy.Column(sqlalchemy.Integer)
LineResonance = sqlalchemy.Column(sqlalchemy.Integer)
Origin_matom = sqlalchemy.Column(sqlalchemy.Boolean)


Expand Down

0 comments on commit 1047ad5

Please sign in to comment.