#!/usr/bin/env python # coding: utf-8 # # test opening HSDS "file" with xarray # In[1]: get_ipython().run_line_magic('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) # In[3]: ds = xr.open_dataset(hsds_url, engine='h5netcdf') # In[4]: ds # In[5]: dsloc = ds.sel(longitude=-70.6+360, latitude=41.55, method='nearest') dsloc['TMP_2maboveground'].plot(); # ## 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) # In[ ]: