casys.grids

OCTANT-NG in-grid classes.

Classes

InGridGeotiffParameters(file_name, band_number)

InGrid parameters from a GeoTIFF file.

InGridNetcdfParameters(file_name, z_name[, ...])

InGrid parameters from a NetCDF file containing 2D grids.

class casys.grids.InGridGeotiffParameters(file_name, band_number)

Bases: InGridParameters

InGrid parameters from a GeoTIFF file.

Parameters:
  • file_name (str | PurePath) – Name of the GEOTIFF file

  • band_number (int) – Number of the band

check_dimensions()
check_method(method)
Parameters:

method (InterpMode)

property converter
property extrapolator
grid(lon, lat)

Returns a grid limited to the zone of interest.

Parameters:
  • lon (ndarray) – Longitudes values.

  • lat (ndarray) – Latitude values.

Returns:

x, y, z values.

property lon_lat_converter
required_fields()

Returns the list of required data fields to run this algorithm.

Return type:

list[str]

Returns:

List of required data fields to run this algorithm.

property x
property y
property z
class casys.grids.InGridNetcdfParameters(file_name, z_name, x_name=None, y_name=None, lon_lat_converter=None, is_lon_lat=True, xr_kwargs=None)

Bases: InGridDatasetParameters

InGrid parameters from a NetCDF file containing 2D grids.

Parameters:
  • file_name (str | PurePath) – Name of the NetCDF file.

  • x_name (str | None) – Name of the x NetCDF variable (longitude if is_lon_lat is True).

  • y_name (str | None) – Name of the y NetCDF variable (latitude if is_lon_lat is True).

  • z_name (str) – Name of the z NetCDF variable (variable to interpolate).

  • lon_lat_converter (LonLatConverter | None) – Converter, making run lon/lat parameters compatible with the grid. (If no converter was provided and is_lon_lat parameter is True the LongitudeNormalizer(min_lon=x[0]) will be used)

  • is_lon_lat (bool) – Is the grid a lon/lat grid ? (To correctly set the parameter need to define what type of grid is used. For example if the lon/lat grid is expected so need to verify that the names and the values of coordinates or of the variables in the grid correspond to the longitude and latitude).

  • xr_kwargs (dict[str, Any]) – Additional parameters to provide to xarray when opening files.

Raises:

InGridError – If ‘lon_lat_converter’ wasn’t provided and ‘is_lon_lat’ equal to False.

check_dimensions()
check_method(method)

Check that the interpolation method is compatible with the grid.

Parameters:

method (InterpMode) – interpolation method for numpy.interpn: ‘linear’ (default), ‘nearest’ or ‘splinef2d’

property converter
property extrapolator
grid(lon, lat)

Returns a grid limited to the zone of interest.

Parameters:
  • lon (ndarray) – Longitudes values.

  • lat (ndarray) – Latitude values.

Returns:

x, y, z values.

guess_axis_names(data)

Automatic guess of the X and Y axis names.

If the x_name and y_name attributes are not specified in the object initialization, it means we should look for the axis called:

  • x/y

  • lon/lat

  • longitude/latitude

If we do not find the axis, the default behavior is to consider the first z dimension as X, the second one as Y, and this triggers a warning.

Parameters:

data – xarray Dataset containing the variable

property lon_lat_converter
required_fields()

Returns the list of required data fields to run this algorithm.

Return type:

list[str]

Returns:

List of required data fields to run this algorithm.

property x
property y
property z