Skip to content
Snippets Groups Projects
weather_cube.html 34.2 KiB
Newer Older
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Preparing the weather data cube &mdash; modspa-pixel 0.1 documentation</title>
      <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
      <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
      <link rel="stylesheet" href="../_static/graphviz.css" type="text/css" />
      <link rel="stylesheet" href="../_static/custom.css" type="text/css" />
  <!--[if lt IE 9]>
    <script src="../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
        <script src="../_static/jquery.js?v=5d32c60e"></script>
        <script src="../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
        <script src="../_static/documentation_options.js?v=2709fde1"></script>
        <script src="../_static/doctools.js?v=888ff710"></script>
        <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
        <script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
    <script src="../_static/js/theme.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Preparing the land cover raster" href="land_cover.html" />
    <link rel="prev" title="Preparing the NDVI data cube" href="ndvi_cube.html" /> 
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >

          
          
          <a href="../index.html" class="icon icon-home">
            modspa-pixel
          </a>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../setup/setup.html">Setting up the correct environnment and parameters</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mode/mode.html">Choosing the run mode</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="input_preparation.html">Preparing the inputs for Modspa-Pixel</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="ndvi_cube.html">Preparing the NDVI data cube</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Preparing the weather data cube</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#modspa_pixel.preprocessing.download_ERA5_weather.request_ER5_weather"><code class="docutils literal notranslate"><span class="pre">request_ER5_weather()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#precipitation">Precipitation</a></li>
<li class="toctree-l3"><a class="reference internal" href="#reference-evapotranspiration">Reference evapotranspiration</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#modspa_pixel.preprocessing.lib_era5_land_pixel.call_era5land_daily_for_MODSPA"><code class="docutils literal notranslate"><span class="pre">call_era5land_daily_for_MODSPA()</span></code></a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#formatting-and-preprocessing-the-raw-data">Formatting and preprocessing the raw data</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#pixel-mode">Pixel mode</a></li>
<li class="toctree-l4"><a class="reference internal" href="#parcel-mode">Parcel mode</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="land_cover.html">Preparing the land cover raster</a></li>
<li class="toctree-l2"><a class="reference internal" href="soil_data.html">Preparing the soil data raster</a></li>
<li class="toctree-l2"><a class="reference internal" href="samir_params.html">Preparing the SAMIR parameter csv file</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../samir/run_samir.html">Run the SAMIR model</a></li>
<li class="toctree-l1"><a class="reference internal" href="../file_structure.html">Project file structure</a></li>
</ul>

        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">modspa-pixel</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../index.html" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="input_preparation.html">Preparing the inputs for Modspa-Pixel</a></li>
      <li class="breadcrumb-item active">Preparing the weather data cube</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../_sources/preprocessing/weather_cube.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <section id="preparing-the-weather-data-cube">
