Sensors Module¶
The sensors module provides classes for representing sensor metadata and calibration data.
Overview¶
Sensor information is crucial for:
Coordinate transformations
Radiometric calibration
Geometric corrections
Geolocation accuracy
VISTA supports both continuous sensor models and sampled sensor data.
Core Classes¶
Base class for sensor geodetic conversion and radiometric modeling |
|
Sensor implementation providing ARF polynomials. |
Sensor¶
The base Sensor owns optional bias images, uniformity gain images, and bad-pixel masks. It also defines
the geolocation and point-spread-function interfaces for subclasses. If no platform is supplied, a default empty
platform is created automatically.
Creating a Sensor¶
import numpy as np
from vista.sensor_platforms import SensorPlatform
from vista.sensors import Sensor
platform = SensorPlatform(name="Tripod")
sensor = Sensor(
name="Camera",
platform=platform,
bias_images=np.zeros((1, 256, 256), dtype=np.float32),
bias_image_frames=np.array([0]),
uniformity_gain_images=np.ones((1, 256, 256), dtype=np.float32),
uniformity_gain_image_frames=np.array([0]),
)
Using Sensor Capabilities¶
# Check what calibration data is available
print(f"Can correct bias: {sensor.can_correct_bias()}")
print(f"Can correct non-uniformity: {sensor.can_correct_non_uniformity()}")
print(f"Can geolocate: {sensor.can_geolocate()}")
SampledSensor¶
SampledSensor adds time-sampled polynomial transforms between pixels and the sensor Attitude
Reference Frame (ARF), plus optional frame-sampled radiometric gain. Its platform supplies the ECEF positions and
pointing unit vectors used for geolocation.
can_geolocate() is true only when the platform position and pointing data and all forward and reverse polynomial
arrays are available.
Module Reference¶
Sensor¶
Base sensor class for geodetic conversion and radiometric modeling.
This module defines the Sensor base class which provides a framework for representing sensors and their characteristics. Sensors support geodetic coordinate conversion, radiometric calibration data (bias, gain, bad pixels), and optional point spread function modeling.
- class vista.sensors.sensor.Sensor(name=None, platform=None, bias_images=None, bias_image_frames=None, uniformity_gain_images=None, uniformity_gain_image_frames=None, bad_pixel_masks=None, bad_pixel_mask_frames=None)[source]¶
Bases:
objectBase class for sensor geodetic conversion and radiometric modeling
The Sensor class provides a framework for representing sensors and their associated characteristics including projection polynomials and radiometric calibration data.
Core Attributes¶
- namestr
Unique name for this sensor. Used as the primary identifier.
- bias_imagesNDArray, optional
3D array of bias/dark frames with shape (num_bias_images, height, width).
- bias_image_framesNDArray, optional
1D array specifying frame ranges for each bias image.
- uniformity_gain_imagesNDArray, optional
3D array of flat-field/gain correction images.
- uniformity_gain_image_framesNDArray, optional
1D array specifying frame ranges for each uniformity gain image.
- bad_pixel_masksNDArray, optional
3D array of bad pixel masks.
- bad_pixel_mask_framesNDArray, optional
1D array specifying frame ranges for each bad pixel mask.
Sensor Platform Information¶
- platformSensorPlatform
SensorPlatform object containing sensor position and pointing information.
Notes
PSF modeling is optional and can be used for fitting signal blobs to estimate irradiance
Sensor names must be unique within a VISTA session
Class variable _instance_count tracks the total number of Sensor instances created
Geodetic conversion requires valid polynomial coefficients for the time of interest
Calibration frame arrays define ranges: frame N applies until frame N+1 starts
- platform: SensorPlatform | None = None¶
- __post_init__()[source]¶
Initialize sensor instance and increment global counter.
Generates a unique UUID for this sensor instance and initializes its name and sensor platform if not provided.
- model_psf(sigma=None, size=None)[source]¶
Model the sensor’s point spread function (PSF).
This is an optional method that can be overridden by subclasses to provide PSF modeling capability. The PSF can be used to fit signal pixel blobs in imagery to estimate irradiance.
- Parameters:
- Returns:
2D array representing the point spread function, or None if not implemented
- Return type:
NDArray[np.float64] or None
Notes
The default implementation returns None. Subclasses should override this method to provide specific PSF models (e.g., Gaussian, Airy disk, etc.).
- can_geolocate()[source]¶
Check if sensor can convert pixels to geodetic coordinates and vice versa.
Notes
The default implementation returns False. Subclasses can override this method.
- Returns:
True if sensor has both forward and reverse geolocation polynomials.
- Return type:
- can_correct_bad_pixel()[source]¶
Check if sensor has radiometric bad pixel masks.
- Returns:
True if sensor has radiometric bad pixel masks.
- Return type:
- can_correct_bias()[source]¶
Check if sensor has bias images
- Returns:
True if sensor has bias images.
- Return type:
- can_correct_non_uniformity()[source]¶
Check if sensor has uniformity gain images
- Returns:
True if sensor has uniformity gain images.
- Return type:
- geodetic_to_pixel(times, loc)[source]¶
Convert geodetic coordinates to pixel coordinates using polynomial coefficients.
- Parameters:
times (np.datetime64 or np.ndarray) – Time(s) for which to perform the conversion. If a number, it is assumed that a time axis for the location is not present. If an array, it is expected to have the same length as the final (time) axis of the location, and each element specifies the time for the corresponding location.
loc (EarthLocation) – Astropy EarthLocation object(s) containing geodetic coordinates in km
- Returns:
rows (np.ndarray) – Array of row pixel coordinates (NaN for base implementation)
columns (np.ndarray) – Array of column pixel coordinates (NaN for base implementation)
- Return type:
Notes
The default implementation returns NaN arrays. Subclasses should override this method to provide geodetic-to-pixel conversion using their specific projection model (e.g., polynomial coefficients).
- pixel_to_geodetic(times, rows, columns)[source]¶
Convert pixel coordinates to geodetic coordinates using polynomial coefficients.
- Parameters:
times (np.datetime64 or np.ndarray) – Time(s) for which to perform the conversion. If a number, it is assumed that a time axis for the rows and columns is not present. If an array, it is expected to have the same length as the final (time) axis of rows/columns, and each element specifies the time for the corresponding pixel coordinates.
rows (np.ndarray) – Array of row pixel coordinates
columns (np.ndarray) – Array of column pixel coordinates
- Returns:
Astropy EarthLocation object(s) with geodetic coordinates (NaN for base implementation)
- Return type:
EarthLocation
Notes
The default implementation returns EarthLocation with NaN coordinates. Subclasses should override this method to provide pixel-to-geodetic conversion using their specific projection model.
- to_hdf5(group)[source]¶
Save sensor radiometric calibration data to an HDF5 group.
- Parameters:
group (h5py.Group) – HDF5 group to write sensor data to (typically sensors/<sensor_uuid>/)
Notes
This method writes radiometric calibration data to the HDF5 group: - bias_images and bias_image_frames - uniformity_gain_images and uniformity_gain_image_frames - bad_pixel_masks and bad_pixel_mask_frames
Subclasses should call super().to_hdf5(group) and then add their own data.
- __init__(name=None, platform=None, bias_images=None, bias_image_frames=None, uniformity_gain_images=None, uniformity_gain_image_frames=None, bad_pixel_masks=None, bad_pixel_mask_frames=None)¶
Sampled Sensor¶
Sampled sensor with geodetic conversion capabilities.
This module defines the SampledSensor class, which extends the base Sensor class to support geodetic coordinate conversion using ARF (Attitude Reference Frame) polynomials and radiometric gain calibration.
- class vista.sensors.sampled_sensor.SampledSensor(name=None, platform=None, bias_images=None, bias_image_frames=None, uniformity_gain_images=None, uniformity_gain_image_frames=None, bad_pixel_masks=None, bad_pixel_mask_frames=None, radiometric_gain=None, radiometric_gain_frames=None, poly_pixel_to_arf_azimuth=None, poly_pixel_to_arf_elevation=None, poly_arf_to_row=None, poly_arf_to_col=None, times=None)[source]¶
Bases:
SensorSensor implementation providing ARF polynomials.
SampledSensor stores ARF polynomials and radiometric gain at known times, providing geodetic coordinate conversion capabilities and gain calibration.
- radiometric_gain¶
1D array of multiplicative factors to convert from counts to irradiance in units of kW/km²/sr.
- Type:
NDArray, optional
- radiometric_gain_frames¶
1D array specifying frame ranges for each radiometric gain value.
- Type:
NDArray, optional
- poly_pixel_to_arf_azimuth¶
Polynomial coefficients for converting (column, row) to ARF azimuth (radians). Shape: (N, num_coeffs) where num_coeffs depends on polynomial order.
- Type:
NDArray[np.float64], optional
- poly_pixel_to_arf_elevation¶
Polynomial coefficients for converting (column, row) to ARF elevation (radians). Shape: (N, num_coeffs) where num_coeffs depends on polynomial order.
- Type:
NDArray[np.float64], optional
- poly_arf_to_row¶
Polynomial coefficients for converting (azimuth, elevation) to row. Shape: (N, num_coeffs) where num_coeffs depends on polynomial order.
- Type:
NDArray[np.float64], optional
- poly_arf_to_col¶
Polynomial coefficients for converting (azimuth, elevation) to column. Shape: (N, num_coeffs) where num_coeffs depends on polynomial order.
- Type:
NDArray[np.float64], optional
- times¶
Times corresponding to each ARF polynomial. Must have length N.
- Type:
NDArray[np.datetime64]
Notes
Duplicate times in the input are automatically removed during initialization
For 2+ unique samples: uses linear interpolation within range, linear extrapolation outside
For 1 sample: returns the same polynomial coefficients for all query times
ARF (Attitude Reference Frame) is a local coordinate system where the X-axis points along the sensor pointing direction
- times: NDArray[datetime64] | None = None¶
- __post_init__()[source]¶
Validate inputs and remove duplicate times.
Ensures times and polynomials have compatible shapes and removes any duplicate time entries along with their corresponding polynomial coefficients.
- Raises:
ValueError – If polynomial coefficients have incompatible shapes with their times.
- append(poly_pixel_to_arf_azimuth, poly_pixel_to_arf_elevation, poly_arf_to_row, poly_arf_to_col, times)[source]¶
Append new times and polynomials to the sensor. Must be compatible with existing data. After appending, duplicate times are removed and arrays are sorted in order of increasing time.
- Parameters:
poly_pixel_to_arf_azimuth (NDArray[np.float64]) – New polynomial samples corresponding to the new times.
poly_pixel_to_arf_elevation (NDArray[np.float64]) – New polynomial samples corresponding to the new times.
poly_arf_to_row (NDArray[np.float64]) – New polynomial samples corresponding to the new times.
poly_arf_to_col (NDArray[np.float64]) – New polynomial samples corresponding to the new times.
times (NDArray[np.datetime64]) – New time sample(s) to append.
- can_geolocate()[source]¶
Check if sensor can convert pixels to geodetic coordinates and vice versa.
- Returns:
True if sensor has all required ARF geolocation data: platform position and pointing vectors and both forward (pixel→ARF) and reverse (ARF→pixel) polynomials.
- Return type:
- get_coefficients(coeffs, times)[source]¶
Return polynomial coefficients for the given times via interpolation/extrapolation.
- Parameters:
coeffs (NDArray[np.float64]) – A reference to one of the sensor’s already existing ARF polynomial coefficients arrays
times (NDArray[np.datetime64]) – Array of times for which to retrieve polynomial coefficients
- Returns:
Polynomial coefficients as (N, num_coeffs) array where N is the number of query times.
- Return type:
NDArray[np.float64]
Notes
For sensors with 1 sample: returns the single set of coefficients for all times
For sensors with 2+ samples: uses linear interpolation within the time range and linear extrapolation outside the range
- pixel_to_geodetic(times, rows, columns)[source]¶
Convert pixel coordinates to geodetic coordinates using ARF polynomials.
Uses ARF (Attitude Reference Frame) polynomials to map (row, column) pixel coordinates to geodetic coordinates by ray-casting to the Earth’s surface. Pixels that do not intersect Earth will have NaN coordinates.
- Parameters:
times (np.datetime64 or np.ndarray) – Time(s) for which to perform the conversion. If a number, it is assumed that a time axis for the rows and columns is not present. If an array, it is expected to have the same length as the final (time) axis of rows/columns, and each element specifies the time for the corresponding pixel coordinates.
rows (np.ndarray) – Array of row pixel coordinates
columns (np.ndarray) – Array of column pixel coordinates
- Returns:
Astropy EarthLocation object(s) with geodetic coordinates. Returns NaN coordinates for pixels that do not intersect Earth. Returns NaN coordinates if polynomials are not available.
- Return type:
EarthLocation
- Raises:
ValueError – If times is an array and its length does not match the length of the last axis of rows and columns
Notes
Requires ARF polynomials to be defined
Returns NaN coordinates if polynomials are not available
Off-Earth pixels will have NaN x/y/z geocentric coordinates. This corresponds to 90/0/NaN for its lat/lon/height values, so a check for NaN coordinates need only check for NaN height.
- geodetic_to_pixel(times, loc)[source]¶
Convert geodetic coordinates to pixel coordinates using ARF polynomials.
Uses ARF (Attitude Reference Frame) polynomials to map geodetic coordinates (latitude, longitude, altitude) to (row, column) pixel coordinates. This method properly handles targets at any altitude, not just ground level.
- Parameters:
times (np.datetime64 or np.ndarray) – Time(s) for which to perform the conversion. If a number, it is assumed that a time axis for the location is not present. If an array, it is expected to have the same length as the final (time) axis of the location, and each element specifies the time for the corresponding location.
loc (EarthLocation) – Astropy EarthLocation object(s) containing geodetic coordinates in km
- Returns:
rows (np.ndarray) – Array of row pixel coordinates (NaNs if polynomials unavailable)
columns (np.ndarray) – Array of column pixel coordinates (NaNs if polynomials unavailable)
- Raises:
ValueError – If times is an array and its length does not match the length of the last axis of location
- Return type:
Notes
Requires ARF polynomials to be defined
Returns NaN coordinates if polynomials are not available
Properly handles targets at any altitude (not limited to ground level)
- to_hdf5(group)[source]¶
Save sampled sensor data to an HDF5 group.
- Parameters:
group (h5py.Group) – HDF5 group to write sensor data to (typically sensors/<sensor_uuid>/)
Notes
This method extends the base Sensor.to_hdf5() by adding: - Geolocation polynomials in geolocation/ subgroup - Radiometric gain values in radiometric/ subgroup
- __init__(name=None, platform=None, bias_images=None, bias_image_frames=None, uniformity_gain_images=None, uniformity_gain_image_frames=None, bad_pixel_masks=None, bad_pixel_mask_frames=None, radiometric_gain=None, radiometric_gain_frames=None, poly_pixel_to_arf_azimuth=None, poly_pixel_to_arf_elevation=None, poly_arf_to_row=None, poly_arf_to_col=None, times=None)¶