Container

Inheritance diagram of gspy.gs_datatree.Container
class gspy.gs_datatree.Container.Container(xarray_obj)

Class defining a survey or dataset

The Survey group contains general metadata about the survey or data colleciton as a whole. Information about where the data was collected, acquisition start and end dates, who collected the data, any clients or contractors involved, system specifications, equipment details, and so on are documented within the Survey as data variables and attributes.

Users are allowed to add as much or little information to data variables as they choose. However, following the CF convention, a set of global dataset attributes are required: * title * institution * source * history * references

A “spatial_ref” variable is also required within Survey and should contain all relevant information about the coordinate reference system.

Once instantiated, tabular and raster classes can be added to the survey. Each tabular or raster dataset is a separate xarray.Dataset.

Survey(metadata)

Parameters:

metadata (str or dict) –

  • If str, a metadata file

  • If dict, dictionary of survey metadata.

Return type:

gspy.Survey

See also

Spatial_ref

For information on creating a spatial ref

classmethod Data(data_filename=None, metadata_file=None, spatial_ref=None, **kwargs)
classmethod Systems(**kwargs)
add(key, *args, **kwargs)
add_container(key, **kwargs)

Add a container to the survey

Parameters:
  • key (str) – Name of the container.

  • kwargs (dict) – Metadata for the container.

Return type:

xarray.DataTree

add_timestamp(*args, **kwargs)
classmethod from_dict(metadata={})
get_all_attr(attr, path=None, **kwargs)
get_system_with_method(method)
static metadata_template(metadata_filename=None, **kwargs)
plot(*args, **kwargs)
plot_cross_section(*args, **kwargs)
static read_metadata(filename=None)

Read metadata for the survey

Parameters:

filename (str) – Metadata file.

Return type:

dict

See also

Survey.write_metadata_template

For more metadata data information

scatter(*args, **kwargs)
set_spatial_ref(kwargs)

Set the spatial ref of the Dataset.

Specifically adds an xarray coordinate called ‘spatial_ref’ which is required for GIS software and the CF convention.

Important

Make sure you call this method into a return variable

ds = ds.add_coordinate_from_dict

Otherwise, the spatial_ref will not be added correctly.

Parameters:

kwargs (dict, gspy.Spatial_ref, or xarray.DataArray) –

  • If dict: creates a Spatial_ref from a dict of metadata.

  • If an existing spatial ref, assign by reference

Returns:

Dataset with spatial_ref added.

Return type:

Dataset

See also

Survey.Spatial_ref

for more details of creating a Spatial_ref

subset(key, value)
to_netcdf(*args, **kwargs)

Write the survey to a netcdf file

Parameters:
  • args (list) – Arguments to pass to xarray.Dataset.to_netcdf

  • kwargs (dict) – Keyword arguments to pass to xarray.Dataset.to_netcdf

Return type:

None

property tree
write_ncml(file, indent=0)

Write an NcML (NetCDF XML) metadata file

Parameters:

filename (str) – Name of the NetCDF file to generate NcML for