ocean_data_gateway.readers.axds.stations

class ocean_data_gateway.readers.axds.stations(kwargs)[source]

Bases: ocean_data_gateway.readers.axds.AxdsReader

Inherits from AxdsReader to search for 1+ stations or dataset_ids.

kw

Contains time search constraints: min_time, max_time. If not input, all time will be used.

Type

dict

variables

variables is None for this class since we read search by dataset_id or station name.

Type

None

approach

approach is defined as ‘stations’ for this class.

Type

string

Attributes
catalog

Write then open the catalog.

dataset_ids

Find dataset_ids for server.

meta

Rearrange the individual metadata into a dataframe.

search_results

Loop over self.urls to read in search results.

urls

Return a list of search urls.

Methods

clear()

data([dataset_ids])

Read in data for some or all dataset_ids.

data_by_dataset(dataset_id)

Return the data for a single dataset_id.

get(k[,d])

items()

keys()

Regular dict-like way to return keys.

meta_by_dataset(dataset_id)

Return the catalog metadata for a single dataset_id.

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()

as a 2-tuple; but raise KeyError if D is empty.

save()

Save datasets locally.

setdefault(k[,d])

update([E, ]**F)

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

url_builder(url_base[, dataset_id, …])

Build an individual search url.

url_dataset_id(dataset_id)

url modification to search for known dataset_id.

url_query(query)

url modification to add query field.

url_region()

url modification to add spatial search box.

url_time()

url modification to add time filtering.

url_variable(variable)

url modification to add variable search.

values()

Regular dict-like way to return values.

write_catalog()

Write catalog file.

write_catalog_layer_group_entry(dataset, …)

Write part of catalog in case of layer_group.

__init__(kwargs)[source]
Parameters

kwargs (dict) –

Can contain arguments to pass onto the base AxdsReader class (catalog_name, parallel, axds_type). The dict entries to initialize this class are: * kw: dict, optional

Contains time search constraints: min_time, max_time. If not input, all time will be used.

  • stations: string, list, optional Input station names as they might be commonly known and therefore can be searched for as a query term. The station names can be input as something like “TABS B” or “8771972” and has pretty good success. Or, use this option if you know the exact dataset_ids for the data you want and axds_type==’platform2’. These need to be the dataset_ids corresponding to the databases that are being searched, so in this case they need to be the Axiom packrat uuid’s. If axds_type==’layer_group’, input the layer_group uuids you want to search for.

Notes

The axds_type needs to match the station name or dataset_id you are searching for.

Methods

__init__(kwargs)

param kwargs

Can contain arguments to pass onto the base AxdsReader class

clear()

data([dataset_ids])

Read in data for some or all dataset_ids.

data_by_dataset(dataset_id)

Return the data for a single dataset_id.

get(k[,d])

items()

keys()

Regular dict-like way to return keys.

meta_by_dataset(dataset_id)

Return the catalog metadata for a single dataset_id.

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()

as a 2-tuple; but raise KeyError if D is empty.

save()

Save datasets locally.

setdefault(k[,d])

update([E, ]**F)

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

url_builder(url_base[, dataset_id, …])

Build an individual search url.

url_dataset_id(dataset_id)

url modification to search for known dataset_id.

url_query(query)

url modification to add query field.

url_region()

url modification to add spatial search box.

url_time()

url modification to add time filtering.

url_variable(variable)

url modification to add variable search.

values()

Regular dict-like way to return values.

write_catalog()

Write catalog file.

write_catalog_layer_group_entry(dataset, …)

Write part of catalog in case of layer_group.

Attributes

catalog

Write then open the catalog.

dataset_ids

Find dataset_ids for server.

meta

Rearrange the individual metadata into a dataframe.

search_results

Loop over self.urls to read in search results.

urls

Return a list of search urls.

_abc_impl = <_abc_data object>
property catalog

Write then open the catalog.

clear()None.  Remove all items from D.
data(dataset_ids=None)

Read in data for some or all dataset_ids.

NOT USED CURRENTLY

Once data is read in for a dataset_ids, it is remembered.

See full documentation in utils.load_data().

data_by_dataset(dataset_id)

Return the data for a single dataset_id.

