0. Prepare Demos

Download sample data and set up parameter files

This Notebook sets up the data for the other demos. It is recommended that you run this and other demos in a conda environment with xcdat and pcmdi_metrics installed. The files to download are listed in https://pcmdiweb.llnl.gov/pss/pmpdata/pmp_tutorial_files.v20240201.txt.

[1]:
# Lets get the file containing the data needed for this demo
import requests
r = requests.get("https://pcmdiweb.llnl.gov/pss/pmpdata/pmp_tutorial_files.v20240201.txt")
with open("data_files.txt","wb") as f:
    f.write(r.content)

Now let’s retrieve these sample files locally. Please edit the following to match a good location on your system:

demo_data_directory is a path where you would like to download our demo data
demo_output_directory is a path where you would like the demos output to be dumped.

The last cell in this notebook automatically sets up the parameter files for the other demos to use your chosen demo_data and demo_output directories.

[2]:
# This is where you will be downloading the sample_data
demo_data_directory = "demo_data_tmp"
# this line is where your output will be stored
demo_output_directory = "demo_output_tmp"

In below cell, you are going to download sample input files from PCMDI server. The total size of dataset is about 2 GB, and so please be aware that downloading will take some time to complete.

[3]:
# Let's download the files
from pcmdi_metrics.io.base import download_sample_data_files
try:
    download_sample_data_files("data_files.txt", demo_data_directory)
    print("All files downloaded")
except Exception:
    print("Download failed")
All files downloaded

The final step is to generate parameter files from templates, using the demo_data_directory and demo_output_directory variables set above.

[4]:
from download_sample_data import generate_parameter_files
generate_parameter_files(demo_data_directory, demo_output_directory)
Preparing parameter file: basic_mjo_param.py
Preparing parameter file: basic_mov_param_sst.py
Preparing parameter file: basic_diurnal_composite.py
Preparing parameter file: basic_param.py
Preparing parameter file: basic_diurnal_compute_daily_mean.py
Preparing parameter file: basic_monsoon_sperber_param.py
Preparing parameter file: basic_diurnal_std_daily_mean.py
Preparing parameter file: basic_monsoon_wang_param.py
Preparing parameter file: basic_diurnal_fourier.py
Preparing parameter file: basic_enso_param.py
Preparing parameter file: basic_annual_cycle_param.py
Preparing parameter file: basic_extremes_param.py
Preparing parameter file: basic_diurnal_std_hourly_mean.py
Preparing parameter file: basic_diurnal_fourierAllGrid.py
Preparing parameter file: basic_mov_param.py
Preparing parameter file: basic_precip_variability_param.py
Saving User Choices

You’re done! Please proceed to the next tutorial