tracmass.config and tracmass.driver#
Configuration management for the seaview processor.
This module handles loading and managing configuration settings using Dynaconf. Settings are loaded from multiple locations in order of increasing priority:
Global settings (/etc/seaview/)
User settings (~/.config/seaview/)
Current directory settings (./)
Any
trm_*.tomlfile in the current directory (e.g.trm_omi.toml), sorted by filenameEnvironment variable specified file (SEAVIEW_SETTINGS_FILE_FOR_DYNACONF)
- tracmass.config.USER_DIR#
Path to user configuration directory.
- Type:
- tracmass.config.GLOB_DIR#
Path to global configuration directory.
- Type:
- tracmass.config.CURR_DIR#
Path to current working directory.
- Type:
- tracmass.config.settings#
The Dynaconf settings object with loaded configuration.
- Type:
Dynaconf
- tracmass.config.change_env(new_env)[source]#
Change the active Dynaconf environment.
- Parameters:
new_env (
str) – The environment name to switch to (e.g., ‘development’, ‘production’).
- tracmass.config.move_vertically()[source]#
Return the
move_verticallyflag from settings.Controls whether particles are advected by the vertical velocity
w. Read from the activetracmass.tomlenvironment; defaults toTrue(particles do move vertically) when the key is absent, matching the historicalno_wflux=False/include_wflux=Truedefaults.
- tracmass.config.n_particle_batches()[source]#
Return the
n_particle_batchesfactor from settings.Number of equal-sized particle groups each
lax.while_loopcall is split into by the full-grid integrators (tracmass.steady_state(),tracmass.time_dependent()), to cap peak per-call GPU scratch memory. Read from the activetracmass.tomlenvironment; defaults to1(no batching) when the key is absent or unparseable.time_dependent_patched/time_dependent_streamingaccept the argument for API symmetry but do not batch.
- tracmass.config.gcm_name(default=None)[source]#
Return the
gcm.nameadapter name from the active settings environment.Reads the
namekey of the[env.gcm]table intracmass.toml(e.g."glorys","ecco2","theoretical","fabboni"). A baregcm = "<name>"string (the pre-[gcm]-table form) is still accepted.
- tracmass.config.gcm_subset()[source]#
Return the GCM spatial subset from the active settings environment.
Reads the
subsetkey of the[env.gcm]table intracmass.tomland returns it as a plaindictwith every key inGCM_SUBSET_KEYSpresent. Missing keys — and keys written as"@none"orfalse— come back asNone(“no limit on that edge”).- Returns:
dict–{"i1": .., "i2": .., "istep": .., "j1": .., "j2": .., "jstep": .., "k1": .., "k2": .., "kstep": ..}— each value anintorNone.- Return type:
See also
apply_gcm_subsetpush this dict into a GCM adapter’s
settings.
Examples
>>> settings.setenv("omi") # [omi.gcm] subset = { i1 = 2600, ... } >>> gcm_subset()["i1"] 2600
- tracmass.config.apply_gcm_subset(module, subset=None)[source]#
Copy the settings-driven spatial subset into a GCM adapter.
Updates
module.settings["subset"]in place so that a subsequentmodule.fluxes(...)call slices the source grid to the configured region. Only keys with a non-Nonevalue are written, so a partially-specified[env.gcm]subsettable intracmass.tomlcomposes with any limits set directly onmodule.settings["subset"].Adapters that generate their grid and expose no
settings["subset"](tracmass.gcm.theoretical,tracmass.gcm.fabboni) are left untouched.- Parameters:
module (
module) – Atracmass.gcmadapter (e.g.tracmass.gcm.ecco2).subset (
dict, optional) – Subset mapping to apply. Defaults togcm_subset()(the active settings environment).
- Returns:
dict– The fully-resolved subset (allGCM_SUBSET_KEYS,intorNone), whether or not the adapter had a slot to receive it.- Return type:
Examples
>>> from tracmass import gcm >>> apply_gcm_subset(gcm.glorys) # honour [env.gcm] subset >>> gcm.glorys.settings["subset"]["k1"] 1
Settings-driven, single-call entry point for a trajectory run.
run() strings together the usual steps — activate a tracmass.toml
environment, build the grid and flux buffer, seed particles, integrate —
taking everything not passed explicitly from the active settings:
Setting |
Used for |
|---|---|
|
GCM adapter ( |
|
Start date, when dtm_start is omitted |
|
End date, when dtm_end is omitted |
|
|
|
|
|
Seeding table ( |
|
Debug output of each run stage ( |
The integrators themselves resolve monitor, recorder, no_wflux and
n_particle_batches from settings (see tracmass.runsetup), and
n_windows from the flux buffer’s dtm_end.
- tracmass.driver.run(dtm_start=None, dtm_end=None, state=None, *, env=None, gcm=None, integrator=None, verbose=None, **kwargs)[source]#
Build the grid and flux buffer, seed, and integrate in one call.
- Parameters:
dtm_start (
strorpd.TimestamporNone, optional) – Start date. Default: thedtm_startsetting, else the adapter’s own default date.dtm_end (
strorpd.TimestamporNone, optional) – End date; earlier than the start date means a backward run. Default: thedtm_endsetting, else start + theruntimesetting, else a single window.state (
ParticleStateorcallableorNone, optional) – Initial particles, orseed(grid) -> ParticleStatecalled once the grid is built (and env is active, so it can read settings). Default: seed from the[env.seed]settings table viatracmass.seed.from_settings().env (
strorNone, optional) –tracmass.tomlenvironment to activate first (viasettings.setenv; it stays active after the call, which is what adapters and integrators read during the run). Default: keep the current environment.gcm (
strorcallableorNone, optional) – Adapter name orfluxescallable. Default: thegcm.namesetting.integrator (
strorNone, optional) – Name of the integrator, a key ofINTEGRATORS. Default: theintegratorsetting, else"time_dependent".verbose (
boolorNone, optional) – Print timestamped debug messages for each stage (adapter calls, flux reads and their size, seeding, compilation, each window) to stderr while the run lasts; seetracmass.verbose. Default: theverbosesetting, else False.**kwargs –
dtmis accepted as an alias for dtm_start (matching thedtmnaming ofLazyFluxFields); the rest are passed on to the integrator (e.g.iter_sub,monitor,recorder,patch_buffer,n_windows).
- Returns:
ParticleState– Final particle state.- Raises:
ValueError – If no GCM is given or configured, integrator is unknown, state is omitted and there is no usable
[env.seed]table, or a string dtm_start / dtm_end is not a date (e.g.run("omi")whererun(env="omi")was meant).TypeError – If both dtm_start and its alias
dtmare given. If a particle state or seed callable is passed as dtm_start or dtm_end (the pre-2026-09-30 argument order).
- Return type:
Examples
>>> from tracmass import seed >>> result = tracmass.run( ... "2020-07-01", ... state=lambda grid: seed.ijk(10, 20, 10, 20, 1, 1, grid=grid), ... env="tempvel", integrator="time_dependent_patched", ... ) >>> result = tracmass.run("2007-06-01", env="omi") # seeding from settings too >>> result = tracmass.run(dtm="2007-06-01", env="omi") # same, via the alias