Sources¶
Sources open datasets for the data objects. Model plugins and other packages add sources under the rompy.source entry point.
Rompy source objects.
SourceBase
pydantic-model
¶
SourceBase(**data: Any)
Bases: RompyBaseModel, ABC
Abstract base class for a source dataset.
Fields:
-
model_type(Literal['base_source'])
model_type
pydantic-field
¶
model_type: Literal['base_source']
Model type discriminator, must be overriden by a subclass
open
¶
Return the filtered dataset object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variables
|
list
|
List of variables to select from the dataset. |
[]
|
filters
|
Filter
|
Filters to apply to the dataset. |
{}
|
Notes
The kwargs are only a placeholder in case a subclass needs to pass additional arguments to the open method.
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
SourceFile
pydantic-model
¶
SourceFile(**data: Any)
Bases: SourceBase
Source dataset from file to open with xarray.open_dataset.
Config:
arbitrary_types_allowed:True
Fields:
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
open
¶
Return the filtered dataset object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variables
|
list
|
List of variables to select from the dataset. |
[]
|
filters
|
Filter
|
Filters to apply to the dataset. |
{}
|
Notes
The kwargs are only a placeholder in case a subclass needs to pass additional arguments to the open method.
SourceIntake
pydantic-model
¶
SourceIntake(**data: Any)
Bases: SourceBase
Source dataset from intake catalog.
note
The intake catalog can be prescribed either by the URI of an existing catalog file
or by a YAML string defining the catalog. The YAML string can be obtained from
calling the yaml() method on an intake dataset instance.
Fields:
-
model_type(Literal['intake']) -
dataset_id(str) -
catalog_uri(Optional[str | Path]) -
catalog_yaml(Optional[str]) -
kwargs(dict)
Validators:
catalog_uri
pydantic-field
¶
The URI of the catalog to read from
catalog_yaml
pydantic-field
¶
The YAML string of the catalog to read from
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
open
¶
Return the filtered dataset object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variables
|
list
|
List of variables to select from the dataset. |
[]
|
filters
|
Filter
|
Filters to apply to the dataset. |
{}
|
Notes
The kwargs are only a placeholder in case a subclass needs to pass additional arguments to the open method.
SourceDatamesh
pydantic-model
¶
SourceDatamesh(**data: Any)
Bases: SourceBase
Source dataset from Datamesh.
Datamesh documentation: https://docs.oceanum.io/datamesh/index.html
Fields:
-
model_type(Literal['datamesh']) -
datasource(str) -
token(Optional[str]) -
kwargs(dict)
token
pydantic-field
¶
Datamesh API token, taken from the environment if not provided
open
¶
open(
filters: Filter,
coords: DatasetCoords,
variables: list = [],
) -> Dataset
Returns the filtered dataset object.
This method is overriden from the base class because the crop filters need to be converted to a geofilter and timefilter for querying Datamesh.
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
SourceWavespectra
pydantic-model
¶
SourceWavespectra(**data: Any)
Bases: SourceBase
Wavespectra dataset from wavespectra reader.
Fields:
model_type
pydantic-field
¶
model_type: Literal['wavespectra'] = 'wavespectra'
Model type discriminator
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
open
¶
Return the filtered dataset object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variables
|
list
|
List of variables to select from the dataset. |
[]
|
filters
|
Filter
|
Filters to apply to the dataset. |
{}
|
Notes
The kwargs are only a placeholder in case a subclass needs to pass additional arguments to the open method.
SourceTimeseriesCSV
pydantic-model
¶
SourceTimeseriesCSV(**data: Any)
Bases: SourceBase
Timeseries source class from CSV file.
This class should return a timeseries from a CSV file. The dataset variables are defined from the column headers, therefore the appropriate read_csv kwargs must be passed to allow defining the columns. The time index is defined from column name identified by the tcol field.
Fields:
-
model_type(Literal['csv']) -
filename(str | Path) -
tcol(str) -
read_csv_kwargs(dict)
Validators:
read_csv_kwargs
pydantic-field
¶
read_csv_kwargs: dict = {}
Keyword arguments to pass to pandas.read_csv
validate_kwargs
pydantic-validator
¶
validate_kwargs() -> SourceTimeseriesCSV
Validate the keyword arguments.
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
open
¶
Return the filtered dataset object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variables
|
list
|
List of variables to select from the dataset. |
[]
|
filters
|
Filter
|
Filters to apply to the dataset. |
{}
|
Notes
The kwargs are only a placeholder in case a subclass needs to pass additional arguments to the open method.
render_datetimes
¶
dict_to_key
¶
Convert a dictionary to a hashable key string.
This function converts a dictionary uniquely to a string which can be used as a hashable key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
The dictionary to convert. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A string representation of the sorted dictionary items. |