How the scripts fit together

The procedure is implemented as three scripts, run in order. Each writes the files the next one reads.

Table 18: The three scripts and the order they run in.

Order

Script

What it does

Principal outputs

1

vm0047_data_retriever.py

Generates the random plots within the donor pool area and retrieves the data the matching needs. Builds the dataset of donor plots with reflectance by band, biomass and land cover.

combined_points.gpkg, dataset_v<version>.gpkg, benchmark_final_v<version>.gpkg

2

vm_0047_baseline_calculation_v2.py

Calculates the baseline and the ex-post performance benchmark: the stocking index, the data for the regression, the screening, the matching, the standardised differences of means, dSI for control and project, the p value and PBt.

lookup_and_distances_new.csv, SDM_df.csv, weights_and_si_df.csv, final_table.csv, all_data_new2.gpkg

3

vm0047_get_ex_ante_PBt_v2.py

Runs the rolling statistics for the ex-ante benchmark over the ex-ante stocking index series.

ex_ante_for_PB2.csv

Scripts 2 and 3 of this edition are version 2 of the scripts delivered earlier: they carry the changes listed in Table 19, each marked v2 in the code, and nothing else. Their paths are relative to the folder that holds them and their inputs. Script 1 is unchanged and keeps the absolute paths of the working area in which the data were retrieved. The files the scripts produce are the ones delivered to the validation/verification body; the correspondence between those files and the annexes of Appendix 7 is given in Annex 3 — Correspondence with the files cited.

Table 19: The changes of version 2, each marked v2 in the code.

Script

Change of version 2

Script 2

Stocking index: NDFI of Souza et al. (2005), by fully constrained unmixing with the five fixed CODED endmembers on reflectance DN × 2.75e-5 − 0.2, in place of a 7-component non-negative matrix factorisation and a band combination chosen by correlation with biomass

Script 2

Observations outside the valid DN range (7,273 to 43,636) masked; a plot with such an observation, or with an undefined NDFI, is removed (the script’s rule for missing data)

Script 2

Band covariates on surface reflectance with the −0.2 offset, then the L2 normalisation

Script 2

MapBiomas Colombia 2018 land-cover screen of the donor plots, after the Copernicus screen

Script 2

Matching covariates: the stocking index of the historical years and the principal components of the six 2018 bands (80% of the variance)

Script 2

Matched control plots joined to their project plot by plot identifier (the earlier script used the donor’s row position)

Script 2

Weights of Equation (2), exp(−MD) / Σ exp(−MD), in place of the distances rescaled to sum to 1

Script 2

SDM of Equation (A2) on the 45 project plots: weighted control mean and standard deviation, pooled standard deviation

Script 2

Paths relative to the folder of the script; a check that the project plots’ row positions equal their identifiers, on which the script relies

Script 2

Compatibility, with no effect on the calculation: DataFrame._append, removed in pandas 3, replaced by pd.concat

Script 3

Paths relative to the folder of the script; a constant series (the flat control) gets slope 0, standard error 0 and p-value 1, the exact values for a flat line, in place of the undefined values the statistics library returns