isofit.utils

Submodules

Functions

analytical_line(→ None)

TODO: Description

empirical_line(→ None)

Perform an empirical line interpolation for reflectance and uncertainty extrapolation

extractions(inputfile, labels, output, chunksize, ...)

generate_noise(config)

Add noise to a radiance spectrum or image.

instrument_model(config)

interpolate_spectra(infile[, outfile, inplace, ...])

Interpolate wavelength bands that are either no data or Nan.

multicomponent_classification(rdn_file, obs_file, ...)

Classify a radiance file based on a per-pixel prior selection.

reconstruct_subs(input_subs_path, output_path, ...)

Helper function to take the flat array that the superpixel

remap(inputfile, labels, outputfile, flag, chunksize)

segment(spectra, nodata_value, npca, segsize, nchunk)

Segment an image using SLIC on a PCA.

surface_model(→ None)

The surface model tool contains everything you need to build basic

Package Contents

analytical_line(rdn_file: str, loc_file: str, obs_file: str, isofit_dir: str, isofit_config: str = None, segmentation_file: str = None, n_atm_neighbors: list = [20], n_cores: int = -1, num_iter: int = 1, smoothing_sigma: list = [2], output_rfl_file: str = None, output_unc_file: str = None, atm_file: str = None, skyview_factor_file: str = None, loglevel: str = 'INFO', logfile: str = None, initializer: str = 'algebraic', segmentation_size: int = 40) None[source]

TODO: Description

empirical_line(reference_radiance_file: str, reference_reflectance_file: str, reference_uncertainty_file: str, reference_locations_file: str, segmentation_file: str, input_radiance_file: str, input_locations_file: str, output_reflectance_file: str, output_uncertainty_file: str, nneighbors: int = 400, nodata_value: float = -9999.0, level: str = 'INFO', logfile: str = None, radiance_factors: numpy.array = None, isofit_config: str = None, n_cores: int = -1, reference_class_file: str = None, segmentation_size: int = 40) None[source]

Perform an empirical line interpolation for reflectance and uncertainty extrapolation :param reference_radiance_file: source file for radiance (interpolation built from this) :param reference_reflectance_file: source file for reflectance (interpolation built from this) :param reference_uncertainty_file: source file for uncertainty (interpolation built from this) :param reference_locations_file: source file for file locations (lon, lat, elev), (interpolation built from this) :param segmentation_file: input file noting the per-pixel segmentation used :param input_radiance_file: input radiance file (interpolate over this) :param input_locations_file: input location file (interpolate over this) :param output_reflectance_file: location to write output reflectance to :param output_uncertainty_file: location to write output uncertainty to :param nneighbors: number of neighbors to use for interpolation :param nodata_value: nodata value of input and output :param level: logging level :param logfile: logging file :param radiance_factors: radiance adjustment factors :param isofit_config: path to isofit configuration JSON file :param n_cores: number of cores to run on :param reference_class_file: optional source file for sub-type-classifications, in order: [base, cloud, water] :param segmentation_size: Number of super pixels

Returns:

None

extractions(inputfile, labels, output, chunksize, flag, reducer: FunctionType, n_cores: int = 1, ray_address: str = None, ray_redis_password: str = None, ray_temp_dir: str = None, ray_ip_head=None, logfile: str = None, loglevel: str = 'INFO')[source]

generate_noise(config)[source]

Add noise to a radiance spectrum or image.

instrument_model(config)[source]

.

interpolate_spectra(infile: str, outfile: str = '', inplace: bool = False, nodata_value: float = -9999.0, n_cores: int = -1, ray_address: str = None, ray_redis_password: str = None, ray_temp_dir: str = None, ray_ip_head=None, task_inflation_factor: int = 1, logfile: str = None, loglevel: str = 'INFO')[source]

Interpolate wavelength bands that are either no data or Nan. The interpolation will only be applied to pixel-vectors that include partial NaNs. This is meant to be used if the number of wavelengths missing is minor, and has not been widely tested if a large number of wavelength vlues are missing.

The interpolation will do two checks. One for “nodata values,” the other for NaN values. Motivated by some sensor products which have rdn data with both no data, and NaN values.

 :param infile: Input file that contains the wavelengths to be interpolated. :type infile: str :param inplace: Flag to tell algorithm to write to new file (False) or write to

