Daymet
In [1]:
Copied!
from springtime.datasets.meteo.daymet import DaymetSinglePoint, DaymetMultiplePoints, DaymetBoundingBox
from springtime.datasets.meteo.daymet import DaymetSinglePoint, DaymetMultiplePoints, DaymetBoundingBox
Data at a single point¶
In [2]:
Copied!
# The latitude of Washington, the USA is 47.751076, and the longitude is -120.740135
target_lat = 47.751076
target_lon = -120.740135
# The latitude of Washington, the USA is 47.751076, and the longitude is -120.740135
target_lat = 47.751076
target_lon = -120.740135
In [3]:
Copied!
# Create a dataset instance
dataset = DaymetSinglePoint(point=(target_lon,target_lat), years=[1990, 2020])
dataset
# Create a dataset instance
dataset = DaymetSinglePoint(point=(target_lon,target_lat), years=[1990, 2020])
dataset
Out[3]:
DaymetSinglePoint(dataset='daymet_single_point', years=YearRange(start=1990, end=2020), variables=(), point=(-120.740135, 47.751076))
In [4]:
Copied!
# Download dataset
dataset.download()
# Download dataset
dataset.download()
In [5]:
Copied!
# Load downloded data as a dataframe
df = dataset.load()
df.head()
# Load downloded data as a dataframe
df = dataset.load()
df.head()
Out[5]:
datetime | geometry | dayl | prcp | srad | swe | tmax | tmin | vp | |
---|---|---|---|---|---|---|---|---|---|
0 | 1990-01-01 | POINT (-120.74013 47.75108) | 29818.61 | 12.68 | 86.56 | 66.10 | 2.14 | -2.68 | 501.57 |
1 | 1990-01-02 | POINT (-120.74013 47.75108) | 29875.77 | 10.44 | 114.20 | 66.00 | 1.47 | -5.76 | 397.66 |
2 | 1990-01-03 | POINT (-120.74013 47.75108) | 29937.57 | 7.58 | 98.15 | 65.27 | 1.33 | -4.27 | 445.06 |
3 | 1990-01-04 | POINT (-120.74013 47.75108) | 30003.96 | 15.35 | 111.24 | 63.49 | 5.19 | -1.76 | 537.01 |
4 | 1990-01-05 | POINT (-120.74013 47.75108) | 30074.88 | 11.16 | 109.80 | 61.99 | 4.23 | -2.43 | 510.71 |
Data at a single point and single variable¶
In [ ]:
Copied!
# The latitude of Washington, the USA is 47.751076, and the longitude is -120.740135
target_lat = 47.751076
target_lon = -120.740135
# The latitude of Washington, the USA is 47.751076, and the longitude is -120.740135
target_lat = 47.751076
target_lon = -120.740135
In [6]:
Copied!
# Create a dataset instance
dataset = DaymetSinglePoint(point=(target_lon,target_lat), years=[1990, 2020], variables=("tmin",))
dataset
# Create a dataset instance
dataset = DaymetSinglePoint(point=(target_lon,target_lat), years=[1990, 2020], variables=("tmin",))
dataset
Out[6]:
DaymetSinglePoint(dataset='daymet_single_point', years=YearRange(start=1990, end=2020), variables=('tmin',), point=(-120.740135, 47.751076))
In [7]:
Copied!
# Download dataset
dataset.download()
# Download dataset
dataset.download()
In [8]:
Copied!
# Load downloded data as a dataframe
df_wa_point = dataset.load()
# df_wa_point.head()
df_wa_point
# Load downloded data as a dataframe
df_wa_point = dataset.load()
# df_wa_point.head()
df_wa_point
Out[8]:
datetime | geometry | tmin | |
---|---|---|---|
0 | 1990-01-01 | POINT (-120.74013 47.75108) | -2.68 |
1 | 1990-01-02 | POINT (-120.74013 47.75108) | -5.76 |
2 | 1990-01-03 | POINT (-120.74013 47.75108) | -4.27 |
3 | 1990-01-04 | POINT (-120.74013 47.75108) | -1.76 |
4 | 1990-01-05 | POINT (-120.74013 47.75108) | -2.43 |
... | ... | ... | ... |
11310 | 2020-12-26 | POINT (-120.74013 47.75108) | -5.66 |
11311 | 2020-12-27 | POINT (-120.74013 47.75108) | -3.84 |
11312 | 2020-12-28 | POINT (-120.74013 47.75108) | -4.36 |
11313 | 2020-12-29 | POINT (-120.74013 47.75108) | -4.93 |
11314 | 2020-12-30 | POINT (-120.74013 47.75108) | -3.71 |
11315 rows × 3 columns
Data from a bounding box¶
In [ ]:
Copied!
# Create a bounding box
# top left / bottom right pair (lat,lon,lat,lon)
area = {'name': 'indianapolis', 'bbox': [-86.5,39.5, -86, 40.1]}
# Create an instance of dataset
dataset = DaymetBoundingBox(area=area, years=[2019, 2020])
dataset
# Create a bounding box
# top left / bottom right pair (lat,lon,lat,lon)
area = {'name': 'indianapolis', 'bbox': [-86.5,39.5, -86, 40.1]}
# Create an instance of dataset
dataset = DaymetBoundingBox(area=area, years=[2019, 2020])
dataset
Out[ ]:
DaymetBoundingBox(dataset='daymet_bounding_box', years=YearRange(start=2019, end=2020), area=NamedArea(name='indianapolis', bbox=BoundingBox(xmin=-86.5, ymin=39.5, xmax=-86.0, ymax=40.1)), mosaic='na', variables=('dayl', 'prcp', 'srad', 'swe', 'tmax', 'tmin', 'vp'), frequency='daily')
In [ ]:
Copied!
# Download data
dataset.download()
# Download data
dataset.download()
|======================================================================| 100% |======================================================================| 100% |======================================================================| 100% |======================================================================| 100% |======================================================================| 100% |======================================================================| 100% |======================================================================| 100% |======================================================================| 100%
Function call took more than 120 seconds, retrying
|======================================================================| 100% |======================================================================| 100% |======================================================================| 100% |======================================================================| 100% |======================================================================| 100% |======================================================================| 100% |======================================================================| 100% |======================================================================| 100% |======================================================================| 100% |======================================================================| 100% |======================================================================| 100% |======================================================================| 100% |======================================================================| 100% |======================================================================| 100%
In [ ]:
Copied!
# Load data as a xarray.Dataset
xa_wa = dataset.load()
xa_wa
# Load data as a xarray.Dataset
xa_wa = dataset.load()
xa_wa
Out[ ]:
<xarray.Dataset> Dimensions: (y: 70, x: 52, time: 1095) Coordinates: * y (y) float32 -159.0 -160.0 -161.0 ... -227.0 -228.0 * x (x) float32 1.095e+03 1.096e+03 ... 1.146e+03 * time (time) datetime64[ns] 2018-01-01T12:00:00 ... 20... Data variables: lat (time, y, x) float32 dask.array<chunksize=(365, 70, 52), meta=np.ndarray> lambert_conformal_conic (time) float64 -3.277e+04 -3.277e+04 ... -3.277e+04 lon (time, y, x) float32 dask.array<chunksize=(365, 70, 52), meta=np.ndarray> dayl (time, y, x) float32 dask.array<chunksize=(730, 70, 52), meta=np.ndarray> prcp (time, y, x) float32 dask.array<chunksize=(730, 70, 52), meta=np.ndarray> srad (time, y, x) float32 dask.array<chunksize=(730, 70, 52), meta=np.ndarray> swe (time, y, x) float32 dask.array<chunksize=(730, 70, 52), meta=np.ndarray> tmax (time, y, x) float32 dask.array<chunksize=(730, 70, 52), meta=np.ndarray> tmin (time, y, x) float32 dask.array<chunksize=(365, 70, 52), meta=np.ndarray> vp (time, y, x) float32 dask.array<chunksize=(730, 70, 52), meta=np.ndarray> Attributes: start_year: 2019 source: Daymet Software Version 4.0 Version_software: Daymet Software Version 4.0 Version_data: Daymet Data Version 4.0 Conventions: CF-1.6 citation: Please see http://daymet.ornl.gov/ for current Dayme... references: Please see http://daymet.ornl.gov/ for current infor... History: Translated to CF-1.0 Conventions by Netcdf-Java CDM ... geospatial_lat_min: 39.43457395273136 geospatial_lat_max: 40.166069168093486 geospatial_lon_min: -86.62665724948563 geospatial_lon_max: -85.85920225420271
Data at multiple points¶
In [ ]:
Copied!
# Create an instance of dataset
points = [(-120.740135, 47.751076), (-120.742, 47.76)]
dataset = DaymetMultiplePoints(points=points, years=[2019, 2020])
dataset
# Create an instance of dataset
points = [(-120.740135, 47.751076), (-120.742, 47.76)]
dataset = DaymetMultiplePoints(points=points, years=[2019, 2020])
dataset
Out[ ]:
DaymetMultiplePoints(dataset='daymet_multiple_points', points=[(-120.740135, 47.751076), (-120.742, 47.76)], years=(2019, 2020))
In [ ]:
Copied!
# Download data
dataset.download()
# Download data
dataset.download()
R version 4.2.2 (2022-10-31) -- "Innocent and Trusting" Copyright (C) 2022 The R Foundation for Statistical Computing Platform: x86_64-conda-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(daymetr) > daymetr::download_daymet( + site = "daymet_single_point_-120.740135_47.751076", + lat = 47.751076, + lon = -120.740135, + start = 2019, + end = 2020, + path="/tmp/data", + internal = FALSE)
Downloading DAYMET data for: daymet_single_point_-120.740135_47.751076 at 47.751076/-120.740135 latitude/longitude ! Done !
> > R version 4.2.2 (2022-10-31) -- "Innocent and Trusting" Copyright (C) 2022 The R Foundation for Statistical Computing Platform: x86_64-conda-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(daymetr) > daymetr::download_daymet( + site = "daymet_single_point_-120.742_47.76", + lat = 47.76, + lon = -120.742, + start = 2019, + end = 2020, + path="/tmp/data", + internal = FALSE)
Downloading DAYMET data for: daymet_single_point_-120.742_47.76 at 47.76/-120.742 latitude/longitude !
> >
Done !
In [ ]:
Copied!
# Load data as a dataframe
xa_wa = dataset.load()
xa_wa
# Load data as a dataframe
xa_wa = dataset.load()
xa_wa
Out[ ]:
<xarray.Dataset> Dimensions: (y: 70, x: 52, time: 1095) Coordinates: * y (y) float32 -159.0 -160.0 -161.0 ... -227.0 -228.0 * x (x) float32 1.095e+03 1.096e+03 ... 1.146e+03 * time (time) datetime64[ns] 2018-01-01T12:00:00 ... 20... Data variables: lat (time, y, x) float32 dask.array<chunksize=(365, 70, 52), meta=np.ndarray> lambert_conformal_conic (time) float64 -3.277e+04 -3.277e+04 ... -3.277e+04 lon (time, y, x) float32 dask.array<chunksize=(365, 70, 52), meta=np.ndarray> dayl (time, y, x) float32 dask.array<chunksize=(730, 70, 52), meta=np.ndarray> prcp (time, y, x) float32 dask.array<chunksize=(730, 70, 52), meta=np.ndarray> srad (time, y, x) float32 dask.array<chunksize=(730, 70, 52), meta=np.ndarray> swe (time, y, x) float32 dask.array<chunksize=(730, 70, 52), meta=np.ndarray> tmax (time, y, x) float32 dask.array<chunksize=(730, 70, 52), meta=np.ndarray> tmin (time, y, x) float32 dask.array<chunksize=(365, 70, 52), meta=np.ndarray> vp (time, y, x) float32 dask.array<chunksize=(730, 70, 52), meta=np.ndarray> Attributes: start_year: 2019 source: Daymet Software Version 4.0 Version_software: Daymet Software Version 4.0 Version_data: Daymet Data Version 4.0 Conventions: CF-1.6 citation: Please see http://daymet.ornl.gov/ for current Dayme... references: Please see http://daymet.ornl.gov/ for current infor... History: Translated to CF-1.0 Conventions by Netcdf-Java CDM ... geospatial_lat_min: 39.43457395273136 geospatial_lat_max: 40.166069168093486 geospatial_lon_min: -86.62665724948563 geospatial_lon_max: -85.85920225420271
In [ ]:
Copied!