Skip to content
Snippets Groups Projects
Commit b1906dc2 authored by Jeremy Auclair's avatar Jeremy Auclair
Browse files

I/O bug correction for SAMIR. Renaming of directories. Improvements of doc.

parent 73d22610
No related branches found
No related tags found
No related merge requests found
Showing
with 3223 additions and 147 deletions
......@@ -6,27 +6,27 @@
"""
# Create class that contains configuration file date
import json # to open config file
from json import load # to open config file
class config:
"""
The `Config` class contains input parameters necessary for the Vegetation and Weather parts to run.
It loads all these parameters from the `.json` input file and loads it automatically.
It loads all these parameters from the ``.json`` input file and loads it automatically.
### Attributes
- start_date: `str`
- end_date: `str`
- path_to_config_file: `str`
- shapefile_path: `str`
- download_path: `str`
- era5_path: `str`
- run_name: `str`
- preferred_provider: `str`
- start_date: ``str``
- end_date: ``str``
- path_to_config_file: ``str``
- shapefile_path: ``str``
- download_path: ``str``
- era5_path: ``str``
- run_name: ``str``
- preferred_provider: ``str``
- ndvi_overwrite: `bool`
- cloud_cover_limit: `int`
- max_cpu: `int`
- cloud_cover_limit: ``int``
- max_cpu: ``int``
"""
# Constructor
......@@ -34,7 +34,7 @@ class config:
# Load json file
with open(config_file, "r") as read_file:
input_data = json.load(read_file)
input_data = load(read_file)
# Add attributes in new object
for key, value in input_data.items():
......
This diff is collapsed.
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -72,12 +72,12 @@
<div itemprop="articleBody">
<h1>All modules for which code is available</h1>
<ul><li><a href="modspa_pixel/code/modspa_samir.html">modspa_pixel.code.modspa_samir</a></li>
<li><a href="modspa_pixel/input/calculate_ndvi.html">modspa_pixel.input.calculate_ndvi</a></li>
<li><a href="modspa_pixel/input/download_ERA5_weather.html">modspa_pixel.input.download_ERA5_weather</a></li>
<li><a href="modspa_pixel/input/download_S2.html">modspa_pixel.input.download_S2</a></li>
<li><a href="modspa_pixel/input/lib_era5_land_pixel.html">modspa_pixel.input.lib_era5_land_pixel</a></li>
<li><a href="modspa_pixel/parameters/params_samir_class.html">modspa_pixel.parameters.params_samir_class</a></li>
<ul><li><a href="modspa_pixel/parameters/params_samir_class.html">modspa_pixel.parameters.params_samir_class</a></li>
<li><a href="modspa_pixel/preprocessing/calculate_ndvi.html">modspa_pixel.preprocessing.calculate_ndvi</a></li>
<li><a href="modspa_pixel/preprocessing/download_ERA5_weather.html">modspa_pixel.preprocessing.download_ERA5_weather</a></li>
<li><a href="modspa_pixel/preprocessing/download_S2.html">modspa_pixel.preprocessing.download_S2</a></li>
<li><a href="modspa_pixel/preprocessing/lib_era5_land_pixel.html">modspa_pixel.preprocessing.lib_era5_land_pixel</a></li>
<li><a href="modspa_pixel/source/modspa_samir.html">modspa_pixel.source.modspa_samir</a></li>
</ul>
</div>
......
This diff is collapsed.
This diff is collapsed.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -7,7 +7,6 @@
│ ├── csv_files
│ │ └── params_samir_test.csv
│ └── params_samir_class.py
├── output
├── DEV_inputs_test
│ ├── soil_100.nc
│ ├── ndvi_100.nc
......@@ -30,49 +29,51 @@
├── test_samir_dask.py
├── tests.py
├── modspa_pixel_env.yml
├── source
│ ├── code_toolbox.py
│ └── modspa_samir.py
├── SAMIR_xls
│ ├── SAMIRv5_juin2015.xlsx
│ └── SAMIRpixel_Reference_Simonneaux2012.xls
├── input
│ ├── download_S2.py
│ ├── lib_era5_land_pixel.py
│ ├── calculate_ndvi.py
│ ├── input_toolbox.py
│ └── download_ERA5_weather.py
├── test_S2_one_tile.csv
├── config
│ ├── config.py
│ └── config_modspa.json
├── dev_samir_xarray.ipynb
├── preprocessing
│ ├── download_S2.py
│ ├── parcel_to_pixel.py
│ ├── lib_era5_land_pixel.py
│ ├── calculate_ndvi.py
│ ├── input_toolbox.py
│ └── download_ERA5_weather.py
├── test_samir.py
├── README.md
├── docs
│ ├── source
│ │ ├── inputs
│ │ │ ├── samir_params.rst
│ │ │ ├── weather_cube.rst
│ │ │ ├── land_cover.rst
│ │ │ ├── ndvi_cube.rst
│ │ │ ├── input_preparation.rst
│ │ │ └── soil_data.rst
│ │ ├── conf.py
│ │ ├── file_structure.rst
│ │ ├── .templates
│ │ ├── filetree.rst
│ │ ├── samir
│ │ │ ├── data_and_ram_management.rst
│ │ │ ├── samir_functions.rst
│ │ │ └── run_samir.rst
│ │ ├── index.rst
│ │ ├── .static
│ │ └── setup
│ │ ├── json_config_file.rst
│ │ ├── conda_env.rst
│ │ └── setup.rst
│ ├── build
│ └── Makefile
└── code
├── code_toolbox.py
└── modspa_samir.py
├── postprocessing
└── docs
├── source
│ ├── inputs
│ │ ├── samir_params.rst
│ │ ├── weather_cube.rst
│ │ ├── land_cover.rst
│ │ ├── ndvi_cube.rst
│ │ ├── input_preparation.rst
│ │ └── soil_data.rst
│ ├── conf.py
│ ├── file_structure.rst
│ ├── .templates
│ ├── filetree.rst
│ ├── samir
│ │ ├── data_and_ram_management.rst
│ │ ├── samir_functions.rst
│ │ └── run_samir.rst
│ ├── index.rst
│ ├── .static
│ └── setup
│ ├── json_config_file.rst
│ ├── conda_env.rst
│ └── setup.rst
├── build
└── Makefile
...
\ No newline at end of file
......@@ -28,11 +28,11 @@ Download satellite imagery
The Sentinel-2 images can be automatically downloaded with the ``eodag`` module by using the following function:
.. autofunction:: modspa_pixel.input.download_S2.download_S2_data
.. autofunction:: modspa_pixel.preprocessing.download_S2.download_S2_data
This will download all the Sentinel-2 images found during the specified window and over the specified area (in the config file) into the download directory as ``zip`` or ``tar`` archives. Specific bands can then be extracted from the archive using this function:
.. autofunction:: modspa_pixel.input.download_S2.extract_zip_archives
.. autofunction:: modspa_pixel.preprocessing.download_S2.extract_zip_archives
The archives can then be deleted, freeing up some disk space.
......@@ -48,14 +48,14 @@ To limit the size of the input datasets, the NDVI data is converted to the ``uin
The NDVI pre_cube can be created with the following function:
.. autofunction:: modspa_pixel.input.calculate_ndvi.calculate_ndvi
.. autofunction:: modspa_pixel.preprocessing.calculate_ndvi.calculate_ndvi
Once this data cube is written, it needs to be interpolated along the time dimension. The processing chain requires NDVI data at a daily frequency, and high resolution satellite imagery rarely has a revisit time smaller than 5 days. The daily interpolation is also done with the ``xarray`` module. The resulting dataset is also saved with the ``uint8`` data type.
The final NDVI cube can be created with the following function:
.. autofunction:: modspa_pixel.input.calculate_ndvi.interpolate_ndvi
.. autofunction:: modspa_pixel.preprocessing.calculate_ndvi.interpolate_ndvi
.. warning:: Both of the previous functions are ressource hungry (**CPU** and **RAM**), it can take up to an hour or more depending on the size of the dataset and the specifications of your machine.
\ No newline at end of file
......@@ -9,7 +9,7 @@ The modspa models (*SAMIR* and *SAFY*) require preprocessed weather data to run.
The weather dataset can be automatically created with the following function:
.. autofunction:: modspa_pixel.input.download_ERA5_weather.request_ER5_weather
.. autofunction:: modspa_pixel.preprocessing.download_ERA5_weather.request_ER5_weather
Precipitation
......@@ -34,7 +34,7 @@ The calculation of the reference evapotranspiration is done using the `ETo <http
The following function is called by the main ``request_ER5_weather`` function to download the data. It calls other necessary sub-functions for the request. It produces netCDF4 datasets for each month of the requested time window, with daily values in each of those datasets.
.. autofunction:: modspa_pixel.input.lib_era5_land_pixel.call_era5land_daily_for_MODSPA
.. autofunction:: modspa_pixel.preprocessing.lib_era5_land_pixel.call_era5land_daily_for_MODSPA
This then produces a spatialized :math:`ET_0` dataset.
......@@ -48,12 +48,12 @@ Downloaded data from the ERA-5 Land server is projected on a WGS 84 lattitude/lo
The output dataset is the one used by the processing chain to run the models. This dataset can be create using this function:
.. autofunction:: modspa_pixel.input.lib_era5_land_pixel.era5Land_daily_to_yearly_nc
.. autofunction:: modspa_pixel.preprocessing.lib_era5_land_pixel.era5Land_daily_to_yearly_nc
:math:`ET_0` calculation is done with this function:
.. autofunction:: modspa_pixel.input.lib_era5_land_pixel.calculate_ET0_pixel
.. autofunction:: modspa_pixel.preprocessing.lib_era5_land_pixel.calculate_ET0_pixel
And the Geotiff conversion to netCDF4 files is done with this function:
.. autofunction:: modspa_pixel.input.lib_era5_land_pixel.combine_weather2netcdf
\ No newline at end of file
.. autofunction:: modspa_pixel.preprocessing.lib_era5_land_pixel.combine_weather2netcdf
\ No newline at end of file
......@@ -2,5 +2,5 @@ How the SAMIR functions works
=============================
.. autofunction:: modspa_pixel.code.modspa_samir.run_samir
.. autofunction:: modspa_pixel.code.modspa_samir.samir_daily
\ No newline at end of file
.. autofunction:: modspa_pixel.source.modspa_samir.run_samir
.. autofunction:: modspa_pixel.source.modspa_samir.samir_daily
\ No newline at end of file
......@@ -84,7 +84,6 @@
│ ├── csv_files
│ │ └── params_samir_test.csv
│ └── params_samir_class.py
├── output
├── DEV_inputs_test
│ ├── soil_100.nc
│ ├── ndvi_100.nc
......@@ -107,50 +106,52 @@
├── test_samir_dask.py
├── tests.py
├── modspa_pixel_env.yml
├── source
│ ├── code_toolbox.py
│ └── modspa_samir.py
├── SAMIR_xls
│ ├── SAMIRv5_juin2015.xlsx
│ └── SAMIRpixel_Reference_Simonneaux2012.xls
├── input
│ ├── download_S2.py
│ ├── lib_era5_land_pixel.py
│ ├── calculate_ndvi.py
│ ├── input_toolbox.py
│ └── download_ERA5_weather.py
├── test_S2_one_tile.csv
├── config
│ ├── config.py
│ └── config_modspa.json
├── dev_samir_xarray.ipynb
├── preprocessing
│ ├── download_S2.py
│ ├── parcel_to_pixel.py
│ ├── lib_era5_land_pixel.py
│ ├── calculate_ndvi.py
│ ├── input_toolbox.py
│ └── download_ERA5_weather.py
├── test_samir.py
├── README.md
├── docs
│ ├── source
│ │ ├── inputs
│ │ │ ├── samir_params.rst
│ │ │ ├── weather_cube.rst
│ │ │ ├── land_cover.rst
│ │ │ ├── ndvi_cube.rst
│ │ │ ├── input_preparation.rst
│ │ │ └── soil_data.rst
│ │ ├── conf.py
│ │ ├── file_structure.rst
│ │ ├── .templates
│ │ ├── filetree.rst
│ │ ├── samir
│ │ │ ├── data_and_ram_management.rst
│ │ │ ├── samir_functions.rst
│ │ │ └── run_samir.rst
│ │ ├── index.rst
│ │ ├── .static
│ │ └── setup
│ │ ├── json_config_file.rst
│ │ ├── conda_env.rst
│ │ └── setup.rst
│ ├── build
│ └── Makefile
└── code
├── code_toolbox.py
└── modspa_samir.py
├── postprocessing
└── docs
├── source
│ ├── inputs
│ │ ├── samir_params.rst
│ │ ├── weather_cube.rst
│ │ ├── land_cover.rst
│ │ ├── ndvi_cube.rst
│ │ ├── input_preparation.rst
│ │ └── soil_data.rst
│ ├── conf.py
│ ├── file_structure.rst
│ ├── .templates
│ ├── filetree.rst
│ ├── samir
│ │ ├── data_and_ram_management.rst
│ │ ├── samir_functions.rst
│ │ └── run_samir.rst
│ ├── index.rst
│ ├── .static
│ └── setup
│ ├── json_config_file.rst
│ ├── conda_env.rst
│ └── setup.rst
├── build
└── Makefile
</pre></div>
</div>
<p></p>
......
......@@ -80,7 +80,6 @@
│ ├── csv_files
│ │ └── params_samir_test.csv
│ └── params_samir_class.py
├── output
├── DEV_inputs_test
│ ├── soil_100.nc
│ ├── ndvi_100.nc
......@@ -103,50 +102,52 @@
├── test_samir_dask.py
├── tests.py
├── modspa_pixel_env.yml
├── source
│ ├── code_toolbox.py
│ └── modspa_samir.py
├── SAMIR_xls
│ ├── SAMIRv5_juin2015.xlsx
│ └── SAMIRpixel_Reference_Simonneaux2012.xls
├── input
│ ├── download_S2.py
│ ├── lib_era5_land_pixel.py
│ ├── calculate_ndvi.py
│ ├── input_toolbox.py
│ └── download_ERA5_weather.py
├── test_S2_one_tile.csv
├── config
│ ├── config.py
│ └── config_modspa.json
├── dev_samir_xarray.ipynb
├── preprocessing
│ ├── download_S2.py
│ ├── parcel_to_pixel.py
│ ├── lib_era5_land_pixel.py
│ ├── calculate_ndvi.py
│ ├── input_toolbox.py
│ └── download_ERA5_weather.py
├── test_samir.py
├── README.md
├── docs
│ ├── source
│ │ ├── inputs
│ │ │ ├── samir_params.rst
│ │ │ ├── weather_cube.rst
│ │ │ ├── land_cover.rst
│ │ │ ├── ndvi_cube.rst
│ │ │ ├── input_preparation.rst
│ │ │ └── soil_data.rst
│ │ ├── conf.py
│ │ ├── file_structure.rst
│ │ ├── .templates
│ │ ├── filetree.rst
│ │ ├── samir
│ │ │ ├── data_and_ram_management.rst
│ │ │ ├── samir_functions.rst
│ │ │ └── run_samir.rst
│ │ ├── index.rst
│ │ ├── .static
│ │ └── setup
│ │ ├── json_config_file.rst
│ │ ├── conda_env.rst
│ │ └── setup.rst
│ ├── build
│ └── Makefile
└── code
├── code_toolbox.py
└── modspa_samir.py
├── postprocessing
└── docs
├── source
│ ├── inputs
│ │ ├── samir_params.rst
│ │ ├── weather_cube.rst
│ │ ├── land_cover.rst
│ │ ├── ndvi_cube.rst
│ │ ├── input_preparation.rst
│ │ └── soil_data.rst
│ ├── conf.py
│ ├── file_structure.rst
│ ├── .templates
│ ├── filetree.rst
│ ├── samir
│ │ ├── data_and_ram_management.rst
│ │ ├── samir_functions.rst
│ │ └── run_samir.rst
│ ├── index.rst
│ ├── .static
│ └── setup
│ ├── json_config_file.rst
│ ├── conda_env.rst
│ └── setup.rst
├── build
└── Makefile
</pre></div>
</div>
<p></p>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment