tracmass.new_flux#
- tracmass.new_flux(grid_or_fluxes, fluxes=None, dtm_start=None, dtm_end=None)[source]#
Create the lazy two-slot flux buffer for a run.
Two call forms:
new_flux(fluxes, dtm_start=..., dtm_end=None) -> (GridFields, LazyFluxFields)Build the grid and the flux buffer together. Equivalent to
g = new_grid(fluxes, ...); return g, new_flux(g, fluxes, ...)but fetching slot 0 only once. This is the original signature and return type.new_flux(grid, fluxes, dtm_start=..., dtm_end=None) -> LazyFluxFieldsReuse a
GridFieldsfromnew_grid()(or an earliernew_flux); build only the flux buffer.grid.reverseandgrid.timestepdrive direction and step size; dtm_end, if given, is only checked for consistency withgrid.reverse.
Flux data (
uflux,vflux,wflux,dzt,zstot) is kept as lazy xarray DataArrays and not loaded into device memory untilcompute()is called. For a backward run (grid.reverse) slot 1 is onegrid.timestepfurther into the past, the velocity fluxes are negated lazily, and eachupdate_flux()call walkslazy.dtmbackward through the archive. Thefluxescallable is never passedreverse=.- Parameters:
grid_or_fluxes (
GridFieldsorcallableorstr) – AGridFieldsselects the grid-reuse form; anything else is thefluxescallable / adapter name of the combined form.fluxes (
callableorstr, optional) – Thefluxes(dtm) -> xr.Datasetcallable (or adapter name). Required — and only used — in the grid-reuse form.dtm_start (
pd.TimestamporstrorNone, optional) – Physical time of slot 0 (past). DefaultNone— fluxes is called with no arguments at all, so its own default applies (forgcm.glorys/gcm.ecco2this falls through totracmass.seagrid.glorys.open_dataset()/tracmass.seagrid.ecco2.open_dataset()’s owndtmdefault).dtm_end (
pd.TimestamporstrorNone, optional) – When earlier than the resolved dtm_start, activates backward tracking (combined form) or is checked againstgrid.reverse(grid-reuse form). Stored aslazy.dtm_end, solazy.n_windowsgives the number of windows to reach it and thetime_dependent*integrators need non_windows.
- Returns:
tuple[GridFields,LazyFluxFields]orLazyFluxFields– A(grid, lazy)tuple for the combined form; justlazyfor the grid-reuse form.lazy.dtmholds the slot-0 timestamp;lazy.timestep/lazy.reversemirror the grid.- Return type:
See also
new_gridbuild just the static grid.