Introduction

Installation

The pywapor package depends on several other packages, most of them get installed automatically when we install pywapor. The GDAL package needs to be installed manually however. Luckily, it is already installed on the backend computer used by Google Colab. We can verify that GDAL is installed by running the following commands.

[1]:
from osgeo import gdal
print("Using gdal version", gdal.__version__)
Using gdal version 3.6.2

Now that we know that Python is able to import the GDAL package, we can install pywapor by running the following command.

[ ]:
!pip install pywapor --quiet

If everything went well, we can now import pywapor in Python, let’s try it (fingers crossed)!

[2]:
import pywapor
print("Using pywapor version:", pywapor.__version__)
OMP: Info #276: omp_set_nested routine deprecated, please use omp_set_max_active_levels instead.
Using pywapor version: 3.3.0

ETLook Input

In order to run the ETLook model, we first need to collect the necessary inputs. For your convenience, the pywapor package has a function that can collect all this data from selected sources and make sure the data is stored in the correct format. In one of the following lessons we will look more closely at how you can adjust these inputs. Here we will focus on running a basic configuration.

Because some of the data portals used require a user to login with a username and a password, we first need to set those up. Most importantly, we will need a NASA Earthdata Login to be able to collect the MODIS and MERRA2 datasets, which can be created over here.

⚠️

After creating your account, you still need to accept some ‘Terms of Use’, before you can continue with this notebook. To do that, login to your newly created account and go to

Applications > Authorized Apps > Approve More Applications

There, make sure the two following applications are authorized: 1. NASA GESDISC DATA ARCHIVE 2. LP DAAC OPeNDAP

⚠️

Once you have your account set up, we can enter our username and password by running the following code (if you skip this step, you’ll be prompted for your username and password once the script starts downloading any product that requires them).

[3]:
pywapor.collect.accounts.setup("NASA")

Now that we have our account set up we can start defining our period and area-of-interest (AOI).

First we define a time period through timelim, our boundingbox through latlim and lonlim and we give a project_folder in which all our data will be stored. Here I’ve chosen an period of exactly 10 days which is the default composite length of pyWAPOR. We’ll talk more about composites in the next lesson. The given boundingbox will show us the Fayoum irrigation scheme in Egypt.

Note that for latlim the first value refers to the southern border of your AOI, so this value should always be smaller than the second. For lonlim, the first value refers to the western border of your AOI.

[3]:
project_folder = r"/Users/hmcoerver/pywapor_notebooks_1"
timelim = ["2021-07-01", "2021-07-11"]
latlim = [28.9, 29.7]
lonlim = [30.2, 31.2]

Then we can run pywapor.pre_et_look.main() to start the downloading.

