<jupyter_start><jupyter_text>A notebook to check daymet dataThe purpose of this notebook is to open and check some DayMet data that will be used to locate a point at which I will run the Biome-BGC biogeochemical model. Here we are just using xarray utilities to open, compute some quick stats on, and plot data in the DayMet tile in which Reynolds Creek CZO falls.  1. Dependencies and DeclarationsThe following libraries are required for this Jupyter notebook:* Numpy - for loading, saving arrays* xArray - for data management and statistical analysis of large netcdf dataset* Matplotlib - for plotting result<jupyter_code>import numpy as np
import xarray as xr
import matplotlib.pyplot as plt

DaymetPath = '/Users/lejoflores/data/daymet/'

prcpName = 'prcp_1980-2018.nc'
tmaxName = 'tmax_1980-2018.nc'
tminName = 'tmin_1980-2018.nc'<jupyter_output><empty_output><jupyter_text>2. Construct the file name<jupyter_code>prcp_file = DaymetPath + prcpName
print(prcp_file)<jupyter_output>/Users/lejoflores/data/daymet/prcp_1980-2018.nc<jupyter_text>3. Open the dataset as an xarray dataset<jupyter_code>ds = xr.open_dataset(prcp_file)
print(ds)<jupyter_output><xarray.Dataset>
Dimensions:                  (nv: 2, time: 14235, x: 195, y: 238)
Coordinates:
  * x                        (x) float64 -1.411e+06 -1.41e+06 -1.409e+06 ...
  * y                        (y) float64 3.06e+05 3.05e+05 3.04e+05 3.03e+05 ...
  * time                     (time) datetime64[ns] 1980-01-01T12:00:00 ...
    lat                      (y, x) float64 ...
    lon                      (y, x) float64 ...
Dimensions without coordinates: nv
Data variables:
    lambert_conformal_conic  int16 ...
    yearday                  (time) int16 ...
    prcp                     (time, y, x) float64 ...
    time_bnds                (time, nv) float64 ...
Attributes:
    tileid:            11912
    start_year:        1980
    source:            Daymet Software Version 3.0
    Version_software:  Daymet Software Version 3.0
    Version_data:      Daymet Data Version 3.0
    Conventions:       CF-1.6
    citation:          Please see http://daymet.ornl.gov/ for current Daymet ...
    [...]<jupyter_text>4. Get the latitude and longitude arrays, verify, and plot them<jupyter_code>lat = ds['lat']
lon = ds['lon']

print(lat.shape)
print(lon.shape)

plt.figure(figsize=(8,6)) 
plt.imshow(lat)
plt.show()
plt.figure(figsize=(8,6))
plt.imshow(lon)
plt.show()<jupyter_output><empty_output><jupyter_text>5. Group the dataset by year and take the mean through time<jupyter_code>ds_ann = ds.groupby('time.year').mean('time')
ds_mean_ann = ds_ann.mean('year')
print(ds_mean_ann)<jupyter_output><xarray.Dataset>
Dimensions:                  (nv: 2, x: 195, y: 238)
Coordinates:
  * x                        (x) float64 -1.411e+06 -1.41e+06 -1.409e+06 ...
  * y                        (y) float64 3.06e+05 3.05e+05 3.04e+05 3.03e+05 ...
    lat                      (y, x) float64 43.9 43.9 43.9 43.91 43.91 43.91 ...
    lon                      (y, x) float64 -118.6 -118.6 -118.6 -118.5 ...
Dimensions without coordinates: nv
Data variables:
    lambert_conformal_conic  float64 -3.277e+04
    yearday                  float64 182.0
    prcp                     (y, x) float64 nan nan nan nan nan nan nan nan ...
    time_bnds                (nv) float64 7.122e+03 7.123e+03<jupyter_text>6. Compute the mean annual precipitation<jupyter_code>MeanAnnPrcp = ds_mean_ann['prcp'].values

plt.figure(figsize=(16,12))
plt.imshow(MeanAnnPrcp*365.0)
plt.colorbar()
plt.show()<jupyter_output><empty_output><jupyter_text>7. Also get and plot min, max, and coefficient of variation<jupyter_code>ds_max_ann = ds_ann.max('year')
ds_min_ann = ds_ann.min('year')
MaxAnnPrcp = ds_max_ann['prcp'].values
MinAnnPrcp = ds_min_ann['prcp'].values

plt.figure(figsize=(16,12))
plt.imshow(MaxAnnPrcp*365.0)
plt.colorbar()
plt.show()

plt.figure(figsize=(16,12))
plt.imshow(MinAnnPrcp*365.0)
plt.colorbar()
plt.show()
ds_cv_ann = ds_ann.std('year')/ds_ann.mean('year')
CVAnnPrcp = ds_cv_ann['prcp'].values

plt.figure(figsize=(16,12))
plt.imshow(CVAnnPrcp*100.0)
plt.colorbar()
plt.show()<jupyter_output><empty_output><jupyter_text>8. Do the same for $T_{max}$  and $T_{min}$<jupyter_code>tmax_file = DaymetPath + tmaxName
tmin_file = DaymetPath + tminName

ds_tmax = xr.open_dataset(tmax_file)
ds_tmin = xr.open_dataset(tmin_file)

ds_tmax_ann = ds_tmax.groupby('time.year').mean('time')
ds_tmin_ann = ds_tmin.groupby('time.year').mean('time')

ds_tmax_mean_ann = ds_tmax_ann.mean('year')
ds_tmin_mean_ann = ds_tmin_ann.mean('year')

MeanAnnTmax = ds_tmax_mean_ann['tmax'].values
MeanAnnTmin = ds_tmin_mean_ann['tmin'].values

plt.figure(figsize=(16,12))
plt.imshow(MeanAnnTmax)
plt.colorbar()
plt.show()

plt.figure(figsize=(16,12))
plt.imshow(MeanAnnTmin)
plt.colorbar()
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12564366632337795, 'fraction_numerical': 0.06199794026776519, 'mean_word_length': 3.263388937664618, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '44245', 'license': 'MIT', 'n_tokens_mistral': 2036, 'n_tokens_neox': 1788, 'n_words': 397, 'path': 'DaymetNotebooks/Check Daymet Data.ipynb', 'repo_name': 'LEAF-BoiseState/Biome-BGC-Wrapper-Scripts', 'size': '4855'}