Skip to content

Commit

Permalink
small cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
jklymak committed Jul 2, 2022
1 parent 0ca41a8 commit 0d42f5e
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions pyglider/slocum.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
Routines to convert raw slocum dinkum files to netcdf timeseries.
"""
from shutil import ReadError
import bitstring
from datetime import datetime
import glob
import logging
import numpy as np
import os
import time
import xarray as xr
import xml.etree.ElementTree as ET
import yaml

import pyglider.utils as utils
import xml.etree.ElementTree as ET
from datetime import datetime


_log = logging.getLogger(__name__)
Expand Down Expand Up @@ -127,26 +127,6 @@ def binary_to_rawnc(indir, outdir, cacdir,
_log.info('All done!')


def _check_diag_header(diag_tuple):
# diagnostic values should be
# ['s', 'a', 4660, 123.45600128173828, 123456789.12345] # 4660 is 0x1234
# for new Slocum G3s (as of 2022), diagnostic values should be
# ['s', 'a', 13330, 1.5184998373247989e+35, -6.257491929421848e-90]
ref_tuple = ['s', 'a', 4660, 123.456, 123456789.12345]
ref_tuple_new = ['s', 'a', 13330, 1.5184998373247989e+35, -6.257491929421848e-90]
for i in range(3):
if (ref_tuple[i] != diag_tuple[i]) and (ref_tuple_new[i] != diag_tuple[i]):
_log.warning('character or int failure: %s', diag_tuple)
return False
if (((abs(ref_tuple[3] - diag_tuple[3]) > .0001) or
(abs(ref_tuple[4] - diag_tuple[4]) > .0001)) and
((abs(ref_tuple_new[3] - diag_tuple[3]) > 0.0001) or
(abs(ref_tuple_new[4] - diag_tuple[4]) > 0.0001))):
_log.warning('floating point failure')
return False
return True


def _decode_sensor_info(dfh, meta):
"""
Helper to decode the sensor list.
Expand Down Expand Up @@ -355,7 +335,7 @@ def dbd_to_dict(dinkum_file, cachedir, keys=None):

data = binaryData.read(f'float{endian}:64')
if not np.allclose(data, 123456789.12345):
_log.warning("float32 failure: %s != 123456789.12345", data)
_log.warning("float64 failure: %s != 123456789.12345", data)
raise ValueError("Diagnostic header check failed.")
_log.debug('Diagnostic check passed. Endian is %s', endian)

Expand Down

0 comments on commit 0d42f5e

Please sign in to comment.