-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
50 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,25 @@ | ||
title: 'Global Precipitation Climatology Project' | ||
title: Daymet | ||
description: > | ||
Global Precipitation Climatology Project (GPCP) Daily Version 1.3 gridded, merged ty | ||
satellite/gauge precipitation Climate data Record (CDR) from 1996 to present. | ||
Daily Surface Weather and Climatological Summaries (Daymet) provides | ||
long-term, continuous, gridded estimates of daily weather and climatology | ||
variables by interpolating and extrapolating ground-based observations through | ||
statistical modeling techniques. The Daymet data products provide driver data | ||
for biogeochemical terrestrial modeling and have myriad applications in many | ||
Earth science, natural resource, biodiversity, and agricultural research | ||
areas. Daymet weather variables include daily minimum and maximum temperature, | ||
precipitation, vapor pressure, shortwave radiation, snow water equivalent, and | ||
day length produced on a 1 km x 1 km gridded surface over continental North | ||
America and Hawaii from 1980 and over Puerto Rico from 1950 through the end of | ||
the most recent full calendar year. | ||
pangeo_forge_version: '0.9.0' | ||
pangeo_notebook_version: '2022.06.02' | ||
recipes: | ||
- id: gpcp-from-gcs | ||
object: 'recipe:recipe' | ||
provenance: | ||
providers: | ||
- name: 'NOAA NCEI' | ||
description: 'National Oceanographic & Atmospheric Administration National Centers for Environmental Information' | ||
roles: | ||
- host | ||
- licensor | ||
url: https://www.ncei.noaa.gov/products/global-precipitation-climatology-project | ||
- name: 'University of Maryland' | ||
description: > | ||
University of Maryland College Park Earth System Science Interdisciplinary Center | ||
(ESSIC) and Cooperative Institute for Climate and Satellites (CICS). | ||
roles: | ||
- producer | ||
url: http://gpcp.umd.edu/ | ||
dict_object: recipe:recipes | ||
provenance: {} | ||
license: 'No constraints on data access or use.' | ||
maintainers: | ||
- name: 'Charles Stern' | ||
orcid: '0000-0002-4078-0852' | ||
github: cisaacstern | ||
- name: 'Charles Stern' | ||
orcid: '0000-0002-4078-0852' | ||
github: cisaacstern | ||
bakery: | ||
id: 'pangeo-ldeo-nsf-earthcube' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,73 @@ | ||
import datetime | ||
import enum | ||
import os | ||
|
||
from pangeo_forge_recipes import patterns | ||
from pangeo_forge_recipes.recipes import XarrayZarrRecipe | ||
|
||
|
||
# class Region(str, enum.Enum): | ||
# NA = 'na' | ||
# PR = 'pr' | ||
# HI = 'hi' | ||
|
||
|
||
# class Frequency(str, enum.Enum): | ||
# DAY = 'daily' | ||
# MONTH = 'mon' | ||
# YEAR = 'ann' | ||
|
||
|
||
AGG_VARIABLES = {'prcp', 'swe', 'tmax', 'tmin', 'vp'} | ||
DAILY_VARIABLES = AGG_VARIABLES | {'dayl', 'srad'} | ||
|
||
def make_recipe(region, frequency): | ||
""" | ||
Make a daymet recipe for given region with given frequency. | ||
def make_format_function(region: str, frequency: str): | ||
region is "na", "pr" or "hi" | ||
frequency is "daily", "mon" (monthly) or "ann" (yearly) | ||
""" | ||
# Aggregate variables available | ||
AGG_VARIABLES = {'prcp', 'swe', 'tmax', 'tmin', 'vp'} | ||
# We have a few more variables available daily, in addition to the aggregate ones | ||
DAILY_VARIABLES = AGG_VARIABLES | {'dayl', 'srad'} | ||
if frequency in {"mon", "ann"}: | ||
|
||
if frequency in {'mon', 'ann'}: | ||
# Aggregated data - monthly or annual | ||
variables = list(AGG_VARIABLES) | ||
|
||
if frequency == 'ann': | ||
nitems_per_file = 1 | ||
kwargs = dict() | ||
else: | ||
nitems_per_file = 12 | ||
kwargs = dict(subset_inputs={'time': 12}) | ||
|
||
def format_function(variable, time): | ||
# https://thredds.daac.ornl.gov/thredds/fileServer/ornldaac/1855/daymet_v4_prcp_monttl_hi_1980.nc | ||
assert variable in AGG_VARIABLES | ||
|
||
folder = '1852' if frequency == "ann" else '1855' | ||
folder = '1852' if frequency == 'ann' else '1855' | ||
if variable == 'prcp': | ||
agg = 'ttl' | ||
else: | ||
agg = 'avg' | ||
return f'https://thredds.daac.ornl.gov/thredds/fileServer/ornldaac/{folder}/daymet_v4_{variable}_{frequency}{agg}_{region}_{time:%Y}.nc' | ||
|
||
else: | ||
variables = list(DAILY_VARIABLES) | ||
nitems_per_file = 365 | ||
kwargs = dict(subset_inputs={'time': 365}) | ||
|
||
def format_function(variable, time): | ||
assert variable in DAILY_VARIABLES | ||
# https://thredds.daac.ornl.gov/thredds/fileServer/ornldaac/1840/daymet_v4_daily_hi_dayl_1980.nc | ||
return f'https://thredds.daac.ornl.gov/thredds/fileServer/ornldaac/1840/daymet_v4_{frequency}_{region}_{variable}_{time:%Y}.nc' | ||
|
||
return format_function | ||
|
||
|
||
def make_recipe(region, frequency): | ||
AGG_VARIABLES = {'prcp', 'swe', 'tmax', 'tmin', 'vp'} | ||
DAILY_VARIABLES = AGG_VARIABLES | {'dayl', 'srad'} | ||
if frequency == "daily": | ||
variables = list(DAILY_VARIABLES) | ||
nitems_per_file = 365 | ||
kwargs = dict(subset_inputs={'time': 365}) | ||
else: | ||
variables = list(AGG_VARIABLES) | ||
|
||
if frequency == "ann": | ||
nitems_per_file = 1 | ||
kwargs = dict() | ||
else: | ||
nitems_per_file = 12 | ||
kwargs = dict(subset_inputs={'time': 12}) | ||
|
||
variable_merge_dim = patterns.MergeDim('variable', keys=variables) | ||
|
||
dates = [datetime.datetime(y, 1, 1) for y in range(1980, 2021)] | ||
concat_dim = patterns.ConcatDim('time', keys=dates, nitems_per_file=nitems_per_file) | ||
|
||
pattern = patterns.FilePattern( | ||
make_format_function(region, frequency), variable_merge_dim, concat_dim | ||
format_function(region, frequency), variable_merge_dim, concat_dim | ||
) | ||
|
||
recipe = XarrayZarrRecipe(pattern, copy_input_to_local_file=True, **kwargs) | ||
|
||
return recipe | ||
|
||
|
||
recipe = make_recipe("na", "mon") | ||
regions = ('na', 'hi', 'pr') | ||
frequencies = ('mon', 'ann') | ||
|
||
recipes = {} | ||
|
||
for region in regions: | ||
for freq in frequencies: | ||
id = f'{region}_{freq}' | ||
recipes[id] = make_recipe(region, freq) |