stilt.footprint.FootprintAccessor.to_paris#
- FootprintAccessor.to_paris(particles=None)[source]#
Return the footprint as a PARIS-format dataset, which openghg reads.
The footprint’s hourly layers go to
srr_time_resolvedby hours back from the release time,H_back. The layer from one hour before the release time to the release time isH_back = 1, because openghg pairsH_back = kwith the flux hour that startskhours before the footprint’s time.H_back = 0, the hour after the release time, stays zero. OnlyH_back0 to 23 are resolved, since openghg reads the axis as a time span and a 24th hour would wrap to 0. Layers 24 or more hours back are summed intosrr_residual, andsrris the sum of all layers. The values are PYSTILT’s: ppm per (µmol m⁻² s⁻¹) is the same quantity as the PARIS unit, (mol/mol)/(mol/m2/s).particle_locations_n,_e,_sand_ware the fraction of the particles that first left the footprint grid through that edge, by grid cell along the edge and by 1 km height layer from the ground to 20 km. A particle that stayed inside counts nowhere. They need the particles; without them they are left out, and openghg refuses the file unless it is told not to expect them.The layers are found from each layer’s
timecoordinate, not from the name of the layer dimension, so one release ofproject.footprints().footworks as well assim.footprint.- Parameters:
particles (
DataFrame|None) – The particles the footprint was made from, such assim.particles. Where they left the grid comes fromgrid_exits()on the footprint’s grid, and the fractions are of the particles in the table.- Returns:
Dimensions
time(one entry, the release time),latitude,longitude,resolution(H_back, 0 to 23 hours) and, with exits,height. A PARIS file holds one site with one entry alongtimeper release: concatenate the datasets of many releases alongtimewithxarray.concat()before writing them withxarray.Dataset.to_netcdf().- Return type:
- Raises:
ValueError – If the footprint’s layers are not one hour long (make it with
tres: 1h), if a layer ends after the release time (a forward run), if the grid is not in longitude and latitude (a projected grid), if the footprint holds several releases or has no release id.
Examples
A footprint of three hourly layers before 18:00, each cell worth 1:
>>> import numpy as np >>> import pandas as pd >>> import xarray as xr >>> release_time = pd.Timestamp("2024-01-15 18:00") >>> layers = release_time - pd.to_timedelta([3, 2, 1], unit="h") >>> foot = xr.DataArray( ... np.ones((3, 2, 2)), ... dims=("time", "lat", "lon"), ... coords={"time": layers, "lat": [40.5, 41.5], "lon": [-112.5, -111.5]}, ... ).assign_coords(release="202401151800_-111.85_40.77_5") >>> ds = foot.stilt.to_paris() >>> ds.srr_time_resolved.sum(["latitude", "longitude"]).values.ravel()[:5] array([0., 4., 4., 4., 0.]) >>> float(ds.srr.sum()) 12.0