[4]:
ds  = pywapor.pre_et_look.main(project_folder, latlim, lonlim, timelim)
> PRE_ET_LOOK
    --> Collecting `ndvi` from `MODIS.MOD13Q1.061`.
        --> Applying 'mask_qa' to `ndvi`.
        --> Saving merged data.
            > peak-memory-usage: 4.6MB, execution-time: 0:00:02.406950.
            > chunksize|dimsize: [time: 2|2, y: 403|403, x: 506|506]
            > timesize: 2 [2021-07-04T00:00, ..., 2021-07-20T00:00]
    --> Collecting `ndvi` from `MODIS.MYD13Q1.061`.
        --> Applying 'mask_qa' to `ndvi`.
        --> Saving merged data.
            > peak-memory-usage: 2.3MB, execution-time: 0:00:02.046644.
            > chunksize|dimsize: [time: 1|1, y: 403|403, x: 506|506]
            > timesize: 1 [2021-07-12T00:00, ..., 2021-07-12T00:00]
    --> Collecting `r0` from `MODIS.MCD43A3.061`.
        --> Applying 'shortwave_r0' to `r0`.
        --> Applying 'mask_qa' to `r0`.
        --> Saving merged data.
            > peak-memory-usage: 10.4MB, execution-time: 0:00:02.102645.
            > chunksize|dimsize: [time: 17|17, y: 207|207, x: 258|258]
            > timesize: 17 [2021-06-28T12:00, ..., 2021-07-14T12:00]
    --> Collecting `p` from `CHIRPS.P05`.
        --> Saving merged data.
            > peak-memory-usage: 85.0KB, execution-time: 0:00:02.059933.
            > chunksize|dimsize: [time: 17|17, y: 18|18, x: 22|22]
            > timesize: 17 [2021-06-28T00:30, ..., 2021-07-14T00:30]
    --> Collecting `z` from `SRTM.30M`.
        --> Saving merged data.
            > peak-memory-usage: 118.8MB, execution-time: 0:00:02.718525.
            > chunksize|dimsize: [time: 1|1, y: 2883|2883, x: 3603|3603]
            > timesize: 1 [2000-02-11T00:00, ..., 2000-02-11T00:00]
    --> Collecting `ra` from `MERRA2.M2T1NXRAD.5.12.4`.
        --> Saving merged data.
            > peak-memory-usage: 587.4KB, execution-time: 0:00:02.036556.
            > chunksize|dimsize: [time: 408|408, y: 4|4, x: 3|3]
            > timesize: 408 [2021-06-28T01:00, ..., 2021-07-15T00:00]
    --> Collecting `t_air`, `t_air_max`, `t_air_min`, `u2m`, `v2m`, `qv`, `p_air`, `p_air_0`, `wv` from `GEOS5.inst3_2d_asm_Nx`.
        --> Downloading data.
            > peak-memory-usage: 1.3MB, execution-time: 0:00:58.193265.
            > chunksize|dimsize: [time: 129|129, y: 5|5, x: 5|5]
        --> Applying 'kelvin_to_celsius' to `t_air`.
        --> Applying 'kelvin_to_celsius' to `t_air_max`.
        --> Applying 'kelvin_to_celsius' to `t_air_min`.
        --> Applying 'pa_to_kpa' to `p_air`.
        --> Applying 'pa_to_kpa' to `p_air_0`.
        --> Saving netCDF.
            > peak-memory-usage: 1.9MB, execution-time: 0:00:02.139208.
            > chunksize|dimsize: [time: 129|129, y: 5|5, x: 5|5]
            > timesize: 129 [2021-06-28T01:30, ..., 2021-07-14T01:30]
    --> Collecting `land_mask`, `rs_min`, `z_obst_max` from `GLOBCOVER.2009_V2.3_Global`.
        --> Calculating `land_mask` from `lulc`.
        --> Calculating `rs_min` from `lulc`.
        --> Calculating `z_obst_max` from `lulc`.
        --> Saving 2009_V2.3_Global.nc.
            > peak-memory-usage: 4.5MB, execution-time: 0:00:02.084982.
            > chunksize|dimsize: [y: 295|295, x: 367|367]
    --> Collecting `lw_offset`, `lw_slope`, `z_oro`, `rn_offset`, `rn_slope`, `t_amp_year`, `t_opt`, `vpd_slope` from `STATICS.WaPOR2`.
        --> Saving WaPOR2.nc.
            > peak-memory-usage: 21.3MB, execution-time: 0:00:02.155611.
            > chunksize|dimsize: [y: 403|403, x: 493|493]
    --> Collecting `se_root` from `se_root.v2`.
        > PRE_SE_ROOT
            --> Collecting `lst` from `MODIS.MOD11A1.061`.
                --> Applying 'mask_bitwise_qa' to `lst`.
                --> Applying 'expand_time_dim' to `lst`.
                --> Saving merged data.
                    > peak-memory-usage: 4.5MB, execution-time: 0:00:02.050519.
                    > chunksize|dimsize: [time: 22|22, y: 104|104, x: 130|130]
                    > timesize: 22 [2021-06-28T10:54, ..., 2021-07-14T10:54]
            --> Collecting `lst` from `MODIS.MYD11A1.061`.
                --> Applying 'mask_bitwise_qa' to `lst`.
                --> Applying 'expand_time_dim' to `lst`.
                --> Saving merged data.
                    > peak-memory-usage: 6.6MB, execution-time: 0:00:02.062050.
                    > chunksize|dimsize: [time: 32|32, y: 104|104, x: 130|130]
                    > timesize: 32 [2021-06-28T12:30, ..., 2021-07-14T12:36]
            --> Collecting `ndvi` from `MODIS.MOD13Q1.061`.
                    > timesize: 2 [2021-07-04T00:00, ..., 2021-07-20T00:00]
            --> Collecting `ndvi` from `MODIS.MYD13Q1.061`.
                    > timesize: 1 [2021-07-12T00:00, ..., 2021-07-12T00:00]
            --> Collecting `t_air`, `t_air_max`, `t_air_min`, `u2m`, `v2m`, `qv`, `wv`, `p_air`, `p_air_0` from `GEOS5.inst3_2d_asm_Nx`.
                    > timesize: 129 [2021-06-28T01:30, ..., 2021-07-14T01:30]
            --> Collecting `r0_bare`, `r0_full` from `STATICS.WaPOR2`.
                --> Saving WaPOR2.nc.
                    --> Appending data to an existing file.
                    > peak-memory-usage: 8.7MB, execution-time: 0:00:02.095425.
                    > chunksize|dimsize: [y: 403|403, x: 493|493]
            --> Spatially aligning 2 `lst` products together.
                --> Using `MYD11A1.061.nc` as reprojecting example.
                    > shape: (104, 130), res: 0.0079° x 0.0079°.
            --> Spatially aligning 2 `ndvi` products together.
                --> Using `MYD13Q1.061.nc` as reprojecting example.
                    > shape: (403, 506), res: 0.0020° x 0.0020°.
            --> Aligning times in `ndvi` (3) with `lst` (54, linear).
                > peak-memory-usage: 419.7MB, execution-time: 0:00:06.515075.
                > chunksize|dimsize: [time: 54|54, y: 403|403, x: 500|506]
                > shape: (54, 403, 506), kwargs: [].
            --> Aligning times in `p_air` (129) with `lst` (54, linear).
                > peak-memory-usage: 730.5KB, execution-time: 0:00:02.061066.
                > chunksize|dimsize: [time: 54|54, y: 5|5, x: 5|5]
                > shape: (54, 5, 5), kwargs: [].
            --> Aligning times in `p_air_0` (129) with `lst` (54, linear).
                > peak-memory-usage: 720.7KB, execution-time: 0:00:02.045368.
                > chunksize|dimsize: [time: 54|54, y: 5|5, x: 5|5]
                > shape: (54, 5, 5), kwargs: [].
            --> Aligning times in `qv` (129) with `lst` (54, linear).
                > peak-memory-usage: 723.1KB, execution-time: 0:00:02.040387.
                > chunksize|dimsize: [time: 54|54, y: 5|5, x: 5|5]
                > shape: (54, 5, 5), kwargs: [].
            --> Aligning times in `t_air` (129) with `lst` (54, linear).
                > peak-memory-usage: 722.0KB, execution-time: 0:00:02.052818.
                > chunksize|dimsize: [time: 54|54, y: 5|5, x: 5|5]
                > shape: (54, 5, 5), kwargs: [].
            --> Aligning times in `t_air_max` (129) with `lst` (54, linear).
                > peak-memory-usage: 564.4KB, execution-time: 0:00:02.055804.
                > chunksize|dimsize: [time: 54|54, y: 5|5, x: 5|5]
                > shape: (54, 5, 5), kwargs: [].
            --> Aligning times in `t_air_min` (129) with `lst` (54, linear).
                > peak-memory-usage: 704.2KB, execution-time: 0:00:02.061281.
                > chunksize|dimsize: [time: 54|54, y: 5|5, x: 5|5]
                > shape: (54, 5, 5), kwargs: [].
            --> Aligning times in `u2m` (129) with `lst` (54, linear).
                > peak-memory-usage: 126.9KB, execution-time: 0:00:02.058494.
                > chunksize|dimsize: [time: 54|54, y: 5|5, x: 5|5]
                > shape: (54, 5, 5), kwargs: [].
            --> Aligning times in `v2m` (129) with `lst` (54, linear).
                > peak-memory-usage: 577.3KB, execution-time: 0:00:02.047801.
                > chunksize|dimsize: [time: 54|54, y: 5|5, x: 5|5]
                > shape: (54, 5, 5), kwargs: [].
            --> Aligning times in `wv` (129) with `lst` (54, linear).
                > peak-memory-usage: 127.6KB, execution-time: 0:00:02.055912.
                > chunksize|dimsize: [time: 54|54, y: 5|5, x: 5|5]
                > shape: (54, 5, 5), kwargs: [].
            --> Using `MOD13Q1.061.nc` as reprojecting example.
                > shape: (403, 506), res: 0.0020° x 0.0020°.
            --> Selected `reproject_bulk` for reprojection of MOD11A1.061.nc.
                --> Applying `reproject_bulk` to MOD11A1.061.nc:lst (nearest).
                    > peak-memory-usage: 252.0MB, execution-time: 0:00:02.344924.
                    > chunksize|dimsize: [time: 54|54, y: 403|403, x: 506|506]
            --> Selected `reproject_chunk` for reprojection of p_air_i.nc.
                --> Warping VRT to netCDF.
                    > peak-memory-usage: 6.7KB, execution-time: 0:00:00.674666.
                --> Saving reprojected data from p_air_i.nc:p_air (bilinear).
                    > peak-memory-usage: 420.1MB, execution-time: 0:00:02.462867.
                    > chunksize|dimsize: [time: 54|54, y: 403|403, x: 506|506]
            --> Selected `reproject_chunk` for reprojection of p_air_0_i.nc.
                --> Warping VRT to netCDF.
                    > peak-memory-usage: 6.3KB, execution-time: 0:00:00.669386.
                --> Saving reprojected data from p_air_0_i.nc:p_air_0 (bilinear).
                    > peak-memory-usage: 420.1MB, execution-time: 0:00:02.373195.
                    > chunksize|dimsize: [time: 54|54, y: 403|403, x: 506|506]
            --> Selected `reproject_chunk` for reprojection of qv_i.nc.
                --> Warping VRT to netCDF.
                    > peak-memory-usage: 6.4KB, execution-time: 0:00:00.686705.
                --> Saving reprojected data from qv_i.nc:qv (bilinear).
                    > peak-memory-usage: 420.1MB, execution-time: 0:00:02.342912.
                    > chunksize|dimsize: [time: 54|54, y: 403|403, x: 506|506]
            --> Selected `reproject_chunk` for reprojection of WaPOR2.nc.
                --> Correcting src_ds.
                    > peak-memory-usage: 6.1MB, execution-time: 0:00:02.059385.
                    > chunksize|dimsize: [y: 403|403, x: 493|493]
                --> Warping VRT to netCDF.
                    > peak-memory-usage: 4.6KB, execution-time: 0:00:00.025533.
                --> Saving reprojected data from WaPOR2_fixed.nc:r0_bare (bilinear).
                    > peak-memory-usage: 6.2MB, execution-time: 0:00:02.055427.
                    > chunksize|dimsize: [y: 403|403, x: 506|506]
            --> Selected `reproject_chunk` for reprojection of WaPOR2.nc.
                --> Correcting src_ds.
                    > peak-memory-usage: 6.1MB, execution-time: 0:00:02.057004.
                    > chunksize|dimsize: [y: 403|403, x: 493|493]
                --> Warping VRT to netCDF.
                    > peak-memory-usage: 4.5KB, execution-time: 0:00:00.025537.
                --> Saving reprojected data from WaPOR2_fixed.nc:r0_full (bilinear).
                    > peak-memory-usage: 6.2MB, execution-time: 0:00:02.043998.
                    > chunksize|dimsize: [y: 403|403, x: 506|506]
            --> Selected `reproject_chunk` for reprojection of t_air_i.nc.
                --> Warping VRT to netCDF.
                    > peak-memory-usage: 6.3KB, execution-time: 0:00:00.674500.
                --> Saving reprojected data from t_air_i.nc:t_air (bilinear).
                    > peak-memory-usage: 420.1MB, execution-time: 0:00:02.519975.
                    > chunksize|dimsize: [time: 54|54, y: 403|403, x: 506|506]
            --> Selected `reproject_chunk` for reprojection of t_air_max_i.nc.
                --> Warping VRT to netCDF.
                    > peak-memory-usage: 6.5KB, execution-time: 0:00:00.695288.
                --> Saving reprojected data from t_air_max_i.nc:t_air_max (bilinear).
                    > peak-memory-usage: 420.1MB, execution-time: 0:00:02.508993.
                    > chunksize|dimsize: [time: 54|54, y: 403|403, x: 506|506]
            --> Selected `reproject_chunk` for reprojection of t_air_min_i.nc.
                --> Warping VRT to netCDF.
                    > peak-memory-usage: 6.3KB, execution-time: 0:00:00.704697.
                --> Saving reprojected data from t_air_min_i.nc:t_air_min (bilinear).
                    > peak-memory-usage: 420.1MB, execution-time: 0:00:02.522146.
                    > chunksize|dimsize: [time: 54|54, y: 403|403, x: 506|506]
            --> Selected `reproject_chunk` for reprojection of u2m_i.nc.
                --> Warping VRT to netCDF.
                    > peak-memory-usage: 6.4KB, execution-time: 0:00:00.706676.
                --> Saving reprojected data from u2m_i.nc:u2m (bilinear).
                    > peak-memory-usage: 420.1MB, execution-time: 0:00:02.514175.
                    > chunksize|dimsize: [time: 54|54, y: 403|403, x: 506|506]
            --> Selected `reproject_chunk` for reprojection of v2m_i.nc.
                --> Warping VRT to netCDF.
                    > peak-memory-usage: 6.7KB, execution-time: 0:00:00.697456.
                --> Saving reprojected data from v2m_i.nc:v2m (bilinear).
                    > peak-memory-usage: 420.1MB, execution-time: 0:00:02.506971.
                    > chunksize|dimsize: [time: 54|54, y: 403|403, x: 506|506]
            --> Selected `reproject_chunk` for reprojection of wv_i.nc.
                --> Warping VRT to netCDF.
                    > peak-memory-usage: 6.3KB, execution-time: 0:00:00.698109.
                --> Saving reprojected data from wv_i.nc:wv (bilinear).
                    > peak-memory-usage: 420.1MB, execution-time: 0:00:02.505286.
                    > chunksize|dimsize: [time: 54|54, y: 403|403, x: 506|506]
            --> Applying 'rename_meteo'.
            --> Applying 'remove_empty_statics'.
            --> Applying 'add_constants_new'.
            --> Applying 'bt_to_lst'.
            --> Applying 'drop_empty_times'.
            --> Creating merged file `se_root_in.nc`.
                > peak-memory-usage: 672.2MB, execution-time: 0:00:06.584694.
                > chunksize|dimsize: [time: 54|54, y: 403|403, x: 506|506]
        < PRE_SE_ROOT (0:01:41.183262)
        > SE_ROOT
            --> Running `se_root` (v2).
            --> Calculating `seasonal_correction`.
            --> Calculating `declination`.
            --> Calculating `day_angle`.
            --> Calculating `air_pressure_kpa2mbar`.
            --> Calculating `air_pressure_kpa2mbar`.
            --> Calculating `vegetation_cover`.
            --> Calculating `air_temperature_kelvin_inst`.
            --> Calculating `air_temperature_kelvin`.
            --> Calculating `vapour_pressure_from_specific_humidity_inst`.
            --> Calculating `vapour_pressure_from_specific_humidity`.
            --> Calculating `specific_humidity_from_vapour_pressure`.
            --> Calculating `moist_air_density_inst`.
            --> Calculating `moist_air_density`.
            --> Calculating `dry_air_density_inst`.
            --> Calculating `dry_air_density`.
            --> Calculating `air_density_inst`.
            --> Calculating `air_density`.
            --> Calculating `wind_speed_blending_height_bare`.
            --> Calculating `longitude_rad`.
            --> Calculating `latitude_rad`.
            --> Calculating `hour_angle`.
            --> Calculating `inverse_earth_sun_distance`.
            --> Calculating `solar_elevation_angle`.
            --> Calculating `solar_elevation_angle_refracted`.
            --> Calculating `relative_optical_airmass`.
            --> Calculating `rayleigh_optical_thickness`.
            --> Calculating `linke_turbidity`.
            --> Calculating `extraterrestrial_irradiance_normal`.
            --> Calculating `beam_irradiance_normal_clear`.
            --> Calculating `beam_irradiance_horizontal_clear`.
            --> Calculating `diffuse_irradiance_horizontal_clear`.
            --> Calculating `ra_clear_horizontal`.
            --> Calculating `atmospheric_emissivity_inst`.
            --> Calculating `net_radiation_bare`.
            --> Calculating `net_radiation_full`.
            --> Calculating `sensible_heat_flux_bare`.
            --> Calculating `sensible_heat_flux_full`.
            --> Calculating `wind_speed_blending_height_full_inst`.
            --> Calculating `friction_velocity_bare_inst`.
            --> Calculating `friction_velocity_full_inst`.
            --> Calculating `monin_obukhov_length_bare`.
            --> Calculating `monin_obukhov_length_full`.
            --> Calculating `wind_speed_soil_inst`.
            --> Calculating `psi_m`.
            --> Calculating `aerodynamical_resistance_forced_convection_soil`.
            --> Calculating `aerodynamical_resistance_forced_convection_bare`.
            --> Calculating `psi_m`.
            --> Calculating `psi_h`.
            --> Calculating `aerodynamical_resistance_forced_convection_full`.
            --> Calculating `psi_m`.
            --> Calculating `psi_m`.
            --> Calculating `psi_h`.
            --> Calculating `psi_h`.
            --> Calculating `maximum_temperature_bare`.
            --> Calculating `maximum_temperature_full`.
            --> Calculating `wet_bulb_temperature_inst_new`.
            --> Calculating `maximum_temperature`.
            --> Calculating `wet_bulb_temperature_kelvin_inst`.
            --> Calculating `air_temperature_kelvin`.
            --> Calculating `minimum_temperature`.
            --> Calculating `soil_moisture_from_maximum_temperature`.
