Skip to content

Commit

Permalink
On write, update stop if it doesn't match last index
Browse files Browse the repository at this point in the history
  • Loading branch information
dcslagel committed Apr 20, 2021
1 parent 051f6dc commit ce6fbde
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
20 changes: 14 additions & 6 deletions lasio/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,21 @@ def write(
)

# -------------------------------------------------------------------------
# TODO: recheck this, it hasn't been validated for the case of a new las
# file created by Lasio
# If an initial curve index was not read from a las file (las.index_initial)
# or the curve index has changed during processing
# or if the STOP value doesn't match the final index value
# then update the step variables before writing to a new las file object.
# -------------------------------------------------------------------------
# if there is a curve index name and the index curve has changed
# then update the step variables
# -------------------------------------------------------------------------
if not (las.index_initial==las.index).all():
index_changed = False
stop_is_different = False

if las.index_initial is not None:
index_changed = not (las.index_initial == las.index).all()
stop_is_different = las.index_initial[-1] != las.well.STOP.value
else:
index_changed = True

if index_changed or stop_is_different:
las.update_start_stop_step(STRT, STOP, STEP)

# Write each section.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def test_write_single_step():
~Well ------------------------------------------------------
STRT.M 1670.0 : START DEPTH
STOP.M 1670.0 : STOP DEPTH
STEP.M 0 : STEP
STEP.M 0.0 : STEP
NULL. -999.25 : NULL VALUE
COMP. ANY OIL COMPANY INC. : COMPANY
WELL. AAAAA_2 : WELL
Expand Down

0 comments on commit ce6fbde

Please sign in to comment.