pygmi.rsense package

Submodules

pygmi.rsense.change module

Calculate change detection indices.

class pygmi.rsense.change.CalculateChange(parent=None)

Bases: BasicModule

Calculate Change Indices.

acceptall()

Accept option.

Updates self.outdata, which is used as input to other modules.

Return type:

None.

invert_selection()

Invert the selected indices.

Return type:

None.

saveproj()

Save project data from class.

Return type:

None.

set_selected_indices()

Set the selected indices.

Return type:

None.

setindices()

Set the available indices.

Return type:

None.

settings(nodialog=False)

Entry point into item.

Parameters:

nodialog (bool, optional) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

setupui()

Set up UI.

Return type:

None.

pygmi.rsense.change.calc_change(flist, ilist=None, showlog=<built-in function print>, piter=<built-in function iter>)

Calculate Change Indices.

Parameters:
  • flist (list of RasterMeta.) – List of batch file list data.

  • ilist (list, optional) – List of strings describing index to calculate.

  • showlog (function, optional) – Display information. The default is print.

  • piter (function, optional) – Progress bar iterator. The default is iter.

Returns:

datfin – List of PyGMI Data.

Return type:

list of PyGMI Data

pygmi.rsense.change.calc_mean(flist, showlog=<built-in function print>, piter=<built-in function iter>)

Load data and calculate iterative Mean.

Parameters:
  • flist (list of RasterMeta) – List of batch file list data.

  • showlog (function, optional) – Display information. The default is print.

  • piter (function, optional) – Progress bar iterator. The default is iter.

Returns:

  • meandat (dictionary of PyGMI Data.) – PyGMI Data representing means.

  • cnt (dictionary of numpy arrays) – Count of values which made up mean.

  • M (dictionary of numpy arrays) – Variance parameter, where Variance = M/cnt.

pygmi.rsense.change.calc_sam(flist, showlog=<built-in function print>, piter=<built-in function iter>)

Load data and calculate spectral angle between two times.

Parameters:
  • flist (list of RasterMeta.) – List of batch file list data.

  • showlog (function, optional) – Display information. The default is print.

  • piter (function, optional) – Progress bar iterator. The default is iter.

Returns:

angle – PyGMI Data of SAM angles.

Return type:

PyGMI Data

pygmi.rsense.change.coefv(mean, std)

Calculate coefficient of variation.

Parameters:
  • mean (numpy array) – numpy array of mean values.

  • std (numpy array) – numpy array of standard deviation values.

Returns:

cv – Array of coefficient of variation values.

Return type:

numpy array

pygmi.rsense.change.imean(mean, newdat, cnt=None, M=None)

Calculate mean and variance parameters.

Parameters:
  • mean (numpy array) – existing mean values.

  • newdat (numpy array) – new data to be added to mean..

  • cnt (numpy array, optional) – cnt of values which made up mean. The default is None.

  • M (numpy array, optional) – Variance parameter, where Variance = M/cnt. The default is None.

Returns:

  • mean (numpy array) – Updated mean of data.

  • cnt (numpy array) – Updated cnt of values which made up mean.

  • M (numpy array) – Updated variance parameter, where Variance = M/cnt.

pygmi.rsense.change.match_data(flist, showlog=<built-in function print>, piter=<built-in function iter>)

Match two datasets.

Parameters:
  • flist (list of RasterMeta) – List of batch file list data.

  • showlog (function, optional) – Display information. The default is print.

  • piter (function, optional) – Progress bar iterator. The default is iter.

Returns:

  • dat1 (list of PyGMI Data) – First dataset with matched bands only.

  • dat2 (list of PyGMI Data) – Second dataset with matched bands only.

pygmi.rsense.change.sam(s1, s2)

Calculate Spectral Angle Mapper (SAM).

Parameters:
  • s1 (numpy array) – Spectrum 1.

  • s2 (numpy array) – Spectrum 2.

Returns:

result – Output angles.

Return type:

numpy array

pygmi.rsense.change.scm(s1, s2)

SCM or MSAM.

Parameters:
  • s1 (numpy array) – Spectrum 1.

  • s2 (numpy array) – Spectrum 2.

Returns:

result – Output angles.

Return type:

numpy array

pygmi.rsense.change.stddev(M, cnt)

Calculate std deviation.

Parameters:
  • M (numpy array) – Variance parameter, where Variance = M/cnt.

  • cnt (numpy array) – cnt of values which made up mean.

Returns:

std – Calculated standard deviation.

Return type:

numpy array

pygmi.rsense.change_viewer module

Change Detection Viewer.

class pygmi.rsense.change_viewer.MyMplCanvas(parent=None, width=10, height=8, dpi=100)

Bases: FigureCanvasQTAgg

Simple canvas with a sine plot.

capture()

Capture.

Return type:

None.

compute_initial_figure(dat, dates)