input file (True)

Parameters:
  • outfile (str) – Output lcoation for the interpolated wavelengths

  • nodata_value (float) – No data value to check against, and interpolate across Flexible typing in numpy boolean operations means this could be float or int

  • n_cores (int) – Number of cores to run. Substantial parallelism is available Defaults to maxing this out on the available system (-1)

  • logfile (str) – File path to write logs to

  • loglevel (str) – Logging level with which to run ISOFIT

multicomponent_classification(rdn_file: str, obs_file: str, loc_file: str, out_file: str, surface_files: str, wavelength_file: std, n_cores: int = -1, dayofyear: int = None, irr_file: str = None, clean: bool = False, thresh: int = 100, ray_address: str = None, ray_redis_password: str = None, ray_temp_dir=None, ray_ip_head=None, loglevel: str = 'INFO', logfile: str = None)[source]

Classify a radiance file based on a per-pixel prior selection. The classification leverages the same methodology ISOFIT uses to select a prior distribution from an input .json or .mat file.

 :param rdn_file: Radiance data cube. Expected to be ENVI format :type rdn_file: str :param obs_file: Location data cube of shape (Lon, Lat, Elevation). Expected to be ENVI format :type obs_file: str :param loc_file:

Observation data cube of shape:

(path length, to-sensor azimuth, to-sensor zenith, to-sun azimuth, to-sun zenith, phase, slope, aspect, cosine i, UTC time)

Expected to be ENVI format

Parameters:
  • out_file (str) – Output path to location where to save output file.

  • surface_files (str or dict) – CLI entry into the classifier uses a .mat or a .json file Apply OE entry into the classifier uses a dict argument.

  • wavelength_file (str) – Standard ISOFIT wavelength file

  • n_cores (int, default=1) – Number of cores to run classifier with.

  • dayofyear (int) – Day of year for earth-sun distance calculation

  • irr_file (str) – Path to irradiance file to use in the classification

  • clean (str) – Experimental method to filter out noisy classification masks. Creates connected binary components and filters out small features.

  • thresh (int) – Threshold size to filter out features smaller than this number of pixels.

  • loglevel (str) – Logging level to use (e.g. DEBUG, INFO, etc.)

  • logfile (str) – Output location for logging file if writing to disk.

reconstruct_subs(input_subs_path, output_path, lbl_working_path)[source]

Helper function to take the flat array that the superpixel algorithms work with and turn them into images at the full resolution of the input/output file. They will have the full array-resolution, but appear as coarser pixel-resolution images.

Parameters:
  • input_subs_path – Input subs file path.

  • output_path – Output reconstructed file path.

  • lbl_working_path – File path to label file for reconstruction.

Returns:

None

remap(inputfile, labels, outputfile, flag, chunksize)[source]

.

segment(spectra: tuple, nodata_value: float, npca: int, segsize: int, nchunk: int, n_cores: int = 1, ray_address: str = None, ray_redis_password: str = None, ray_temp_dir=None, ray_ip_head=None, logfile=None, loglevel='INFO')[source]

Segment an image using SLIC on a PCA.

Parameters:
  • spectra – tuple of filepaths of image to segment and (optionally) output label file

  • nodata_value – data to ignore in radiance image

  • npca – number of pca components to use

  • segsize – mean segmentation size

  • nchunk – size of each image chunk

  • n_cores – number of cores to use

  • ray_address – ray address to connect to (for multinode implementation)

  • ray_redis_password – ray password to use (for multinode implementation)

  • ray_temp_dir – ray temp directory to reference

  • ray_ip_head – ray ip head to reference (for multinode use)

  • logfile – logging file to output to

  • loglevel – logging level to use

surface_model(config_path: str, wavelength_path: str = None, output_path: str = None, seed: int = 13, multisurface: bool = False) None[source]

The surface model tool contains everything you need to build basic multicomponent (i.e. colleciton of Gaussian) surface priors for the multicomponent surface model.

Parameters:
  • config_path – path to a JSON formatted surface model configuration

  • wavelength_path – optional path to a three-column wavelength file, overriding the configuration file settings

  • output_path – optional path to the destination .mat file, overriding the configuration file settings

  • seed – seed used for clustering

Returns:

None