Configuration¶
grid_doctor.config holds library-wide settings. A setting is resolved in
this order, later ones winning:
- the built-in default,
- the environment variable
GRID_DOCTOR_<SETTING>(read at import), - assignment at runtime.
| Setting | Default | Values | Environment variable |
|---|---|---|---|
ellipsoid |
"sphere" |
"sphere", "WGS84" |
GRID_DOCTOR_ELLIPSOID |
weights_store |
None ($XDG_CACHE_HOME/grid-doctor/weights) |
local path, file:// or memory:// URL |
GRID_DOCTOR_WEIGHTS_STORE |
import grid_doctor as gd
gd.config.ellipsoid = "WGS84" # HEALPix geometry on WGS84
with gd.config.set(ellipsoid="sphere", weights_store="/work/ab1234/weights"):
... # restored after the block
Settings are process-wide: a with gd.config.set(...) block also affects
other threads while it is open, and dask workers in other processes only see
the environment variable.
ellipsoid applies to grids being created (regridding, binning, weight
generation). The ellipsoid is recorded in the output (CF
reference_ellipsoid_name, semi_major_axis and inverse_flattening for
WGS84) and in weight files; reading, selecting from or coarsening existing
data uses the recorded ellipsoid. HEALPix metadata or a weight file without
these attributes is spherical. A dataset with no HEALPix metadata at all gets
this setting when selecting from it with an explicit level=; coarsening
requires the HEALPix metadata.
weights_store is where cached_weights and
regrid_to_healpix look up and store weight
files; see Weights Store. grid-doctor never guesses a scratch
or project directory: point it at one yourself, for example on an HPC system
where the home directory has a small quota.
grid_doctor.config
¶
Library-wide settings.
Each setting has a built-in default, which the environment variable
GRID_DOCTOR_<SETTING> overrides (read when grid_doctor.config is
imported), which assignment at runtime overrides in turn::
import grid_doctor as gd
gd.config.ellipsoid = "WGS84"
with gd.config.set(ellipsoid="sphere"): # restored after the block
...
Settings are process-wide: a with gd.config.set(...) block also affects
other threads while it is open.
ellipsoid = 'sphere'
module-attribute
¶
Ellipsoid on which new HEALPix grids are built, passed to healpix_geo:
"sphere" (consistent with ESMF's spherical area calculation) or
"WGS84". It is recorded in the output and in weight files; code reading
existing data uses the recorded one instead (a sphere if the HEALPix
metadata or weight file records none). Only a dataset with no HEALPix
metadata at all, selected from with an explicit level=, falls back to
this setting. Environment variable: GRID_DOCTOR_ELLIPSOID.
weights_store = None
module-attribute
¶
Location of the default
WeightsStore: a local path or a
file:// or memory:// URL. None uses
$XDG_CACHE_HOME/grid-doctor/weights (~/.cache/grid-doctor/weights).
Environment variable: GRID_DOCTOR_WEIGHTS_STORE.
SETTINGS = ('ellipsoid', 'weights_store')
module-attribute
¶
Names of all settings.
set(**settings)
¶
Change settings inside a with block, restoring them afterwards.
Raises:
| Type | Description |
|---|---|
AttributeError
|
If a setting does not exist. |
ValueError
|
If a value is invalid; no setting is changed then. |