@@ -56,10 +56,8 @@ def read_nortek(
56
56
57
57
userdata = _find_userdata (filename , userdata )
58
58
59
- with _NortekReader (
60
- filename , debug = debug , do_checksum = do_checksum , nens = nens
61
- ) as rdr :
62
- rdr .readfile ()
59
+ rdr = _NortekReader (filename , debug = debug , do_checksum = do_checksum , nens = nens )
60
+ rdr .readfile ()
63
61
rdr .dat2sci ()
64
62
dat = rdr .data
65
63
@@ -300,14 +298,10 @@ def filesize(
300
298
return self ._filesz
301
299
302
300
@property
303
- def pos (
304
- self ,
305
- ):
301
+ def pos (self ):
306
302
return self .f .tell ()
307
303
308
- def init_ADV (
309
- self ,
310
- ):
304
+ def init_ADV (self ):
311
305
dat = self .data = {
312
306
"data_vars" : {},
313
307
"coords" : {},
@@ -335,9 +329,7 @@ def init_ADV(
335
329
self .n_samp_guess = int (self .filesize / dlta + 1 )
336
330
self .n_samp_guess *= int (self .config ["fs" ])
337
331
338
- def init_AWAC (
339
- self ,
340
- ):
332
+ def init_AWAC (self ):
341
333
dat = self .data = {
342
334
"data_vars" : {},
343
335
"coords" : {},
@@ -392,9 +384,7 @@ def findnext(self, do_cs=True):
392
384
sum += cs
393
385
cs = val
394
386
395
- def read_id (
396
- self ,
397
- ):
387
+ def read_id (self ):
398
388
"""Read the next 'ID' from the file."""
399
389
self ._thisid_bytes = bts = self .read (2 )
400
390
tmp = unpack (self .endian + "BB" , bts )
@@ -414,9 +404,7 @@ def read_id(
414
404
return val
415
405
return tmp [1 ]
416
406
417
- def readnext (
418
- self ,
419
- ):
407
+ def readnext (self ):
420
408
id = "0x%02x" % self .read_id ()
421
409
if id in self .fun_map :
422
410
func_name = self .fun_map [id ]
@@ -503,9 +491,7 @@ def checksum(self, byts):
503
491
else :
504
492
self .f .seek (2 , 1 )
505
493
506
- def read_user_cfg (
507
- self ,
508
- ):
494
+ def read_user_cfg (self ):
509
495
# ID: '0x00 = 00
510
496
if self .debug :
511
497
logging .info (
@@ -607,9 +593,7 @@ def read_user_cfg(
607
593
int (Mode1 [2 ])
608
594
] # noqa
609
595
610
- def read_head_cfg (
611
- self ,
612
- ):
596
+ def read_head_cfg (self ):
613
597
# ID: '0x04 = 04
614
598
if self .debug :
615
599
logging .info (
@@ -631,9 +615,7 @@ def read_head_cfg(
631
615
)
632
616
self .checksum (byts )
633
617
634
- def read_hw_cfg (
635
- self ,
636
- ):
618
+ def read_hw_cfg (self ):
637
619
# ID 0x05 = 05
638
620
if self .debug :
639
621
logging .info (
@@ -700,9 +682,7 @@ def _init_data(self, vardict):
700
682
if va .standard_name :
701
683
self .data ["standard_name" ][nm ] = va .standard_name
702
684
703
- def read_vec_data (
704
- self ,
705
- ):
685
+ def read_vec_data (self ):
706
686
# ID: 0x10 = 16
707
687
c = self .c
708
688
dat = self .data
@@ -741,9 +721,7 @@ def read_vec_data(
741
721
self .checksum (byts )
742
722
self .c += 1
743
723
744
- def read_vec_checkdata (
745
- self ,
746
- ):
724
+ def read_vec_checkdata (self ):
747
725
# ID: 0x07 = 07
748
726
if self .debug :
749
727
logging .info (
@@ -794,9 +772,7 @@ def _sci_data(self, vardict):
794
772
if retval is not None :
795
773
dat [nm ] = retval
796
774
797
- def sci_vec_data (
798
- self ,
799
- ):
775
+ def sci_vec_data (self ):
800
776
self ._sci_data (nortek_defs .vec_data )
801
777
dat = self .data
802
778
@@ -814,9 +790,7 @@ def sci_vec_data(
814
790
# Apply velocity scaling (1 or 0.1)
815
791
dat ["data_vars" ]["vel" ] *= self .config ["vel_scale_mm" ]
816
792
817
- def read_vec_hdr (
818
- self ,
819
- ):
793
+ def read_vec_hdr (self ):
820
794
# ID: '0x12 = 18
821
795
if self .debug :
822
796
logging .info (
@@ -846,9 +820,7 @@ def read_vec_hdr(
846
820
self .config ["data_header" ] = [self .config ["data_header" ]]
847
821
self .config ["data_header" ] += [hdrnow ]
848
822
849
- def read_vec_sysdata (
850
- self ,
851
- ):
823
+ def read_vec_sysdata (self ):
852
824
# ID: 0x11 = 17
853
825
c = self .c
854
826
if self .debug :
@@ -884,9 +856,7 @@ def read_vec_sysdata(
884
856
) = unpack (self .endian + "2H3hH2BH" , byts [8 :])
885
857
self .checksum (byts )
886
858
887
- def sci_vec_sysdata (
888
- self ,
889
- ):
859
+ def sci_vec_sysdata (self ):
890
860
"""Translate the data in the vec_sysdata structure into
891
861
scientific units.
892
862
"""
@@ -937,9 +907,7 @@ def sci_vec_sysdata(
937
907
tbx .interpgaps (dv ["roll" ], t )
938
908
tbx .interpgaps (dv ["temp" ], t )
939
909
940
- def read_microstrain (
941
- self ,
942
- ):
910
+ def read_microstrain (self ):
943
911
"""Read ADV microstrain sensor (IMU) data"""
944
912
945
913
def update_defs (dat , mag = False , orientmat = False ):
@@ -1058,9 +1026,7 @@ def update_defs(dat, mag=False, orientmat=False):
1058
1026
self .checksum (byts0 + byts )
1059
1027
self .c += 1 # reset the increment
1060
1028
1061
- def sci_microstrain (
1062
- self ,
1063
- ):
1029
+ def sci_microstrain (self ):
1064
1030
"""Rotate orientation data into ADV coordinate system."""
1065
1031
# MS = MicroStrain
1066
1032
dv = self .data ["data_vars" ]
@@ -1085,9 +1051,7 @@ def sci_microstrain(
1085
1051
dv ["angrt" ] *= self .config ["fs" ]
1086
1052
dv ["accel" ] *= self .config ["fs" ]
1087
1053
1088
- def read_awac_profile (
1089
- self ,
1090
- ):
1054
+ def read_awac_profile (self ):
1091
1055
# ID: '0x20' = 32
1092
1056
dat = self .data
1093
1057
if self .debug :
@@ -1135,9 +1099,7 @@ def read_awac_profile(
1135
1099
self .checksum (byts )
1136
1100
self .c += 1
1137
1101
1138
- def sci_awac_profile (
1139
- self ,
1140
- ):
1102
+ def sci_awac_profile (self ):
1141
1103
self ._sci_data (nortek_defs .awac_profile )
1142
1104
# Calculate the ranges.
1143
1105
cs_coefs = {2000 : 0.0239 , 1000 : 0.0478 , 600 : 0.0797 , 400 : 0.1195 }
@@ -1158,9 +1120,7 @@ def sci_awac_profile(
1158
1120
self .data ["attrs" ]["cell_size" ] = cs
1159
1121
self .data ["attrs" ]["blank_dist" ] = bd
1160
1122
1161
- def read_awac_waves_hdr (
1162
- self ,
1163
- ):
1123
+ def read_awac_waves_hdr (self ):
1164
1124
# ID: '0x31'
1165
1125
c = self .c
1166
1126
if self .debug :
@@ -1205,9 +1165,7 @@ def read_awac_waves_hdr(
1205
1165
self .config ["data_header" ] = [self .config ["data_header" ]]
1206
1166
self .config ["data_header" ] += [hdrnow ]
1207
1167
1208
- def read_awac_waves (
1209
- self ,
1210
- ):
1168
+ def read_awac_waves (self ):
1211
1169
"""Read awac wave and suv data"""
1212
1170
# IDs: 0x30 & 0x36
1213
1171
c = self .c
@@ -1244,21 +1202,13 @@ def read_awac_waves(
1244
1202
self .checksum (byts )
1245
1203
self .c += 1
1246
1204
1247
- def dat2sci (
1248
- self ,
1249
- ):
1205
+ def dat2sci (self ):
1250
1206
for nm in self ._dtypes :
1251
1207
getattr (self , "sci_" + nm )()
1252
1208
for nm in ["data_header" , "checkdata" ]:
1253
1209
if nm in self .config and isinstance (self .config [nm ], list ):
1254
1210
self .config [nm ] = _recatenate (self .config [nm ])
1255
1211
1256
- def __exit__ (self , type , value , trace ):
1257
- self .close ()
1258
-
1259
- def __enter__ (self ):
1260
- return self
1261
-
1262
1212
1263
1213
def _crop_data (obj , range , n_lastdim ):
1264
1214
for nm , dat in obj .items ():
0 commit comments