Compute initial figure.

Parameters:
  • dat (PyGMI Data) – PyGMI dataset.

  • dates (str) – Dates to show on title.

Return type:

None.

update_plot(dat, dates)

Update plot.

Parameters:
  • dat (PyGMI Data) – PyGMI dataset.

  • dates (str) – Dates to show on title.

Return type:

None.

class pygmi.rsense.change_viewer.SceneViewer(parent=None)

Bases: BasicModule

Scene Viewer.

capture()

Capture all scenes in the current view as an animation.

Return type:

None.

manip_change()

Change manipulation or bands.

Return type:

None.

newdata(indx)

Get new dataset.

Parameters:

indx (int) – Current index.

Return type:

None.

nextscene()

Get next scene.

Return type:

None.

prevscene()

Get previous scene.

Return type:

None.

saveproj()

Save project data from class.

Return type:

None.

settings(nodialog=False)

Entry point into item.

Parameters:

nodialog (bool, optional) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

setupui()

Set up UI.

Return type:

None.

updatescenelist()

Update the scene list.

Returns:

Boolean to indicate success.

Return type:

bool

pygmi.rsense.emit module

EMIT is used to import EMIT satellite data into PyGMI.

It uses code by Erik Bolch, ebolch@contractor.usgs.gov

pygmi.rsense.emit.apply_glt(ds_array, glt_array, fill_value=-9999, GLT_NODATA_VALUE=0)

Apply GLT.

This function applies the GLT array to a numpy array of either 2 or 3 dimensions.

Parameters:
  • ds_array (numpy array) – A numpy array of the desired variable.

  • glt_array (GLT array) – A GLT array constructed from EMIT GLT data.

  • fill_value (int, optional) – Fill value. The default is -9999.

  • GLT_NODATA_VALUE (int, optional) – GLT nodata value. The default is 0.

Returns:

out_ds – a numpy array of orthorectified data.

Return type:

numpy array

pygmi.rsense.emit.coord_vects(ds)

Calculate the Lat and Lon Vectors/Coordinate Grid.

This function calculates the Lat and Lon Coordinate Vectors using the GLT and Metadata from an EMIT dataset read into xarray.

Parameters:

ds (xarray.Dataset) – an xarray.Dataset containing the root variable and metadata of an EMIT dataset.

Returns:

  • lon (numpy array) – Longitude.

  • lat (numpy array) – Latitude.

pygmi.rsense.emit.emit_xarray(filepath, ortho=False, qmask=None, unpacked_bmask=None)

EMIT xarray.

This function utilizes other functions in this module to streamline opening an EMIT dataset as an xarray.Dataset.

Parameters:
  • filepath (str) – a file path to an EMIT netCDF file.

  • ortho (bool, optional) – Whether to orthorectify the dataset or leave in crosstrack/downtrack coordinates. The default is False.

  • qmask (numpy array, optional) – Output from the quality_mask function used to mask pixels based on quality flags selected in that function. Any non-orthorectified array with the proper crosstrack and downtrack dimensions can also be used. The default is None.

  • unpacked_bmask (numpy array, optional) – From the band_mask function, used to mask band-specific pixels that have been interpolated. The default is None.

Returns:

out_xr – Dataset constructed based on the parameters provided.

Return type:

xarray.Dataset

pygmi.rsense.emit.main()

EMIT data.

pygmi.rsense.emit.ortho_xr(ds, GLT_NODATA_VALUE=0, fill_value=-9999)

Use apply_glt to create an orthorectified xarray dataset.

Parameters:
  • ds (xarray.Dataset) – Dataset produced by emit_xarray.

  • GLT_NODATA_VALUE (int, optional) – No data value for the GLT tables. The default is 0.

  • fill_value (int, optional) – The fill value for EMIT datasets. The default is -9999.

Returns:

out_xr – an orthocorrected xarray dataset.

Return type:

xarray.Dataset

pygmi.rsense.emit.xr_to_pygmi(xr_ds, piter=<built-in function iter>, showlog=<built-in function print>, tnames=None, metaonly=False)

Xarray to PyGMI dataset.

Takes an EMIT dataset read into an xarray dataset using the emit_xarray function and convert to PyGMI dataset.

Parameters:

xr_ds (xarray.Dataset) – an EMIT dataset read into xarray using the emit_xarray function.

Returns:

dat – list of pygmi Data

Return type:

list

pygmi.rsense.features module

List of features for hyperspectral interpretation.

pygmi.rsense.hyperspec module

Hyperspectral Interpretation Routines.

class pygmi.rsense.hyperspec.AnalSpec(parent=None)

Bases: BasicModule

Analyse spectra.

button_press_callback(event)

Button press callback.

Parameters:

event (matplotlib.backend_bases.MouseEvent) – Mouse Event.

Return type:

None.

