test opening HSDS "file" with xarray

In [1]:
%matplotlib inline
import xarray as xr
In [2]:
endpoint = 'http://149.165.156.174:5101'
xsede_hsds_file = '/home/john/tmp2m_2months.nc'
#xsede_hsds_file = '/home/rsignell/tmp2m_2017.nc'
hsds_url = endpoint + xsede_hsds_file
print(hsds_url)
http://149.165.156.174:5101/home/john/tmp2m_2months.nc
In [3]:
ds = xr.open_dataset(hsds_url, engine='h5netcdf')
In [4]:
ds
Out[4]:
<xarray.Dataset>
Dimensions:            (latitude: 880, longitude: 1760, time: 1416)
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) float64 1.483e+09 1.483e+09 1.483e+09 ...
Data variables:
    TMP_2maboveground  (time, latitude, longitude) float64 ...
Attributes:
    GRIB2_grid_template:       [40]
    nco_openmp_thread_number:  [1]
In [5]:
dsloc = ds.sel(longitude=-70.6+360, latitude=41.55, method='nearest')

dsloc['TMP_2maboveground'].plot();
/notebooks/rsignell/my-conda-envs/h5pyd/lib/python3.6/site-packages/xarray/plot/utils.py:51: FutureWarning: 'pandas.tseries.converter.register' has been moved and renamed to 'pandas.plotting.register_matplotlib_converters'. 
  converter.register()

Read time series from local netcdf4 file

In [6]:
nc_url = '/notebooks/rsignell/data/CFSR/tmp2m_2months.nc'
ds2 = xr.open_dataset(nc_url)
dsloc2 = ds2.sel(longitude=-70.6+360, latitude=41.55, method='nearest')
dsloc2['TMP_2maboveground'].plot();

Read time series using NetCDF Subset Service as Points

In [ ]:
import pandas as pd
url = 'https://js-170-55.jetstream-cloud.org/thredds/ncss/grib/CFSr_v2/tmp2m?latitude=24.&longitude=24.&time_start=2017-01-01T01%3A00%3A00Z&time_end=2017-12-01T00%3A00%3A00Z&vertCoord=&accept=csv'
df = pd.read_csv(url)

Open dataset on OPeNDAP with Xarray

In [ ]:
dap_url = 'http://js-170-55.jetstream-cloud.org/thredds/dodsC/grib/CFSr_v2/tmp2m'
In [ ]:
ds2 = xr.open_dataset(dap_url)