<span id="weather"></span><h1>Preparing the weather data cube<a class="headerlink" href="#preparing-the-weather-data-cube" title="Link to this heading"></a></h1>
<p>The modspa models (<em>SAMIR</em> and <em>SAFY</em>) require preprocessed weather data to run. The <em>SAMIR</em> model needs spatialized <strong>precipitation</strong> and <strong>reference evapotranspiration</strong> as inputs. This requires various raw weather variables to be downloaded and processed to create a data cube with the same structure and georeferencing as the <a class="reference internal" href="ndvi_cube.html#ndvi"><span class="std std-ref">NDVI data cube</span></a>. The raw weather data is downloaded and processed to produce the necessary variables.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>As of now, only the <strong>ERA 5</strong> data download is implemented. It allows to download weather data all over the world with a simple python api.</p>
</div>
<p>The weather dataset can be automatically created with the following function:</p>
<dl class="py function">
<dt class="sig sig-object py" id="modspa_pixel.preprocessing.download_ERA5_weather.request_ER5_weather">
<span class="sig-prename descclassname"><span class="pre">modspa_pixel.preprocessing.download_ERA5_weather.</span></span><span class="sig-name descname"><span class="pre">request_ER5_weather</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">config_file</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ndvi_path</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">raw_S2_image_ref</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">shapefile</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mode</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">'pixel'</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">str</span></span></span><a class="reference internal" href="../_modules/modspa_pixel/preprocessing/download_ERA5_weather.html#request_ER5_weather"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#modspa_pixel.preprocessing.download_ERA5_weather.request_ER5_weather" title="Link to this definition"></a></dt>
<dd><p>Download ERA5 reanalysis daily weather files, concatenate and calculate ET0
to obtain a netCDF4 dataset for precipitation and ET0 values. Weather data
reprojection and conversion can take some time for large spatial windows.</p>
<section id="arguments">
<h2>Arguments<a class="headerlink" href="#arguments" title="Link to this heading"></a></h2>
<ol class="arabic simple">
<li><dl class="simple">
<dt>config_file: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>json configuration file</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>ndvi_path: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>path to ndvi cube, used for weather data reprojection</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>raw_S2_image_ref: <code class="docutils literal notranslate"><span class="pre">str</span></code> <code class="docutils literal notranslate"><span class="pre">default</span> <span class="pre">=</span> <span class="pre">None</span></code></dt><dd><p>unmodified sentinel-2 image at correct resolution for
weather data reprojection in pixel mode</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>shapefile: <code class="docutils literal notranslate"><span class="pre">str</span></code> <code class="docutils literal notranslate"><span class="pre">default</span> <span class="pre">=</span> <span class="pre">None</span></code></dt><dd><p>path to shapefile for extraction in parcel mode</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>mode: <code class="docutils literal notranslate"><span class="pre">str</span></code> <code class="docutils literal notranslate"><span class="pre">default</span> <span class="pre">=</span> <span class="pre">'pixel'</span></code></dt><dd><p>choose between <code class="docutils literal notranslate"><span class="pre">'pixel'</span></code> and <code class="docutils literal notranslate"><span class="pre">'parcel'</span></code> mode</p>
</dd>
</dl>
</li>
</ol>
</section>
<section id="returns">
<h2>Returns<a class="headerlink" href="#returns" title="Link to this heading"></a></h2>
<ol class="arabic simple">
<li><dl class="simple">
<dt>weather_file: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>path to netCDF4 file containing weather data</p>
</dd>
</dl>
</li>
</ol>
</section>
</dd></dl>