disp_splib(row)

Change library spectra for display.

Parameters:

row (int) – row of table, unused.

Return type:

None.

feature_change()

Change depth marker combo.

Return type:

None.

hull()

Change whether hull is removed or not.

Return type:

None.

load_splib()

Load ENVI spectral library data.

Return type:

None.

on_combo()

On combo.

Return type:

None.

rotate_view()

Rotates view.

Return type:

None.

saveproj()

Save project data from class.

Return type:

None.

settings(nodialog=False)

Entry point into item.

Parameters:

nodialog (bool, optional) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

setupui()

Set up UI.

Return type:

None.

class pygmi.rsense.hyperspec.GraphMap(parent=None)

Bases: FigureCanvasQTAgg

Graph Map.

parent

reference to the parent routine

Type:

parent

compute_initial_figure()

Compute initial figure.

init_graph()

Initialise the graph.

Return type:

None.

class pygmi.rsense.hyperspec.ProcFeatures(parent=None)

Bases: BasicModule

Process Hyperspectral Features.

acceptall()

Accept option.

Updates self.outdata, which is used as input to other modules.

Return type:

None.

product_change()

Change product combo.

Return type:

None.

saveproj()

Save project data from class.

Return type:

None.

settings(nodialog=False)

Entry point into item.

Parameters:

nodialog (bool, optional) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

setupui()

Set up UI.

Return type:

None.

pygmi.rsense.hyperspec.calcfeatures(dat, mineral, feature, ratio, product, cryst=None, rfilt=True, piter=<built-in function iter>)

Calculate feature dataset.

Parameters:
  • dat (list of PyGMI Data) – Input PyGMI data.

  • mineral (str) – Mineral description.

  • feature (dictionary) – Dictionary containing the hyperspectral features.

  • ratio (dictionary) – Dictionary containing string definitions of ratios.

  • product (dictionary) – Final hyperspectral products. Each dictionary value, is a list of features or ratios with thresholds to be combined.

  • cryst (dictionary, optional) – Crystallinity of the product, if available

  • rfilt (bool) – Flag to decide whether to filter final ratio products less than 1.0

  • piter (function, optional) – Progress bar iterable. The default is iter.

Returns:

datfin – Output datasets.

Return type:

list of PyGMI Data.

pygmi.rsense.hyperspec.cubic_calc(xdat, crem, imin)

Find minimum of function using an analytic cubic calculation for speed.

Parameters:
  • xdat (numpy array) – wavelengths - x data.

  • crem (numpy array) – continuum removed data - y data.

  • imin (int) – Index for estimated minimum.

Returns:

  • x (float) – wavelength at minimum.

  • y (float) – y value at minimum.

pygmi.rsense.hyperspec.fproc(fdat, ptmp, dtmp, i1a, i2a, xdat, mtmp)

Feature process.

This function finds the minimum value of a feature.

Parameters:
  • fdat (numpy array) – Feature data

  • ptmp (numpy array) – Feature wavelengths.

  • dtmp (numpy array) – Feature depths.

  • i1a (int) – Start index of feature definition.

  • i2a (int) – End Index of feature definition.

  • xdat (numpy array) – Wavelengths of feature definition.

Returns:

  • ptmp (numpy array) – Feature wavelengths.

  • dtmp (numpy array) – Feature depths.

pygmi.rsense.hyperspec.indexcalc(formula, dat)

Calculate an index using numexpr.

Parameters:
  • formula (str) – string expression containing index formula.

  • dat (dict) – Dictionary of variables to be used in calculation.

Returns:

out – This can be a masked array.

Return type:

numpy array

pygmi.rsense.hyperspec.phull(sample1)

Hull Calculation.

Parameters:

sample1 (numpy array) – Sample to create a hull for.

Returns:

out – Output hull.

Return type:

numpy array

pygmi.rsense.hyperspec.readsli(ifile)

Read an ENVI sli file.

Parameters:

ifile (str) – Input sli spectra file.

Returns:

spectra – Dictionary of spectra with wavelengths and reflectances.

Return type:

dictionary

pygmi.rsense.iodefs module

Import remote sensing data.

class pygmi.rsense.iodefs.ExportBatch(parent=None)

Bases: ContextModule

Export Raster File List.

acceptall()

Accept choice.

click_ternary()

Click ternary event.

Return type:

None.

get_odir(odir='')

Get output directory.

Parameters:

odir (str, optional) – Output directory submitted for testing. The default is ‘’.

Return type:

None.

run()

Run.

Returns:

True if successful, False otherwise.

Return type:

bool

setupui()

Set up UI.

Return type:

None.

class pygmi.rsense.iodefs.ImportBatch(parent=None)

Bases: BasicModule

Batch Import Data Interface.

This does not actually import data, but rather defines a list of datasets to be used by other routines.

idir

Input directory.

Type:

