- Home
- Documentation
- API reference
- Core
- hyperproc.grid
hyperproc.grid¶
Source-derived reference
Generated from the current hyperproc 0.1.2 checkout.
Implementation: hyperproc/grid.py. Signatures, defaults, docstrings, and expandable source are extracted statically; the module is not imported or executed. Names beginning with _ are implementation details, not a stable public API.
Use the function signature as the authority for individual parameter defaults and return annotations. Original docstrings sometimes group parameter names or wrap return descriptions across lines; these descriptions are preserved rather than inferred or rewritten.
Turn a swath into a map-projected grid.
Sensors that ship per-pixel latitude/longitude instead of an affine transform (PRISMA L1/L2B/L2C, PACE, un-orthorectified EMIT) cannot be written to GeoTIFF directly: their ground track is rotated and slightly curved, so no single six-number transform describes it. PRISMA's L2C swath, for instance, runs about 79 degrees off north.
:func:georeference resamples such a dataset onto a regular north-up grid by
building a GLT (geometry lookup table) - the same device EMIT ships in its
own granules, and what prismaread's base_georef produces. Every output pixel
is a verbatim copy of one input pixel: nearest-neighbour by construction, so
no spectra are invented by interpolation.
DEFAULT_RESOLUTION_DEG = {'PACE': 0.01}
module-attribute
¶
utm_epsg(lon: float, lat: float) -> int
¶
EPSG code of the UTM zone containing a point (zone 60 at lon = 180, with the Norway and Svalbard exceptions of the UTM grid).
Source code in hyperproc/grid.py
georeference(ds: xr.Dataset, epsg: int | None = None, resolution: float | None = None, radius: float | None = None, fill_holes: bool = True, like: xr.Dataset | None = None) -> xr.Dataset
¶
Resample a lat/lon swath onto a regular projected grid.
| PARAMETER | DESCRIPTION |
|---|---|
ds
|
dataset carrying 2-D
TYPE:
|
epsg
|
target CRS. Defaults to the UTM zone under the scene centre,
which for PRISMA reproduces the zone ASI uses for its own L2D.
Pass
TYPE:
|
resolution
|
output pixel size in target-CRS units.
TYPE:
|
radius
|
hard upper bound of the search, in metres. Defaults to twice the 99th-percentile source pixel half-diagonal.
TYPE:
|
fill_holes
|
a cell is filled when its nearest source pixel lies within
that pixel's own half-diagonal (its footprint), so gaps where the
grid is finer than the swath close, while nothing is invented past
the swath edge or the along-track ends.
TYPE:
|
like
|
a projected dataset whose grid to reproduce exactly (CRS,
pixel size, origin and shape), for example ASI's PRISMA L2D, so
the result compares cell for cell. Overrides
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dataset
|
A new Dataset on |
Dataset
|
func: |
Dataset
|
mask marks cells the swath actually covers. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
|
Source code in hyperproc/grid.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
latlon_grid(ds: xr.Dataset) -> tuple[np.ndarray, np.ndarray]
¶
WGS-84 (lat, lon) of every cell centre of a projected dataset.
Derived from the CRS and the full affine transform, so it is exact even
where the granule ships no geolocation arrays - including the rotated,
flight-aligned AVIRIS grids, where the 1-D x/y coordinates describe
only the top row and left column. The affine is rebuilt from the
coordinates the same way the GeoTIFF writer does, so subsets stay right.
Source code in hyperproc/grid.py
_ecef(lat: np.ndarray, lon: np.ndarray) -> np.ndarray
¶
Sphere-surface cartesian metres, so a KD-tree measures real distance.
Doing the search in degrees would distort badly over a swath spanning 23 degrees of latitude, where a degree of longitude shrinks by a third.
Source code in hyperproc/grid.py
_nearest_glt(lat, lon, gx, gy, ok, epsg, radius, resolution, fill_holes)
¶
Nearest source pixel per output cell, rejected beyond radius.
This is what pyresample's radius_of_influence does. Dilating a
forward-mapped GLT instead - the obvious cheap approach - fails twice on a
wide swath: it smears the edge pixel outward past the real swath boundary,
and it still cannot reach across the gaps where pixels are widest.
Source code in hyperproc/grid.py
_native_spacing(sx: np.ndarray, sy: np.ndarray) -> float
¶
Median distance between horizontally adjacent swath pixels.
Source code in hyperproc/grid.py
_apply_glt(arr: np.ndarray, glt: np.ndarray, valid: np.ndarray) -> np.ndarray
¶
Gather source pixels into the output grid. 2-D or 3-D, NaN outside.