Returns

  • A tuple of (dataset_id, data), where data type depends on self.axds_type

  • If `self.axds_type==’platform2’` (a pandas DataFrame)

  • If `self.axds_type==’layer_group’` (an xarray Dataset)

Notes

Read behavior depends on axds_type:

  • If self.axds_type==’platform2’: data is read into memory with dask.

  • If self.axds_type==’layer_group’: data is pointed to with dask but nothing is read in except metadata associated with the xarray Dataset.

property dataset_ids

Find dataset_ids for server.

Notes

The dataset_ids are read from the catalog, so the catalog is created before this can happen.

The number of dataset_ids can change if a variable is removed from the list of variables and this is rerun.

get(k[, d])D[k] if k in D, else d.  d defaults to None.
items()a set-like object providing a view on D’s items
keys()

Regular dict-like way to return keys.

property meta

Rearrange the individual metadata into a dataframe.

meta_by_dataset(dataset_id)

Return the catalog metadata for a single dataset_id.

TO DO: Should this return intake-style or a row of the metadata dataframe?

pop(k[, d])v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()(k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

save()

Save datasets locally.

property search_results

Loop over self.urls to read in search results.

Notes

The logic removes duplicate searches. This returns a dict of the datasets from the search results with the key of each entry being the dataset_id. For

  • self.axds_type == “platform2”: dataset_id is the uuid

  • self.axds_type == “layer_group”: dataset_id is the module_uuid since multiple layer_groups can be linked under one module_uuid

setdefault(k[, d])D.get(k,d), also set D[k]=d if k not in D
update([E, ]**F)None.  Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

url_builder(url_base, dataset_id=None, add_region=False, add_time=False, variable=None, query=None)

Build an individual search url.

Parameters
  • url_base (string) – There are 2 possible bases for the url: * self.url_axds_type, for searching * self.url_docs_base, for selecting known dataset by dataset_id

  • dataset_id (string, optional) – dataset_id of station, if known.

  • add_region (boolean, optional) – True to filter the search by lon/lat box. Requires self.kw that contains keys min_lon, max_lon, min_lat, max_lat.

  • add_time (boolean, optional) – True to filter the search by time range. Requires self.kw that contains keys min_time and max_time.

  • variable (string, optional) – String of variable description to filter by, if desired. If axds_type==’platform2’, find the variable name options with class function odg.all_variables(‘axds’), search for variable names by string with odg.search_variables(‘axds’, variables), and check your variable list with check_variables(‘axds’, variables). If axds_type==’layer_group’, there is no official variable list and you can instead just put in a basic variable name and hope the search works.

  • query (string, optional) – This could be any search query you want, but it is used in the code to search for station names (not dataset_ids).

Returns

Return type

Url for search.

url_dataset_id(dataset_id)

url modification to search for known dataset_id.

Parameters

dataset_id (string) – String of dataset_id to exactly match.

Returns

Return type

Modification for url to search for dataset_id.

url_query(query)

url modification to add query field.

Parameters

query (string) – String to query for. Can be multiple words.

Returns

Return type

Modification for url to add query field.

url_region()

url modification to add spatial search box.

Returns

Return type

Modification for url to add lon/lat filtering.

Notes

Uses the kw dictionary already stored in the class object to access the spatial limits of the box.

url_time()

url modification to add time filtering.

Returns

Return type

Modification for url to add time filtering.

Notes

Uses the kw dictionary already stored in the class object to access the time limits of the search.

url_variable(variable)

url modification to add variable search.

Parameters

variable (string) – String to search for.

Returns

Return type

Modification for url to add variable search.

Notes

This variable search is specifically by parameter group and only works for axds_type=’platform2’. For axds_type=’layer_group’, use url_query with the variable name.

property urls

Return a list of search urls.

Notes

Use this through the class methods region or stations to put together the search urls to represent the basic reader setup.

values()

Regular dict-like way to return values.

write_catalog()

Write catalog file.

write_catalog_layer_group_entry(dataset, dataset_id, urlpath, layer_groups)

Write part of catalog in case of layer_group.

Notes

This is used to manage the logic for axds_type=’layer_group’ in which the module is being linked to the set of layer_groups.