seagliderOG1 API

seagliderOG1.convertOG1.add_gps_info_to_dataset(ds, gps_ds)[source]

Add LATITUDE_GPS, LONGITUDE_GPS, and TIME_GPS to the dataset. The values will be present within the N_MEASUREMENTS but with non-Nan values only when the GPS information is available. The dataset will be sorted by TIME.

Parameters:
  • (xarray.Dataset) (gps_ds)

  • (xarray.Dataset)

Returns:

xarray.Dataset

Return type:

The new dataset with added GPS information. This only includes values for LATITUDE_GPS, LONGITUDE_GPS, TIME_GPS when the GPS information is available.

Note

This also sorts by ctd_time (from original basestation dataset) or TIME from ds. If the data are not sorted by time, there may be unintended consequences.

seagliderOG1.convertOG1.assign_variable_attributes(ds, vocab_attrs={'AD2CP_HEADING': {'URI': 'https://vocab.nerc.ac.uk/collection/P02/current/HEADING/', 'comment': 'measured by AD2CP', 'long_name': 'Orientation (horizontal relative to magnetic north) of measurement platform {heading} by compass'}, 'AD2CP_PITCH': {'URI': 'https://vocab.nerc.ac.uk/collection/P02/current/PITCH/', 'comment': 'measured by AD2CP', 'long_name': 'Orientation (pitch) of measurement platform by inclinometer'}, 'AD2CP_PRES': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/PRES', 'comment': 'adcp pressure sensor', 'long_name': 'Pressure (spatial coordinate) exerted by the water body by profiling pressure sensor and correction to read zero at sea level', 'observation_type': 'measured', 'positive': 'down', 'reference_datum': 'sea-surface', 'sensor': 'sensor_adcp', 'standard_name': 'sea_water_pressure', 'units': 'dbar', 'valid_max': 2000, 'valid_min': 0}, 'AD2CP_ROLL': {'URI': 'https://vocab.nerc.ac.uk/collection/P02/current/ROLL/', 'comment': 'measured by AD2CP', 'long_name': 'Orientation (roll angle) of measurement platform by inclinometer'}, 'AD2CP_TIME': {'URI': 'https://vocab.nerc.ac.uk/collection/P02/current/AYMD/', 'axis': 'T', 'calendar': 'gregorian', 'comment': 'measured by AD2CP', 'long_name': 'time of measurement', 'observation_type': 'measured', 'standard_name': 'time', 'units': 'seconds since 1970-01-01 00:00:00 UTC'}, 'BATTERY_PACK': {'long_name': 'battery packaging'}, 'BATTERY_TYPE': {'battery_type_vocabulary': 'https://github.com/OceanGlidersCommunity/OG-format-user-manual/blob/main/vocabularyCollection/battery_type.md', 'long_name': 'type of the battery'}, 'BBP470': {'URI': 'https://vocab.nerc.ac.uk/collection/P02/current/BBP470/', 'long_name': 'Particle backscattering at 470 nanometers.', 'observation_type': 'calculated', 'units': 'm-1'}, 'BBP470_REF': {'long_name': 'What is this - maybe dark counts. blue.', 'observation_type': 'observed'}, 'BBP700': {'URI': 'https://vocab.nerc.ac.uk/collection/P02/current/BBP700/', 'long_name': 'Particle backscattering at 700 nanometers.', 'observation_type': 'calculated', 'units': 'm-1'}, 'BBP700_REF': {'long_name': 'What is this - maybe dark counts. red.', 'observation_type': 'observed'}, 'CDOM': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/CDOM/', 'long_name': 'Concentration of coloured dissolved organic matter in sea water'}, 'CHLA': {'URI': 'https://vocab.nerc.ac.uk/collection/P02/current/CPWC/', 'long_name': 'chlorophyll', 'observation_type': 'calculated', 'standard_name': 'concentration_of_chlorophyll_in_sea_water', 'units': 'mg m-3', 'valid_max': 50, 'valid_min': 0}, 'CNDC': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/CNDC/', 'long_name': 'Electrical conductivity of the water body by CTD', 'observation_type': 'measured', 'sensor': 'sensor_ctd', 'standard_name': 'sea_water_electrical_conductivity', 'units': 'mS cm-1', 'valid_max': 85.0, 'valid_min': 0.0}, 'CNDC_RAW': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/CNDC/', 'long_name': 'Electrical conductivity of the water body by CTD', 'observation_type': 'measured', 'sensor': 'sensor_ctd', 'standard_name': 'sea_water_electrical_conductivity', 'units': 'mS cm-1', 'valid_max': 85.0, 'valid_min': 0.0}, 'DAVG_CURR_EAST': {'long_name': 'depth-averaged current in eastward direction', 'observation_type': 'calculated', 'positive': 'east', 'sensor': 'sensor_ctd, flight_model', 'standard_name': 'eastward_sea_water_velocity', 'units': 'm s-1'}, 'DAVG_CURR_EAST_QC': {'long_name': 'depth-averaged current quality control', 'observation_type': 'quality flag', 'sensor': 'sensor_ctd, flight_model', 'standard_name': 'status_flag'}, 'DAVG_CURR_NORTH': {'long_name': 'depth-averaged current in northward direction', 'observation_type': 'calculated', 'positive': 'north', 'sensor': 'sensor_ctd, flight_model', 'standard_name': 'northward_sea_water_velocity', 'units': 'm s-1'}, 'DENSITY': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/DENSITY/', 'comment': 'raw, uncorrected salinity', 'long_name': 'The mass of a unit volume of any body of fresh or salt water', 'observation_type': 'calculated', 'sources': 'salinity temperature pressure', 'standard_name': 'sea_water_density', 'units': 'kg m-3', 'valid_max': 1040, 'valid_min': 1000}, 'DEPLOYMENT_LATITUDE': {'long_name': 'latitude of deployment', 'standard_name': 'latitude', 'units': 'degrees_north'}, 'DEPLOYMENT_LONGITUDE': {'long_name': 'longitude of deployment', 'standard_name': 'longitude', 'units': 'degrees_east'}, 'DEPLOYMENT_TIME': {'calendar': 'gregorian', 'long_name': 'date of deployment', 'standard_name': 'time', 'units': 'seconds since 1970-01-01T00:00:00Z'}, 'DEPTH': {'accuracy': 1, 'comment': 'from science pressure and interpolated', 'long_name': 'glider depth', 'observation_type': 'calculated', 'platform': 'platform', 'positive': 'down', 'precision': 2, 'reference_datum': 'surface', 'resolution': 0.02, 'sensor': 'sensor_ctd', 'source': 'pressure', 'standard_name': 'depth', 'units': 'm', 'valid_max': 2000, 'valid_min': 0}, 'DEPTH_Z': {'comment': 'Defined with positive up', 'long_name': 'glider depth', 'observation_type': 'calculated', 'platform': 'platform', 'positive': 'up', 'reference_datum': 'surface', 'sensor': 'sensor_ctd', 'source': 'pressure', 'standard_name': 'depth', 'units': 'm', 'valid_max': 0, 'valid_min': -4000}, 'DOXY': {'URI': 'https://vocab.nerc.ac.uk/collection/P02/current/DOXY/', 'long_name': 'oxygen concentration', 'observation_type': 'calculated', 'standard_name': 'mole_concentration_of_dissolved_molecular_oxygen_in_sea_water', 'units': 'mmol m-3', 'valid_max': 425, 'valid_min': 0}, 'DPAR': {'URI': 'https://vocab.nerc.ac.uk/collection/P02/current/DPAR/', 'long_name': 'Downwelling vector irradiance as energy of electromagnetic radiation (PAR wavelengths) in the water body by cosine-collector radiometer.', 'observation_type': 'measured'}, 'EAST_DISPLACEMENT': {'long_name': 'eastward displacement of platform, from flight model', 'sensor': 'flight_model', 'units': 'm'}, 'ED380': {'URI': 'https://vocab.nerc.ac.uk/collection/P02/current/ED380/', 'average_method': 'geometric mean', 'long_name': 'The vertical component of light at 380nm wavelength travelling downwards', 'observation_type': 'measured', 'standard_name': '380nm_downwelling_irradiance', 'units': 'W m-2 nm-1'}, 'ED490': {'URI': 'https://vocab.nerc.ac.uk/collection/P02/current/ED490/', 'average_method': 'geometric mean', 'long_name': 'The vertical component of light at 490nm wavelength travelling downwards', 'observation_type': 'measured', 'standard_name': '490nm_downwelling_irradiance', 'units': 'W m-2 nm-1'}, 'EPSIFY01': {'URI': 'http://vocab.nerc.ac.uk/collection/P01/current/EPSIFY01/', 'long_name': 'Log10 turbulent kinetic energy dissipation {epsilon} per unit volume of the water body by turbulence profiler shear sensor'}, 'EPSIFY02': {'URI': 'http://vocab.nerc.ac.uk/collection/P01/current/EPSIFY02/', 'long_name': 'Log10 turbulent kinetic energy dissipation {epsilon} per unit volume of the water body by turbulence profiler shear sensor'}, 'FLUOCDOM': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/FLUOCDOM/', 'long_name': 'Raw fluorescence from coloured dissolved organic matter sensor'}, 'FLUOCHLA': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/FLUOCHLA/', 'long_name': 'Raw signal (counts) of instrument output by in-situ chlorophyll fluorometer'}, 'FLUOPHYC': {'URI': 'http://vocab.nerc.ac.uk/collection/OG1/current/FLUOPHYC/', 'long_name': 'Phycoerythrin signal from fluorescence sensor'}, 'GLIDER_FIRMWARE_VERSION': {'long_name': 'version of the internal glider firmware'}, 'GLIDER_HORZ_VELO_MODEL': {'comment': 'Vehicle horizontal speed based on hdm', 'long_name': 'glider_horizontal_speed_from_glider_flight_model', 'observation_type': 'calculated', 'positive': 'east', 'sensor': 'sensor_glider_model', 'standard_name': 'horizontal_glider_speed', 'units': 'm s-1'}, 'GLIDER_VERT_VELO_MODEL': {'long_name': 'glider vertical speed from glider flight model', 'observation_type': 'calculated', 'positive': 'up', 'sensor': 'sensor_glider_model', 'standard_name': 'vertical_glider_speed', 'units': 'm s-1'}, 'GLIDER_VERT_VELO_PRESSURE': {'long_name': 'glider vertical speed from pressure', 'observation_type': 'calculated', 'positive': 'up', 'sensor': 'sensor_ctd', 'standard_name': 'vertical_glider_speed', 'units': 'm s-1'}, 'GLIDE_ANGLE': {'comment': 'Glide angle based on hdm', 'long_name': 'glide angle from hydrodynamic model', 'observation_type': 'calculated', 'positive': 'east', 'units': 'degrees'}, 'GLIDE_SPEED': {'comment': 'Vehicle speed based on hdm', 'long_name': 'glider speed from hydrodynamic model', 'observation_type': 'calculated', 'positive': 'east', 'units': 'm s-1'}, 'HEADING': {'URI': 'https://vocab.nerc.ac.uk/collection/P02/current/HEADING/', 'long_name': 'Orientation (horizontal relative to magnetic north) of measurement platform {heading} by compass'}, 'HUMIDITY': {'URI': 'http://vocab.nerc.ac.uk/collection/P01/current/CRELZZ01/', 'long_name': 'Relative humidity of the atmosphere', 'sensor': 'sensor_meteorology', 'units': 'percent'}, 'ICES_CODE': {'ices_code_vocabulary': 'https://vocab.ices.dk/?codeguid=690d82e2 -b4e2-4e30-9772-7499c66144c6', 'long_name': 'ICES platform code of the glider '}, 'LANDSTATION_VERSION': {'long_name': 'version of the server onshore'}, 'LATITUDE': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/LAT/', 'axis': 'Y', 'coordinate_reference_frame': 'urn:ogc:crs:EPSG::4326', 'long_name': 'Latitude north', 'observation_type': 'measured', 'platform': 'platform', 'reference': 'WGS84', 'standard_name': 'latitude', 'units': 'degrees_north', 'valid_max': 90, 'valid_min': -90}, 'LATITUDE_GPS': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/LAT/', 'axis': 'Y', 'long_name': 'Latitude north by unspecified GPS system', 'observation_type': 'measured', 'platform': 'platform', 'standard_name': 'latitude', 'units': 'degrees_north', 'valid_max': 90, 'valid_min': -90}, 'LONGITUDE': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/LON/', 'axis': 'X', 'coordinate_reference_frame': 'urn:ogc:crs:EPSG::4326', 'long_name': 'Longitude east', 'observation_type': 'measured', 'platform': 'platform', 'reference': 'WGS84', 'standard_name': 'longitude', 'units': 'degrees_east', 'valid_max': 180, 'valid_min': -180}, 'LONGITUDE_GPS': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/LON/', 'axis': 'X', 'long_name': 'Longitude east by unspecified GPS system', 'observation_type': 'measured', 'platform': 'platform', 'standard_name': 'longitude', 'units': 'degrees_east', 'valid_max': 180, 'valid_min': -180}, 'NORTH_DISPLACEMENT': {'long_name': 'northward displacement of platform, from flight model', 'sensor': 'flight_model', 'units': 'm'}, 'OXYSAT': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/OXYSAT/', 'long_name': 'Oxygen saturation by Optode', 'observation_type': 'calculated', 'standard_name': 'mole_fraction_of_oxygen_in_sea_water', 'units': 'percent', 'valid_max': 150, 'valid_min': 0}, 'PHASE': {'comment': 'This is based only on splitting each dive cycle into the period before the glider reaches the maximum pressure of that cycle (descent, PHASE=2) and the period after the glider reaches the maximum pressure of that cycle (ascent, PHASE=1)', 'long_name': 'behavior of the glider at sea', 'phase_vocabulary': 'https://github.com/OceanGlidersCommunity/OG-format-user-manual/blob/main/vocabularyCollection/phase.md', 'units': '1'}, 'PHYC': {'URI': 'http://vocab.nerc.ac.uk/collection/OG1/current/PHYC/', 'long_name': 'Phycoerythrin concentration per unit volume of fresh or salt water.'}, 'PITCH': {'URI': 'https://vocab.nerc.ac.uk/collection/P02/current/PITCH/', 'long_name': 'Orientation (pitch) of measurement platform by inclinometer'}, 'PITCH_CTL': {'long_name': 'Pitch control of the glider', 'sensor': 'engineering', 'units': 'counts'}, 'PLATFORM_DEPTH_RATING': {'convention': 'positive value expected - e.g., 100m depth = 100', 'long_name': 'depth limit in meters of the glider for this mission'}, 'PLATFORM_MAKER': {'long_name': 'glider manufacturer', 'platform_maker_vocabulary': 'https://vocab.nerc.ac.uk/collection/B75/current/ORG01077/'}, 'PLATFORM_MODEL': {'long_name': 'model of the glider', 'platform_model_vocabulary': 'https://vocab.nerc.ac.uk/collection/B76/current/B7600024/'}, 'PLATFORM_NAME': {'long_name': 'Local or nickname of the glider'}, 'PLATFORM_SERIAL_NUMBER': {'long_name': 'glider serial number'}, 'POTDENS0': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/POTDENS0/', 'long_name': 'Potential density of water body at surface', 'observation_type': 'calculated', 'sources': 'salinity temperature pressure', 'standard_name': 'sea_water_potential_density', 'units': 'kg m-3', 'valid_max': 1040, 'valid_min': 1000}, 'PRES': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/PRES', 'comment': 'ctd pressure sensor', 'long_name': 'Pressure (spatial coordinate) exerted by the water body by profiling pressure sensor and correction to read zero at sea level', 'observation_type': 'measured', 'positive': 'down', 'reference_datum': 'sea-surface', 'sensor': 'sensor_ctd', 'standard_name': 'sea_water_pressure', 'units': 'dbar', 'valid_max': 2000, 'valid_min': 0}, 'PRESSURE_AIR': {'URI': 'http://vocab.nerc.ac.uk/collection/P01/current/CAPBZZ01/', 'long_name': 'Pressure (spatial coordinate) exerted by the atmosphere', 'sensor': 'sensor_meteorology', 'units': 'dbar'}, 'PROFILE_NUMBER': {'long_name': 'profile index', 'units': '1'}, 'PSAL': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/PSAL/', 'comment': 'Practical salinity of the water body by CTD and computation using UNESCO 1983 algorithm', 'long_name': 'water salinity', 'observation_type': 'calculated', 'sensor': 'sensor_ctd', 'sources': 'CNDC, TEMP, PRES', 'standard_name': 'sea_water_practical_salinity', 'units': '1e-3', 'valid_max': 40, 'valid_min': 0}, 'PSAL_RAW': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/PSAL/', 'comment': 'Practical salinity of the water body by CTD and computation using UNESCO 1983 algorithm', 'long_name': 'water salinity', 'observation_type': 'calculated', 'sensor': 'sensor_ctd', 'sources': 'CNDC, TEMP, PRES', 'standard_name': 'sea_water_practical_salinity', 'units': '1e-3', 'valid_max': 40, 'valid_min': 0}, 'RBBP700': {'URI': 'http://vocab.nerc.ac.uk/collection/OG1/current/RBBP700/', 'long_name': 'Raw signal from backscattering sensor.', 'observation_type': 'observed', 'units': '1'}, 'ROLL': {'URI': 'https://vocab.nerc.ac.uk/collection/P02/current/ROLL/', 'long_name': 'Orientation (roll angle) of measurement platform by inclinometer'}, 'ROLL_CTL': {'long_name': 'Roll control of the glider', 'sensor': 'engineering', 'units': 'counts'}, 'SENSOR_type_serialnumber': {'long_name': 'RBR Legato 3 CTD', 'sensor_calibration_date': '2021-01-01', 'sensor_maker': 'RBR', 'sensor_maker_vocabulary': 'https://vocab.nerc.ac.uk/collection/L35/current/MAN0049', 'sensor_model': 'RBR Legato3 CTD', 'sensor_model_vocabulary': 'https://vocab.nerc.ac.uk/collection/L22/current/TOOL1745', 'sensor_serial_number': '12345', 'sensor_type_vocabulary': 'https://vocab.nerc.ac.uk/collection/L05/current/130'}, 'SIGMA_T': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/SIGMA_T/', 'long_name': 'Sigma-t', 'observation_type': 'calculated', 'sources': 'salinity temperature pressure', 'standard_name': 'sea_water_sigma_t', 'units': 'kg m-3', 'valid_max': 50, 'valid_min': 0}, 'SIGTHETA': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/SIGTHETA/', 'long_name': 'Sigma-theta', 'observation_type': 'calculated', 'sources': 'salinity temperature pressure', 'standard_name': 'sea_water_sigma_theta', 'units': 'kg m-3', 'valid_max': 50, 'valid_min': 0}, 'TCPUCHLA': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/TCPUCHLA/', 'long_name': 'Turbidity of water in the water body'}, 'TELECOM_TYPE': {'long_name': 'types of telecommunication systems used by the glider, multiple telecom type are separated by a comma', 'telecom_type_vocabulary': 'https://github.com/OceanGlidersCommunity/OG-format-user-manual/blob/main/vocabularyCollection/telecom_type.md'}, 'TEMP': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/TEMP/', 'long_name': 'Temperature of the water body by CTD ', 'observation_type': 'measured', 'standard_name': 'sea_water_temperature', 'units': 'Celsius', 'valid_max': 42, 'valid_min': -5}, 'TEMP_AIR': {'URI': 'http://vocab.nerc.ac.uk/collection/P01/current/CDTASS01/', 'long_name': 'Temperature of the atmosphere by dry bulb thermometer', 'sensor': 'sensor_meteorology', 'units': 'Celsius'}, 'TEMP_OXYGEN': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/TEMP/', 'comment': 'measured by oxygen optode', 'long_name': 'Temperature of the water body by CTD ', 'observation_type': 'measured', 'standard_name': 'sea_water_temperature', 'units': 'Celsius', 'valid_max': 42, 'valid_min': -5}, 'TEMP_RAW': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/TEMP/', 'long_name': 'Temperature of the water body by CTD ', 'observation_type': 'measured', 'standard_name': 'sea_water_temperature', 'units': 'Celsius', 'valid_max': 42, 'valid_min': -5}, 'THETA': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/THETA/', 'long_name': 'Potential temperature of the water body by computation using UNESCO 1983 algorithm.', 'observation_type': 'calculated', 'sources': 'salinity temperature pressure', 'standard_name': 'sea_water_potential_temperature', 'units': 'Celsius', 'valid_max': 42, 'valid_min': -5}, 'TIME': {'URI': 'https://vocab.nerc.ac.uk/collection/P02/current/AYMD/', 'long_name': 'time of measurement', 'observation_type': 'measured', 'standard_name': 'time'}, 'TIME_GPS': {'long_name': 'time of each GPS location', 'units': 'seconds since 1970-01-01T00:00:00Z'}, 'TRACKING_SYSTEM': {'long_name': 'type of tracking systems used by the glider, multiple tracking system are separated by a comma', 'tracking_system_vocabulary': 'https://github.com/OceanGlidersCommunity/OG-format-user-manual/blob/main/vocabularyCollection/tracking_system.md'}, 'TURB': {'URI': 'https://vocab.nerc.ac.uk/collection/OG1/current/TURB/', 'long_name': 'Turbidity of water in the water body'}, 'VBD_CC': {'long_name': 'Variable buoyancy device in cubic centimeters', 'sensor': 'engineering', 'units': 'cm3'}, 'VERT_CURR_MODEL': {'URI': 'http://vocab.nerc.ac.uk/collection/P01/current/LRZAZZZZ/', 'long_name': 'vertical current of seawater derived from glider flight model', 'observation_type': 'calculated', 'positive': 'up', 'sensor': 'sensor_ctd', 'standard_name': 'vertical_current', 'units': 'm s-1'}, 'WIND_DIRECTION': {'URI': 'http://vocab.nerc.ac.uk/collection/P01/current/EWDASS01/', 'long_name': 'Direction (from) of wind relative to True North {wind direction} in the atmosphere by in-situ anemometer', 'sensor': 'sensor_meteorology'}, 'WIND_SPEED': {'URI': 'http://vocab.nerc.ac.uk/collection/P01/current/EWSBSS01/', 'long_name': 'Speed of wind {wind speed} in the atmosphere by in-situ anemometer', 'sensor': 'sensor_meteorology', 'units': 'm s-1'}, 'WMO_IDENTIFIER': {'long_name': 'wmo id'}, 'maximum_wave_height': {'long_name': 'maximum wave height, from MOSE sensor', 'sensor': 'sensor_wave', 'units': 'm'}, 'mean_wave_period': {'long_name': 'mean wave period, from MOSE sensor', 'sensor': 'sensor_wave', 'units': 's'}, 'northward_displacement': {'long_name': 'northward displacement of platform, from MOSE sensor', 'sensor': 'sensor_wave', 'units': 'm'}, 'percentage_error_lines': {'long_name': 'percentage of error lines from MOSE sensor, used to calculate wave stats', 'sensor': 'sensor_wave', 'units': 'percent'}, 'significant_wave_height': {'URI': 'http://vocab.nerc.ac.uk/collection/P01/current/GTDHZZ01/', 'long_name': 'Significant wave height of waves {Hs} on the water body', 'sensor': 'sensor_wave', 'units': 'm'}, 'significant_wave_period': {'URI': 'http://vocab.nerc.ac.uk/collection/P01/current/GTZHZZ01/', 'long_name': 'Zero-crossing period of waves (highest one third) {significant wave period Ts} on the water body', 'sensor': 'sensor_wave', 'units': 's'}, 'vertical_displacement': {'long_name': 'Vertical displacement of platform, from MOSE sensor', 'sensor': 'sensor_wave', 'units': 'm'}, 'westward_displacement': {'long_name': 'northward displacement of platform, from MOSE sensor', 'sensor': 'sensor_wave', 'units': 'm'}}, unit_format={'S/m': 'S m-1', 'cm/s': 'cm s-1', 'degrees_Celsius': 'Celsius', 'g/m^3': 'g m-3', 'm/s': 'm s-1', 'meters': 'm'})[source]

Assigns variable attributes to a dataset where they are missing and reformats units according to the provided unit_format. Attributes that already exist in the dataset are not changed, except for unit reformatting.

Parameters:
  • (xarray.Dataset) (ds)

  • (dict) (unit_str_format)

  • (dict)

Returns:

  • xarray.Dataset (The dataset with updated attributes.)

  • attr_warnings (set) (A set containing warning messages for attribute mismatches.)

seagliderOG1.convertOG1.convert_to_OG1(datasets, contrib_to_append=None)[source]

Processes a list of xarray datasets or a single xarray dataset, converts them to OG1 format, concatenates the datasets, sorts by time, and applies attributes.

Parameters:
  • xarray.Dataset) (datasets (list or)

  • (dict (contrib_to_append)

  • optional) (Dictionary containing additional contributor information to append.)

Returns:

xarray.Dataset

Return type:

The concatenated and processed dataset.

seagliderOG1.convertOG1.extract_attr_to_keep(ds1, attr_as_is={'acknowledgment', 'date_created', 'disclaimer', 'file_version', 'geospatial_lat_max', 'geospatial_lat_min', 'geospatial_lon_max', 'geospatial_lon_min', 'geospatial_vertical_max', 'geospatial_vertical_min', 'id', 'institution', 'keywords', 'keywords_vocabulary', 'license', 'naming_authority', 'project'})[source]
seagliderOG1.convertOG1.extract_attr_to_rename(ds1, attr_to_rename={'comment': 'history', 'platform_id': 'PLATFORM_SERIAL_NUMBER', 'site': 'summary', 'uri': 'uuid', 'uri_comment': 'UUID'})[source]
seagliderOG1.convertOG1.extract_variables(ds)[source]

Further splits the variables from the basestation file that had no dimensions. Extracts them according to whether they were originally from sg_calib_constants, or were from log files, or were other mission/dive specific values.

Parameters:

(xarray.Dataset) (ds)

Returns:

tuple

  • sg_cal (xarray.Dataset): Dataset with variables starting with ‘sg_cal_’, (originally from sg_calib_constants.m). Renamed to remove the prefix, so can be accessed with sg_cal.hd_a.

  • dc_log (xarray.Dataset): Dataset with variables starting with ‘log_’. From log files.

  • dc_other (xarray.Dataset): Other mission/dive specific values. Includes depth-averaged currents but also things like magnetic_variation

Return type:

A tuple containing three xarray Datasets:

seagliderOG1.convertOG1.get_contributors(ds, values_to_append=None)[source]
seagliderOG1.convertOG1.get_time_attributes(ds)[source]

Extracts and cleans time-related attributes from the dataset.

Parameters:

(xarray.Dataset) (ds)

Returns:

dict

Return type:

A dictionary containing cleaned time-related attributes.

seagliderOG1.convertOG1.process_and_save_data(input_location, save=False, output_dir='../data', run_quietly=True)[source]

Processes and saves data from the specified input location. This function loads and concatenates datasets from the server, converts them to OG1 format, and saves the resulting dataset to a NetCDF file. If the file already exists, the function will prompt the user to decide whether to overwrite it or not.

Parameters: input_location (str): The location of the input data to be processed. save (bool): Whether to save the processed dataset to a file. Default is False. output_dir (str): The directory where the output file will be saved. Default is ‘../data’.

Returns: xarray.Dataset: The processed dataset.

seagliderOG1.convertOG1.process_dataset(ds1)[source]

Processes a dataset by performing a series of transformations and extractions.

Parameter

ds1 (xarray.Dataset): The input dataset containing various attributes and variables.

returns:
  • tuple (A tuple containing:) –

    • ds_new (xarray.Dataset): The processed dataset with renamed variables, assigned attributes,

      converted units, and additional information such as GPS info and dive number.

    • attr_warnings (list): A list of warnings related to attribute assignments.

    • sg_cal (xarray.Dataset): A dataset containing variables starting with ‘sg_cal’.

    • dc_other (xarray.Dataset): A dataset containing other variables not categorized under ‘sg_cal’ or ‘dc_log’.

    • dc_log (xarray.Dataset): A dataset containing variables starting with ‘log_’.

  • Steps

    1. Handle and split the inputs
      • Extract the dive number from the attributes

      • Split the dataset by unique dimensions.

      • Extract the gps_info from the split dataset.

      • Extract variables starting with ‘sg_cal’. These are originally from sg_calib_constants.m.

    2. Rename the dataset dimensions, coordinates and variables according to OG1
      • Extract and rename dimensions for ‘sg_data_point’. These will be the N_MEASUREMENTS.

      • Rename variables according to the OG1 vocabulary.

      • Assign variable attributes according to OG1. Pass back warnings where there were conflicts.

      • Convert units in the dataset (e.g., cm/s to m/s) where possible.

      • Convert QC flags to int8.

    3. Add new variables
      • Add GPS info as LATITUDE_GPS, LONGITUDE_GPS and TIME_GPS (increase length of N_MEASUREMENTS)

      • Add the divenum as a variable of length N_MEASUREMENTS

      • Add the PROFILE_NUMBER (odd for dives, even for ascents)

      • Add the PHASE of the dive (1 for ascent, 2 for descent, 3 for between the first two surface points)

      • Add the DEPTH_Z with positive up

    4. Return the new dataset, the attribute warnings, the sg_cal dataset, and the dc_other dataset.

Note

Possibility of undesired behaviour:
  • It sorts by TIME

  • If there are not two surface GPS fixes before a dive, it may inadvertantly turn the whole thing to a dive.

Checking for valid coordinates: https://github.com/pydata/xarray/issues/3743

seagliderOG1.convertOG1.rename_dimensions(ds, rename_dict={'sg_data_point': 'N_MEASUREMENTS'})[source]

Rename dimensions of an xarray Dataset based on a provided dictionary for OG1 vocabulary.

Parameters:
  • (xarray.Dataset) (ds)

  • (dict (rename_dict) – and values are the new dimension names. Defaults to vocabularies.dims_rename_dict.

  • optional) (A dictionary where keys are the current dimension names) – and values are the new dimension names. Defaults to vocabularies.dims_rename_dict.

Returns:

  • xarray.Dataset (A new dataset with renamed dimensions.)

  • Raises

  • Warning (If no variables with dimensions matching any key in rename_dict are found.)

seagliderOG1.convertOG1.standardise_OG10(ds, unit_format={'S/m': 'S m-1', 'cm/s': 'cm s-1', 'degrees_Celsius': 'Celsius', 'g/m^3': 'g m-3', 'm/s': 'm s-1', 'meters': 'm'})[source]

Standardizes the dataset to OG1 format by renaming dimensions, variables, and assigning attributes.

Parameters:

(xarray.Dataset) (ds)

Returns:

xarray.Dataset

Return type:

The standardized dataset.

seagliderOG1.convertOG1.update_dataset_attributes(ds, contrib_to_append)[source]

Updates the attributes of the dataset based on the provided attribute input.

Parameters:
  • (xarray.Dataset) (ds)

  • (module) (vocabularies)

Returns:

xarray.Dataset

Return type:

The dataset with updated attributes.

seagliderOG1.readers.create_pooch_registry_from_directory(directory)[source]

Create a Pooch registry from files in a specified directory.

Parameters: directory (str): The path to the directory containing the files.

Returns: dict: A dictionary representing the Pooch registry with filenames as keys and their SHA256 hashes as values.

seagliderOG1.readers.filter_files_by_profile(file_list, start_profile=None, end_profile=None)[source]

Filter a list of files based on the start_profile and end_profile.

Parameters: file_list (list): List of filenames to filter. start_profile (int, optional): The starting profile number to filter files. Defaults to None. end_profile (int, optional): The ending profile number to filter files. Defaults to None.

Returns: list: A list of filtered filenames.

seagliderOG1.readers.list_files_in_https_server(url)[source]

List files in an HTTPS server directory using BeautifulSoup and requests.

Parameters: url (str): The URL to the directory containing the files.

Returns: list: A list of filenames found in the directory.

seagliderOG1.readers.load_sample_dataset(dataset_name='p0040034_20031007.nc')[source]
seagliderOG1.readers.read_basestation(source, start_profile=None, end_profile=None)[source]

Load datasets from either an online source or a local directory, optionally filtering by profile range.

Parameters: source (str): The URL to the directory containing the NetCDF files or the path to the local directory. start_profile (int, optional): The starting profile number to filter files. Defaults to None. end_profile (int, optional): The ending profile number to filter files. Defaults to None.

Returns: A list of xarray.Dataset objects loaded from the filtered NetCDF files.

seagliderOG1.plotters.plot_ctd_depth_vs_time(ds, start_traj=None, end_traj=None)[source]

Plots CTD depth vs time, optionally filtered by trajectory range, and highlights non-NaN GPS latitude values.

Parameters: ds (xr.Dataset): The input dataset containing ‘ctd_time’, ‘ctd_depth’, and ‘gps_lat’. start_traj (int, optional): The starting trajectory number to filter the data. Default is None. end_traj (int, optional): The ending trajectory number to filter the data. Default is None.

seagliderOG1.plotters.plot_depth_colored(data, color_by=None, start_dive=None, end_dive=None)[source]

Plots depth as a function of time, optionally colored by another variable, and filtered by dive number.

Parameters: data (pd.DataFrame or xr.Dataset): The input data containing ‘ctd_depth’ and ‘ctd_time’. color_by (str, optional): The variable to color the plot by. Default is None. start_dive (int, optional): The starting dive number to filter the data. Default is None. end_dive (int, optional): The ending dive number to filter the data. Default is None.

seagliderOG1.plotters.plot_profile_depth(data)[source]

Plots the profile depth (ctd_depth) as a function of time (ctd_time). Reduces the total number of points to be less than 100,000.

Parameters: data (pd.DataFrame or xr.Dataset): The input data containing ‘ctd_depth’ and ‘ctd_time’.

seagliderOG1.plotters.show_attributes(data)[source]

Processes an xarray Dataset or a netCDF file, extracts attribute information, and returns a DataFrame with details about the attributes.

Parameters: data (str or xr.Dataset): The input data, either a file path to a netCDF file or an xarray Dataset.

Returns: pandas.DataFrame: A DataFrame containing the following columns:

  • Attribute: The name of the attribute.

  • Value: The value of the attribute.

seagliderOG1.plotters.show_contents(data, content_type='variables')[source]

Wrapper function to show contents of an xarray Dataset or a netCDF file.

Parameters: data (str or xr.Dataset): The input data, either a file path to a netCDF file or an xarray Dataset. content_type (str): The type of content to show, either ‘variables’ (or ‘vars’) or ‘attributes’ (or ‘attrs’). Default is ‘variables’.

Returns: pandas.io.formats.style.Styler or pandas.DataFrame: A styled DataFrame with details about the variables or attributes.

seagliderOG1.plotters.show_variables(data)[source]

Processes an xarray Dataset or a netCDF file, extracts variable information, and returns a styled DataFrame with details about the variables.

Parameters: data (str or xr.Dataset): The input data, either a file path to a netCDF file or an xarray Dataset.

Returns: pandas.io.formats.style.Styler: A styled DataFrame containing the following columns:

  • dims: The dimension of the variable (or “string” if it is a string type).

  • name: The name of the variable.

  • units: The units of the variable (if available).

  • comment: Any additional comments about the variable (if available).

seagliderOG1.plotters.show_variables_by_dimension(data, dimension_name='trajectory')[source]

Processes an xarray Dataset or a netCDF file, extracts variable information, and returns a styled DataFrame with details about the variables filtered by a specific dimension.

Parameters: data (str or xr.Dataset): The input data, either a file path to a netCDF file or an xarray Dataset. dimension_name (str): The name of the dimension to filter variables by.

Returns: pandas.io.formats.style.Styler: A styled DataFrame containing the following columns:

  • dims: The dimension of the variable (or “string” if it is a string type).

  • name: The name of the variable.

  • units: The units of the variable (if available).

  • comment: Any additional comments about the variable (if available).

seagliderOG1.writers.save_dataset(ds, output_file='../test.nc')[source]

Attempts to save the dataset to a NetCDF file. If a TypeError occurs due to invalid attribute values, it converts the invalid attributes to strings and retries the save operation.

Parameters:
  • (xarray.Dataset) (ds)

  • (str) (output_file)

Returns:

  • bool (True if the dataset was saved successfully, False otherwise.)

  • Based on (https://github.com/pydata/xarray/issues/3743)

seagliderOG1.tools.add_dive_number(ds, dive_number)[source]

Add dive number as a variable to the dataset.

Parameters: ds (xarray.Dataset): The dataset to which the dive number will be added.

Returns: xarray.Dataset: The dataset with the dive number added.

seagliderOG1.tools.add_sensor_to_dataset(dsa, ds, sg_cal)[source]
seagliderOG1.tools.add_sensors_old(ds, dsa)[source]
seagliderOG1.tools.add_standard_global_attrs(ds)[source]
seagliderOG1.tools.assign_phase(ds)[source]

This function adds new variables ‘PHASE’ and ‘PHASE_QC’ to the dataset ds, which indicate the phase of each measurement. The phase is determined based on the pressure readings (‘PRES’) for each unique dive number (‘dive_num’).

Note: In this formulation, we are only separating into dives and climbs based on when the glider is at the maximum depth. Future work needs to separate out the other phases: https://github.com/OceanGlidersCommunity/OG-format-user-manual/blob/main/vocabularyCollection/phase.md and generate a PHASE_QC. Assigns phase values to the dataset based on pressure readings.

Parameters:

(xarray.Dataset) (ds)

Returns:

  • xarray.Dataset (The dataset with an additional ‘PHASE’ variable, where:)

  • xarray.Dataset (The dataset with additional ‘PHASE’ and ‘PHASE_QC’ variables, where:) –

    • ‘PHASE’ indicates the phase of each measurement:
      • Phase 2 is assigned to measurements up to and including the maximum pressure point.

      • Phase 1 is assigned to measurements after the maximum pressure point.

    • ’PHASE_QC’ is an additional variable with no QC applied.

  • Note (In this formulation, we are only separating into dives and climbs based on when the glider is at the maximum depth. Future work needs to separate out the other phases: https://github.com/OceanGlidersCommunity/OG-format-user-manual/blob/main/vocabularyCollection/phase.md and generate a PHASE_QC)

seagliderOG1.tools.assign_profile_number(ds, divenum_str='divenum')[source]
seagliderOG1.tools.calc_Z(ds)[source]

Calculate the depth (Z position) of the glider using the gsw library to convert pressure to depth.

Parameters:

(xarray.Dataset) (ds)

Returns:

xarray.Dataset

Return type:

The dataset with an additional ‘DEPTH’ variable.

seagliderOG1.tools.convert_qc_flags(dsa, qc_name)[source]
seagliderOG1.tools.convert_units(ds, preferred_units=['m s-1', 'dbar', 'S m-1'], unit_conversion={'Celsius': {'factor': 1, 'units_name': 'degrees_Celsius'}, 'Pa': {'factor': 0.0001, 'units_name': 'dbar'}, 'S m-1': {'factor': 0.1, 'units_name': 'mS cm-1'}, 'S/m': {'factor': 0.1, 'units_name': 'mS/cm'}, 'cm': {'factor': 0.01, 'units_name': 'm'}, 'cm s-1': {'factor': 0.01, 'units_name': 'm s-1'}, 'cm/s': {'factor': 0.01, 'units_name': 'm/s'}, 'dbar': {'factor': 10, 'units_name': 'kPa'}, 'degrees_Celsius': {'factor': 1, 'units_name': 'Celsius'}, 'g m-3': {'factor': 0.001, 'units_name': 'kg m-3'}, 'kg m-3': {'factor': 1000, 'units_name': 'g m-3'}, 'km': {'factor': 1000, 'units_name': 'm'}, 'm': {'factor': 0.001, 'units_name': 'km'}, 'm s-1': {'factor': 100, 'units_name': 'cm s-1'}, 'm/s': {'factor': 100, 'units_name': 'cm/s'}, 'mS cm-1': {'factor': 10, 'units_name': 'S m-1'}, 'mS/cm': {'factor': 10, 'units_name': 'S/m'}})[source]

Convert the units of variables in an xarray Dataset to preferred units. This is useful, for instance, to convert cm/s to m/s.

Parameters:
  • (xarray.Dataset) (ds)

  • (list) (preferred_units)

  • (dict) (unit_conversion)

  • string (Each key is a unit) –

    • ‘factor’: The factor to multiply the variable by to convert it.

    • ’units_name’: The new unit name after conversion.

  • with (and each value is a dictionary) –

    • ‘factor’: The factor to multiply the variable by to convert it.

    • ’units_name’: The new unit name after conversion.

Returns:

xarray.Dataset

Return type:

The dataset with converted units.

seagliderOG1.tools.convert_units_var(var_values, current_unit, new_unit, unit_conversion={'Celsius': {'factor': 1, 'units_name': 'degrees_Celsius'}, 'Pa': {'factor': 0.0001, 'units_name': 'dbar'}, 'S m-1': {'factor': 0.1, 'units_name': 'mS cm-1'}, 'S/m': {'factor': 0.1, 'units_name': 'mS/cm'}, 'cm': {'factor': 0.01, 'units_name': 'm'}, 'cm s-1': {'factor': 0.01, 'units_name': 'm s-1'}, 'cm/s': {'factor': 0.01, 'units_name': 'm/s'}, 'dbar': {'factor': 10, 'units_name': 'kPa'}, 'degrees_Celsius': {'factor': 1, 'units_name': 'Celsius'}, 'g m-3': {'factor': 0.001, 'units_name': 'kg m-3'}, 'kg m-3': {'factor': 1000, 'units_name': 'g m-3'}, 'km': {'factor': 1000, 'units_name': 'm'}, 'm': {'factor': 0.001, 'units_name': 'km'}, 'm s-1': {'factor': 100, 'units_name': 'cm s-1'}, 'm/s': {'factor': 100, 'units_name': 'cm/s'}, 'mS cm-1': {'factor': 10, 'units_name': 'S m-1'}, 'mS/cm': {'factor': 10, 'units_name': 'S/m'}})[source]

Convert the units of variables in an xarray Dataset to preferred units. This is useful, for instance, to convert cm/s to m/s.

Parameters:
  • (xarray.Dataset) (ds)

  • (list) (preferred_units)

  • (dict) (unit_conversion)

  • string (Each key is a unit) –

    • ‘factor’: The factor to multiply the variable by to convert it.

    • ’units_name’: The new unit name after conversion.

  • with (and each value is a dictionary) –

    • ‘factor’: The factor to multiply the variable by to convert it.

    • ’units_name’: The new unit name after conversion.

Returns:

xarray.Dataset

Return type:

The dataset with converted units.

seagliderOG1.tools.encode_times(ds)[source]
seagliderOG1.tools.encode_times_og1(ds)[source]
seagliderOG1.tools.find_best_dtype(var_name, da)[source]
seagliderOG1.tools.get_sg_attrs(ds)[source]
seagliderOG1.tools.mailer(subject, message, recipient='callum.rollo@voiceoftheocean.org')[source]
seagliderOG1.tools.natural_sort(unsorted_list)[source]
seagliderOG1.tools.reformat_units_var(ds, var_name, unit_format={'S/m': 'S m-1', 'cm/s': 'cm s-1', 'degrees_Celsius': 'Celsius', 'g/m^3': 'g m-3', 'm/s': 'm s-1', 'meters': 'm'})[source]

Renames units in the dataset based on the provided dictionary for OG1.

Parameters:
  • (xarray.Dataset) (ds)

  • (dict) (unit_format)

Returns:

xarray.Dataset

Return type:

The dataset with renamed units.

seagliderOG1.tools.sensor_sampling_period(glider, mission)[source]
seagliderOG1.tools.set_best_dtype(ds)[source]
seagliderOG1.tools.set_best_dtype_value(value, var_name)[source]

Determines the best data type for a single value based on its variable name and converts it.

Parameters:

value (any) – The input value to convert.

Returns:

converted_value – The value converted to the best data type.

Return type:

any

seagliderOG1.tools.set_fill_value(new_dtype)[source]
seagliderOG1.tools.split_by_unique_dims(ds)[source]

Splits an xarray dataset into multiple datasets based on the unique set of dimensions of the variables.

Parameters: ds (xarray.Dataset): The input xarray dataset containing various variables.

Returns: tuple: A tuple containing xarray datasets, each with variables sharing the same set of dimensions.