matheo.band_integration.band_integration#
Functions to band integrate spectra for given spectral response function.
- matheo.band_integration.band_integration.band_int(d: ndarray, x: ndarray, r: ndarray, x_r: ndarray, d_axis_x: int = 0, x_r_centre: None | float = None, u_d: None | float | ndarray = None, u_x: None | float | ndarray = None, u_r: None | float | ndarray = None, u_x_r: None | float | ndarray = None, rint_norm: bool = True) float | ndarray | Tuple[float | ndarray, float | ndarray][source]#
Returns integral of data array over a response band (i.e., d(x) * r(x_r))
N.B. In case where
x == x_randxis evenly sampled, an accelerated function is used.- Parameters:
d – data to be band integrated
x – data coordinates
r – band response function(s). For a single band, a 1D length-M array is required, where M is the length of
x_r. Multiple bands may be defined in an N x M array, where N is number of response bands.x_r – band response function coordinates
d_axis_x – (default 0) if d greater than 1D, specify axis to band integrate along
x_r_centre – (optional) centre of band response function in data coordinates, if there is an offset. Defined by location of band response function peak in data coordinates. Useful to define where sensor is looking along an extended input, e.g. spatially.
u_d – (optional) uncertainty in data
u_x – (optional) uncertainty in data coordinates
u_r – (optional) uncertainty in band response function
u_x_r – (optional) uncertainty in band response function coordinates
rint_norm – (default: True) option to normalise result by integral of r
- Returns:
band integrated data
- Returns:
uncertainty of band integrated data (skipped if no input uncertainties provided)
- matheo.band_integration.band_integration.band_int2ax(d: ndarray, x: ndarray, y: ndarray, rx: ndarray, x_rx: ndarray, ry: ndarray, y_ry: ndarray, d_axis_x: int = 0, d_axis_y: int = 0, x_rx_centre: None | float = None, y_ry_centre: None | float = None, u_d: None | float | ndarray = None, u_x: None | float | ndarray = None, u_y: None | float | ndarray = None, u_rx: None | float | ndarray = None, u_x_rx: None | float | ndarray = None, u_ry: None | float | ndarray = None, u_y_ry: None | float | ndarray = None, rint_norm: bool = True) float | ndarray | Tuple[float | ndarray, float | ndarray][source]#
Sequentially band integrates multi-dimensional data array along x axis and y axis
N.B. In case where
x == x_rxandxis evenly sampled ory == y_ryandyis evenly spaced, an accelerated function is used.- Parameters:
d – data to be band integrated
x – data coordinates along first band integration axis
y – data coordinates along second band integration axis
rx – first axis band response function(s). For a single band, a 1D length-M array is required, where M is the length of
x_rx. Multiple bands may be defined in an N x M array, where N is number of response bands.x_rx – first band response function coordinates
ry – second axis band response function(s). For a single band, a 1D length-M array is required, where M is the length of
y_ry. Multiple bands may be defined in an N x M array, where N is number of response bands.y_ry – second band response function coordinates
d_axis_x – (default 0) x axis in data array
d_axis_y – (default 1) y axis in data array
x_rx_centre – (optional) centre of rx function in data coordinates, if there is an offset. Defined by location of band response function peak in data coordinates. Useful to define where sensor is looking along an extended input, e.g. spatially.
y_ry_centre – (optional) centre of ry function in data coordinates, if there is an offset (as for x_rx_centre)
u_d – (optional) uncertainty in data
u_x – (optional) uncertainty in data coordinates along first band integration axis
u_y – (optional) uncertainty in data coordinates along second band integration axis
u_rx – (optional) uncertainty in first band response function
u_x_rx – (optional) uncertainty in first band response function coordinates
u_ry – (optional) uncertainty in second band response function
u_y_ry – (optional) uncertainty in second band response function coordinates
rint_norm – (default: True) option to normalise result by integral of r
- Returns:
band integrated data
- Returns:
uncertainty of band integrated data (skipped if no input uncertainties provided)
- matheo.band_integration.band_integration.band_int2d(d: ndarray, x: ndarray, y: ndarray, psf: ndarray, x_psf: ndarray, y_psf: ndarray, d_axis_x: int = 0, d_axis_y: int = 1, u_d: None | float | ndarray = None, u_x: None | float | ndarray = None, u_y: None | float | ndarray = None, u_psf: None | float | ndarray = None, u_x_psf: None | float | ndarray = None, u_y_psf: None | float | ndarray = None) float | ndarray | Tuple[float | ndarray, float | ndarray][source]#
Returns integral of a 2D data array over a response band defined by a 2D point spread function (i.e., d(x, y) * psf(x_psf, y_psf))
- Parameters:
d – two dimensional data to be band integrated
x – data x coordinates
y – data y coordinates
psf – two dimensional point spread function of band response
x_psf – psf x coordinates
y_psf – psf y coordinates
d_axis_x – (default 0) x axis in data array, if d more than 2D
d_axis_y – (default 1) y axis in data array, if d more than 2D
u_d – (optional) uncertainty in data
u_x – (optional) uncertainty in data x coordinates
u_y – (optional) uncertainty in data y coordinates
u_psf – (optional) uncertainty in point spread function of band response
u_x_psf – (optional) uncertainty in psf x coordinates
u_y_psf – (optional) uncertainty in psf x coordinates
- Returns:
band integrated data
- Returns:
uncertainty of band integrated data (skipped if no input uncertainties provided)
- matheo.band_integration.band_integration.band_int3ax(d: ndarray, x: ndarray, y: ndarray, z: ndarray, rx: ndarray, x_rx: ndarray, ry: ndarray, y_ry: ndarray, rz: ndarray, z_rz: ndarray, d_axis_x: int = 0, d_axis_y: int = 1, d_axis_z: int = 2, x_rx_centre: None | float = None, y_ry_centre: None | float = None, z_rz_centre: None | float = None, u_d: None | float | ndarray = None, u_x: None | float | ndarray = None, u_y: None | float | ndarray = None, u_z: None | float | ndarray = None, u_rx: None | float | ndarray = None, u_x_rx: None | float | ndarray = None, u_ry: None | float | ndarray = None, u_y_ry: None | float | ndarray = None, u_rz: None | float | ndarray = None, u_z_rz: None | float | ndarray = None, rint_norm: bool = True) float | ndarray | Tuple[float | ndarray, float | ndarray][source]#
Sequentially band integrates multi-dimensional data array along x, y and z axes
N.B. In case where
x == x_rxandxis evenly sampled,y == y_ryandyis evenly spaced, orz == z_rzandzis evenly spaced, an accelerated function is used.- Parameters:
d – data to be band integrated
x – data coordinates along first band integration axis
y – data coordinates along second band integration axis
z – data coordinates along third band integration axis
rx – first axis band response function(s). For a single band, a 1D length-M array is required, where M is the length of
x_rx. Multiple bands may be defined in an N x M array, where N is number of response bands.x_rx – first band response function coordinates
ry – second axis band response function(s). For a single band, a 1D length-M array is required, where M is the length of
y_ry. Multiple bands may be defined in an N x M array, where N is number of response bands.y_ry – second band response function coordinates
rz – third axis band response function(s). For a single band, a 1D length-M array is required, where M is the length of
z_rz. Multiple bands may be defined in an N x M array, where N is number of response bands.z_rz – third band response function coordinates
d_axis_x – (default 0) x axis in data array
d_axis_y – (default 1) y axis in data array
d_axis_z – (default 2) z axis in data array
x_rx_centre – (optional) centre of rx function in data coordinates, if there is an offset. Defined by location of band response function peak in data coordinates. Useful to define where sensor is looking along an extended input, e.g. spatially.
y_ry_centre – (optional) centre of ry function in data coordinates, if there is an offset (as for x_rx_centre)
z_rz_centre – (optional) centre of rz function in data coordinates, if there is an offset (as for x_rx_centre)
u_d – (optional) uncertainty in data
u_x – (optional) uncertainty in data coordinates along first band integration axis
u_y – (optional) uncertainty in data coordinates along second band integration axis
u_z – (optional) uncertainty in data coordinates along third band integration axis
u_rx – (optional) uncertainty in first band response function
u_x_rx – (optional) uncertainty in first band response function coordinates
u_ry – (optional) uncertainty in second band response function
u_y_ry – (optional) uncertainty in second band response function coordinates
u_rz – (optional) uncertainty in second band response function
u_z_rz – (optional) uncertainty in third band response function coordinates
rint_norm – (default: True) option to normalise result by integral of r
- Returns:
band integrated data
- Returns:
uncertainty of band integrated data (skipped if no input uncertainties provided)
- matheo.band_integration.band_integration.cutout_nonzero(y, x, buffer=0.2)[source]#
Returns continuous non-zero part of function y(x)
- Parameters:
y (numpy.ndarray) – function data values
x (numpy.ndarray) – function coordinate data values
buffer (float) – fraction of non-zero section of y to include as buffer on either side (default: 0.2)
- matheo.band_integration.band_integration.get_x_offset(y, x, x_centre)[source]#
Returns coordinate offset required to centre function on given position.
- Parameters:
y – function values
x – function coordinates
x_centre – function centre defined my location of maximum value.
- Returns:
coordinate offset to centre function on x_centre
- matheo.band_integration.band_integration.iter_band_int(d: ndarray, x: ndarray, iter_r: Iterable, d_axis_x: int = 0, u_d: None | float | ndarray = None, u_x: None | float | ndarray = None, u_r: None | float | ndarray = None, u_x_r: None | float | ndarray = None, rint_norm: bool | None = True) float | ndarray | Tuple[float | ndarray, float | ndarray][source]#
Returns integral of data array over a set of response bands defined by iterator
- Parameters:
d – data to be band integrated
x – data coordinates
iter_r – iterable that returns band response function and band response function coordinates at each iteration
d_axis_x – (default 0) if d greater than 1D, specify axis to band integrate along
u_d – uncertainty in data
u_x – uncertainty in data coordinates
u_r – uncertainty in band response function
u_x_r – uncertainty in band response function coordinates
rint_norm – (default: True) option to normalise result by integral of r
- Returns:
band integrated data
- Returns:
uncertainty of band integrated data (skipped if no input uncertainties provided)
- matheo.band_integration.band_integration.pixel_int(d: ndarray, x: ndarray, x_pixel: ndarray | None = None, width_pixel: ndarray | None = None, u_d: None | float | ndarray = None, u_x: None | float | ndarray = None, u_x_pixel: None | float | ndarray = None, u_width_pixel: None | float | ndarray = None, band_shape: Callable | str = 'triangle', r_sampling: None | float = None, d_axis_x: int = 0, x_pixel_centre: None | float = None, eval_iter: bool = False) ndarray | Tuple[ndarray, ndarray][source]#
Returns integral of data array over a set of response bands (i.e., d(x) * r_i(x_r) for i pixels)
- Parameters:
d – data to be band integrated
x – data coordinates
x_pixel – centre of band response per pixel
width_pixel – width of band response per pixel
u_d – uncertainty in data
u_x – uncertainty in data coordinates
u_x_pixel – uncertainty in centre of band response per pixel
u_width_pixel – uncertainty in width of band response per pixel
band_shape – (default:
triangle) functional shape of response band - must be either a defined name, one of ‘triangle’, ‘tophat’, or ‘gaussian’, or a python function with the interfacef(x, centre, width), wherexis a numpy array of the x coordinates to define the function along,centreis the response band centre, andwidthis the response band width.r_sampling – x sampling interval for derived pixel band response functions (if omitted pixel band response functions defined along x, this results in an accelerated computation)
d_axis_x – (default:
0) if d greater than 1D, specify axis pixels are alongx_pixel_centre – centre of pixels in data coordinates, if there is an offset. Defined as half way between max and min pixel values. Useful to define where sensor is looking along an extended input, e.g. spatially.
eval_iter – (default: False) option to evaluate each pixel iteratively, saving memory
- Returns:
band integrated data
- Returns:
uncertainty in band integrated data
- matheo.band_integration.band_integration.pixel_int2d(d: ndarray, x: ndarray, y: ndarray, x_pixel: ndarray, y_pixel: ndarray, width_pixel: ndarray, psf_shape: str = 'triangle', d_axis_x: int = 0, d_axis_y: int = 0, u_d: None | float | ndarray = None, u_x: None | float | ndarray = None, u_y: None | float | ndarray = None, u_x_pixel: None | float | ndarray = None, u_y_pixel: None | float | ndarray = None, u_width_pixel: None | float | ndarray = None) Tuple[ndarray, ndarray][source]#
Returns integral of data array over a response band (i.e., d(x) * r(x_r))
- Parameters:
d – data to be band integrated
x – data x coordinates
y – data y coordinates
x_pixel – x positions of centre of psf per pixel
y_pixel – y positions of centre of psf per pixel
width_pixel – width of psf per pixel
psf_shape – (default X) psf shape - must be one of…
d_axis_x – (default 0) x axis in data array, if d more than 2D
d_axis_y – (default 1) y axis in data array, if d more than 2D
u_d – uncertainty in data
u_x – uncertainty in data x coordinates
u_y – uncertainty in data y coordinates
u_x_pixel – uncertainty in x positions of centre of psf per pixel
u_y_pixel – uncertainty in y positions of centre of psf per pixel
u_width_pixel – uncertainty in width of psf per pixel
- Returns:
band integrated data
- Returns:
uncertainty in band integrated data
- matheo.band_integration.band_integration.return_r_pixel(x_pixel: ndarray, width_pixel: ndarray, x: ndarray, f: Callable, x_pixel_off: None | float = None) ndarray[source]#
Returns per pixel response function, expressed as an n_x X n_pixel matrix, where n_x is the length of wavelength coordinates of the response function defintion and n_pixel matrix is the number of pixels.
- Parameters:
x_pixel – centre of band response per pixel
width_pixel – width of band response per pixel
x – coordinates to define band response functions
f – functional shape of response band - a python function with the interface
f(x, centre, width), wherexis a numpy array of the x coordinates to define the function along,centreis the response band centre, andwidthis the response band width.x_pixel_off – offset to pixel centre locations
- Returns:
pixel response function matrix
- matheo.band_integration.band_integration.spectral_band_int_sensor(d: ndarray, wl: ndarray, platform_name: str, sensor_name: str, detector_name: str | None = None, band_names: None | List[str] = None, d_axis_wl: int = 0, u_d: ndarray | None = None, u_wl: ndarray | None = None) Tuple[ndarray, ndarray] | Tuple[ndarray, ndarray, ndarray][source]#
Returns spectral band integrated data array for named sensor spectral bands
- Parameters:
d – data to be band integrated
wl – data wavelength coordinates
platform_name – satellite name (must be valid value for
sensor_name – name of instrument on satellite
detector_name – (optional) name of sensor detector. Can be used in sensor has SRF data for for different
detectors separately - if not specified in this case different :param band_names: (optional) sensor bands to evaluate band integral for, if omitted band integral evaluated for all bands within spectral range of data :param d_axis_wl: (default 0) spectral axis in data array :param u_d: (optional) uncertainty in data :param u_wl: (optional) uncertainty in data coordinates along first band integration axis
- Returns:
band integrated data
- Returns:
band integrated data centre wavelengths
- Returns:
uncertainties in band integrated data (skipped if no input uncertainties provided)