Base Classes¶
This is a reference API class listing.
- class rompy.core.BaseModel(run_id='run_0001', model=None, template=None, checkout=None, settings=None, output_dir=None)¶
- class rompy.core.BaseGrid¶
An object which provides an abstract representation of a grid in some geographic space
This is the base class for all Grid objects. The minimum representation of a grid are two NumPy array’s representing the vertices or nodes of some structured or unstructured grid, its bounding box and a boundary polygon. No knowledge of the grid connectivity is expected.
- bbox(buffer=0.0)¶
Returns a bounding box for the spatial grid
This function returns a list [ll_x, ll_y, ur_x, ur_y] where ll_x, ll_y (ur_x, ur_y) are the lower left (upper right) x and y coordinates bounding box of the model domain
- boundary(tolerance=0.2)¶
Returns a boundary polygon as a Shapely Polygon object. Sub-classes can override the private method Grid._get_boundary() but must return a Shapely polygon object.
- tolerancefloat
See https://shapely.readthedocs.io/en/stable/manual.html#object.simplify
polygon : shapely.Polygon see https://shapely.readthedocs.io/en/stable/manual.html#Polygon
- boundary_points(tolerance=0.2)¶
Convenience function to convert boundary Shapely Polygon to arrays of coordinates
- tolerancefloat
Passed to Grid.boundary See https://shapely.readthedocs.io/en/stable/manual.html#object.simplify
- class rompy.swan.SwanModel(run_id='run_0001', template=None, checkout=None, settings=None, output_dir=None)¶
- class rompy.swan.SwanGrid(gridtype=None, x0=None, y0=None, rot=None, dx=None, dy=None, nx=None, ny=None, exc=None, gridfile=None)¶
- nearby_spectra(ds_spec, dist_thres=0.05, plot=True)¶
Find points nearby and project to the boundary
- ds_spec: xarray.Dataset
an XArray dataset of wave spectra at a number of points. Dataset variable names standardised using wavespectra.read_* functions.
See https://wavespectra.readthedocs.io/en/latest/api.html#input-functions
- dist_thres: float, optional [Default: 0.05]
Maximum distance to translate the input spectra to the grid boundary
- plot: boolean, optional [Default: True]
Generate a plot that shows the applied projections
- xarray.Dataset
A subset of ds_spec with lat and lon coordinates projected to the boundary
- class rompy.intake.NetCDFFCStackSource(*args, **kwargs)¶
An extension of intake-xarray in an opinionated fashion to open a stack of forecast model results stored as netcdf using xarray.
Expands urlpath with the product of values passed in parameter
fmt_fieldsto establish a finite set of urls to stack. Uses fsspec so that the file system can be on a local or http. Useful for subsetting catalogs of netcdf files. Defers to XArray for file opening and backend driver selection.- urlpathstr
Templated path to scan for source file(s). May include format pattern strings. Some examples:
{{ CATALOG_DIR }}/data/{year}/air_{month}.nchttps://some.thredds.server/thredds/catalog/model/{year}/{month}/catalog.html
- fn_fmtstr, optional
Templated file name to check for existence in the broadcast urlpath Example:
air_{month}.nc
- fmt_fields: dict
Dictionary of keys corresponding to urlpath format entries. The product of all values is broadcast across urlpath to establish a finite set of locations to look for source files.
- url_replace:
Dictionary of string substitutions to be made on found urls. Example:
{‘catalog’:’dodsC’}
- ds_filters:
Dictionary of common dataset manipulations that are applied in order during dataset preprocessing. Configurable from catalog entry yaml. Filters currently available are [‘sort’,’subset’,’crop’,’timenorm’,’rename’] Examples:
- {‘rename’:{‘dir’:’mean_dir’},
‘sort’:[‘direction’], ‘timenorm’:’hour’, ‘crop’:{‘lon’:slice(-32.2,-33.2),
‘lat’:slice(114.,115.)}
}
Additional documentation to follow - see source code for xarray implementation details.
- startdt, enddt: datetime, optional
Start and end dates to crop final stacked dataset to.
- hindcast: bool, optional
Rather than return a stack of forecasts, return a dataset with a unique time dimension selecting the minimum lead time for each time point. Useful for establishing a pseudo-reanalysis dataset from a stack of forecasts.
- chunksint or dict, optional
Chunks is used to load the new dataset into dask arrays.
chunks={}loads the dataset with dask using a single chunk for all arrays.- xarray_kwargs: dict
Additional xarray kwargs for xr.open_dataset().
- storage_options: dict
If using a remote fs (whether caching locally or not), these are the kwargs to pass to that FS.