Skip to content

Commit

Permalink
CF standard attribute fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcvey3 committed Jun 22, 2023
1 parent f0746c1 commit da85ec2
Show file tree
Hide file tree
Showing 78 changed files with 168 additions and 163 deletions.
6 changes: 3 additions & 3 deletions dolfyn/io/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def _create_dataset(data):

FoR = {}
n_beams = max(min(data['attrs']['n_beams'], 4), 3) # need to keep dimension at 3 or 4
beams = list(range(1, n_beams+1))
beams = np.arange(1, n_beams+1, dtype=np.int32)
FoR['beam'] = xr.DataArray(beams, dims=['beam'], name='beam', attrs={
'units': '1', 'long_name': 'Beam Reference Frame'})
FoR['dir'] = xr.DataArray(beams, dims=['dir'], name='dir', attrs={
Expand All @@ -131,8 +131,8 @@ def _create_dataset(data):
if 'mat' in key:
if 'inst' in key: # beam2inst & inst2head orientation matrices
ds[key] = xr.DataArray(data['data_vars'][key],
coords={'x': beams, 'x*': beams},
dims=['x', 'x*'],
coords={'x1': beams, 'x2': beams},
dims=['x1', 'x2'],
attrs={'units': '1',
'long_name': 'Rotation Matrix'})
elif 'orientmat' in key: # earth2inst orientation matrix
Expand Down
3 changes: 2 additions & 1 deletion dolfyn/io/nortek.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,8 @@ def _init_data(self, vardict):
self.data[va.group][nm] = va._empty_array(**shape_args)
self.data['units'][nm] = va.units
self.data['long_name'][nm] = va.long_name
self.data['standard_name'][nm] = va.standard_name
if va.standard_name:
self.data['standard_name'][nm] = va.standard_name

def read_vec_data(self,):
# ID: 0x10 = 16
Expand Down
3 changes: 3 additions & 0 deletions dolfyn/io/nortek2.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,9 @@ def _reorg(dat):
dnow = dat[id]
outdat['units'].update(dnow['units'])
outdat['long_name'].update(dnow['long_name'])
for ky in dnow['units']:
if not dnow['standard_name'][ky]:
dnow['standard_name'].pop(ky)
outdat['standard_name'].update(dnow['standard_name'])
cfg['burst_config' + tag] = lib._headconfig_int2dict(
lib._collapse(dnow['config'], exclude=collapse_exclude,
Expand Down
7 changes: 3 additions & 4 deletions dolfyn/io/nortek2_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
from struct import Struct
from . import nortek2_lib as lib

dt32 = 'float32'
dt64 = 'float64'

dt32 = 'float32'
grav = 9.81
# The starting value for the checksum:
cs0 = int('0xb58c', 0)
Expand Down Expand Up @@ -208,9 +207,9 @@ def __call__(self, array):
('batt', 'H', [], _LinFunc(0.1, dtype=dt32),
'V', 'Battery Voltage', 'battery_voltage'),
('mag', 'h', [3], _LinFunc(0.1, dtype=dt32),
'uT', 'Compass', 'magnetic_field_vector'),
'uT', 'Compass'),
('accel', 'h', [3], _LinFunc(1. / 16384 * grav, dtype=dt32),
'm s-2', 'Acceleration', 'platform_acceleration'),
'm s-2', 'Acceleration'),
('ambig_vel', 'h', [], _LinFunc(0.001, dtype=dt32), 'm s-1'),
('data_desc', 'H', [], None),
('xmit_energy', 'H', [], None, '1', 'Sound Pressure Level of Acoustic Signal'),
Expand Down
6 changes: 3 additions & 3 deletions dolfyn/io/rdi.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def read_rdi(filename, userdata=None, nens=None, debug_level=-1,
ds['beam2inst_orientmat'] = xr.DataArray(
_calc_beam_orientmat(ds.beam_angle,
ds.beam_pattern == 'convex'),
coords={'x': [1, 2, 3, 4],
'x*': [1, 2, 3, 4]},
dims=['x', 'x*'],
coords={'x1': [1, 2, 3, 4],
'x2': [1, 2, 3, 4]},
dims=['x1', 'x2'],
attrs={'units': '1',
'long_name': 'Rotation Matrix'})

Expand Down
17 changes: 9 additions & 8 deletions dolfyn/io/rdi_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
}

data_defs = {'number': ([], 'data_vars', 'uint32', '1', 'Ensemble Number', 'number_of_observations'),
'rtc': ([7], 'sys', 'uint16', '1', '', ''),
'rtc': ([7], 'sys', 'uint16', '1', 'Real Time Clock', ''),
'builtin_test_fail': ([], 'data_vars', 'bool', '1', 'Built-In Test Failures', ''),
'c_sound': ([], 'data_vars', 'float32', 'm s-1', 'Speed of Sound', 'speed_of_sound_in_sea_water'),
'depth': ([], 'data_vars', 'float32', 'm', 'Depth', 'depth_below_platform'),
'depth': ([], 'data_vars', 'float32', 'm', 'Depth', 'depth'),
'pitch': ([], 'data_vars', 'float32', 'degree', 'Pitch', 'platform_pitch'),
'roll': ([], 'data_vars', 'float32', 'degree', 'Roll', 'platform_roll'),
'heading': ([], 'data_vars', 'float32', 'degree', 'Heading', 'platform_orientation'),
Expand All @@ -50,7 +50,7 @@
'pitch_std': ([], 'data_vars', 'float32', 'degree', 'Pitch Standard Deviation', ''),
'roll_std': ([], 'data_vars', 'float32', 'degree', 'Roll Standard Deviation', ''),
'adc': ([8], 'sys', 'uint8', '1', 'Analog-Digital Converter Output', ''),
'error_status': ([], 'attrs', 'float32', '1', '', ''),
'error_status': ([], 'attrs', 'float32', '1', 'Error Status', ''),
'pressure': ([], 'data_vars', 'float32', 'dbar', 'Pressure', 'sea_water_pressure'),
'pressure_std': ([], 'data_vars', 'float32', 'dbar', 'Pressure Standard Deviation', ''),
'vel': (['nc', 4], 'data_vars', 'float32', 'm s-1', 'Water Velocity', ''),
Expand All @@ -60,7 +60,7 @@
'beam_consistency_indicator_from_multibeam_acoustic_doppler_velocity_profiler_in_sea_water'),
'prcnt_gd': (['nc', 4], 'data_vars', 'uint8', '%', 'Percent Good',
'proportion_of_acceptable_signal_returns_from_acoustic_instrument_in_sea_water'),
'status': (['nc', 4], 'data_vars', 'float32', '1', '', ''),
'status': (['nc', 4], 'data_vars', 'float32', '1', 'Status', ''),
'dist_bt': ([4], 'data_vars', 'float32', 'm', 'Bottom Track Measured Depth', ''),
'vel_bt': ([4], 'data_vars', 'float32', 'm s-1', 'Platform Velocity from Bottom Track', ''),
'corr_bt': ([4], 'data_vars', 'uint8', '1', 'Bottom Track Acoustic Signal Correlation', ''),
Expand All @@ -73,8 +73,8 @@
'alt_status': ([], 'data_vars', 'uint8', 'bit', 'Altimeter Status', ''),
'time_gps': ([], 'coords', 'float64', 'seconds since 1970-01-01 00:00:00', 'GPS Time', 'time'),
'clock_offset_UTC_gps': ([], 'data_vars', 'float64', 's', 'Instrument Clock Offset from UTC', ''),
'latitude_gps': ([], 'data_vars', 'float32', 'deg N', 'Latitude', 'latitude'),
'longitude_gps': ([], 'data_vars', 'float32', 'deg E', 'Longitude', 'longitude'),
'latitude_gps': ([], 'data_vars', 'float32', 'degrees_north', 'Latitude', 'latitude'),
'longitude_gps': ([], 'data_vars', 'float32', 'degrees_east', 'Longitude', 'longitude'),
'avg_speed_gps': ([], 'data_vars', 'float32', 'm s-1', 'Average Platform Speed', 'platform_speed_wrt_ground'),
'avg_dir_gps': ([], 'data_vars', 'float32', 'degree', 'Average Platform Direction', 'platform_course'),
'speed_made_good_gps': ([], 'data_vars', 'float32', 'm s-1', 'Platform Speed Made Good', 'platform_speed_wrt_ground'),
Expand All @@ -98,7 +98,7 @@
'signal_intensity_from_multibeam_acoustic_doppler_velocity_sensor_in_sea_water'),
'prcnt_gd_sl': (['nc', 4], 'data_vars', 'uint8', '%', 'Surface Layer Percent Good',
'proportion_of_acceptable_signal_returns_from_acoustic_instrument_in_sea_water'),
'status_sl': (['nc', 4], 'data_vars', 'float32', '1', '', ''),
'status_sl': (['nc', 4], 'data_vars', 'float32', '1', 'Surface Layer Status', ''),
}


