yatsm.mapping package¶
Submodules¶
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 (int) – Ordinal date for start of map records
- end (int) – Ordinal date for end of map records
- result_location (str) – Location of results
- image_ds (gdal.Dataset) – Example dataset
- first (bool) – Use first change instead of last
- out_format (str, optional) – Output date format
- magnitude (bool, optional) – output magnitude of each change?
- ndv (int, optional) – NoDataValue
- pattern (str, optional) – filename pattern of saved record results
- warn_on_empty (bool, optional) – 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:
-
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 (int) – Ordinal date for start of map records
- end (int) – Ordinal date for end of map records
- result_location (str) – Location of results
- image_ds (gdal.Dataset) – Example dataset
- ndv (int, optional) – NoDataValue
- pattern (str, optional) – filename pattern of saved record results
- warn_on_empty (bool, optional) – 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 (int) – ordinal date for prediction image
- result_location (str) – Location of the results
- image_ds (gdal.Dataset) – Example dataset
- after (bool, optional) – If date intersects a disturbed period, use next available time segment
- before (bool, optional) – If date does not intersect a model, use previous non-disturbed time segment
- qa (bool, optional) – Add QA flag specifying segment type (intersect, after, or before)
- pred_proba (bool, optional) – Include additional band with classification value probabilities
- ndv (int, optional) – NoDataValue
- pattern (str, optional) – filename pattern of saved record results
- warn_on_empty (bool, optional) – 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 (int) – Ordinal date for prediction image
- result_location (str) – Location of the results
- image_ds (gdal.Dataset) – Example dataset
- after (bool, optional) – If date intersects a disturbed period, use next available time segment
- before (bool, optional) – If date does not intersect a model, use previous non-disturbed time segment
- qa (bool, optional) – Add QA flag specifying segment type (intersect, after, or before)
- ndv (int, optional) – NoDataValue
- pattern (str, optional) – filename pattern of saved record results
- warn_on_empty (bool, optional) – 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:
-
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 (int) – Ordinal date for prediction image
- result_location (str) – Location of the results
- bands (list) – Bands to predict
- coefs (list) – List of coefficients to output
- image_ds (gdal.Dataset) – Example dataset
- prefix (str, optional) – Use coef/rmse with refit prefix (default: ‘’)
- amplitude (bool, optional) – Map amplitude of seasonality instead of individual coefficient estimates for sin/cosine pair (default: False)
- after (bool, optional) – If date intersects a disturbed period, use next available time segment (default: False)
- before (bool, optional) – If date does not intersect a model, use previous non-disturbed time segment (default: False)
- qa (bool, optional) – Add QA flag specifying segment type (intersect, after, or before) (default: False)
- ndv (int, optional) – NoDataValue (default: -9999)
- pattern (str, optional) – filename pattern of saved record results
- warn_on_empty (bool, optional) – 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:
-
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 (int) – Ordinal date for prediction image
- result_location (str) – Location of the results
- image_ds (gdal.Dataset) – Example dataset
- bands (str, list) – Bands to predict - ‘all’ for every band, or specify a list of bands
- prefix (str, optional) – Use coef/rmse with refit prefix (default: ‘’)
- after (bool, optional) – If date intersects a disturbed period, use next available time segment
- before (bool, optional) – If date does not intersect a model, use previous non-disturbed time segment
- qa (bool, optional) – Add QA flag specifying segment type (intersect, after, or before)
- ndv (int, optional) – NoDataValue
- pattern (str, optional) – filename pattern of saved record results
- warn_on_empty (bool, optional) – 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