str

get_sfile(nodialog=False)

Get the satellite filenames.

saveproj()

Save project data from class.

Return type:

None.

setsensor()

Set the sensor band data.

Return type:

None.

settings(nodialog=False)

Entry point into item.

Parameters:

nodialog (bool, optional) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

setupui()

Set up UI.

Return type:

None.

class pygmi.rsense.iodefs.ImportData(parent=None)

Bases: BasicModule

Import Data - Interfaces with rasterio routines.

get_sfile()

Get the satellite filename.

saveproj()

Save project data from class.

Return type:

None.

settings(nodialog=False)

Entry point into item.

Parameters:

nodialog (bool, optional) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

setupui()

Set up UI.

Return type:

None.

class pygmi.rsense.iodefs.ImportSentinel5P(parent=None)

Bases: BasicModule

Import Sentinel 5P data to shapefile.

clipchoice()

Choose clip style.

Return type:

None.

get_5P_data(meta)

Get 5P data.

Parameters:

meta (Dictionary) – Dictionary containing metadata.

Returns:

gdf – geopandas dataframe.

Return type:

DataFrame

get_5P_meta()

Get 5P metadata.

Returns:

meta – Dictionary containing metadata.

Return type:

Dictionary

loadshp()

Load shapefile filename.

Return type:

None.

saveproj()

Save project data from class.

Return type:

None.

settings(nodialog=False)

Entry point into item.

Parameters:

nodialog (bool, optional) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

setupui()

Set up UI.

Return type:

None.

pygmi.rsense.iodefs.calculate_toa(dat, showlog=<built-in function print>)

Top of atmosphere correction.

Includes VNIR, SWIR and TIR bands.

Parameters:
  • dat (Data) – PyGMI raster dataset

  • showlog (function, optional) – Routine to show text messages. The default is print.

Returns:

out – PyGMI raster dataset

Return type:

Data

pygmi.rsense.iodefs.consolidate_aster_list(flist)

Consolidate ASTER files from a file list, getting rid of extra files.

Parameters:

flist (list) – List of filenames.

Returns:

flist – List of filenames.

Return type:

list

pygmi.rsense.iodefs.convert_ll_to_utm(lon, lat)

Convert latitude and longitude to UTM.

https://stackoverflow.com/a/40140326/4556479

Parameters:
  • lon (float) – Longitude.

  • lat (float) – latitude.

Returns:

epsg_code – EPSG code.

Return type:

str

pygmi.rsense.iodefs.etree_to_dict(t)

Convert an ElementTree to dictionary.

From K3–rnc: https://stackoverflow.com/questions/7684333/converting-xml-to-dictionary-using-elementtree

Parameters:

t (Elementtree) – Root.

Returns:

d – Dictionary of ElementTree items.

Return type:

dictionary

pygmi.rsense.iodefs.export_batch(indata, odir, filt, tnames=None, piter=None, showlog=<built-in function print>, otype=None, sunfile=None, cell=25.0, alpha=0.75)

Export a batch of files directly from satellite format to disk.

Parameters:
  • indata (dictionary) – Dictionary containing ‘RasterFileList’ as one of its keys.

  • odir (str) – Output Directory.

  • filt (str) – type of file to export.

  • tnames (list, optional) – list of band names to import, in order. the default is None.

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • otype (str) – output type of file, regular or RGB ternary (with possible sunshading)

  • sunfile (str) – either a filename of an external file to be used for sunshading, or an existing band name. the default is None.

  • cell (float) – Between 1 and 100 - controls sunshade detail. The default is 25.

  • alpha (float) – How much incident light is reflected (0 to 1). The default is .75.

Return type:

None.

pygmi.rsense.iodefs.get_aster_ged(ifile, piter=None, showlog=<built-in function print>, tnames=None, metaonly=False)

Get ASTER GED data.

