Installed-wheel product demos#

Use the programs in examples/product/ to read a TIFF, resize a Sentinel-2 band, or orthorectify an RPC image into an in-memory array. They report execution details as JSON; they do not save the pixels to a raster file or compare them with an independent oracle.

Install a wheel built with the features required below, following the installation and feature-build instructions. GPU programs also need a compatible NVIDIA driver and caller-installed CuPy; the wheel does not install CuPy. Copy the entire examples/product/ directory from a checkout or extracted source distribution to a location outside the source tree, keeping _scorecard.py beside the programs. Run the commands below from that copied directory with the Python interpreter that has the wheel installed. The programs are examples, not wheel entry points.

Read TIFF into NumPy or CuPy#

tiff_read.py reads all bands from image 0. The NumPy path needs the default host wheel and an input within the portable TIFF profile. Pass a window in pixel coordinates to bound the output allocation; omitting it reads the full image.

python tiff_read.py image.tif --output numpy --window 10 20 3 2 \
  --scorecard tiff-numpy.json

The program allocates its output and supplies it to cugeo-raster as caller-owned memory. NumPy output is (height, width) for scalar band selection and CHW (bands, height, width) otherwise. The scorecard records its shape, dtype, residency, and native read receipt.

The CuPy path requires an nvtiff feature wheel and the direct scalar nvTIFF profile. The native parser rejects inputs outside that profile before invoking nvTIFF; a TIFF or COG accepted by the NumPy path may therefore be unavailable here.

python tiff_read.py image.tif --output cupy --window 10 20 3 2 \
  --scorecard tiff-cupy.json

CuPy output is caller-owned CHW over BIP storage, retaining the band axis. The program waits for decode completion before reporting success. Compressed-byte staging and foreign codec memory or transfer counts can be unknown. This program does not use GPUDirect Storage (GDS); the separate GDS guide owns that path and its qualification commands.

Resize a Sentinel-2 JP2 band#

sentinel2_jp2_affine.py requires an nvjpeg2k feature wheel, CuPy, and a lossless JP2 within the direct JPEG2000 profile. Its capability preflight checks the nvjpeg2k diagnostics key and reports unavailable when the installed native library lacks that feature.

The command accepts a component JP2 or an unpacked single-granule L1C/L2A SAFE directory within the SAFE catalog profile:

python sentinel2_jp2_affine.py B04.jp2 --scale 0.5 --scorecard jp2.json
python sentinel2_jp2_affine.py product.SAFE --band B02 --resolution 10 --scale 0.5

--scale must be positive. The program requests base-resolution decode followed by bilinear affine sampling into caller-owned CuPy output, using a non-default stream and waiting before return. It retains compressed input in host memory; decoded pixels stay on the device. A single band has shape (height, width); multiband JP2 output is CHW over BIP storage. SAFE selection opens one spectral band without applying the product’s scale or offset. The scorecard records nodata only, not scale or offset. The demo does not build a mosaic. See the Sentinel-2 input layout for public inputs and the SAFE requirements. A demo invocation does not qualify another band, processing level, or profile.

Orthorectify an RPC image with a DEM#

rpc_dem_cupy.py requires a wheel built with cuda,orthorect, a CUDA-enabled cugeo-proj library, and CuPy. Use uncompressed UInt16 single-band TIFF imagery with embedded RPC00B metadata and an uncompressed single-band TIFF DEM with an affine transform and EPSG CRS. The orthorectification contract defines the accepted DEM types and grid conditions.

The DEM must contain WGS84 ellipsoidal heights in metres. The required flag declares those units and vertical reference; this program performs no vertical conversion. To request a grid proposal from RPC boundary samples at a declared height interval, run:

python rpc_dem_cupy.py image.tif dem-ellipsoid.tif \
  --terrain-vertical-reference wgs84_ellipsoid \
  --height-range 0 200 --scorecard ortho.json

Without --crs or --resolution X Y, planning selects UTM from the RPC center and estimates resolution there. A failed inverse RPC sample stops planning. The proposed bounds do not guarantee terrain-aware edge coverage. To supply your own grid, pass --shape HEIGHT WIDTH, --transform C A B F D E in native GDAL order, and --crs EPSG_CODE together. The transform maps pixel coordinates to destination CRS coordinates as x = C + A*column + B*row and y = F + D*column + E*row.

The program allocates a two-dimensional CuPy output. cugeo-raster decodes bounded image and DEM windows on the host, copies them to the GPU, runs CUDA geometry and sampling, and drains the explicit stream before returning. The scorecard reports those transfers and the native receipt. Real-sensor qualification is limited by the missing authenticated source package; see the qualification input guide for that boundary.

Interpret the JSON output#

Each program prints a scorecard and optionally writes it to --scorecard PATH. Exit status 0 means execution completed, 2 means the requested route is unavailable, and 1 means execution failed. Argument-parser errors print usage and exit 2 before creating a scorecard. The programs do not substitute another backend or import GDAL or Rasterio.

Check status and message first, then output for shape, dtype, and residency. native_receipts, transfers_bytes, memory_bytes, and execution describe copies, staging, waits, and allocations. Unknown or unmeasured values are null, not zero; individual receipt fields do not establish total process or device memory use. execution.gds is not-used.

correctness.status is not-checked even after successful execution: these programs run no independent pixel oracle. timings_ns.total includes input hashing and setup after argument parsing; cold_execution covers the operation through completion, and warm_execution is unmeasured. These one-shot timings do not establish comparative performance. The scorecard schema defines the fields. Contributors can find packaging and installed-consumer checks in the development checks.