Usageο
This page explains how to use the CryoGrid Optimization Automatization project once it has been installed and set up.
Add MATLAB Pathο
Before running any scripts, make sure the src/, CryoGrid/, data/ and forcing/ folders and subfolders
are added to the MATLAB path:
addpath('path_to_project/src')
savepath
This ensures that all functions, files and scripts are accessible.
Overview of Scriptsο
The main script included in the project is:
main_optimization_parallel.mRuns the full optimization workflow in parallel for one sensor at the time. This is the main script to configure and run the optimization workflow. You typically only need to modify this script to set your sensor and paths.
This script calls, with run_program_parallel script, other functions for input file generation, snow detection,
Bayesian optimization, and post-processing.
Runs the workflow for a single sensor.
functions/ folderContains MATLAB functions such as detect_snow_presence.m, run_CG_from_excel.m, score_model_seasonal.m, etc.
CryoGrid/ folderContains all the CryoGrid model. It is the model which simulate the permafrost temperature in the sensor area. In this folder, you have all the necessary files and scripts to run a CryoGrid simulation.
Input Dataο
Sensor CSV Files :ο
Located in data/Daily_mean/
Each CSV file should contain daily temperature measurements for a sensor.
Example:
csv
DATE,TEMP
2023-01-01,-2.1
2023-01-02,-1.8
...
This filename should contain the sensor ID, followed by βdaily_mean.csvβ.
Exemple :
MON1_daily_mean.csv
Sensor Excel File :ο
Located in
data/PAPROG_Data_set.xlsxContains sensor metadata (IDs, altitudes, sensor_depth, slope_angle, etcβ¦)
Important : This file should contain all the requires columns mentionned in the
get_sensor_info.min the function folder
Visualization of the excel sensor metadata fileο
Sensor forcing file :ο
.mat file located in
forcing/Forcing_Data/Used by CryoGrid as input forcing for simulations
The filename should contain the sensor ID, and strat with βFORCINGβ (any other information in the filename are not necessary).
Exemple :
FORCING_data_01Aug1958_01Aug2024_MON1.mat
Warning: Ensure all sensor CSV and .mat files are in the correct folders with matching sensor IDs.
Running the Optimizationο
Open the βmain_optimization_parallel.mβ MATLAB script.
Configure Sensor and Pathsο
Before running the script, set the following variables in MATLAB:
the sensor ID you want to study
path to the PAPROG_Dataset
path to the daily_mean temperature sensor folder
path to the forcing folder
path to the CryoGrid Excel file, called CG_single.xlsx in the β¦/CryoGridCommunity_results/CG_single/ folder
path to the CryoGridCommunity_results/ and CryoGridCommunity_source/folders
Set Optimization Parametersο
Now you can set the optimisation informations :
season_weights
number of iterations
step time, > Note: Step time should not exceed 1. For CryoGrid, the ideal value is 0.25.
bounds of the optimised parameters : z0, albedo and snow fraction
Run the Scriptο
Steps performed:
Update CryoGrid input files (CG_single.xlsx) based on sensor characteristics
Detect snow periods using daily temperature data
Run CryoGrid simulations in a Bayesian optimization loop
Save results in CryoGridCommunity_results/
Image of MATLAB running main_optimization_parallel.mο
Parallelisationο
To reduce the simulation runtime, this code is parallelized. The Bayesian loop :
Uses parallel workers to run CryoGrid simulations with different tested parameters in the same time
Automatically creates temporary folders with lock files to avoid conflicts and doing post-processing
Saves results in separate folders per sensor
Parameters and Configurationο
Default parameters are stored in CryoGridCommunity_results/CG_single/CONSTANTS_excel.xlsx .
Parameters you want to adjust :
albedo [dimensionless]
z0 (roughness length) [m]
snow_fraction [dimensionless]
Additional configuration options can be added in the future, like a new optimized variable.
Output Resultsο
Results are stored in CryoGrid/CryoGridCommunity_results/.
π Figures πο
In the output files, you have the figures folder with :
Snow detection graph
Snow detection graph for sensor MON1ο
Bayesian score convergence graph
Bayesion best score evolution graph for sensor MON1ο
Graph of score in function of iteration
Score in function of iteration graph for sensor MON1ο
Histogram and individual influence of tested values for each optimized parameters
Histogram and individual optimized parameters influence results for sensor MON1ο
3D surface/interpolation graph of parameters
3D surface/interpolation parameters graph for sensor MON1ο
Temperature graph comparison between the first and the best simulation
Best an first simulation for sensor MON1ο
Best simulated temperature graph correlated with the snowfall accumulation curve over a hydrological year
Best simulation with cumulative snowfall for sensor MON1ο
Seasonal scatter plot
Seasonal scatter plot for sensor MON1ο
Uncertainty envelope
Uncertainty envelope graph for sensor MON1ο
Summarize Excel filesο
You have the summary excel files :
results_*sensor_ID*.xlsxwith the bests simulations, associated parameters values and statistics indicatorsbayesopt_results_*sensor_ID*.xlsxwhich summarise the Bayesian loop with all iterations and their parameter values
Matlab file resultο
And the total Matlab resume file called bayesopt_results_*sensor_ID*.mat where you have the details of each iteration,
for exemple the simulated temperature vector.