roms_tools.setup.nesting.make_nesting_info

roms_tools.setup.nesting.make_nesting_info#

roms_tools.setup.nesting.make_nesting_info(parent_grid: Grid, child_grid: Grid, filepath: str | None = None, prefix: str = 'child', period: float = 3600.0, include_bgc: bool = False, include_pressure_fluxes: bool = False, boundaries: dict | None = None, verbose: bool = False, format: Literal['NETCDF4', 'NETCDF3_CLASSIC', 'NETCDF3_64BIT_OFFSET', 'NETCDF3_64BIT_DATA'] = 'NETCDF4') Dataset#

Maps child grid boundary points onto absolute indices of the parent grid, and saves the nesting information to NetCDF files.

This function updates the mapping of child boundaries to parent-grid indices. This mapping depends on the updated mask from align_grid, since masked (land) points may extend outside the parent grid.

The mapping is done by interpolating the spatial indices of the child grid boundaries onto the parent grid, ensuring alignment between the two grids. It supports all four boundaries (south, east, north, and west) and considers different grid locations (rho, u, and v). Additionally, it updates land indices if they fall onto land points in the parent grid.

Parameters:
  • parent_grid (Grid) – The parent grid dataset containing longitude, latitude, and mask variables.

  • child_grid (Grid) – The child grid dataset containing longitude, latitude, mask, and angle variables.

  • filepath (Union[str, Path]) – The base path and filename for the output files. The filenames will include the specified path and the .nc extension. If None is provided, the dataset will not be saved. Defaults to None.

  • prefix (str) – Prefix for variable names in ds_nesting. Defaults to “child”.

  • period (float) – Temporal resolution for boundary outputs in seconds. Defaults to 3600 (hourly).

  • include_bgc (bool) – Whether to include BGC variables in boundary outputs. Defaults to False.

  • include_pressure_fluxes (bool, optional) – Whether to include baroclinic pressure fluxes in boundary outputs. Defaults to False.

  • boundaries (dict, optional) – A dictionary specifying which child boundaries should be mapped onto the parent grid. Keys should be “south”, “east”, “north”, and “west”, with boolean values indicating whether to process each boundary. Defaults to mapping all boundaries.

  • verbose (bool, optional) – Indicates whether to print grid generation steps with timing. Defaults to False.

  • format ({"NETCDF4", "NETCDF3_CLASSIC", "NETCDF3_64BIT_OFFSET", "NETCDF3_64BIT_DATA"}, optional) – NetCDF file format when filepath is provided. Defaults to "NETCDF4".

Returns:

xarray.Dataset – A dataset containing the mapped boundary indices for rho, u, and v grid points. - For rho points: Contains mapped xi and eta indices. - For u and v points: Contains mapped xi, eta, and angle values. - Attributes include long names, output variable names, units, and output period.