Skip to content
Snippets Groups Projects
ndvi_cube.html 30.3 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 NDVI 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 weather data cube" href="weather_cube.html" />
    <link rel="prev" title="Preparing the inputs for Modspa-Pixel" href="input_preparation.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 current"><a class="reference internal" href="input_preparation.html">Preparing the inputs for Modspa-Pixel</a><ul class="current">
<li class="toctree-l2 current"><a class="current reference internal" href="#">Preparing the NDVI data cube</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#download-satellite-imagery">Download satellite imagery</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#modspa_pixel.preprocessing.download_S2.download_S2_data"><code class="docutils literal notranslate"><span class="pre">download_S2_data()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#modspa_pixel.preprocessing.download_S2.extract_zip_archives"><code class="docutils literal notranslate"><span class="pre">extract_zip_archives()</span></code></a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#calculate-ndvi">Calculate NDVI</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#modspa_pixel.preprocessing.calculate_ndvi.calculate_ndvi"><code class="docutils literal notranslate"><span class="pre">calculate_ndvi()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#modspa_pixel.preprocessing.calculate_ndvi.interpolate_ndvi"><code class="docutils literal notranslate"><span class="pre">interpolate_ndvi()</span></code></a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="weather_cube.html">Preparing the weather data cube</a></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 NDVI data cube</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../_sources/preprocessing/ndvi_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-ndvi-data-cube">
<span id="ndvi"></span><h1>Preparing the NDVI data cube<a class="headerlink" href="#preparing-the-ndvi-data-cube" title="Link to this heading"></a></h1>
<p>The <em>Normalized Difference Vegetation Index</em> (<strong>NDVI</strong>) is a commonly used index to estimate vegetation changes through satellite imagery. It does not correspond to a physical quantity, but is a good proxy for the biomass. It uses the fact that vegetation has a very low reflectance in the red band (which is a photosynthetic active radiation) and a very high reflection in the near infrared band (unused part of the sun’s light spectrum). It is usually between -1 and 1, with high negative values corresponding to open water bodies, high positive values corresponding to highly vegetated areas and values around 0 to mineral or human-made surfaces.</p>
<p>In the <strong>modspa_pixel</strong> processing chain, it is calculated as follows</p>
<div class="math notranslate nohighlight">
\[NDVI = \frac{NIR - (RED + corr_{ACORVI})}{NIR + (RED + corr_{ACORVI})}\]</div>
<p>Where:</p>
<ol class="arabic simple">
<li><p>RED: red band</p></li>
<li><p>NIR: near infrared band</p></li>
<li><p><span class="math notranslate nohighlight">\(corr_{ACORVI}\)</span>: correction parameter applied to the red band to smooth extreme NDVI values, equal to <span class="math notranslate nohighlight">\(0.05%\)</span> of the red band range</p></li>
</ol>
<section id="download-satellite-imagery">
<h2>Download satellite imagery<a class="headerlink" href="#download-satellite-imagery" title="Link to this heading"></a></h2>
<p>The Sentinel-2 images can be automatically downloaded with the <code class="docutils literal notranslate"><span class="pre">eodag</span></code> module by using the following function:</p>
<dl class="py function">
<dt class="sig sig-object py" id="modspa_pixel.preprocessing.download_S2.download_S2_data">
<span class="sig-prename descclassname"><span class="pre">modspa_pixel.preprocessing.download_S2.</span></span><span class="sig-name descname"><span class="pre">download_S2_data</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">preferred_provider</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">shapefile</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">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>, <em class="sig-param"><span class="n"><span class="pre">cloud_cover_limit</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">80</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">List</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../_modules/modspa_pixel/preprocessing/download_S2.html#download_S2_data"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#modspa_pixel.preprocessing.download_S2.download_S2_data" title="Link to this definition"></a></dt>
<dd><p>download_S2_data uses the eodag module to look for all products of a given provider
(copernicus or theia) during a specific time window and covering the whole shapefile
enveloppe (several Sentinel-2 tiles might be needed, only one can be chosen for the
pixel mode). It then downloads that data into the download path parametered in the
config file. Paths to the downloaded data are returned and saved as a <code class="docutils literal notranslate"><span class="pre">csv</span></code> file.
An extra month of data is downloaded for a better interpolation, it is then discarded
and the final NDVI cube has the dates defined in the config file.</p>
<section id="arguments">
<h3>Arguments<a class="headerlink" href="#arguments" title="Link to this heading"></a></h3>
<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>beginning of the time window to download (format: <code class="docutils literal notranslate"><span class="pre">YYYY-MM-DD</span></code>)</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 of the time window to download (format: <code class="docutils literal notranslate"><span class="pre">YYYY-MM-DD</span></code>)</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>preferred_provider: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>chosen source of the Sentinel-2 data (<code class="docutils literal notranslate"><span class="pre">copernicus</span></code> or <code class="docutils literal notranslate"><span class="pre">theia</span></code>)</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>path where a csv file containing the product paths will be saved</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>shapefile: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>path to the shapefile (<code class="docutils literal notranslate"><span class="pre">.shp</span></code>) for which the data is downloaded</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>run download code in ‘pixel’ or ‘parcel’ mode</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>cloud_cover_limit: <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">80</span></code></dt><dd><p>maximum percentage to pass the filter before download (between 0 and 100)</p>
</dd>
</dl>
</li>
</ol>
</section>
<section id="returns">
<h3>Returns<a class="headerlink" href="#returns" title="Link to this heading"></a></h3>
<ol class="arabic simple">
<li><dl class="simple">
<dt>product_paths: <code class="docutils literal notranslate"><span class="pre">list[str]</span></code></dt><dd><p>a list of the paths to the downloaded data</p>
</dd>
</dl>
</li>
</ol>
</section>
</dd></dl>