Parameters:
  • ifile (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • tnames (list, optional) – list of band names to import, in order. The default is None.

  • metaonly (bool, optional) – Retrieve only the metadata for the file. The default is False.

Returns:

dat – dataset imported

Return type:

PyGMI raster Data

pygmi.rsense.iodefs.get_aster_ged_bin(ifile)

Get ASTER GED binary format.

Emissivity_Mean_Description: Mean Emissivity for each pixel on grid-box using all ASTER data from 2000-2010 Emissivity_SDev_Description: Emissivity Standard Deviation for each pixel on grid-box using all ASTER data from 2000-2010 Temperature_Mean_Description: Mean Temperature (K) for each pixel on grid-box using all ASTER data from 2000-2010 Temperature_SDev_Description: Temperature Standard Deviation for each pixel on grid-box using all ASTER data from 2000-2010 NDVI_Mean_Description: Mean NDVI for each pixel on grid-box using all ASTER data from 2000-2010 NDVI_SDev_Description: NDVI Standard Deviation for each pixel on grid-box using all ASTER data from 2000-2010 Land_Water_Map_LWmap_Description: Land Water Map using ASTER visible bands Observations_NumObs_Description: Number of values used in computing mean and standard deviation for each pixel. Geolocation_Latitude_Description: Latitude Geolocation_Longitude_Description: Longitude ASTER_GDEM_ASTGDEM_Description: ASTER GDEM resampled to NAALSED

Parameters:

ifile (str) – filename to import

Returns:

dat – dataset imported

Return type:

PyGMI raster Data

pygmi.rsense.iodefs.get_aster_hdf(ifile, piter=None, showlog=<built-in function print>, tnames=None, metaonly=False)

Get ASTER hdf Data.

This function needs the original filename to extract the date.

Parameters:
  • ifile (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • tnames (list, optional) – list of band names to import, in order. The default is None.

  • metaonly (bool, optional) – Retrieve only the metadata for the file. The default is False.

Returns:

dat – dataset imported

Return type:

PyGMI raster Data

pygmi.rsense.iodefs.get_aster_zip(ifile, piter=None, showlog=<built-in function print>, tnames=None, metaonly=False)

Get ASTER zip Data.

Parameters:
  • ifile (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • tnames (list, optional) – list of band names to import, in order. The default is None.

  • metaonly (bool, optional) – Retrieve only the metadata for the file. The default is False.

Returns:

dat – dataset imported

Return type:

PyGMI raster Data

pygmi.rsense.iodefs.get_data(ifile, piter=None, showlog=<built-in function print>, tnames=None, metaonly=False)

Load a raster dataset off the disk using the rasterio libraries.

It returns the data in a PyGMI data object.

Parameters:
  • ifile (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • tnames (list, optional) – list of band names to import, in order. The default is None.

  • metaonly (bool, optional) – Retrieve only the metadata for the file. The default is False.

Returns:

dat – dataset imported

Return type:

list of PyGMI Data

pygmi.rsense.iodefs.get_emit(ifile, piter=None, showlog=<built-in function print>, tnames=None, metaonly=False)

Get EMIT Data.

Parameters:
  • ifile (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • tnames (list, optional) – list of band names to import, in order. The default is None.

  • metaonly (bool, optional) – Retrieve only the metadata for the file. The default is False.

Returns:

dat – dataset imported

Return type:

PyGMI raster Data

pygmi.rsense.iodefs.get_from_rastermeta(ldata, piter=None, showlog=<built-in function print>, tnames=None)

Import data from a RasterMeta item.

Parameters:
  • ldata (RasterMeta or list) – List of RasterMeta or single item.

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • tnames (list, optional) – list of band names to import, in order. The default is None.

Returns:

dat – List of data.

Return type:

list of PyGMI Data

pygmi.rsense.iodefs.get_hyperion(ifile, piter=None, showlog=<built-in function print>, tnames=None, metaonly=False)

Get Hyperion Data.

Parameters:
  • ifile (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • tnames (list, optional) – list of band names to import, in order. The default is None.

  • metaonly (bool, optional) – Retrieve only the metadata for the file. The default is False.

Returns:

out – PyGMI raster dataset

Return type:

Data

pygmi.rsense.iodefs.get_landsat(ifilet, piter=None, showlog=<built-in function print>, tnames=None, metaonly=False)

Get Landsat Data.

Parameters:
  • ifilet (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • tnames (list, optional) – list of band names to import, in order. The default is None.

  • metaonly (bool, optional) – Retrieve only the metadata for the file. The default is False.

Returns:

out – PyGMI raster dataset

Return type:

Data

pygmi.rsense.iodefs.get_modisv6(ifile, piter=None, showlog=<built-in function print>, tnames=None, metaonly=False)

Get MODIS v006 data.

Parameters:
  • ifile (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • tnames (list, optional) – list of band names to import, in order. The default is None.

  • metaonly (bool, optional) – Retrieve only the metadata for the file. The default is False.

Returns:

dat – dataset imported

Return type:

PyGMI raster Data

pygmi.rsense.iodefs.get_sentinel1(ifile, piter=None, showlog=<built-in function print>, tnames=None, metaonly=False)

Get Sentinel-1 Data.

Parameters:
  • ifile (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • tnames (list, optional) – list of band names to import, in order. The default is None.

  • metaonly (bool, optional) – Retrieve only the metadata for the file. The default is False.

Returns:

dat – dataset imported

Return type:

PyGMI raster Data

pygmi.rsense.iodefs.get_sentinel2(ifile, piter=None, showlog=<built-in function print>, tnames=None, metaonly=False)

Get Sentinel-2 Data.

Parameters:
  • ifile (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • tnames (list, optional) – list of band names to import, in order. The default is None.

  • metaonly (bool, optional) – Retrieve only the metadata for the file. The default is False.

Returns:

dat – dataset imported

Return type:

PyGMI raster Data

pygmi.rsense.iodefs.get_spot(ifile, piter=None, showlog=<built-in function print>, tnames=None, metaonly=False)

Get Spot DIMAP Data.

Parameters:
  • ifile (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • tnames (list, optional) – list of band names to import, in order. The default is None.

  • metaonly (bool, optional) – Retrieve only the metadata for the file. The default is False.

Returns:

dat – dataset imported

Return type:

PyGMI raster Data

pygmi.rsense.iodefs.get_ternary(dat, sunfile=None, clippercl=1.0, clippercu=1.0, cell=25.0, alpha=0.75, piter=<built-in function iter>, showlog=<built-in function print>)

Create a ternary image, with optional sunshading.

Parameters:
  • dat (list of PyGMI Data) – PyGMI Data.

  • sunfile (str, optional) – Sunshading band or filename. The default is None.

  • clippercl (float, optional) – Lower clip percentage for colour bar. The default is 1.

  • clippercu (float, optional) – Upper clip percentage for colour bar. The default is 1.

  • cell (float, optional) – Between 1 and 100 - controls sunshade detail. The default is 25.

  • alpha (float, optional) – How much incident light is reflected (0 to 1). The default is .75.

Returns:

newimg – list of PyGMI data.

Return type:

list of PyGMI Data.

pygmi.rsense.iodefs.get_worldview(ifilet, piter=None, showlog=<built-in function print>, tnames=None, metaonly=False)

Get WorldView Data.

Parameters:
  • ifilet (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • tnames (list, optional) – list of band names to import, in order. The default is None.

  • metaonly (bool, optional) – Retrieve only the metadata for the file. The default is False.

Returns:

out – PyGMI raster dataset

Return type:

Data

pygmi.rsense.iodefs.set_export_filename(dat, odir, otype=None)

Set the export filename according to convention.

Different satellite products have different simplified conventions for output filenames to avoid names getting too long.

Parameters:
  • dat (list of PyGMI Data.) – List of PyGMI data.

  • odir (str) – Output directory.

  • otype (str, optional.) – Output file type. Default is None.

Returns:

ofile – Output file name.

Return type:

str

pygmi.rsense.iodefs.utm_to_south(dat)

Make sure all UTM labels are for southern hemisphere.

Parameters:

dat (list of PyGMI Data) – List of Data.

Returns:

dat – List of Data.

Return type:

list of PyGMI Data

pygmi.rsense.landsat_composite module

Calculate Landsat composite scenes.

class pygmi.rsense.landsat_composite.LandsatComposite(parent=None)

Bases: BasicModule

Landsat Composite Interface.

idir

Input directory.

Type:

str

get_idir()

Get the input directory.

Return type:

None.

saveproj()

Save project data from class.

Return type:

None.

settings(nodialog=False)

Entry point into item.

Parameters:

nodialog (bool, optional) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

setupui()

Set up UI.

Return type:

None.

pygmi.rsense.landsat_composite.composite(idir, dreq=10, mean=None, showlog=<built-in function print>, piter=None)

Create a Landsat composite.

Parameters:
  • idir (str) – Input directory.

  • dreq (int, optional) – Distance to cloud in pixels. The default is 10.

  • mean (float, optional) – The mean or target day. If not specified, it is calculated automatically. The default is None.

  • showlog (function, optional) – Function for printing text. The default is print.

  • piter (function, optional) – Progress bar iterable. The default is None.

Returns:

datfin – List of PyGMI Data.

Return type:

list of PyGMI Data.

pygmi.rsense.landsat_composite.import_and_score(ifile, dreq, mean, std, showlog=<built-in function print>, piter=None)

Import data and score it.

Parameters:
  • ifile (str) – Input filename.

  • dreq (int, optional) – Distance to cloud in pixels. The default is 10.

  • mean (float) – The mean or target day.

  • std (float) – The standard deviation of all days.

  • showlog (function, optional) – Function for printing text. The default is print.

  • piter (function, optional) – Progress bar iterable. The default is None.

Returns:

dat – Dictionary of bands imported.

Return type:

dictionary.

pygmi.rsense.menu module

Remote Sensing Menu Routines.

class pygmi.rsense.menu.MenuWidget(parent=None)

Bases: object

Widget class to call the main interface.

This widget class creates menus to be found on the main interface. Normal as well as context menus are defined here.

parent

Reference to MainWidget class found in main.py

Type:

pygmi.main.MainWidget

anal_spec()

Analyse Spectra.

batch_list()

Import batch list.

calc_change()

Calculate change.

calc_ci()

Calculate Condition Indices.

calc_ratios()

Calculate Ratios.

exportlist()

Export Raster File List.

import_sat()

Import Satellite data.

import_sentinel5p()

Import Sentinel 5P data.

lsat_comp()

Calculate Landsat Composite.

mnf()

Calculate MNF.

pca()

Calculate PCA.

proc_features()

Process Features.

view_change()

View Change Detection.

pygmi.rsense.ratios module

Calculate remote sensing ratios.

class pygmi.rsense.ratios.ConditionIndices(parent=None)

Bases: BasicModule

Calculate Satellite Condition Indices.

acceptall()

Accept option.

Updates self.outdata, which is used as input to other modules.

Return type:

None.

invert_selection()

Invert the selected ratios.

Return type:

None.

saveproj()

Save project data from class.

Return type:

None.

set_selected_ratios()

Set the selected ratios.

Return type:

None.

setratios()

Set the available indices.

Return type:

None.

settings(nodialog=False)

Entry point into item.

Parameters:

nodialog (bool, optional) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

setupui()

Set up UI.

Return type:

None.

class pygmi.rsense.ratios.SatRatios(parent=None)

Bases: BasicModule

Calculate Satellite Ratios.

acceptall()

Accept option.

Updates self.outdata, which is used as input to other modules.

Return type:

None.

invert_selection()

Invert the selected ratios.

Return type:

None.

saveproj()

Save project data from class.

Return type:

None.

set_selected_ratios()

Set the selected ratios.

Return type:

None.

setratios()

Set the available ratios.

The ratio definitions are for the ASTER satellite. Band 0 refers to an imaginary blue band.

Return type:

None.

settings(nodialog=False)

Entry point into item.

Parameters:

nodialog (bool, optional) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

setupui()

Set up UI.

Return type:

None.

pygmi.rsense.ratios.calc_ratios(dat, rlist, showlog=<built-in function print>, piter=<built-in function iter>, sensor=None)

Calculate Band ratios.

Note that this routine assumes that the ratio you supply is correct for your data.

Parameters:
  • dat (list of PyGMI Data.) – List of PyGMI Data.

  • rlist (list) – List of strings, containing ratios to calculate..

  • showlog (function, optional) – Display information. The default is print.

  • piter (function, optional) – Progress bar iterator. The default is iter.

Returns:

datfin – List of PyGMI Data.

Return type:

list of PyGMI Data.

pygmi.rsense.ratios.correct_bands(rlist, sensor, bfile=None)

Correct the band designations.

Ratio formula are defined in terms of ASTER bands. This converts that to the target sensor.

Parameters:
  • rlist (list) – List of input ratios.

  • sensor (str) – Target sensor.

Returns:

rlist2 – List of converted ratios.

Return type:

list

pygmi.rsense.ratios.get_TCI(lst)

Calculate TCI.

Parameters:

lst (list of PyGMI Data.) – list of PyGMI datasets - land surface temperatures.

Returns:

tci – output TCI datasets.

Return type:

list of PyGMI Data.

pygmi.rsense.ratios.get_VCI(evi, index)

Calculate VCI.

Parameters:
  • evi (list of PyGMI Data) – list of EVI datasets.

  • index (str) – index for dataid.

Returns:

vci – output VCI datasets.

Return type:

list of PyGMI Data

pygmi.rsense.ratios.get_VHI(tci, vci, alpha=0.5)

Calculate VHI.

Parameters:
  • tci (list) – TCI dataset list.

  • vci (list) – VCI dataset list.

  • alpha (float, optional) – Weight for proportion of TCI and VCI. The default is 0.5.

Returns:

vhi – Output VHI datasets.

Return type:

list of PyGMI Data

pygmi.rsense.ratios.get_aster_list(flist)

Get ASTER files from a file list.

Parameters:

flist (list) – List of filenames.

Returns:

flist – List of filenames.

Return type:

list

pygmi.rsense.ratios.get_landsat_list(flist, sensor=None, allsats=False)

Get Landsat files from a file list.

Parameters:

flist (list) – List of filenames.

Returns:

flist – List of filenames.

Return type:

list

pygmi.rsense.ratios.get_sentinel_list(flist)

Get Sentinel-2 files from a file list.

Parameters:

flist (list) – List of filenames.

Returns:

flist – List of filenames.

Return type:

list

pygmi.rsense.ratios.landslide_index(dat, sensor=None, showlog=<built-in function print>, piter=<built-in function iter>)

Calculate Band ratios.

Note that this routine assumes that the ratio you supply is correct for your data.

Parameters:
  • dat (list of PyGMI Data.) – List of PyGMI Data.

  • showlog (function, optional) – Display information. The default is print.

  • piter (function, optional) – Progress bar iterator. The default is iter.

Returns:

datfin – Red, green and blue PyGMI Data.

Return type:

list of PyGMI Data.

pygmi.rsense.transforms module

Transforms such as PCA and MNF.

class pygmi.rsense.transforms.MNF(parent=None)

Bases: BasicModule

Perform MNF Transform.

acceptall()

Accept option.

Updates self.outdata, which is used as input to other modules.

Return type:

None.

changeoutput()

Change the interface to reflect whether full calculation is needed.

Return type:

None.

saveproj()

Save project data from class.

Return type:

None.

settings(nodialog=False)

Entry point into item.

Parameters:

nodialog (bool, optional) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

setupui()

Set up UI.

Return type:

None.

class pygmi.rsense.transforms.PCA(parent=None)

Bases: BasicModule

Perform PCA Transform.

acceptall()

Accept option.

Updates self.outdata, which is used as input to other modules.

Return type:

None.

changeoutput()

Change the interface to reflect whether full calculation is needed.

Return type:

None.

saveproj()

Save project data from class.

Return type:

None.

settings(nodialog=False)

Entry point into item.

Parameters:

nodialog (bool, optional) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

setupui()

Set up UI.

Return type:

None.

pygmi.rsense.transforms.blockwise_cov(A)

Blockwise covariance.

Parameters:

A (numpy array) – Matrix.

Returns:

ncov – Covariance matrix.

Return type:

numpy array

pygmi.rsense.transforms.blockwise_dot(A, B, max_elements=134217728)

Compute the dot product of two matrices in a block-wise fashion.

Only blocks of A with a maximum size of max_elements will be processed simultaneously.

from : https://stackoverflow.com/questions/20983882/efficient-dot-products-of-large-memory-mapped-arrays

Parameters:
  • A (numpy array) – MxN matrix.

  • B (Numpy array) – NxO matrix.

  • max_elements (int, optional) – Maximum number of elements in a block. The default is int(2**27).

Returns:

out – Output dot product.

Return type:

numpy array

pygmi.rsense.transforms.get_noise(x2d, mask, noisetype='', piter=<built-in function iter>)

Calculate noise dataset from original data.

Parameters:
  • x2d (numpy array) – Input array, of dimension (MxNxChannels).

  • mask (numpy array) – mask of dimension (MxN).

  • noisetype (str, optional) – Noise type to calculate. Can be ‘diagonal’, ‘hv average’ or ‘’. The default is ‘’.

Returns:

  • nevals (numpy array) – Noise eigenvalues.

  • nevecs (numpy array) – Noise eigenvectors.

pygmi.rsense.transforms.mnf_calc(dat, ncmps=None, noisetxt='hv average', showlog=<built-in function print>, piter=<built-in function iter>, fwdonly=True)

MNF Calculation.

Parameters:
  • dat (list of PyGMI Data.) – List of PyGMI Data.

  • ncmps (int or None, optional) – Number of components to use for filtering. The default is None (meaning all).

  • noisetxt (txt, optional) – Noise type. Can be ‘diagonal’, ‘hv average’ or ‘quad’. The default is ‘hv average’.

  • showlog (function, optional) – Function for printing text. The default is print.

  • piter (function, optional) – Iteration function, used for progress bars. The default is iter.

  • fwdonly (bool, optional) – Option to perform forward calculation only. The default is True.

Returns:

  • odata (list of PyGMI Data.) – Output list of PyGMI Data. Can be forward or inverse transformed data.

  • ev (numpy array) – Explained variance, from PCA.

pygmi.rsense.transforms.pca_calc(dat, ncmps=None, showlog=<built-in function print>, piter=<built-in function iter>, fwdonly=True)

PCA Calculation.

Parameters:
  • dat (list of PyGMI Data.) – List of PyGMI Data.

  • ncmps (int or None, optional) – Number of components to use for filtering. The default is None (meaning all).

  • showlog (function, optional) – Function for printing text. The default is print.

  • piter (function, optional) – Iteration function, used for progress bars. The default is iter.

  • fwdonly (bool, optional) – Option to perform forward calculation only. The default is True.

Returns:

  • odata (list of PyGMI Data.) – Output list of PyGMI Data. Can be forward or inverse transformed data.

  • ev (numpy array) – Explained variance, from PCA.

pygmi.rsense.transforms.pca_calc_fitlist(flist, ncmps=None, showlog=<built-in function print>, piter=<built-in function iter>, fwdonly=True)

PCA Calculation with using list of files in common fit.

Parameters:
  • dat (list of PyGMI Data.) – List of PyGMI Data.

  • ncmps (int or None, optional) – Number of components to use for filtering. The default is None (meaning all).

  • showlog (function, optional) – Function for printing text. The default is print.

  • piter (function, optional) – Iteration function, used for progress bars. The default is iter.

  • fwdonly (bool, optional) – Option to perform forward calculation only. The default is True.

Returns:

  • odata (list of PyGMI Data.) – Output list of PyGMI Data.Can be forward or inverse transformed data.

  • ev (numpy array) – Explained variance, from PCA.

Module contents

Remote Sensing Routines.