/Users/hmcoerver/miniconda3/envs/pywapor/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in power
  return func(*(_execute_task(a, cache) for a in args))
/Users/hmcoerver/miniconda3/envs/pywapor/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in log
  return func(*(_execute_task(a, cache) for a in args))
            --> Saving output to `se_root_out.nc`.
                > peak-memory-usage: 1.7GB, execution-time: 0:00:04.706942.
                > chunksize|dimsize: [time: 1|32, y: 403|403, x: 506|506]
        < SE_ROOT (0:00:07.801339)
            > timesize: 32 [2021-07-04T10:11, ..., 2021-07-13T13:30]
    --> Compositing 26 variables.
        --> (1/26) Compositing `ndvi` (mean).
            --> Using `MYD13Q1.061.nc` as reprojecting example.
                > shape: (403, 506), res: 0.0020° x 0.0020°.
            --> Saving `ndvi` composites.
                > peak-memory-usage: 14.0MB, execution-time: 0:00:04.051637.
                > chunksize|dimsize: [time_bins: 1|1, y: 403|403, x: 506|506]
        --> (2/26) Compositing `r0` (mean).
            --> Saving `r0` composites.
                > peak-memory-usage: 20.8MB, execution-time: 0:00:02.041443.
                > chunksize|dimsize: [time_bins: 1|1, y: 207|207, x: 258|258]
        --> (3/26) Compositing `se_root` (max).
            --> Saving `se_root` composites.
                > peak-memory-usage: 105.8MB, execution-time: 0:00:02.043909.
                > chunksize|dimsize: [time_bins: 1|1, y: 403|403, x: 506|506]
        --> (4/26) Compositing `p` (mean).
            --> Saving `p` composites.
                > peak-memory-usage: 158.7KB, execution-time: 0:00:02.035397.
                > chunksize|dimsize: [time_bins: 1|1, y: 18|18, x: 22|22]
        --> (5/26) Compositing `z` (None).
            --> Saving `z` composites.
                > peak-memory-usage: 317.0MB, execution-time: 0:00:02.218434.
                > chunksize|dimsize: [y: 2883|2883, x: 3603|3603]
        --> (6/26) Compositing `ra` (mean).
            --> Saving `ra` composites.
                > peak-memory-usage: 126.6KB, execution-time: 0:00:02.026313.
                > chunksize|dimsize: [time_bins: 1|1, y: 4|4, x: 3|3]
        --> (7/26) Compositing `t_air` (mean).
            --> Saving `t_air` composites.
                > peak-memory-usage: 81.0KB, execution-time: 0:00:02.038170.
                > chunksize|dimsize: [time_bins: 1|1, y: 5|5, x: 5|5]
        --> (8/26) Compositing `t_air_max` (max).
            --> Saving `t_air_max` composites.
                > peak-memory-usage: 79.2KB, execution-time: 0:00:02.045304.
                > chunksize|dimsize: [time_bins: 1|1, y: 5|5, x: 5|5]
        --> (9/26) Compositing `t_air_min` (min).
            --> Saving `t_air_min` composites.
                > peak-memory-usage: 79.9KB, execution-time: 0:00:02.033259.
                > chunksize|dimsize: [time_bins: 1|1, y: 5|5, x: 5|5]
        --> (10/26) Compositing `u2m` (mean).
            --> Saving `u2m` composites.
                > peak-memory-usage: 80.1KB, execution-time: 0:00:02.032857.
                > chunksize|dimsize: [time_bins: 1|1, y: 5|5, x: 5|5]
        --> (11/26) Compositing `v2m` (mean).
            --> Saving `v2m` composites.
                > peak-memory-usage: 80.8KB, execution-time: 0:00:02.039636.
                > chunksize|dimsize: [time_bins: 1|1, y: 5|5, x: 5|5]
        --> (12/26) Compositing `qv` (mean).
            --> Saving `qv` composites.
                > peak-memory-usage: 80.1KB, execution-time: 0:00:02.041625.
                > chunksize|dimsize: [time_bins: 1|1, y: 5|5, x: 5|5]
        --> (13/26) Compositing `p_air` (mean).
            --> Saving `p_air` composites.
                > peak-memory-usage: 82.4KB, execution-time: 0:00:02.042425.
                > chunksize|dimsize: [time_bins: 1|1, y: 5|5, x: 5|5]
        --> (14/26) Compositing `p_air_0` (mean).
            --> Saving `p_air_0` composites.
                > peak-memory-usage: 80.6KB, execution-time: 0:00:02.029064.
                > chunksize|dimsize: [time_bins: 1|1, y: 5|5, x: 5|5]
        --> (15/26) Compositing `wv` (mean).
            --> Saving `wv` composites.
                > peak-memory-usage: 82.0KB, execution-time: 0:00:02.043172.
                > chunksize|dimsize: [time_bins: 1|1, y: 5|5, x: 5|5]
        --> (16/26) Compositing `land_mask` (None).
            --> Saving `land_mask` composites.
                > peak-memory-usage: 10.9MB, execution-time: 0:00:02.035853.
                > chunksize|dimsize: [y: 295|295, x: 367|367]
        --> (17/26) Compositing `rs_min` (None).
            --> Saving `rs_min` composites.
                > peak-memory-usage: 10.9MB, execution-time: 0:00:02.035558.
                > chunksize|dimsize: [y: 295|295, x: 367|367]
        --> (18/26) Compositing `z_obst_max` (None).
            --> Saving `z_obst_max` composites.
                > peak-memory-usage: 10.9MB, execution-time: 0:00:02.035093.
                > chunksize|dimsize: [y: 295|295, x: 367|367]
        --> (19/26) Compositing `lw_offset` (None).
            --> Saving `lw_offset` composites.
                > peak-memory-usage: 20.1MB, execution-time: 0:00:02.023444.
                > chunksize|dimsize: [y: 403|403, x: 493|493]
        --> (20/26) Compositing `lw_slope` (None).
            --> Saving `lw_slope` composites.
                > peak-memory-usage: 20.1MB, execution-time: 0:00:02.027710.
                > chunksize|dimsize: [y: 403|403, x: 493|493]
        --> (21/26) Compositing `z_oro` (None).
            --> Saving `z_oro` composites.
                > peak-memory-usage: 20.1MB, execution-time: 0:00:02.035870.
                > chunksize|dimsize: [y: 403|403, x: 493|493]
        --> (22/26) Compositing `rn_offset` (None).
            --> Saving `rn_offset` composites.
                > peak-memory-usage: 20.1MB, execution-time: 0:00:02.026657.
                > chunksize|dimsize: [y: 403|403, x: 493|493]
        --> (23/26) Compositing `rn_slope` (None).
            --> Saving `rn_slope` composites.
                > peak-memory-usage: 20.1MB, execution-time: 0:00:02.039963.
                > chunksize|dimsize: [y: 403|403, x: 493|493]
        --> (24/26) Compositing `t_amp_year` (None).
            --> Saving `t_amp_year` composites.
                > peak-memory-usage: 20.1MB, execution-time: 0:00:02.045023.
                > chunksize|dimsize: [y: 403|403, x: 493|493]
        --> (25/26) Compositing `t_opt` (None).
            --> Saving `t_opt` composites.
                > peak-memory-usage: 20.1MB, execution-time: 0:00:02.043364.
                > chunksize|dimsize: [y: 403|403, x: 493|493]
        --> (26/26) Compositing `vpd_slope` (None).
            --> Saving `vpd_slope` composites.
                > peak-memory-usage: 20.1MB, execution-time: 0:00:02.040027.
                > chunksize|dimsize: [y: 403|403, x: 493|493]
    --> Using `MOD13Q1.061.nc` as reprojecting example.
        > shape: (403, 506), res: 0.0020° x 0.0020°.
    --> Selected `reproject_chunk` for reprojection of r0_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.4KB, execution-time: 0:00:00.026767.
        --> Saving reprojected data from r0_bin.nc:r0 (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.063902.
            > chunksize|dimsize: [time_bins: 1|1, y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of p_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.4KB, execution-time: 0:00:00.020505.
        --> Saving reprojected data from p_bin.nc:p (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.058044.
            > chunksize|dimsize: [time_bins: 1|1, y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of z_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.4KB, execution-time: 0:00:00.223920.
        --> Saving reprojected data from z_bin.nc:z (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.059220.
            > chunksize|dimsize: [y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of ra_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.4KB, execution-time: 0:00:00.020150.
        --> Saving reprojected data from ra_bin.nc:ra (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.052687.
            > chunksize|dimsize: [time_bins: 1|1, y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of t_air_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.4KB, execution-time: 0:00:00.020837.
        --> Saving reprojected data from t_air_bin.nc:t_air (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.040231.
            > chunksize|dimsize: [time_bins: 1|1, y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of t_air_max_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.4KB, execution-time: 0:00:00.021634.
        --> Saving reprojected data from t_air_max_bin.nc:t_air_max (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.040899.
            > chunksize|dimsize: [time_bins: 1|1, y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of t_air_min_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.4KB, execution-time: 0:00:00.019293.
        --> Saving reprojected data from t_air_min_bin.nc:t_air_min (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.066216.
            > chunksize|dimsize: [time_bins: 1|1, y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of u2m_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.4KB, execution-time: 0:00:00.020501.
        --> Saving reprojected data from u2m_bin.nc:u2m (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.038963.
            > chunksize|dimsize: [time_bins: 1|1, y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of v2m_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.6KB, execution-time: 0:00:00.027923.
        --> Saving reprojected data from v2m_bin.nc:v2m (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.051929.
            > chunksize|dimsize: [time_bins: 1|1, y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of qv_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.4KB, execution-time: 0:00:00.018443.
        --> Saving reprojected data from qv_bin.nc:qv (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.039134.
            > chunksize|dimsize: [time_bins: 1|1, y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of p_air_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.5KB, execution-time: 0:00:00.019653.
        --> Saving reprojected data from p_air_bin.nc:p_air (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.042740.
            > chunksize|dimsize: [time_bins: 1|1, y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of p_air_0_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.4KB, execution-time: 0:00:00.019796.
        --> Saving reprojected data from p_air_0_bin.nc:p_air_0 (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.039967.
            > chunksize|dimsize: [time_bins: 1|1, y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of wv_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.6KB, execution-time: 0:00:00.020281.
        --> Saving reprojected data from wv_bin.nc:wv (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.065591.
            > chunksize|dimsize: [time_bins: 1|1, y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of land_mask_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.6KB, execution-time: 0:00:00.018478.
        --> Saving reprojected data from land_mask_bin.nc:land_mask (nearest).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.037978.
            > chunksize|dimsize: [y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of rs_min_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.6KB, execution-time: 0:00:00.020165.
        --> Saving reprojected data from rs_min_bin.nc:rs_min (nearest).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.047624.
            > chunksize|dimsize: [y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of z_obst_max_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.5KB, execution-time: 0:00:00.020377.
        --> Saving reprojected data from z_obst_max_bin.nc:z_obst_max (nearest).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.053738.
            > chunksize|dimsize: [y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of lw_offset_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.5KB, execution-time: 0:00:00.028017.
        --> Saving reprojected data from lw_offset_bin.nc:lw_offset (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.054108.
            > chunksize|dimsize: [y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of lw_slope_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.5KB, execution-time: 0:00:00.027808.
        --> Saving reprojected data from lw_slope_bin.nc:lw_slope (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.050819.
            > chunksize|dimsize: [y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of z_oro_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.6KB, execution-time: 0:00:00.025668.
        --> Saving reprojected data from z_oro_bin.nc:z_oro (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.050029.
            > chunksize|dimsize: [y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of rn_offset_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.5KB, execution-time: 0:00:00.026838.
        --> Saving reprojected data from rn_offset_bin.nc:rn_offset (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.041462.
            > chunksize|dimsize: [y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of rn_slope_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.8KB, execution-time: 0:00:00.057042.
        --> Saving reprojected data from rn_slope_bin.nc:rn_slope (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.051023.
            > chunksize|dimsize: [y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of t_amp_year_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.5KB, execution-time: 0:00:00.028345.
        --> Saving reprojected data from t_amp_year_bin.nc:t_amp_year (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.047508.
            > chunksize|dimsize: [y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of t_opt_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.6KB, execution-time: 0:00:00.029862.
        --> Saving reprojected data from t_opt_bin.nc:t_opt (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.042394.
            > chunksize|dimsize: [y: 403|403, x: 506|506]
    --> Selected `reproject_chunk` for reprojection of vpd_slope_bin.nc.
        --> Warping VRT to netCDF.
            > peak-memory-usage: 4.5KB, execution-time: 0:00:00.024393.
        --> Saving reprojected data from vpd_slope_bin.nc:vpd_slope (bilinear).
            > peak-memory-usage: 6.2MB, execution-time: 0:00:02.038998.
            > chunksize|dimsize: [y: 403|403, x: 506|506]
    --> Calculating local means (r = 0.25°) of `z`.
        --> Filling 806 missing pixels in 'z'.
    --> Applying 'lapse_rate'.
    --> Applying 'rename_vars'.
    --> Applying 'fill_attrs'.
    --> Applying 'calc_doys'.
    --> Applying 'remove_empty_statics'.
    --> Applying 'add_constants_new'.
    --> Creating merged file `et_look_in.nc`.
        > peak-memory-usage: 15.0MB, execution-time: 0:00:02.611772.
        > chunksize|dimsize: [time_bins: 1|1, y: 403|403, x: 506|506]
< PRE_ET_LOOK (0:07:53.360714)

Once you see the output line < PRE_ET_LOOK, the code has finished. The function has created a bunch of files in you project_folder and returned a variables ds. This variable contains a xarray.Dataset. XArray is an Python-package that let’s you work with large multi-dimensional datasets. We can see the file this dataset is stored in like this.

[5]:
fh = ds.encoding["source"]
print(fh)
/Users/hmcoerver/pywapor_notebooks_1/et_look_in.nc

As you can see, the dataset is stored inside a file called et_look_in.nc, this file contains all the data we need to run the et_look model!

We can have a closer look at the contents of the datasets by simply calling ds like this.

[6]:
ds
[6]:
<xarray.Dataset>
Dimensions:              (x: 506, y: 403, time_bins: 1)
Coordinates:
  * x                    (x) float64 30.2 30.2 30.2 30.21 ... 31.2 31.2 31.2
  * y                    (y) float64 29.7 29.7 29.7 29.69 ... 28.91 28.9 28.9
    spatial_ref          int64 ...
  * time_bins            (time_bins) datetime64[ns] 2021-07-01
Data variables: (12/78)
    ndvi                 (time_bins, y, x) float64 dask.array<chunksize=(1, 403, 506), meta=np.ndarray>
    r0                   (time_bins, y, x) float64 dask.array<chunksize=(1, 403, 506), meta=np.ndarray>
    se_root              (time_bins, y, x) float64 dask.array<chunksize=(1, 403, 506), meta=np.ndarray>
    p_24                 (time_bins, y, x) float64 dask.array<chunksize=(1, 403, 506), meta=np.ndarray>
    z                    (y, x) float64 dask.array<chunksize=(403, 506), meta=np.ndarray>
    ra_24                (time_bins, y, x) float64 dask.array<chunksize=(1, 403, 506), meta=np.ndarray>
    ...                   ...
    o2                   float64 ...
    co2_ref              int64 ...
    gcgdm                float64 ...
    phot_eff             float64 ...
    r0_bare              float64 ...
    r0_full              float64 ...

The output of calling ds is interactive. It contains several parts, at the top you’ll see Dimensions, which gives information about the dimensions of our dataset. In the W-E (or x) direction, the dataset contains 523 values, while in the S-N (y) direction 418, i.e. we have 523 * 418 = 218,614 pixels! Finally, there is an time_bins-dimension, which is of size 1. Remember that we selected a period of 10 days, pre_et_look created 1 composite for that period, hence the size of 1 (we’ll talk more about this in a next lesson).

Then there is a part called Data variables, you might have to click on it to expand its information. Once you do that, you’ll see a list of variables for which the data is stored inside the file specified by fh. After each variable name, you can see it’s dimensions. E.g. ndvi is a 3-dimensional variable, while z is 2-dimensional. To get more information about a variable, you can click on the little ‘paper’-icon at the end of the line. If you look at the info for ndvi for example, you should see that ndvi stands for “Normalized difference vegetation index” and its unit is [-].

Finally, just like geotiff files, this dataset also contains information like it’s coordinate reference system and boundaries. We can access that information like this.

[7]:
print(ds.rio.crs)
print(ds.rio.bounds())
print(ds.rio.resolution())
EPSG:4326
(30.198124670407314, 28.90197637470393, 31.201417564659167, 29.70104166399938)
(0.001982792281130139, -0.001982792281130138)

XArray datasets are also easy to plot, for example, we can create a map of z like this (Note that XArray is smart enough to automatically fill in the units and the description of the variable!).

[8]:
ds.z.plot()
[8]:
<matplotlib.collections.QuadMesh at 0x167379540>
../_images/notebooks_1_introduction_20_1.png

If we want to make a map of a 3-dimensional variable, we’ll have to select for which time (i.e. time_bins) we want to create the map. Here I’m selecting the first map, i.e. at index 0.

[9]:
ds.r0.isel(time_bins = 0).plot()
[9]:
<matplotlib.collections.QuadMesh at 0x1664901f0>
../_images/notebooks_1_introduction_22_1.png

If for some reason you have lost the variable ds (maybe you restarted you computer) and don’t want to run pre_et_look again, you can simply open the file specified by fh like this. (The decode_coords keyword is used to make sure the CRS information is loaded correctly.)

[10]:
import xarray as xr
ds = xr.open_dataset(fh, decode_coords = "all")

Running ETLook

Now that we have created the input file for the model, we can run the model! We simply pass the ds to pywapor.et_look.main().

[11]:
ds_out = pywapor.et_look.main(ds)
> ET_LOOK
    --> Running `et_look` (v2).
    --> Calculating `declination`.
    --> Calculating `inverse_earth_sun_distance`.
    --> Calculating `vegetation_cover`.
    --> Calculating `leaf_area_index`.
    --> Calculating `effective_leaf_area_index`.
    --> Calculating `soil_fraction`.
    --> Calculating `latitude_rad`.
    --> Calculating `sunset_hour_angle`.
    --> Calculating `daily_solar_radiation_toa_flat`.
    --> Calculating `transmissivity`.
    --> Calculating `stress_radiation`.
    --> Calculating `air_pressure_kpa2mbar`.
    --> Calculating `air_pressure_daily`.
    --> Calculating `air_pressure`.
    --> Calculating `vapour_pressure_from_specific_humidity_daily`.
    --> Calculating `vapour_pressure_from_specific_humidity`.
    --> Calculating `saturated_vapour_pressure`.
    --> Calculating `vapour_pressure_deficit_daily`.
    --> Calculating `vapour_pressure_deficit`.
    --> Calculating `stress_vpd`.
    --> Calculating `stress_temperature`.
    --> Calculating `atmospheric_canopy_resistance`.
    --> Calculating `air_temperature_kelvin_daily`.
    --> Calculating `air_temperature_kelvin`.
    --> Calculating `longwave_radiation_fao`.
    --> Calculating `interception_mm`.
    --> Calculating `latent_heat_daily`.
    --> Calculating `latent_heat`.
    --> Calculating `interception_wm2`.
    --> Calculating `net_radiation`.
    --> Calculating `net_radiation_canopy`.
    --> Calculating `stress_moisture`.
    --> Calculating `canopy_resistance`.
    --> Calculating `obstacle_height`.
    --> Calculating `roughness_length`.
    --> Calculating `wind_speed`.
    --> Calculating `initial_canopy_aerodynamic_resistance`.
    --> Calculating `wind_speed_blending_height_daily`.
    --> Calculating `wind_speed_blending_height`.
    --> Calculating `dry_air_density_daily`.
    --> Calculating `dry_air_density`.
    --> Calculating `moist_air_density_daily`.
    --> Calculating `moist_air_density`.
    --> Calculating `air_density_daily`.
    --> Calculating `air_density`.
    --> Calculating `psychrometric_constant_daily`.
    --> Calculating `psychrometric_constant`.
    --> Calculating `slope_saturated_vapour_pressure_daily`.
    --> Calculating `slope_saturated_vapour_pressure`.
    --> Calculating `saturated_vapour_pressure`.
    --> Calculating `initial_daily_transpiration`.
    --> Calculating `initial_sensible_heat_flux_canopy_daily`.
    --> Calculating `displacement_height`.
    --> Calculating `initial_friction_velocity_daily`.
    --> Calculating `transpiration`.
    --> Calculating `transpiration_mm`.
    --> Calculating `net_radiation_soil`.
    --> Calculating `soil_resistance`.
    --> Calculating `initial_soil_aerodynamic_resistance`.
    --> Calculating `initial_friction_velocity_soil_daily`.
    --> Calculating `soil_thermal_conductivity`.
    --> Calculating `volumetric_heat_capacity`.
    --> Calculating `damping_depth`.
    --> Calculating `bare_soil_heat_flux`.
    --> Calculating `soil_heat_flux`.
    --> Calculating `initial_daily_evaporation`.
    --> Calculating `initial_sensible_heat_flux_soil_daily`.
    --> Calculating `evaporation`.
    --> Calculating `evaporation_mm`.
    --> Calculating `et_actual_mm`.
    --> Calculating `net_radiation_grass`.
    --> Calculating `et_reference`.
    --> Calculating `et_reference_mm`.
    --> Calculating `air_temperature_kelvin_daily`.
    --> Calculating `air_temperature_kelvin`.
    --> Calculating `air_temperature_kelvin_daily`.
    --> Calculating `air_temperature_kelvin`.
    --> Calculating `mean_temperature_kelvin_daytime`.
    --> Calculating `temperature_dependency`.
    --> Calculating `affinity_constant_co2`.
    --> Calculating `inhibition_constant_o2`.
    --> Calculating `co2_o2_specificity_ratio`.
    --> Calculating `co2_level_annual`.
    --> Calculating `autotrophic_respiration`.
    --> Calculating `par`.
    --> Calculating `fpar`.
    --> Calculating `co2_fertilisation`.
    --> Calculating `net_primary_production_max`.
    --> Calculating `net_primary_production`.
    --> Saving output to `et_look_out.nc`.
        > peak-memory-usage: 467.3MB, execution-time: 0:00:02.788765.
        > chunksize|dimsize: [time_bins: 1|1, y: 403|403, x: 506|506]
< ET_LOOK (0:00:07.011274)

This should go pretty quickly (a couple of seconds). Again, we can see a new netCDF file has been created.

[12]:
fh_out = ds_out.encoding["source"]
print(fh_out)
/Users/hmcoerver/pywapor_notebooks_1/et_look_out.nc

And we can check the contents of the new dataset just like we did before.

[13]:
ds_out
[13]:
<xarray.Dataset>
Dimensions:       (time_bins: 1, y: 403, x: 506)
Coordinates:
  * x             (x) float64 30.2 30.2 30.2 30.21 ... 31.19 31.2 31.2 31.2
  * y             (y) float64 29.7 29.7 29.7 29.69 ... 28.91 28.91 28.9 28.9
    spatial_ref   int64 ...
  * time_bins     (time_bins) datetime64[ns] 2021-07-01
Data variables:
    int_mm        (time_bins, y, x) float64 dask.array<chunksize=(1, 403, 506), meta=np.ndarray>
    t_24_mm       (time_bins, y, x) float64 dask.array<chunksize=(1, 403, 506), meta=np.ndarray>
    e_24_mm       (time_bins, y, x) float64 dask.array<chunksize=(1, 403, 506), meta=np.ndarray>
    et_24_mm      (time_bins, y, x) float64 dask.array<chunksize=(1, 403, 506), meta=np.ndarray>
    et_ref_24_mm  (time_bins, y, x) float64 dask.array<chunksize=(1, 403, 506), meta=np.ndarray>
    se_root       (time_bins, y, x) float64 dask.array<chunksize=(1, 403, 506), meta=np.ndarray>
    npp           (time_bins, y, x) float64 dask.array<chunksize=(1, 403, 506), meta=np.ndarray>

As you can see, the Dimensions and Attributes parts are the same. The Data variables however, now contain our output variables. We can plot them in the same way as we did with the input dataset.

[14]:
ds_out.et_24_mm.isel(time_bins = 0).plot()
[14]:
<matplotlib.collections.QuadMesh at 0x166716470>
../_images/notebooks_1_introduction_32_1.png

If you want to do some calulcations with the data, you can get easily get a numpy-array (e.g. for et_24_mm). Note that this loads the array into you working memory.

[15]:
import numpy as np

et_data = ds_out.et_24_mm.isel(time_bins = 0).values

print("resolution:", et_data.shape)
print("total pixels:", et_data.size)
print("number of pixels with missing data:", np.sum(np.isnan(et_data)))
print("maximum value: {0:.2f}".format(np.nanmax(et_data)))
print("minimum value: {0:.2f}".format(np.nanmin(et_data)))
print("mean: {0:.2f}".format(np.nanmean(et_data)))
print("median: {0:.2f}".format(np.nanmedian(et_data)))
resolution: (403, 506)
total pixels: 203918
number of pixels with missing data: 32916
maximum value: 9.82
minimum value: 0.00
mean: 1.96
median: 0.10

As we could see, the output dataset only contained 6 variables. If you’d want to output all the variables that ET_Look calculated however, you could run pywapor.et_look.main like this.

[16]:
ds_out_all = pywapor.et_look.main(fh, export_vars = "all")
> ET_LOOK
    --> Running `et_look` (v2).
    --> Calculating `declination`.
    --> Calculating `inverse_earth_sun_distance`.
    --> Calculating `vegetation_cover`.
    --> Calculating `leaf_area_index`.
    --> Calculating `effective_leaf_area_index`.
    --> Calculating `soil_fraction`.
    --> Calculating `latitude_rad`.
    --> Calculating `sunset_hour_angle`.
    --> Calculating `daily_solar_radiation_toa_flat`.
    --> Calculating `transmissivity`.
    --> Calculating `stress_radiation`.
    --> Calculating `air_pressure_kpa2mbar`.
    --> Calculating `air_pressure_daily`.
    --> Calculating `air_pressure`.
    --> Calculating `vapour_pressure_from_specific_humidity_daily`.
    --> Calculating `vapour_pressure_from_specific_humidity`.
    --> Calculating `saturated_vapour_pressure`.
    --> Calculating `vapour_pressure_deficit_daily`.
    --> Calculating `vapour_pressure_deficit`.
    --> Calculating `stress_vpd`.
    --> Calculating `stress_temperature`.
    --> Calculating `atmospheric_canopy_resistance`.
    --> Calculating `air_temperature_kelvin_daily`.
    --> Calculating `air_temperature_kelvin`.
    --> Calculating `longwave_radiation_fao`.
    --> Calculating `interception_mm`.
    --> Calculating `latent_heat_daily`.
    --> Calculating `latent_heat`.
    --> Calculating `interception_wm2`.
    --> Calculating `net_radiation`.
    --> Calculating `net_radiation_canopy`.
    --> Calculating `stress_moisture`.
    --> Calculating `canopy_resistance`.
    --> Calculating `obstacle_height`.
    --> Calculating `roughness_length`.
    --> Calculating `wind_speed`.
    --> Calculating `initial_canopy_aerodynamic_resistance`.
    --> Calculating `wind_speed_blending_height_daily`.
    --> Calculating `wind_speed_blending_height`.
    --> Calculating `dry_air_density_daily`.
    --> Calculating `dry_air_density`.
    --> Calculating `moist_air_density_daily`.
    --> Calculating `moist_air_density`.
    --> Calculating `air_density_daily`.
    --> Calculating `air_density`.
    --> Calculating `psychrometric_constant_daily`.
    --> Calculating `psychrometric_constant`.
    --> Calculating `slope_saturated_vapour_pressure_daily`.
    --> Calculating `slope_saturated_vapour_pressure`.
    --> Calculating `saturated_vapour_pressure`.
    --> Calculating `initial_daily_transpiration`.
    --> Calculating `initial_sensible_heat_flux_canopy_daily`.
    --> Calculating `displacement_height`.
    --> Calculating `initial_friction_velocity_daily`.
    --> Calculating `transpiration`.
    --> Calculating `transpiration_mm`.
    --> Calculating `net_radiation_soil`.
    --> Calculating `soil_resistance`.
    --> Calculating `initial_soil_aerodynamic_resistance`.
    --> Calculating `initial_friction_velocity_soil_daily`.
    --> Calculating `soil_thermal_conductivity`.
    --> Calculating `volumetric_heat_capacity`.
    --> Calculating `damping_depth`.
    --> Calculating `bare_soil_heat_flux`.
    --> Calculating `soil_heat_flux`.
    --> Calculating `initial_daily_evaporation`.
    --> Calculating `initial_sensible_heat_flux_soil_daily`.
    --> Calculating `evaporation`.
    --> Calculating `evaporation_mm`.
    --> Calculating `et_actual_mm`.
    --> Calculating `net_radiation_grass`.
    --> Calculating `et_reference`.
    --> Calculating `et_reference_mm`.
    --> Calculating `air_temperature_kelvin_daily`.
    --> Calculating `air_temperature_kelvin`.
    --> Calculating `air_temperature_kelvin_daily`.
    --> Calculating `air_temperature_kelvin`.
    --> Calculating `mean_temperature_kelvin_daytime`.
    --> Calculating `temperature_dependency`.
    --> Calculating `affinity_constant_co2`.
    --> Calculating `inhibition_constant_o2`.
    --> Calculating `co2_o2_specificity_ratio`.
    --> Calculating `co2_level_annual`.
    --> Calculating `autotrophic_respiration`.
    --> Calculating `par`.
    --> Calculating `fpar`.
    --> Calculating `co2_fertilisation`.
    --> Calculating `net_primary_production_max`.
    --> Calculating `net_primary_production`.
    --> Saving output to `et_look_out.nc`.
        > peak-memory-usage: 334.9MB, execution-time: 0:00:04.382046.
        > chunksize|dimsize: [time_bins: 1|1, y: 403|403, x: 506|506]
< ET_LOOK (0:00:08.456798)

Now ds_out_all contains all the variables calculated by ET_Look.

[17]:
list(ds_out_all.data_vars)
[17]:
['ndvi',
 'r0',
 'se_root',
 'p_24',
 'z',
 'ra_24',
 't_air_24',
 't_air_max_24',
 't_air_min_24',
 'u2m_24',
 'v2m_24',
 'qv_24',
 'p_air_24',
 'p_air_0_24',
 'wv_24',
 'land_mask',
 'rs_min',
 'z_obst_max',
 'lw_offset',
 'lw_slope',
 'z_oro',
 'rn_offset',
 'rn_slope',
 't_amp_year',
 't_opt',
 'vpd_slope',
 't_diff',
 'doy',
 'nd_min',
 'nd_max',
 'vc_pow',
 'vc_min',
 'vc_max',
 'lai_pow',
 'diffusion_slope',
 'diffusion_intercept',
 't_min',
 't_max',
 'vp_slope',
 'vp_offset',
 'int_max',
 'tenacity',
 'rcan_max',
 'ndvi_obs_min',
 'ndvi_obs_max',
 'obs_fr',
 'z_obs',
 'z_b',
 'c1',
 'iter_h',
 'r_soil_pow',
 'r_soil_min',
 'se_top',
 'porosity',
 'r0_grass',
 'eps_a',
 'z0m_full',
 'z0m_bare',
 'aod550_i',
 'fraction_h_bare',
 'fraction_h_full',
 'disp_bare',
 'disp_full',
 'r0_bare_wet',
 'IO',
 'dh_ap',
 'd_s',
 'dh_dp',
 'ar_slo',
 'ar_int',
 'fpar_slope',
 'fpar_offset',
 'o2',
 'co2_ref',
 'gcgdm',
 'phot_eff',
 'r0_bare',
 'r0_full',
 'ad_24',
 'ad_dry_24',
 'ad_moist_24',
 'dd',
 'decl',
 'disp',
 'e_24',
 'e_24_init',
 'e_24_mm',
 'et_24_mm',
 'et_ref_24',
 'et_ref_24_mm',
 'g0_24',
 'g0_bs',
 'h_canopy_24_init',
 'h_soil_24_init',
 'iesd',
 'int_mm',
 'int_wm2',
 'l_net',
 'lai',
 'lai_eff',
 'lat_rad',
 'lh_24',
 'npp',
 'apar',
 'p_air_0_24_mbar',
 'psy_24',
 'r_canopy',
 'r_canopy_0',
 'r_soil',
 'ra_24_toa_flat',
 'ra_canopy_init',
 'ra_soil_init',
 'rn_24',
 'rn_24_canopy',
 'rn_24_grass',
 'rn_24_soil',
 'sf_soil',
 'ssvp_24',
 'stc',
 'stress_moist',
 'stress_rad',
 'stress_temp',
 'stress_vpd',
 'svp_24',
 't_24',
 't_24_init',
 't_24_mm',
 't_air_k_24',
 'trans_24',
 'u_24',
 'u_b_24',
 'u_star_24_init',
 'u_star_24_soil_init',
 'vc',
 'vhc',
 'vp_24',
 'vpd_24',
 'ws',
 'z0m',
 'z_obst',
 'tau_co2_o2',
 'year',
 't_air_k_min',
 't_air_k_max',
 't_air_k_12',
 't_dep',
 'k_m',
 'k_0',
 'npp_max',
 'co2_fert',
 'f_par',
 'a_d',
 'co2_act']