Skip to content

Module fordead.steps.step5_export_results

Functions

export_results

def export_results(
    data_directory,
    start_date='2015-06-23',
    end_date='2030-01-02',
    frequency='M',
    multiple_files=False,
    conf_threshold_list=None,
    conf_classes_list=None
)
Writes results in the chosen period, form and using chosen frequency.
See details here : https://fordead.gitlab.io/fordead_package/docs/user_guides/english/05_export_results/


Parameters
----------
data_directory : str
    Path of the output directory
start_date : str
    Start date for exporting results (format : 'YYYY-MM-DD')
end_date : str
    End date for exporting results (format : 'YYYY-MM-DD')
frequency : str
    Frequency used to aggregate results, if value is 'sentinel', then periods correspond to the period between sentinel dates used in the detection, or it can be the frequency as used in pandas.date_range. e.g. 'M' (monthly), '3M' (three months), '15D' (fifteen days)
multiple_files : bool
    If True, one shapefile is exported for each period containing the areas in dieback at the end of the period. Else, a single shapefile is exported containing diebackd areas associated with the period of dieback
conf_threshold_list : list
    List of thresholds used as bins to discretize the confidence index into several classes
conf_classes_list : list
    List of classes names, if conf_threshold_list has n values, conf_classes_list must have n+1 values

Returns
-------

extract_results

def extract_results(
    data_directory,
    points,
    output_dir=None,
    index_name='id_point',
    chunks=100
)
Extract points of interest from the results computed at the MGRS-tile scale.

Parameters
----------
data_directory : str
    Path of the directory containing results from the region of interest
points: str | geopandas.GeoDataFrame
    Path to vector file containing points to be extracted or geodataframe containing points to be extracted
output_dir: str
    Path of the directory where results should be exported. If None, results are returned.
index_name: str
    Name of the column containing the point ID. If it does not exist, it is added filling it with the index values of the points.
chunks: int
    Chunk length to import data as dask arrays and save RAM, advised if computed area in data_directory is large

Returns
-------
None or Tuple[pandas.DataFrame]
    If output_dir is None, returns the timeseries, current_state and periods dataframes

Details
-------
Extracted results:

    - timeseries
        - vi: vegetation index, 
        - masks: the combination of all masks
        - predicted_vi: predicted vegetation index
        - diff_vi: difference between vegetation index
        - anomaly: anomaly of vi


    - current_state: current state variables at the last date of analysis (dieback, soil and other timeless masks)
        - dieback_: the state of dieback detection variables; 
          Note that dieback_first_date is the start date period, i.e. "healthy" if dieback_state=0 or "dieback" if dieback_state=1.
        - soil_: the state of soil detection variables, same note as above


    - periods.csv: dieback and healthy period summary
        - period: the period index
        - cum_diff: cumulated difference between vegetation index and predicted vegetation index
        - start_date: starting date of the "dieback" or "stress" period, i.e. the first date of a series of 3+ anmalies
        - end_date: actually the starting date of the following healthy period, i.e. the first date of a series of 3+ non-anomalies
        - start_date_index, end_date_index: date indexes of the start and end dates
        - nb_dates: number of dates in the "dieback" or "stress" period,
          starting at the first unconfirmed anomaly (i.e. usually 2 dates before the first confirmed anomaly),
          and ending at the date before the first confirmed non-anomaly
          This is why usually nb_dates = (end_date_index - start_date_index)+2


    - static: static data of the tile
        - coeff_i: coefficients of the model
        - forest_mask: the forest mask value
        - first_detection_date: the starting date of detection of the pixel timeseries
        - first_detection_date_index: the date index of first_detection_date