<jupyter_start><jupyter_text>GODAS OpenDAP server connector  This is a connector to the NCEP Global Ocean Data Assimilation System (GODAS) ocean reanalysis.Appropriate citation information can be found on this page http://apdrc.soest.hawaii.edu/datadoc/godas_pentad.php Interaction with the data in python can be done using the xarray library only which we install here<jupyter_code>import sys
!{sys.executable} -m pip install xarray<jupyter_output>Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: xarray in /home/sebastien/.local/lib/python3.6/site-packages (0.16.0)
Requirement already satisfied: setuptools>=41.2 in /home/sebastien/.local/lib/python3.6/site-packages (from xarray) (50.3.2)
Requirement already satisfied: pandas>=0.25 in /home/sebastien/.local/lib/python3.6/site-packages (from xarray) (1.1.1)
Requirement already satisfied: numpy>=1.15 in /home/sebastien/.local/lib/python3.6/site-packages (from xarray) (1.19.1)
Requirement already satisfied: numpy>=1.15 in /home/sebastien/.local/lib/python3.6/site-packages (from xarray) (1.19.1)
Requirement already satisfied: python-dateutil>=2.7.3 in /home/sebastien/.local/lib/python3.6/site-packages (from pandas>=0.25->xarray) (2.8.1)
Requirement already satisfied: pytz>=2017.2 in /home/sebastien/.local/lib/python3.6/site-packages (from pandas>=0.25->xarray) (2020.1)
Requirement already satisfied: six>=1.5 in /home/sebastie[...]<jupyter_text>We can now load the library<jupyter_code>import xarray as xr<jupyter_output><empty_output><jupyter_text>Here we use the opendap server maintained by the Asia-Pacific data-research center at university of Hawaii.The averaging window and grid over which data are available can be explored using the browser using the following url: http://apdrc.soest.hawaii.edu/dods/public_data/Reanalysis_Data/GODASWe select are the 5 day average data on the temperature grid and connect to the dataset.<jupyter_code>dset = xr.open_dataset('http://apdrc.soest.hawaii.edu:80/dods/public_data/Reanalysis_Data/GODAS/pentad/tgrid')<jupyter_output><empty_output><jupyter_text>A number of variables are available from that url<jupyter_code>for var_name in dset.data_vars:
    print(var_name, dset.variables[var_name].attrs['long_name'])<jupyter_output>potdsl ** (profile) potential temp. [k] 
dbssbmxl ** bottom ocn mixed layer geometric depth below sea surface [m] 
dbssbitl ** bottom ocn isothermal layer geometric depth below sea surface [m] 
saltydsl ** (profile) salinity [kg/kg] 
sltflsfc ** surface salt flux [g/cm^2/s] 
sshgsfc ** surface sea surface height relative to geoid [m] 
thflxsfc ** surface total downward heat flux at surface [w/m^2]<jupyter_text>Let's select the potential temperature. The field is a 3D field and has 3 dimensions of space (lon:longitude. lat:latitude, lev:depth) and one of time<jupyter_code>print(dset.potdsl.dims)<jupyter_output>('time', 'lev', 'lat', 'lon')<jupyter_text>More information on the dimensions can be found in the dataset object<jupyter_code>print("Level dimension:", dset.lev)
print("Time dimension:", dset.time)<jupyter_output>Level dimension: <xarray.DataArray 'lev' (lev: 40)>
array([   5.,   15.,   25.,   35.,   45.,   55.,   65.,   75.,   85.,   95.,
        105.,  115.,  125.,  135.,  145.,  155.,  165.,  175.,  185.,  195.,
        205.,  215.,  225.,  238.,  262.,  303.,  366.,  459.,  584.,  747.,
        949., 1193., 1479., 1807., 2174., 2579., 3016., 3483., 3972., 4478.])
Coordinates:
  * lev      (lev) float64 5.0 15.0 25.0 35.0 ... 3.483e+03 3.972e+03 4.478e+03
Attributes:
    grads_dim:      z
    grads_mapping:  levels
    units:          millibar
    long_name:      altitude
    minimum:        5.0
    maximum:        4478.0
    resolution:     114.69231
Time dimension: <xarray.DataArray 'time' (time: 2967)>
array(['1980-01-05T00:00:00.000000000', '1980-01-10T00:00:00.000000000',
       '1980-01-15T00:00:00.000000000', ..., '2020-08-13T00:00:00.000000000',
       '2020-08-18T00:00:00.000000000', '2020-08-23T00:00:00.000000000'],
      dtype='datetime64[ns]')
Coordinates:
  * time     (time) dat[...]<jupyter_text>Here we can load the data for the first level (nearest to the surface and for the first time stamp) and plot it.<jupyter_code>%matplotlib inline
dset.potdsl.isel(time=0,lev=0).plot()<jupyter_output><empty_output><jupyter_text>We can also load the data for down to 2000m (levels 0 to 35) and write them to disk in compressed netCDF format<jupyter_code>dset.potdsl.isel(time=0,lev=slice(0,35)).to_netcdf('/tmp/temp_file.nc',
                                                   encoding={'potdsl':{'zlib': True,
                                                             'complevel': 4}})<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.126207475850483, 'fraction_numerical': 0.08399832003359933, 'mean_word_length': 3.9357512953367877, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 6, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '606042', 'license': 'MIT', 'n_tokens_mistral': 1873, 'n_tokens_neox': 1622, 'n_words': 435, 'path': 'data_connectors/GODAS_connector/GODAS.ipynb', 'repo_name': 'metocean/TAIAO', 'size': '4762'}