<section id="precipitation">
<h2>Precipitation<a class="headerlink" href="#precipitation" title="Link to this heading"></a></h2>
<p>No special calculation is necessary for this variable. Only the reprojection to the NDVI data cube is necessary. This variable is also used to calculate the reference evapotranspiration.</p>
</section>
<section id="reference-evapotranspiration">
<h2>Reference evapotranspiration<a class="headerlink" href="#reference-evapotranspiration" title="Link to this heading"></a></h2>
<p>Reference crop evapotranspiration or reference evapotranspiration is the estimation of the evapotranspiration from the “reference surface.” The reference surface is a hypothetical grass reference crop with an assumed crop height of 0.12 m, a fixed surface resistance of 70 s/m and an albedo of 0.23. The reference surface closely resembles an extensive surface of green, well-watered grass of uniform height, actively growing and completely shading the ground.</p>
<p>The calculation of the reference evapotranspiration is done using the <a class="reference external" href="https://github.com/Evapotranspiration/ETo">ETo</a> module. The following variables are downloaded for this calculation:</p>
<ul class="simple">
<li><p><strong>2m_temperature</strong>: air temperature 2 meters above the surface.</p></li>
<li><p><strong>2m_dewpoint_temperature</strong>: air dewpoint temperature 2 meters above the surface.</p></li>
<li><p><strong>surface_solar_radiation_downward</strong>: total downward solar radiation.</p></li>
<li><p><strong>total_precipitation</strong>: total precipitation.</p></li>
<li><p><strong>10m_u_component_of_wind</strong>: north/south wind speed 10 meters above the surface.</p></li>
<li><p><strong>10m_v_component_of_wind</strong>: east/west wind speed 10 meters above the surface.</p></li>
</ul>
<p>The following function is called by the main <code class="docutils literal notranslate"><span class="pre">request_ER5_weather</span></code> 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.</p>
<dl class="py function">
<dt class="sig sig-object py" id="modspa_pixel.preprocessing.lib_era5_land_pixel.call_era5land_daily_for_MODSPA">
<span class="sig-prename descclassname"><span class="pre">modspa_pixel.preprocessing.lib_era5_land_pixel.</span></span><span class="sig-name descname"><span class="pre">call_era5land_daily_for_MODSPA</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">start_date</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">end_date</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">area</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">float</span><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_path</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">processes</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">9</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="../_modules/modspa_pixel/preprocessing/lib_era5_land_pixel.html#call_era5land_daily_for_MODSPA"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#modspa_pixel.preprocessing.lib_era5_land_pixel.call_era5land_daily_for_MODSPA" title="Link to this definition"></a></dt>
<dd><p>request ERA5-land daily variables needed for ET0 calculus and MODSPA forcing
<a class="reference external" href="https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-land?tab=overview">reanalysis_era5</a></p>
<section id="information-on-requested-variables">
<h3>Information on requested variables<a class="headerlink" href="#information-on-requested-variables" title="Link to this heading"></a></h3>
<dl class="simple">
<dt>called land surface variables :</dt><dd><ul class="simple">
<li><p><strong>2m_temperature</strong></p></li>
<li><p><strong>2m_dewpoint_temperature</strong></p></li>
<li><p><strong>surface_solar_radiation_downward</strong></p></li>
<li><p><strong>surface_net_solar_radiation</strong></p></li>
<li><p><strong>surface_pressure</strong></p></li>
<li><p><strong>mean_sea_level_pressure</strong></p></li>
<li><p><strong>potential_evaporation</strong></p></li>
<li><p><strong>evaporation</strong></p></li>
<li><p><strong>total_evaporation</strong></p></li>
<li><p><strong>total_precipitation</strong></p></li>
<li><p><strong>snowfall</strong></p></li>
<li><p><strong>10m_u_component_of_wind</strong></p></li>
<li><p><strong>10m_v_component_of_wind</strong></p></li>
</ul>
</dd>
</dl>
<section id="id1">
<h4>Arguments<a class="headerlink" href="#id1" title="Link to this heading"></a></h4>
<ol class="arabic simple">
<li><dl class="simple">
<dt>start_date: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>start date in YYYY-MM-DD format</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>end_date: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>end date in YYYY-MM-DD format</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>area: <code class="docutils literal notranslate"><span class="pre">List[float]</span></code></dt><dd><p>bounding box of the demanded area
area = [lat_max, lon_min, lat_min, lon_max]</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>output_path: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>output file name, <code class="docutils literal notranslate"><span class="pre">.nc</span></code> extension</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>processes: <code class="docutils literal notranslate"><span class="pre">int</span></code> <code class="docutils literal notranslate"><span class="pre">default</span> <span class="pre">=</span> <span class="pre">9</span></code></dt><dd><p>number of logical processors on which to run the download command.
can be higher than your actual number of processor cores,
download operations have a low CPU demand.</p>
</dd>
</dl>
</li>
</ol>
</section>
<section id="id2">
<h4>Returns<a class="headerlink" href="#id2" title="Link to this heading"></a></h4>
<p><code class="docutils literal notranslate"><span class="pre">None</span></code></p>
</section>
</section>
</dd></dl>

