yatsm.mapping package

Module contents

Module for making map products from YATSM results

Contains functions used in “map” command line interface script.

yatsm.mapping.get_change_date(start, end, result_location, image_ds, first=False, out_format='%Y%j', magnitude=False, ndv=-9999, pattern='yatsm_r*', warn_on_empty=False)[source]

Output raster with changemap

Parameters:
  • start – Ordinal date for start of map records
  • end – Ordinal date for end of map records
  • result_location – Location of results
  • image_ds – Example dataset
  • first – Use first change instead of last
  • out_format – Output date format
  • magnitude – output magnitude of each change?
  • ndv – NoDataValue
  • pattern – filename pattern of saved record results
  • warn_on_empty – Log warning if result contained no result records (default: False)
Returns:

A 2D np.ndarray array containing the changes between the

start and end date. Also includes, if specified, a 3D np.ndarray of the magnitude of each change plus the indices of these magnitudes

Return type:

tuple

yatsm.mapping.get_change_num(start, end, result_location, image_ds, ndv=-9999, pattern='yatsm_r*', warn_on_empty=False)[source]

Output raster with changemap

Parameters:
  • start – Ordinal date for start of map records
  • end – Ordinal date for end of map records
  • result_location – Location of results
  • image_ds – Example dataset
  • ndv – NoDataValue
  • pattern – filename pattern of saved record results
  • warn_on_empty – Log warning if result contained no result records (default: False)
Returns:

2D numpy array containing the number of changes

between the start and end date; list containing band names

Return type:

np.ndarray

yatsm.mapping.get_classification(date, result_location, image_ds, after=False, before=False, qa=False, pred_proba=False, ndv=0, pattern='yatsm_r*', warn_on_empty=False)[source]

Output raster with classification results

Parameters:
  • date – ordinal date for prediction image
  • result_location – Location of the results
  • image_ds – Example dataset
  • after – If date intersects a disturbed period, use next available time segment
  • before – If date does not intersect a model, use previous non-disturbed time segment
  • qa – Add QA flag specifying segment type (intersect, after, or before)
  • pred_proba – Include additional band with classification value probabilities
  • ndv – NoDataValue
  • pattern – filename pattern of saved record results
  • warn_on_empty – Log warning if result contained no result records (default: False)
Returns:

2D numpy array containing the classification map for the

date specified

Return type:

np.ndarray

yatsm.mapping.get_phenology(date, result_location, image_ds, after=False, before=False, qa=False, ndv=-9999, pattern='yatsm_r*', warn_on_empty=False)[source]

Output a raster containing phenology information

Phenology information includes spring_doy, autumn_doy, pheno_cor, peak_evi, peak_doy, and pheno_nobs.

Parameters:
  • date – Ordinal date for prediction image
  • result_location – Location of the results
  • image_ds – Example dataset
  • after – If date intersects a disturbed period, use next available time segment
  • before – If date does not intersect a model, use previous non-disturbed time segment
  • qa – Add QA flag specifying segment type (intersect, after, or before)
  • ndv – NoDataValue
  • pattern – filename pattern of saved record results
  • warn_on_empty – Log warning if result contained no result records (default: False)
Returns:

A tuple (np.ndarray, list) containing the 3D np.ndarray of the

phenology metrics, and the band names for the output dataset

Return type:

tuple

yatsm.mapping.get_coefficients(date, result_location, image_ds, bands, coefs, prefix='', amplitude=False, after=False, before=False, qa=False, ndv=-9999, pattern='yatsm_r*', warn_on_empty=False)[source]

Output a raster with coefficients from CCDC

Parameters:
  • date – Ordinal date for prediction image
  • result_location – Location of the results
  • bands – Bands to predict
  • coefs – List of coefficients to output
  • image_ds – Example dataset
  • prefix – Use coef/rmse with refit prefix (default: ‘’)
  • amplitude – Map amplitude of seasonality instead of individual coefficient estimates for sin/cosine pair (default: False)
  • after – If date intersects a disturbed period, use next available time segment (default: False)
  • before – If date does not intersect a model, use previous non-disturbed time segment (default: False)
  • qa – Add QA flag specifying segment type (intersect, after, or before) (default: False)
  • ndv – NoDataValue (default: -9999)
  • pattern – filename pattern of saved record results
  • warn_on_empty – Log warning if result contained no result records (default: False)
Returns:

A tuple (np.ndarray, list) containing the 3D numpy.ndarray of

the coefficients (coefficient x band x pixel), and the band names for the output dataset

Return type:

tuple

yatsm.mapping.get_prediction(date, result_location, image_ds, bands='all', prefix='', after=False, before=False, qa=False, ndv=-9999, pattern='yatsm_r*', warn_on_empty=False)[source]

Output a raster with the predictions from model fit for a given date

Parameters:
  • date – Ordinal date for prediction image
  • result_location – Location of the results
  • image_ds – Example dataset
  • bands – Bands to predict - ‘all’ for every band, or specify a list of bands
  • prefix – Use coef/rmse with refit prefix (default: ‘’)
  • after – If date intersects a disturbed period, use next available time segment
  • before – If date does not intersect a model, use previous non-disturbed time segment
  • qa – Add QA flag specifying segment type (intersect, after, or before)
  • ndv – NoDataValue
  • pattern – filename pattern of saved record results
  • warn_on_empty – Log warning if result contained no result records (default: False)
Returns:

A 3D numpy.ndarray containing the prediction for each band,

for each pixel

Return type:

np.ndarray