Skip to content

Commit 5f75b62

Browse files
authored
Merge pull request #199 from upsonp/blank_header_lines_196
added fix for issue #196 and unit test
2 parents 37cd1b5 + 6d9231b commit 5f75b62

File tree

3 files changed

+218
-0
lines changed

3 files changed

+218
-0
lines changed

ctd/read.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ def _parse_seabird(lines, ftype):
166166
break
167167
else: # btl.
168168
# There is no *END* like in a .cnv file, skip two after header info.
169+
# Skip empty lines.
170+
if not line:
171+
continue
172+
169173
if not (line.startswith("*") | line.startswith("#")):
170174
# Fix commonly occurring problem when Sbeox.* exists in the file
171175
# the name is concatenated to previous parameter

tests/data/btl/blank_line_header.btl

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
* Sea-Bird SBE25 Data File:
2+
* FileName = C:\Users\Science\Documents\CAR2022102\ctd data\22102007.hex
3+
* Software Version 1.59
4+
* Temperature SN = Sbe03_1817
5+
* Conductivity SN = Sbe04-0735
6+
* System UpLoad Time = Mar 31 2022 08:30:05
7+
** Latitude: 41 12.513 N
8+
** Longitude: 067 09.722 W
9+
** Ship: CFA3098 CCGS Capt Jacques Cartier
10+
** Cruise: CAR2022102
11+
** Station_Label:755
12+
** Set_number:007
13+
** Stratum_number:5Z41
14+
** Station: 007
15+
** Sounding: 61
16+
** ID_Start:474815
17+
** Event_Comments: 2022 Georges Bank SurveyKP
18+
* ds
19+
* SBE 25 CTD V 4.0a SN 184 03/31/22 11:27:10.920
20+
* external pressure sensor, range = 1500 psia, tcval = 16
21+
* xtal = 9437427 clk = 32767.537 vmain = 12.5 iop = 4 vlith = 3.9
22+
* ncasts = 1 samples = 5815 free = 49165 lwait = 0 msec
23+
*
24+
* CTD configuration:
25+
* number of scans averaged = 1, data stored at 8 scans per second
26+
* real time data transmitted at 8 scans per second
27+
* minimum conductivity frequency for pump turn on = 1500
28+
* battery type = ALKALINE
29+
*
30+
* 7 external voltages sampled
31+
* stored voltage # 0 = external voltage 0
32+
* stored voltage # 1 = external voltage 1
33+
* stored voltage # 2 = external voltage 2
34+
* stored voltage # 3 = external voltage 3
35+
* stored voltage # 4 = external voltage 4
36+
* stored voltage # 5 = external voltage 5
37+
* stored voltage # 6 = external voltage 6
38+
*
39+
40+
41+
* S>
42+
* dh
43+
* cast 0 03/31 10:46:00 smpls 0 to 5814 nv = 7 avg = 1 stp = switch of
44+
45+
* S>
46+
# interval = seconds: 0.125
47+
# start_time = Mar 31 2022 10:46:00 [Instrument's time stamp, header]
48+
# <Sensors count="10" >
49+
# <sensor Channel="1" >
50+
# <!-- Frequency 0, Temperature -->
51+
# <TemperatureSensor SensorID="55" >
52+
# <SerialNumber>Sbe03_1817</SerialNumber>
53+
# <CalibrationDate>24-Nov-2004</CalibrationDate>
54+
# <!-- t0pcor = -2.0600e-007 specified on DatCnv command line -->
55+
# <UseG_J>1</UseG_J>
56+
# <A>3.68120516e-003</A>
57+
# <B>6.00510844e-004</B>
58+
# <C>1.36911401e-005</C>
59+
# <D>1.80939934e-006</D>
60+
# <F0_Old>5918.752</F0_Old>
61+
# <G>4.85872870e-003</G>
62+
# <H>6.78186362e-004</H>
63+
# <I>2.69032925e-005</I>
64+
# <J>2.15066050e-006</J>
65+
# <F0>1000.000</F0>
66+
# <Slope>1.00000000</Slope>
67+
# <Offset>0.0000</Offset>
68+
# </TemperatureSensor>
69+
# </sensor>
70+
# <sensor Channel="2" >
71+
# <!-- Frequency 1, Conductivity -->
72+
# <ConductivitySensor SensorID="3" >
73+
# <SerialNumber>Sbe04-0735</SerialNumber>
74+
# <CalibrationDate>07-Jan-2009</CalibrationDate>
75+
# <UseG_J>1</UseG_J>
76+
# <!-- Cell const and series R are applicable only for wide range sensors. -->
77+
# <SeriesR>0.0000</SeriesR>
78+
# <CellConst>2000.0000</CellConst>
79+
# <ConductivityType>0</ConductivityType>
80+
# <Coefficients equation="0" >
81+
# <A>0.00000000e+000</A>
82+
# <B>0.00000000e+000</B>
83+
# <C>-9.57000000e-008</C>
84+
# <D>0.00000000e+000</D>
85+
# <M>0.0</M>
86+
# <CPcor>0.00000000e+000</CPcor>
87+
# </Coefficients>
88+
# <Coefficients equation="1" >
89+
# <G>-3.99405308e+000</G>
90+
# <H>4.26940024e-001</H>
91+
# <I>2.75670483e-004</I>
92+
# <J>7.86847868e-006</J>
93+
# <CPcor>-9.57000000e-008</CPcor>
94+
# <CTcor>3.2500e-006</CTcor>
95+
# <!-- WBOTC not applicable unless ConductivityType = 1. -->
96+
# <WBOTC>0.00000000e+000</WBOTC>
97+
# </Coefficients>
98+
# <Slope>1.00000000</Slope>
99+
# <Offset>0.00000</Offset>
100+
# </ConductivitySensor>
101+
# </sensor>
102+
# <sensor Channel="3" >
103+
# <!-- Pressure voltage, Pressure, Strain Gauge -->
104+
# <PressureSensor SensorID="49" >
105+
# <SerialNumber>Sbe29-0274</SerialNumber>
106+
# <CalibrationDate>12-Jan-2009</CalibrationDate>
107+
# <A0>7.888379e+002</A0>
108+
# <A1>-2.082626e-001</A1>
109+
# <A2>3.829048e-007</A2>
110+
# <Offset>0.00000</Offset>
111+
# </PressureSensor>
112+
# </sensor>
113+
# <sensor Channel="4" >
114+
# <!-- A/D voltage 0, Oxygen, SBE 43 -->
115+
# <OxygenSensor SensorID="38" >
116+
# <SerialNumber>Sbe43-1157</SerialNumber>
117+
# <CalibrationDate>23-May-2017</CalibrationDate>
118+
# <Use2007Equation>1</Use2007Equation>
119+
# <CalibrationCoefficients equation="0" >
120+
# <!-- Coefficients for Owens-Millard equation. -->
121+
# <Boc>0.0000</Boc>
122+
# <Soc>0.0000e+000</Soc>
123+
# <offset>0.0000</offset>
124+
# <Pcor>0.00e+000</Pcor>
125+
# <Tcor>0.0000</Tcor>
126+
# <Tau>0.0</Tau>
127+
# </CalibrationCoefficients>
128+
# <CalibrationCoefficients equation="1" >
129+
# <!-- Coefficients for Sea-Bird equation - SBE calibration in 2007 and later. -->
130+
# <Soc>4.8000e-001</Soc>
131+
# <offset>-0.5166</offset>
132+
# <A>-3.8247e-003</A>
133+
# <B> 1.8386e-004</B>
134+
# <C>-2.9783e-006</C>
135+
# <D0> 2.5826e+000</D0>
136+
# <D1> 1.92634e-004</D1>
137+
# <D2>-4.64803e-002</D2>
138+
# <E> 3.6000e-002</E>
139+
# <Tau20> 1.6900</Tau20>
140+
# <H1>-3.3000e-002</H1>
141+
# <H2> 5.0000e+003</H2>
142+
# <H3> 1.4500e+003</H3>
143+
# </CalibrationCoefficients>
144+
# </OxygenSensor>
145+
# </sensor>
146+
# <sensor Channel="5" >
147+
# <!-- A/D voltage 1, Free -->
148+
# </sensor>
149+
# <sensor Channel="6" >
150+
# <!-- A/D voltage 2, Free -->
151+
# </sensor>
152+
# <sensor Channel="7" >
153+
# <!-- A/D voltage 3, Free -->
154+
# </sensor>
155+
# <sensor Channel="8" >
156+
# <!-- A/D voltage 4, Fluorometer, Chelsea Minitracka -->
157+
# <FluoroChelseaMinitrackaSensor SensorID="6" >
158+
# <SerialNumber>Mini-175028</SerialNumber>
159+
# <CalibrationDate>28 Jan 1998</CalibrationDate>
160+
# <Vacetone>0.067</Vacetone>
161+
# <Vacetone100>5.419</Vacetone100>
162+
# <Offset>0.000</Offset>
163+
# </FluoroChelseaMinitrackaSensor>
164+
# </sensor>
165+
# <sensor Channel="9" >
166+
# <!-- A/D voltage 5, Free -->
167+
# </sensor>
168+
# <sensor Channel="10" >
169+
# <!-- A/D voltage 6, PAR/Irradiance, Biospherical/Licor -->
170+
# <PAR_BiosphericalLicorChelseaSensor SensorID="42" >
171+
# <SerialNumber>SPQA-4859</SerialNumber>
172+
# <CalibrationDate>04-Sept-2014</CalibrationDate>
173+
# <M>-0.77060200</M>
174+
# <B>-3.52671700</B>
175+
# <CalibrationConstant>4.28000000</CalibrationConstant>
176+
# <Multiplier>1.00000000</Multiplier>
177+
# <Offset>0.00000000</Offset>
178+
# </PAR_BiosphericalLicorChelseaSensor>
179+
# </sensor>
180+
# </Sensors>
181+
# datcnv_date = Apr 19 2022 11:52:32, 7.26.6.28
182+
# datcnv_in = C:\Users\PROUDFOOTMA\Documents\.MISSIONS\2022\CAR2022102_WinterGF\Data\CTD\Reprocessed_Pinky\CTDDATA\22102007.hex C:\Users\PROUDFOOTMA\Documents\.MISSIONS\2022\CAR2022102_WinterGF\Data\CTD\Reprocessed_Pinky\Pinky1_Sbe25-0184standalone_Apr2022.xmlcon
183+
# datcnv_ox_hysteresis_correction = yes
184+
# datcnv_bottle_scan_range_source = BL file
185+
# datcnv_scans_per_bottle = 37
186+
# bottlesum_date = Apr 19 2022 11:52:36, 7.26.6.28
187+
# bottlesum_in = C:\Users\PROUDFOOTMA\Documents\.MISSIONS\2022\CAR2022102_WinterGF\Data\CTD\Reprocessed_Pinky\CTDDATA\22102007.ros C:\Users\PROUDFOOTMA\Documents\.MISSIONS\2022\CAR2022102_WinterGF\Data\CTD\Reprocessed_Pinky\Pinky1_Sbe25-0184standalone_Apr2022.xmlcon C:\Users\PROUDFOOTMA\Documents\.MISSIONS\2022\CAR2022102_WinterGF\Data\CTD\Reprocessed_Pinky\CTDDATA\22102007.BL
188+
# bottlesum_ox_tau_correction = yes
189+
Bottle Bottle Date Sbeox0ML/L Sal00 Potemp090C Sigma-é00 Scan TimeS PrSM T090C C0S/m Sbeox0V FlCM Par
190+
Position S/N Time
191+
4 474818 Mar 31 2022 6.0542 33.2232 6.7908 26.0473 792 98.875 5.556 6.7912 3.348640 2.3385 5.3210 2.2323e+00 (avg)
192+
10:47:36 11 1.353 0.329 0.0067 0.000340 0.0249 0.3117 1.9796e-01 (sdev)
193+
3 474817 Mar 31 2022 6.7306 33.2207 6.7863 26.0459 3250 406.125 26.130 6.7886 3.349098 2.5941 5.8026 4.8180e-02 (avg)
194+
10:52:43 11 1.353 0.503 0.0009 0.000096 0.0016 0.2241 6.2121e-03 (sdev)
195+
2 474816 Mar 31 2022 6.7188 33.2219 6.7951 26.0457 3691 461.250 51.103 6.7996 3.351271 2.5846 6.2792 3.1472e-03 (avg)
196+
10:53:38 11 1.353 0.476 0.0026 0.000221 0.0019 0.3323 1.0053e-04 (sdev)
197+
1 474815 Mar 31 2022 6.7283 33.2220 6.7985 26.0453 3969 496.000 59.278 6.8037 3.352000 2.5782 6.0967 2.0116e-03 (avg)
198+
10:54:13 11 1.353 0.365 0.0004 0.000037 0.0022 0.2897 0.0000e+00 (sdev)

tests/test_read.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,22 @@ def test_header_parse():
112112
np.testing.assert_almost_equal(xbt._metadata["lat"], -19.7174805)
113113

114114

115+
def test_header_parse_blank_line():
116+
# check that a BTL file can still be loaded if the header section contains blank lines
117+
118+
# if the blank line in the header causes the reader to exit before reading the file
119+
# the line looking for the Date in the ctd.from_btl() will throw a ValueError.
120+
btl = ctd.from_btl(
121+
data_path.joinpath(
122+
"btl",
123+
"blank_line_header.btl",
124+
),
125+
)
126+
127+
# if a value error wasn't thrown, ensure the names array for the _metadata was set
128+
assert btl._metadata["names"].index("Date")
129+
130+
115131
def test_pressure_field_labels():
116132
"""
117133
Support different pressure field labels encountered in Sea-Bird cnv files.

0 commit comments

Comments
 (0)