hydro.discoverability

Functions for adding ACDD/discoverability attributes to datasets based on their contents

Functions

flag_histogram(ds)

For flag variables, create a histogram of how many times each flag value appears

min_max(ds)

Set min/max attributes on all the numeric data variables including

temporal(ds)

Set the temporal extent global attributes

geospatial(ds)

Set the geospatial extent global attributes

add_discoverability_attributes(ds)

Add (or update) all the discoverability metadata from all the other functions in this module

Module Contents

hydro.discoverability.flag_histogram(ds)[source]

For flag variables, create a histogram of how many times each flag value appears

Parameters:

ds (xarray.Dataset)

Return type:

xarray.Dataset

hydro.discoverability.min_max(ds)[source]

Set min/max attributes on all the numeric data variables including flags

This will use two “made up” attribute names of: * actual_max * actual_min

The more well known attributes of “valid_min” and “valid_max” apply to the packed data, so if there are add_offset and scale_factor attributes, any valid_* attributes would apply to the data before scaling/multiplying. Additionally, generic applications should mask any values outside the “valid” ranges. CF defines an attribute “actual_range” that includes both min and max values of the unpacked data. For JSON-LD/schema.org reasons we need the min/max as separate values.

Parameters:

ds (xarray.Dataset)

Return type:

xarray.Dataset

hydro.discoverability.temporal(ds)[source]

Set the temporal extent global attributes

This includes: * time_coverage_start * time_coverage_end

Parameters:

ds (xarray.Dataset)

Return type:

xarray.Dataset

hydro.discoverability.geospatial(ds)[source]

Set the geospatial extent global attributes

These include: * geospatial_lat_min * geospatial_lat_max * geospatial_lon_min * geospatial_lon_max * geospatial_vertical_min * geospatial_vertical_max * geospatial_vertical_positive (always “down”) * geospatial_vertical_units (always “dbar”)

Note that according to the “spec” of ACDD 1.3 if the lon min is greater than the lon max, this indicates that the geospatial extent crosses the discontinuity meridian. This function assumes that if the difference between the min/max of lon is larger than 300 degrees that crossing is occurring.

The behavior if the ship goes to a longitude singularity such as the north pole not explicitly handled.

The ACDD 1.3 “spec” also allows for the pressure units of bar to be used for the vertical units.

Parameters:

ds (xarray.Dataset)

Return type:

xarray.Dataset

hydro.discoverability.add_discoverability_attributes(ds)[source]

Add (or update) all the discoverability metadata from all the other functions in this module

Parameters:

ds (xarray.Dataset)

Return type:

xarray.Dataset