# About 


# Structure  
The repository has provides nececssry scripts for preprocessing, training and postprocessing of the Land Cover (LC) and Leaf Area Index (LAI) for the CERISE project. The global model is consisit of smaller windows (tiles) that are trained independently, and then stichhed together in the later stage. 
As the LAI is what will be the final deleivarable of the project, it is more advance and works better. 


# Workflow 

Both LC and LAI codes are using Python and designed for HPC system with SLURM. 
The code has 4 parths. 

### Preprocessing 
Starts with defining the composition of the windows (tiles) in a notebook , that generate a region.json file that includes the coordinate of the all tiles. 
Preprocessing that is reading all the needed data and used can indicate what data should be included. This is done via flags. Based on the purpose of the preprocessing, "Training" "Validation" or "Inference", a different ground truth is used. The data is cut and stacked for each window seperatly and stored in the common data output. It is also generate .json file and a numpy file that inclueds data for further processing. 

### Training 
The models have  support for Random Forest and XGBoost for training. Some hyper parametrs can be passed as variables, but most is hard-coded in the training script. It is using the prepared features, ground truth. If there is groud truth available for the years (Validation) that are not included in the training, it is generating validation metrics. It generates prediction, with inference for the test year(s).

### Inference 

## preprocessing_devel.py
This script read and trim the input data to requested Lat. Lon. Append the and flattening the data. Save the data. If the data is available it will just load it. Creates valid mask, and exclude what is needed to be removed.  Plots the distributions of the classes. Save the features and labels. 

The data split so far is as simple as it get 80 - 20. In future, it should be based on temporal relationship to be used in training. 

Included input data: 
- LUH2f 
- HILDA+ 

to be included: 
- elevation
- soil moisture  
- radiation 



