Skip to content

Commit 7ee8cdc

Browse files
authored
Update read.py
update the from_cnv reading options to include "prM" without a space as a key, update the prkey error conditional statements to be able to read files that may have more than 1 key (such as both depth and pressure)
1 parent 78b043d commit 7ee8cdc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ctd/read.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ def from_cnv(fname):
405405

406406
prkeys = [
407407
"prM ",
408+
"prM",
408409
"prE",
409410
"prDM",
410411
"pr50M",
@@ -416,8 +417,12 @@ def from_cnv(fname):
416417
"prDE",
417418
]
418419
prkey = [key for key in prkeys if key in df.columns]
419-
if len(prkey) != 1:
420-
raise ValueError(f"Expected one pressure/depth column, got {prkey}.")
420+
if len(prkey) ==0:
421+
raise ValueError(f"Expected one pressure/depth column, didn't receive any")
422+
elif len(prkey) >1:
423+
#if multiple keys present then keep the first one
424+
prkey=prkey[0]
425+
421426
df.set_index(prkey, drop=True, inplace=True)
422427
df.index.name = "Pressure [dbar]"
423428
if prkey == "depSM":

0 commit comments

Comments
 (0)