<p>This then produces a spatialized <span class="math notranslate nohighlight">\(ET_0\)</span> dataset.</p>
</section>
<section id="formatting-and-preprocessing-the-raw-data">
<h2>Formatting and preprocessing the raw data<a class="headerlink" href="#formatting-and-preprocessing-the-raw-data" title="Link to this heading"></a></h2>
<section id="pixel-mode">
<h3>Pixel mode<a class="headerlink" href="#pixel-mode" title="Link to this heading"></a></h3>
<p>The raw dataset now has a precipitation variable and a <span class="math notranslate nohighlight">\(ET_0\)</span> variable.</p>
<p>Downloaded data from the ERA-5 Land server is projected on a WGS 84 lattitude/longitude projection, at 0.1° resolution. This data then needs to be reprojected on the same grid as the NDVI data, which is usually at a much higher resolution (of the order of 10 meters). The reprojection and clipping is done by the <code class="docutils literal notranslate"><span class="pre">OTB</span></code> <a class="reference external" href="https://www.orfeo-toolbox.org/CookBook/Applications/app_Superimpose.html">**Superimpose**</a> application, which has the advantage of being very efficient for large datasets. However, it only handles <strong>Geotiff</strong> images and not <strong>netCDF4</strong> files. The low resolution dataset first has to be saved as Geotiff files (one per variable), reprojected and clipped with <code class="docutils literal notranslate"><span class="pre">otbcli_Superimpose</span></code> and then opened and converted to a netCDF4 file. This can take some time for large datasets.</p>
<p>The output dataset is the one used by the processing chain to run the models. This dataset can be create using this function:</p>
<dl class="py function">
<dt class="sig sig-object py" id="modspa_pixel.preprocessing.lib_era5_land_pixel.era5Land_daily_to_yearly_pixel">
<span class="sig-prename descclassname"><span class="pre">modspa_pixel.preprocessing.lib_era5_land_pixel.</span></span><span class="sig-name descname"><span class="pre">era5Land_daily_to_yearly_pixel</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">list_era5land_files</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_file</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">raw_S2_image_ref</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ndvi_path</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">h</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_ram</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">8</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">remove</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">str</span></span></span><a class="reference internal" href="../_modules/modspa_pixel/preprocessing/lib_era5_land_pixel.html#era5Land_daily_to_yearly_pixel"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#modspa_pixel.preprocessing.lib_era5_land_pixel.era5Land_daily_to_yearly_pixel" title="Link to this definition"></a></dt>
<dd><p>Calculate ET0 values from the ERA5 netcdf weather variables.
Output netcdf contains the ET0 and precipitation values for
each day in the selected time period and reprojected
(reprojection run on two processors) on the same grid as the
NDVI values.</p>
<section id="id3">
<h4>Arguments<a class="headerlink" href="#id3" title="Link to this heading"></a></h4>
<ol class="arabic simple">
<li><dl class="simple">
<dt>list_era5land_files: <code class="docutils literal notranslate"><span class="pre">List[str]</span></code></dt><dd><p>list of netcdf files containing the necessary variables</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>output_file: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>output file name without extension</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>raw_S2_image_ref: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>raw Sentinel 2 image at right resolution for reprojection</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>ndvi_path: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>path to ndvi dataset, used for attributes and coordinates</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>h: <code class="docutils literal notranslate"><span class="pre">float</span></code> <code class="docutils literal notranslate"><span class="pre">default</span> <span class="pre">=</span> <span class="pre">10</span></code></dt><dd><p>height of ERA5 wind measurements in meters</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>max_ram: <code class="docutils literal notranslate"><span class="pre">int</span></code> <code class="docutils literal notranslate"><span class="pre">default</span> <span class="pre">=</span> <span class="pre">8</span></code></dt><dd><p>max ram (in GiB) for reprojection and conversion. Two
subprocesses are spawned for OTB, each receiviving 
half of requested memory.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>remove: <code class="docutils literal notranslate"><span class="pre">bool</span></code> <code class="docutils literal notranslate"><span class="pre">default</span> <span class="pre">=</span> <span class="pre">True</span></code></dt><dd><p>weather to remove temporary files</p>
</dd>
</dl>
</li>
</ol>
</section>
<section id="id4">
<h4>Returns<a class="headerlink" href="#id4" title="Link to this heading"></a></h4>
<ol class="arabic simple">
<li><dl class="simple">
<dt>output_file_final: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>path to <code class="docutils literal notranslate"><span class="pre">netCDF4</span></code> file containing precipitation and ET0 data</p>
</dd>
</dl>
</li>
</ol>
</section>
</dd></dl>

