Commit cdd618a9 authored by Willi Rath's avatar Willi Rath

Add markdown version

parent 833f21bb
# Using git.geomar.de/data to calculate SSH variance
## Preamble
Import a few modules:
- `pyplot` is loaded by `xarray`, but we need to explicitly modify a dictionary to increase figure size
- `pathlib.Path` is good for handling paths
- `seaborn` makes plots nice
- `xarray` will do the calculations and call the plotting
Then, make plots nicer.
```python
%matplotlib inline
import matplotlib.pyplot as plt
from pathlib import Path
import seaborn as sns
import xarray as xr
```
```python
plt.rcParams['figure.figsize'] = [15, 9]
sns.set_context("notebook", font_scale=1.5, rc={"lines.linewidth": 2.5})
```
## Using a local checkout
In `taurus:/data/c2/TMdata/git_geomar_de_data/`, there's a checkout of `SLTAC_GLO_PHY_L4_REP`, `v1.0.0`. Generate a list of all files for the year 1993 and open all files as one data set and calculate temporal variance of absolute dynamic topography, `adt`.
```python
data_path = Path("/data/c2/TMdata/git_geomar_de_data/")
data_set = "SLTAC_GLO_PHY_L4_REP"
ref = "v1.0.0"
full_path = data_path / data_set / ref / "data"
file_list = [str(fp) for fp in full_path.glob("1993/*.nc")]
```
```python
xr.open_mfdataset(file_list).adt.var(dim="time").plot()
```
/home/wrath/TM/software/miniconda3_20170727/envs/py3_std/lib/python3.6/site-packages/dask/array/reductions.py:279: RuntimeWarning: invalid value encountered in true_divide
u = total / n
/home/wrath/TM/software/miniconda3_20170727/envs/py3_std/lib/python3.6/site-packages/dask/array/numpy_compat.py:45: RuntimeWarning: invalid value encountered in true_divide
x = np.divide(x1, x2, out)
<matplotlib.collections.QuadMesh at 0x7f52a2613278>
![png](example_01_SLTAC_adt_variance_local_and_opendap_files/example_01_SLTAC_adt_variance_local_and_opendap_5_2.png)
## OPeNDAP
There is <https://data.geomar.de/thredds/tmdata/git_geomar_de_data/catalog.html>. Clicking will bring a list of data-file urls (which, lacking a decent crawler, we'll have to improvise here). Open all urls in one dataset and again create the variance plot with `xarray`.
```python
# wave hands and pull a list of urls from somewhere (the local file listing for now...)
base_url = "https://data.geomar.de/thredds/dodsC/tmdata/git_geomar_de_data/SLTAC_GLO_PHY_L4_REP/v1.0.0/data/1993/{file_name}"
url_list = [base_url.format(file_name=fn) for fn in [p.name for p in full_path.glob("1993/*.nc")]]
```
```python
xr.open_mfdataset(url_list).adt.var(dim="time").plot()
```
/home/wrath/TM/software/miniconda3_20170727/envs/py3_std/lib/python3.6/site-packages/dask/array/reductions.py:279: RuntimeWarning: invalid value encountered in true_divide
u = total / n
/home/wrath/TM/software/miniconda3_20170727/envs/py3_std/lib/python3.6/site-packages/dask/array/numpy_compat.py:45: RuntimeWarning: invalid value encountered in true_divide
x = np.divide(x1, x2, out)
<matplotlib.collections.QuadMesh at 0x7f52981def28>
![png](example_01_SLTAC_adt_variance_local_and_opendap_files/example_01_SLTAC_adt_variance_local_and_opendap_8_2.png)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment