%matplotlib inline
import xarray as xr
import h5pyd
import warnings
warnings.simplefilter('ignore')
h5pyd.getServerInfo()
{'about': 'HSDS is a webservice for HSDS data', 'endpoint': 'http://149.165.156.12:5101', 'greeting': 'Welcome to HSDS!', 'hsds_version': '0.1', 'name': 'HSDS XSEDE Jetstream', 'password': '***************', 'start_time': 1515637934, 'state': 'READY', 'username': 'rsignell'}
chunk_size=1
in time¶url_hsds = 'http://149.165.156.12:5101/home/rsignell/tmp2m_2017_rechunked_1.nc'
ds_hsds = xr.open_dataset(url_hsds, engine='h5netcdf', decode_cf=True)
ds_hsds
<xarray.Dataset> Dimensions: (latitude: 880, longitude: 1760, time: 8016) Coordinates: * latitude (latitude) float64 -89.84 -89.64 -89.44 -89.23 -89.03 ... * longitude (longitude) float64 0.0 0.2045 0.4091 0.6136 0.8182 ... * time (time) datetime64[ns] 2017-01-01T01:00:00 ... Data variables: TMP_2maboveground (time, latitude, longitude) float64 ... Attributes: Conventions: COARDS GRIB2_grid_template: 40 History: Fri Dec 22 14:18:00 2017: ncrcat tmp2m.cdas1.2... NCO: 4.7.0 nco_openmp_thread_number: 1
ds_hsds['TMP_2maboveground']
<xarray.DataArray 'TMP_2maboveground' (time: 8016, latitude: 880, longitude: 1760)> [12415180800 values with dtype=float64] Coordinates: * latitude (latitude) float64 -89.84 -89.64 -89.44 -89.23 -89.03 -88.82 ... * longitude (longitude) float64 0.0 0.2045 0.4091 0.6136 0.8182 1.023 ... * time (time) datetime64[ns] 2017-01-01T01:00:00 2017-01-01T02:00:00 ... Attributes: least_significant_digit: 2 level: 2 m above ground long_name: Temperature short_name: TMP_2maboveground units: K
ds_hsds['TMP_2maboveground'].sel(time='2017-01-15 04:00').plot()
<matplotlib.collections.QuadMesh at 0x7fae27b006a0>
start = '2017-01-01'
stop = '2017-03-01'
(lon0, lat0) = (-71.5+360, 41.5)
loc_hsds = ds_hsds.sel(longitude=lon0, latitude=lat0, method='nearest')
d_hsds = loc_hsds.sel(time=slice(start,stop))
%time d_hsds['TMP_2maboveground'].plot(figsize=(12,2));
CPU times: user 84 ms, sys: 4 ms, total: 88 ms Wall time: 12.6 s
[<matplotlib.lines.Line2D at 0x7fae1d152668>]
f = h5pyd.File(url_hsds,'r')
ds = f['TMP_2maboveground']
print(ds.chunks)
[1, 440, 880]
ds_hsds['TMP_2maboveground']
<xarray.DataArray 'TMP_2maboveground' (time: 8016, latitude: 880, longitude: 1760)> [12415180800 values with dtype=float64] Coordinates: * latitude (latitude) float64 -89.84 -89.64 -89.44 -89.23 -89.03 -88.82 ... * longitude (longitude) float64 0.0 0.2045 0.4091 0.6136 0.8182 1.023 ... * time (time) datetime64[ns] 2017-01-01T01:00:00 2017-01-01T02:00:00 ... Attributes: least_significant_digit: 2 level: 2 m above ground long_name: Temperature short_name: TMP_2maboveground units: K
chunk_size=4
in time¶url_hsds = 'http://149.165.156.12:5101/home/rsignell/tmp2m_2017_rechunked.nc'
ds_hsds = xr.open_dataset(url_hsds, engine='h5netcdf', decode_cf=True)
loc_hsds = ds_hsds.sel(longitude=lon0, latitude=lat0, method='nearest')
d_hsds = loc_hsds.sel(time=slice(start,stop))
%time d_hsds['TMP_2maboveground'].plot(figsize=(12,2));
CPU times: user 76 ms, sys: 0 ns, total: 76 ms Wall time: 613 ms
[<matplotlib.lines.Line2D at 0x7fae1d844978>]
f = h5pyd.File(url_hsds,'r')
ds = f['TMP_2maboveground']
ds.chunks
[4, 220, 440]
chunk_size=1
in time¶url_dap = 'http://js-170-55.jetstream-cloud.org/thredds/dodsC/data/CFSR/2017/tmp2m_2months_rechunked_1.nc'
ds_dap = xr.open_dataset(url_dap)
loc_dap = ds_dap.sel(longitude=lon0, latitude=lat0, method='nearest')
d_dap = loc_dap.sel(time=slice(start,stop))
print('Chunk Sizes: ',d_dap['TMP_2maboveground']._ChunkSizes)
%time d_dap['TMP_2maboveground'].plot(figsize=(12,2));
Chunk Sizes: [ 1 440 880] CPU times: user 60 ms, sys: 8 ms, total: 68 ms Wall time: 560 ms
[<matplotlib.lines.Line2D at 0x7fae1d2237b8>]
chunk_size=4
in time¶url_dap = 'http://js-170-55.jetstream-cloud.org/thredds/dodsC/data/CFSR/2017/tmp2m_2months_rechunked_4.nc'
ds_dap = xr.open_dataset(url_dap)
loc_dap = ds_dap.sel(longitude=lon0, latitude=lat0, method='nearest')
d_dap = loc_dap.sel(time=slice(start,stop))
%time d_dap['TMP_2maboveground'].plot(figsize=(12,2));
CPU times: user 80 ms, sys: 0 ns, total: 80 ms Wall time: 597 ms
[<matplotlib.lines.Line2D at 0x7fae1d1ebc88>]
url_dap = 'http://js-170-55.jetstream-cloud.org/thredds/dodsC/data/CFSR/2017/tmp2m_2months.nc'
ds_dap = xr.open_dataset(url_dap)
loc_dap = ds_dap.sel(longitude=lon0, latitude=lat0, method='nearest')
d_dap = loc_dap.sel(time=slice(start,stop))
%time d_dap['TMP_2maboveground'].plot(figsize=(12,2));
CPU times: user 60 ms, sys: 0 ns, total: 60 ms Wall time: 16.6 s
[<matplotlib.lines.Line2D at 0x7fae1d1cbb38>]
url_dap_grb2 = 'http://js-170-55.jetstream-cloud.org/thredds/dodsC/grib/CFSr_v2/tmp2m/Best'
ds_dap_grb2 = xr.open_dataset(url_dap_grb2)
loc_dap_grb2 = ds_dap_grb2.sel(lon=lon0, lat=lat0, method='nearest')
d_dap_grb2 = loc_dap_grb2.sel(time=slice(start,stop))
%time d_dap_grb2['Temperature_height_above_ground'].plot(figsize=(12,2));
url = ('https://js-170-55.jetstream-cloud.org/thredds'
'/ncss/grib/CFSr_v2/tmp2m/Best?var=Temperature_height_above_ground&'
'latitude={}&longitude={}&time_start={}T01%3A00%3A00Z&time_end={}T00%3A00%3A00Z&'
'vertCoord=&accept=csv'.format(lat0,lon0,start,stop))
%time df = pd.read_csv(url, parse_dates=True, index_col='time')
df['Temperature_height_above_ground[unit="K"]'].plot(figsize=(12,2))