<p><span class="math notranslate nohighlight">\(ET_0\)</span> calculation is done with this function:</p>
<dl class="py function">
<dt class="sig sig-object py" id="modspa_pixel.preprocessing.lib_era5_land_pixel.calculate_ET0_pixel">
<span class="sig-prename descclassname"><span class="pre">modspa_pixel.preprocessing.lib_era5_land_pixel.</span></span><span class="sig-name descname"><span class="pre">calculate_ET0_pixel</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pixel_dataset</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Dataset</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lat</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lon</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">h</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">10</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">ndarray</span></span></span><a class="reference internal" href="../_modules/modspa_pixel/preprocessing/lib_era5_land_pixel.html#calculate_ET0_pixel"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#modspa_pixel.preprocessing.lib_era5_land_pixel.calculate_ET0_pixel" title="Link to this definition"></a></dt>
<dd><p>Calculate ET0 over the year for a single pixel of the ERA5 weather dataset.</p>
<section id="id5">
<h4>Arguments<a class="headerlink" href="#id5" title="Link to this heading"></a></h4>
<ol class="arabic simple">
<li><dl class="simple">
<dt>pixel_dataset: <code class="docutils literal notranslate"><span class="pre">xr.Dataset</span></code></dt><dd><p>extracted dataset that contains all information for a single pixel</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>lat: <code class="docutils literal notranslate"><span class="pre">float</span></code></dt><dd><p>latitudinal coordinate of that pixel</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>lon: <code class="docutils literal notranslate"><span class="pre">float</span></code></dt><dd><p>longitudinal coordinate of that pixel</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>h: <code class="docutils literal notranslate"><span class="pre">float</span></code> <code class="docutils literal notranslate"><span class="pre">default</span> <span class="pre">=</span> <span class="pre">10</span></code></dt><dd><p>height of ERA5 wind measurement in meters</p>
</dd>
</dl>
</li>
</ol>
</section>
<section id="id6">
<h4>Returns<a class="headerlink" href="#id6" title="Link to this heading"></a></h4>
<ol class="arabic simple">
<li><dl class="simple">
<dt>ET0_values: <code class="docutils literal notranslate"><span class="pre">np.ndarray</span></code></dt><dd><p>numpy array containing the ET0 values for each day</p>
</dd>
</dl>
</li>
</ol>
</section>
</dd></dl>

<p>And the Geotiff conversion to netCDF4 files is done with this function:</p>
<dl class="py function">
<dt class="sig sig-object py" id="modspa_pixel.preprocessing.lib_era5_land_pixel.combine_weather2netcdf">
<span class="sig-prename descclassname"><span class="pre">modspa_pixel.preprocessing.lib_era5_land_pixel.</span></span><span class="sig-name descname"><span class="pre">combine_weather2netcdf</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rain_file</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ET0_tile</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ndvi_path</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">save_path</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">available_ram</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="../_modules/modspa_pixel/preprocessing/lib_era5_land_pixel.html#combine_weather2netcdf"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#modspa_pixel.preprocessing.lib_era5_land_pixel.combine_weather2netcdf" title="Link to this definition"></a></dt>
<dd><p>Convert the Rain and ET0 geotiffs into a single weather netcdf dataset.</p>
<section id="id7">
<h4>Arguments<a class="headerlink" href="#id7" title="Link to this heading"></a></h4>
<ol class="arabic simple">
<li><dl class="simple">
<dt>rain_file: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>path to Rain tif</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>ET0_tile: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>path to ET0 tif</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>ndvi_path: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>path to ndvi cube</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>save_path: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>save path of weather netcdf dataset</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>available_ram: <code class="docutils literal notranslate"><span class="pre">int</span></code></dt><dd><p>available ram in GiB for conversion</p>
</dd>
</dl>
</li>
</ol>
</section>
<section id="id8">
<h4>Returns<a class="headerlink" href="#id8" title="Link to this heading"></a></h4>
<p><code class="docutils literal notranslate"><span class="pre">None</span></code></p>
</section>
</dd></dl>

</section>
<section id="parcel-mode">
<h3>Parcel mode<a class="headerlink" href="#parcel-mode" title="Link to this heading"></a></h3>
</section>
</section>
</section>


           </div>
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="ndvi_cube.html" class="btn btn-neutral float-left" title="Preparing the NDVI data cube" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="land_cover.html" class="btn btn-neutral float-right" title="Preparing the land cover raster" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2023, auclairj.</p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>