stilt.Project.jacobian#

Project.jacobian(sel, target, time_bins, *, workers=None)[source]#

Sum the selected footprints onto a target, per time bin, as one sparse matrix.

The same operation as foot.stilt.aggregate, for every selected footprint at once. Each footprint cell is split among the target cells it overlaps in proportion to area, time layers are summed within each of time_bins, and cells or layers outside the target or the bins are dropped. The selection must hold one variant, and one realization of an ensemble: ens[ens.realization == k].

Footprints are read and summed one receptor at a time, in workers threads. Each thread holds one footprint, so memory stays at a few footprints whatever the selection’s size; the result itself is sparse.

Parameters:
  • sel (Any) – The simulations, as for status(), all of one variant (and one realization of an ensemble).

  • target (Grid | Mesh | Zones) – Where the fluxes are: a grid, mesh, or set of zones.

  • time_bins (IntervalIndex) – Flux time bins, such as a flux inventory’s steps. They must be closed on the left (closed="left"): each bin holds the footprint hours that start in it.

  • workers (int | None) – Threads that read and sum batches. Defaults to the CPUs this process may use (in a Slurm job, the job’s), at most 8: more threads add memory and stop adding speed.

Returns:

Rows are the selected receptors with a non-empty footprint, in selection order; columns are (time bin, target cell). Receptors with an empty footprint are listed in empty, and those not run yet in missing.

Return type:

Jacobian

Raises:
  • TypeError – If time_bins is not a pandas.IntervalIndex.

  • ValueError – If the selection holds more or fewer than one variant, or several realizations of an ensemble, the variant has no grid or no footprints yet, or time_bins is not closed on the left.