#!/usr/bin/env python
# coding: utf-8
#
# # Polytope Client
#
# ## Installation on Jupyterhub
# Open the terminal and install from source (not yet available on pypi):
# ```
# cd /shared/eduard/polytope-client
# python3.6 setup.py sdist
# python3.6 -m pip install dist/polytope_client-0.1.0.tar.gz --user
# ```
# In[ ]:
from polytope_client import api
c = api.Client()
# you will be prompted for a password the first time
# and a token will be stored locally
c.set_config(key="username", value="")
# In[ ]:
filename = '/shared/eduard/polytope_request_test.grib'
request = """
collection = fc,
stream = oper,
levtype = sfc,
param = 165.128/166.128/167.128,
dataset = interim,
step = 0,
grid = 0.75/0.75,
time = 00/06/12/18,
date = 2015-03-23/to/2015-03-24,
type = an,
class = ei,
expver = 0001,
target = """
c.retrieve(request = request, output_file = filename, inline_request = True)
# In[ ]:
import xarray as xr
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# read dwd grib data from local directory
tmp = xr.open_dataset(filename, engine='cfgrib')
# In[4]:
tmp
# In[5]:
tmp.t2m.sel(time='2015-03-24T18:00:00').plot(x="longitude", y="latitude")
# In[6]:
tmp.t2m.plot(x="longitude", y="latitude", col="time", col_wrap=4)