<p>This will download all the Sentinel-2 images found during the specified window (an additional month before and after the start and end dates are downloaded to make sure there is enough clear data for daily interpolation, the extra data is then discarded) and over the specified area (shapefile declared in the config file) into the download directory as <code class="docutils literal notranslate"><span class="pre">zip</span></code> or <code class="docutils literal notranslate"><span class="pre">tar</span></code> archives. Specific bands can then be extracted from the archive using this function:</p>
<dl class="py function">
<dt class="sig sig-object py" id="modspa_pixel.preprocessing.download_S2.extract_zip_archives">
<span class="sig-prename descclassname"><span class="pre">modspa_pixel.preprocessing.download_S2.</span></span><span class="sig-name descname"><span class="pre">extract_zip_archives</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">download_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">list_paths</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 class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">preferred_provider</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">remove_archive</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">False</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">List</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../_modules/modspa_pixel/preprocessing/download_S2.html#extract_zip_archives"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#modspa_pixel.preprocessing.download_S2.extract_zip_archives" title="Link to this definition"></a></dt>
<dd><p>Extract specific bands in a zip archive for a list of tar archives.</p>
<section id="id1">
<h3>Arguments<a class="headerlink" href="#id1" title="Link to this heading"></a></h3>
<ol class="arabic simple">
<li><dl class="simple">
<dt>download_path: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>path in which the archives will be extracted (usually where the archives are located)</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>list_paths: <code class="docutils literal notranslate"><span class="pre">List[str]</span></code></dt><dd><p>list of paths to the zip archives</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>bands_to_extract: <code class="docutils literal notranslate"><span class="pre">List[str]</span></code></dt><dd><p>list of strings that will be used to match specific bands. For example if you are looking
for bands B3 and B4 in a given archive, <cite>bands_to_extract = [‘*_B3.TIF’, ‘*_B4.TIF’]</cite>. This
depends on the product architecture.</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>path where a csv file containing the product paths will be saved</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>remove_archive: <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">False</span></code></dt><dd><p>boolean to choose whether to remove the archive or not</p>
</dd>
</dl>
</li>
</ol>
</section>
<section id="id2">
<h3>Returns<a class="headerlink" href="#id2" title="Link to this heading"></a></h3>
<ol class="arabic simple">
<li><dl class="simple">
<dt>product_list: <code class="docutils literal notranslate"><span class="pre">List[str]</span></code></dt><dd><p>list of the paths to the extracted products</p>
</dd>
</dl>
</li>
</ol>
</section>
</dd></dl>

