polaris.mesh.radius.rescale_sphere_radius

polaris.mesh.radius.rescale_sphere_radius(ds: Dataset, radius: float | None = None) → list[str][source]

Rescale the coordinates, lengths and areas of a spherical MPAS mesh to a new sphere radius, in place, and update the sphere_radius global attribute to match. Latitudes, longitudes, angles and dimensionless fields are unchanged. The variables rescaled are the length_variables and area_variables groups from polaris.mesh.variables.get_mesh_variables(). Those not in ds are skipped, so the function works on any MPAS component’s mesh, initial-condition or restart file.

Parameters:
  • ds (xarray.Dataset) – A dataset on a spherical MPAS mesh with a positive sphere_radius global attribute. The variables are replaced with rescaled copies that keep their attributes and encoding.

  • radius (float, optional) – The new sphere radius in meters. The default is the PCD’s mean_radius.

Returns:

rescaled (list of str) – The names of the variables that were rescaled

Raises:

ValueError – If the mesh is not spherical or sphere_radius is missing or not positive