Expand Down Expand Up @@ -146,7 +146,8 @@ def _idata(dat, nm, sz):
dat[group][nm] = arr
dat['units'][nm] = units
dat['long_name'][nm] = long_name
dat['standard_name'][nm] = standard_name
if standard_name:
dat['standard_name'][nm] = standard_name
return dat


Expand Down
7 changes: 4 additions & 3 deletions dolfyn/rotate/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,10 @@ def set_inst2head_rotmat(ds, rotmat, inplace=True):
rotate2(ds, 'inst', inplace=True)

ds['inst2head_rotmat'] = xr.DataArray(np.array(rotmat),
dims=['x', 'x*'],
coords={'x': [1, 2, 3],
'x*': [1, 2, 3]})
dims=['x1', 'x2'],
coords={'x1': [1, 2, 3],
'x2': [1, 2, 3]},
attrs={'units':'1'})

ds.attrs['inst2head_rotmat_was_set'] = 1 # logical
# Note that there is no validation that the user doesn't
Expand Down
4 changes: 2 additions & 2 deletions dolfyn/tests/data/AWAC_test01.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/AWAC_test01_clean.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/AWAC_test01_earth2inst.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/AWAC_test01_earth2principal.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/AWAC_test01_inst2beam.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/AWAC_test01_ud.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/BenchFile01.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/BenchFile01_avg.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/BenchFile01_func.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/BenchFile01_rotate_beam2inst.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/BenchFile01_rotate_earth2principal.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/BenchFile01_rotate_inst2earth.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/H-AWAC_test01.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/RDI_7f79.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/RDI_test01.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/RDI_test01_ofilt.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/RDI_test01_rotate_beam2inst.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/RDI_test01_rotate_earth2principal.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/RDI_test01_rotate_inst2earth.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/RDI_withBT.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/RiverPro_test01.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/Sig1000_BadTime01.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/Sig1000_IMU.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/Sig1000_IMU_ofilt.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/Sig1000_IMU_rotate_beam2inst.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/Sig1000_IMU_rotate_inst2earth.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/Sig1000_IMU_ud.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/Sig1000_tidal.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/Sig1000_tidal_clean.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/Sig500_Echo.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/Sig500_Echo_clean.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/Sig500_Echo_crop.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/Sig500_Echo_earth2inst.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/Sig500_Echo_inst2beam.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/Sig500_last_ensemble_is_whole.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/Sig_SkippedPings01.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/VelEchoBT01.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/VelEchoBT01_rotate_beam2inst.nc
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/dat_rdi_bt.mat
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/dat_vec.mat
Git LFS file not shown
4 changes: 2 additions & 2 deletions dolfyn/tests/data/dat_vm.mat
Git LFS file not shown

0 comments on commit da85ec2

Please sign in to comment.