<p>The archives can then be deleted, freeing up some disk space.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The scripts to download LandSat data will be added soon.</p>
</div>
</section>
<section id="calculate-ndvi">
<h2>Calculate NDVI<a class="headerlink" href="#calculate-ndvi" title="Link to this heading"></a></h2>
<p>The NDVI calculation is done using the <code class="docutils literal notranslate"><span class="pre">xarray</span></code> module. This allows for an easy parallelization of the NDVI calculation (with the integrated <code class="docutils literal notranslate"><span class="pre">dask</span></code> module). The first step is to calculate the NDVI for the existing images and save them in a <strong>data cube</strong> (a stack of two dimensional images along a time dimension). This first <strong>data cube</strong> is called the NDVI <em>pre_cube</em>. The chosen file format is <code class="docutils literal notranslate"><span class="pre">netCDF4</span></code> (<code class="docutils literal notranslate"><span class="pre">.nc</span></code>) for a more efficient reading and writing process.</p>
<p>To limit the size of the input datasets, the NDVI data is converted to the <code class="docutils literal notranslate"><span class="pre">uint8</span></code> data type (one <em>Byte</em> per pixel). It means NDVI values are saved as integers between 0 and 255 (which correspond to 0 and 1 values). This gives a precision of about 0.4 % for the NDVI values, which is lower than the uncertainty of the satellite measurements. Little actual data is lost.</p>
<p>The NDVI pre_cube can be created with the following function:</p>
<dl class="py function">
<dt class="sig sig-object py" id="modspa_pixel.preprocessing.calculate_ndvi.calculate_ndvi">
<span class="sig-prename descclassname"><span class="pre">modspa_pixel.preprocessing.calculate_ndvi.</span></span><span class="sig-name descname"><span class="pre">calculate_ndvi</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">extracted_paths</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 class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">str</span></span></em>, <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">chunk_size</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">dict</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">{'time':</span> <span class="pre">-1,</span> <span class="pre">'x':</span> <span class="pre">1000,</span> <span class="pre">'y':</span> <span class="pre">1000}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">acorvi_corr</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">500</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/calculate_ndvi.html#calculate_ndvi"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#modspa_pixel.preprocessing.calculate_ndvi.calculate_ndvi" title="Link to this definition"></a></dt>
<dd><p>Calculate ndvi images in a xarray dataset (a data cube) and save it.
ndvi values are scaled and saved as <code class="docutils literal notranslate"><span class="pre">uint8</span></code> (0 to 255).</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Current version for Copernicus Sentinel-2 images</p>
</div>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>only 10 and 20 meters currently supported</p>
</div>
<section id="id3">
<h3>Arguments<a class="headerlink" href="#id3" title="Link to this heading"></a></h3>
<li><dl class="simple">
<dt>extracted_paths: <code class="docutils literal notranslate"><span class="pre">Union[List[str],</span> <span class="pre">str]</span></code></dt><dd><p>list of paths to extracted sentinel-2 products
or path to <code class="docutils literal notranslate"><span class="pre">csv`</span></code> file containing those paths</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>config_file: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>path to configuration file</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>chunk_size: <code class="docutils literal notranslate"><span class="pre">dict</span></code> <code class="docutils literal notranslate"><span class="pre">default</span> <span class="pre">=</span> <span class="pre">{'x':</span> <span class="pre">1000,</span> <span class="pre">'y':</span> <span class="pre">1000,</span> <span class="pre">'time':</span> <span class="pre">-1}</span></code></dt><dd><p>dictionnary containing the chunk size for
the xarray dask calculation</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>acorvi_corr: <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">500</span></code></dt><dd><p>acorvi correction parameter to add to the red band
to adjust ndvi values</p>
</dd>
</dl>
</li>
</ol>
</section>
<section id="id4">
<h3>Returns<a class="headerlink" href="#id4" title="Link to this heading"></a></h3>
<ol class="arabic simple">
<li><dl class="simple">
<dt>ndvi_precube_path: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>path to save the ndvi pre-cube</p>
</dd>
</dl>
</li>
</ol>
</section>
</dd></dl>

<p>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 <code class="docutils literal notranslate"><span class="pre">xarray</span></code> module. The resulting dataset is also saved with the <code class="docutils literal notranslate"><span class="pre">uint8</span></code> data type.</p>
<p>The final NDVI cube can be created with the following function:</p>
<dl class="py function">
<dt class="sig sig-object py" id="modspa_pixel.preprocessing.calculate_ndvi.interpolate_ndvi">
<span class="sig-prename descclassname"><span class="pre">modspa_pixel.preprocessing.calculate_ndvi.</span></span><span class="sig-name descname"><span class="pre">interpolate_ndvi</span></span><span class="sig-paren">(</span><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">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">chunk_size</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">dict</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">{'time':</span> <span class="pre">-1,</span> <span class="pre">'x':</span> <span class="pre">500,</span> <span class="pre">'y':</span> <span class="pre">500}</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/calculate_ndvi.html#interpolate_ndvi"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#modspa_pixel.preprocessing.calculate_ndvi.interpolate_ndvi" title="Link to this definition"></a></dt>
<dd><p>Interpolate the ndvi cube to a daily frequency between the
desired dates defined in the <code class="docutils literal notranslate"><span class="pre">json</span></code> config file. The extra
month of data downloaded is used for a better interpolation,
it is then discarded and the final NDVI cube has the dates
defined in the config file.</p>
<section id="id5">
<h3>Arguments<a class="headerlink" href="#id5" title="Link to this heading"></a></h3>
<ol class="arabic simple">
<li><dl class="simple">
<dt>ndvi_path: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>path to ndvi pre-cube</p>
</dd>
<dt>config_file: <code class="docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>path to <code class="docutils literal notranslate"><span class="pre">json</span></code> config file</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>chunk_size: <code class="docutils literal notranslate"><span class="pre">dict</span></code> <code class="docutils literal notranslate"><span class="pre">default</span> <span class="pre">=</span> <span class="pre">{'x':</span> <span class="pre">500,</span> <span class="pre">'y':</span> <span class="pre">500,</span> <span class="pre">'time':</span> <span class="pre">-1}</span></code></dt><dd><p>chunk size to use by dask for calculation,
<code class="docutils literal notranslate"><span class="pre">'time'</span> <span class="pre">=</span> <span class="pre">-1</span></code> means the chunk has the whole
time dimension in it. The Dataset can’t be
divided along the time axis for interpolation.</p>
</dd>
</dl>
</section>
<section id="id6">
<h3>Returns<a class="headerlink" href="#id6" title="Link to this heading"></a></h3>
<p><code class="docutils literal notranslate"><span class="pre">None</span></code></p>
</section>
</dd></dl>

<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Both of the previous functions are ressource hungry (<strong>CPU</strong> and <strong>RAM</strong>), it can take up to an hour or more depending on the size of the dataset and the specifications of your machine.</p>
</div>
</section>
</section>


           </div>
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="input_preparation.html" class="btn btn-neutral float-left" title="Preparing the inputs for Modspa-Pixel" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="weather_cube.html" class="btn btn-neutral float-right" title="Preparing the weather data cube" 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>