Source
source
Rompy source objects.
Attributes
Classes
SourceBase
Bases: RompyBaseModel, ABC
Abstract base class for a source dataset.
Source code in rompy/core/source.py
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['base_source'] = Field(description='Model type discriminator, must be overriden by a subclass')
Functions
open
Return the filtered dataset object.
Parameters
variables : list, optional List of variables to select from the dataset. filters : Filter, optional 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.
Source code in rompy/core/source.py
SourceFile
Bases: SourceBase
Source dataset from file to open with xarray.open_dataset.
Source code in rompy/core/source.py
Attributes
model_type
class-attribute
instance-attribute
uri
class-attribute
instance-attribute
kwargs
class-attribute
instance-attribute
variable
class-attribute
instance-attribute
SourceIntake
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.
Source code in rompy/core/source.py
Attributes
model_type
class-attribute
instance-attribute
dataset_id
class-attribute
instance-attribute
catalog_uri
class-attribute
instance-attribute
catalog_uri: Optional[str | Path] = Field(default=None, description='The URI of the catalog to read from')
catalog_yaml
class-attribute
instance-attribute
catalog_yaml: Optional[str] = Field(default=None, description='The YAML string of the catalog to read from')
kwargs
class-attribute
instance-attribute
kwargs: dict = Field(default={}, description='Keyword arguments to define intake dataset parameters')
Functions
check_catalog
check_catalog() -> SourceIntake
Source code in rompy/core/source.py
SourceDatamesh
Bases: SourceBase
Source dataset from Datamesh.
Datamesh documentation: https://docs.oceanum.io/datamesh/index.html
Source code in rompy/core/source.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
Attributes
model_type
class-attribute
instance-attribute
datasource
class-attribute
instance-attribute
token
class-attribute
instance-attribute
token: Optional[str] = Field(default=None, description='Datamesh API token, taken from the environment if not provided')
kwargs
class-attribute
instance-attribute
kwargs: dict = Field(default={}, description='Keyword arguments to pass to `oceanum.datamesh.Connector`')
Functions
open
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.
Source code in rompy/core/source.py
SourceWavespectra
Bases: SourceBase
Wavespectra dataset from wavespectra reader.
Source code in rompy/core/source.py
SourceTimeseriesCSV
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.
Source code in rompy/core/source.py
Attributes
model_type
class-attribute
instance-attribute
filename
class-attribute
instance-attribute
tcol
class-attribute
instance-attribute
read_csv_kwargs
class-attribute
instance-attribute
read_csv_kwargs: dict = Field(default={}, description='Keyword arguments to pass to pandas.read_csv')
Functions
validate_kwargs
validate_kwargs() -> SourceTimeseriesCSV
Validate the keyword arguments.
Source code in rompy/core/source.py
Functions
render_datetimes
Convert datetime objects in a dictionary to ISO format strings.
Parameters
dict_obj : dict The dictionary to process.
Returns
dict The processed dictionary with datetime objects converted to strings.
Source code in rompy/core/source.py
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
data : dict The dictionary to convert.
Returns
str A string representation of the sorted dictionary items.