Standard Resample¶
Module: spectralbridge.standard_resample.
Legacy spectral resampling helpers with HyTools-derived code.
apply_resampler is substantially identical to the HyTools implementation in
src/hytools/transform/resampling.py. Other parts of this module have distinct
or uncertain lineage; see HYTOOLS_PROVENANCE.md.
HyTools: Hyperspectral image processing library Copyright (C) 2021 University of Wisconsin Authors named in the relevant source notice: Adam Chlus, Zhiwei Ye, Philip Townsend. License: GNU General Public License, version 3 Upstream: https://github.com/EnSpec/hytools Audited revision: 31286d64541791a9815d29443a33726fa4d54031
Modified for SpectralBridge. SpectralBridge's project license and the upstream
notice are recorded in LICENSE, NOTICE, and HYTOOLS_PROVENANCE.md.
API glossary ยท Workflow / scientific context
Signatures and documentation below are collected from the current source. Advanced objects are not newly declared stable by inclusion here.
Audience: advanced.
apply_resampler ¶
apply_resampler(hy_obj, data)
Apply a HyTools resampler configuration to a data slice.
This function is substantially identical to HyTools
transform.resampling.apply_resampler at the audited revision recorded in
the module notice. SpectralBridge retains it for the legacy resampling path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hy_obj
|
TYPE
|
DESCRIPTION. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
band |
TYPE
|
DESCRIPTION. |
Audience: advanced.
resampler_hy_obj ¶
resampler_hy_obj(sensor_type, json_file, hdr_path)
Configure the retained legacy sensor-response resampler and ENVI writer.
Initializes the resampler object with the specified sensor type, JSON file, and HDR file path. - sensor_type: The type of the sensor (e.g., 'Landsat 8 OLI') for which resampling is to be performed. - json_file: Path to the JSON file containing Landsat band parameters (wavelengths and FWHMs). - hdr_path: Path to the HDR file which contains wavelength information for the sensor data.
The method performs several key steps: 1. Reads and converts wavelengths from the HDR file into a NumPy array. 2. Sets up a fixed number of bands and a default FWHM value, creating an array for these FWHMs. 3. Initializes a dictionary to store ancillary data and an array to flag bad bands. 4. Reads the JSON file to get the band parameters for the given sensor type. 5. Checks if the sensor type is valid and present in the JSON data. 6. Extracts output wavelengths and FWHM values for the specified sensor type and stores them. 7. Configures the resampler settings (type, output wavelengths, and FWHMs).
The configuration for resampling is set up based on the Landsat sensor type specified. This includes defining the output wavelengths and FWHMs which are crucial for the resampling process.
get_in_wavelength
staticmethod
¶
get_in_wavelength(hdr_path)
Reads and extracts wavelength information from an ENVI header file.
- hdr_path: The file path to the ENVI header (.hdr) file.
The method performs the following steps:
1. Reads the header file using the Spectral Python (SPy) library's read_envi_header function.
2. Extracts the wavelength information, which is typically a list of strings representing wavelength values.
3. Converts these string values to floats, making them usable for numerical operations.
Returns: - A list of wavelength values as floats if successfully extracted.
If the wavelength information is not found in the header file, the method raises a ValueError, indicating the absence of this crucial data. This method is essential for processing spectral data as it provides the fundamental wavelength values needed for various analytical processes, such as resampling.
get_in_fwhm
staticmethod
¶
get_in_fwhm(number_of_bands, fwhm_value)
Generate a list of FWHM values for each band in hyperspectral data.
:param number_of_bands: int The total number of bands in the hyperspectral data. :param fwhm_value: float, optional (default is 5) The FWHM value for each band (in nm).
:return: list A list of FWHM values for each band.
create_header_info ¶
create_header_info(hdr_path)
Create header information for the resampled data. :param hdr_path: string Path and file name of the hdr file :return: dict Dictionary containing header information for the ENVI file, including CRS.
save_envi_data
staticmethod
¶
save_envi_data(data, header_info, output_filename)
Save data in ENVI format.
:param data: The hyperspectral data to save. :param header_info: Header information for the data. :param output_filename: The filename for the saved data.
Audience: advanced.
load_envi_data ¶
load_envi_data(filename)
Load hyperspectral data from an ENVI binary file.
:param filename: The filename of the ENVI binary file (without the .hdr extension). :return: The loaded hyperspectral data as a spectral image object.
Audience: advanced.
translate_to_sensor ¶
translate_to_sensor(sensor_type, json_file, hdr_path, resampling_file_path: str, output_file_path: str)
Read an existing ENVI product and write one target-sensor product through the retained legacy resampler.
Audience: advanced.
translate_to_other_sensors ¶
translate_to_other_sensors(brdf_corrected_img_file: NEONReflectanceBRDFCorrectedENVIFile)
Run the retained legacy resampler for its configured Landsat and MicaSense targets.