Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
*.nc4
*checkpoint.ipynb

examples/TestECMWF.py
examples/multilook_geometry.ipynb
*.BK
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export PYTHONPATH=${PYAPS_HOME}:${PYTHONPATH}
Installing Python dependencies

```
mdkir PyAPS; cd PyAPS
git clone https://github.com/AngeliqueBenoit/pyaps3.git
mkdir PyAPS; cd PyAPS
git clone https://github.com/yunjunz/pyaps3.git

wget https://github.com/ecmwf/cdsapi/archive/v0.1.4.tar.gz -O cdsapi-0.1.4.tar.gz
tar -xvf cdsapi-0.1.4.tar.gz; cd cdsapi-0.1.4
Expand All @@ -29,16 +29,18 @@ python setup.py install

## Account setup for global atmospheric models
### [ERA-5](https://retostauffer.org/code/Download-ERA5/)
ERA-5 data set is redistributed over the Copernicus Climate Data Store (CDS), [create a new account](https://cds.climate.copernicus.eu/user/register) on the CDS website if you don't own a user account yet. On the profile, you will find your user id (**UID**) and your personal **API Key**.

For batch script data downloads you’ll have to create a local ASCII file with your user information (UID, API key) which is used by the python package (cdsapi). To do so (linux) simply create a file called .cdsapirc in your home directory and add the following two lines:
ERA-5 data set is redistributed over the Copernicus Climate Data Store (CDS), [create a new account](https://cds.climate.copernicus.eu/user/register) on the CDS website if you don't own a user account yet. On the profile, you will find your user id (**UID**) and your personal **API Key**. Add the key to the `model.cfg` file as below:

```
url: https://cds.climate.copernicus.eu/api/v2
key: 1234:abcdefghij-134-abcdefgadf-82391b9d3f
#####key for ECMWF in Climate Data Store Application Program Interface
#Get it from https://retostauffer.org/code/Download-ERA5/
[CDS]
key = 12345:abcdefghij-134-abcdefgadf-82391b9d3f
```

where 1234 is your personal user ID (UID), the part behind the colon your personal API key. Line one simply contains the URL to the web API. More details can be found [here](https://cds.climate.copernicus.eu/api-how-to).
where 12345 is your personal user ID (UID), the part behind the colon your personal API key. More details on CDSAPI can be found [here](https://cds.climate.copernicus.eu/api-how-to).

Run `examples/TestECMWF.ipynb` in Jupyter Notebook in your local machine to check if everything works.

## Citing this work
The metholody and validation of DelayPackage can be found in:
Expand Down
4 changes: 2 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
Details of the python module can be obtained `here. <http://code.google.com/p/pyaps>`_
'''

__all__ = ['geocoord','rdrcoord','autoget','pyapsobj']
__all__ = ['geocoord','rdrcoord','autoget','objects']

#from .geocoord import PyAPS_geo
#from .rdrcoord import PyAPS_rdr
from .pyapsobj import PyAPS
from .objects import PyAPS
from .autoget import *


Expand Down
8 changes: 5 additions & 3 deletions autoget.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def ECMWFdload(bdate,hr,filedir,model='ERA5',datatype='fc',humidity='Q',snwe=Non
# Initialize

# Check data
assert model in ('ERA5', 'ERAINT', 'HRES'), 'Unknown model for ECMWF'
assert model in ('ERA5', 'ERAINT', 'HRES'), 'Unknown model for ECMWF: {}'.format(model)

# Infos for downloading
if model in 'ERAINT':
Expand All @@ -61,7 +61,7 @@ def ECMWFdload(bdate,hr,filedir,model='ERA5',datatype='fc',humidity='Q',snwe=Non
else:
humidparam = 133
elif humidity in 'R':
if model in 'era5':
if model in 'ERA5':
humidparam = 'relative_humidity'
else:
humidparam = 157
Expand All @@ -77,6 +77,8 @@ def ECMWFdload(bdate,hr,filedir,model='ERA5',datatype='fc',humidity='Q',snwe=Non
if not flist:
flist = []
for k in range(len(bdate)):
day = bdate[k]

if model == 'ERA5':
fname = os.path.join(filedir, 'ERA-5_{}_{}.grb'.format(day, hr))
elif model == 'ERAINT':
Expand Down Expand Up @@ -129,7 +131,7 @@ def ECMWFdload(bdate,hr,filedir,model='ERA5',datatype='fc',humidity='Q',snwe=Non
print(indict)

# Make the request
c.retrieve('reanalysis-{}-pressure-levels'.format(model),indict,target=fname)
c.retrieve('reanalysis-{}-pressure-levels'.format(model.lower()),indict,target=fname)

#-------------------------------------------
# CASE 2: request for WEB API client (old ECMWF platform, deprecated, for ERA-Int and HRES)
Expand Down
9 changes: 5 additions & 4 deletions era.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ def get_era(fname,minlat,maxlat,minlon,maxlon,cdic, humidity='Q',verbose=False):
grb=grbs.read(1)[0]
lats,lons = grb.latlons()
g = cdic['g']
mask = (lats > minlat) & (lats < maxlat) \
& (lons > minlon) & (lons < maxlon)
mask = (lats > minlat) & (lats < maxlat) & (lons > minlon) & (lons < maxlon)
[ii,jj] = np.where(mask == True)
del mask
latlist = lats[ii,jj]
Expand Down Expand Up @@ -170,7 +169,7 @@ def get_ecmwf(model,fname,minlat,maxlat,minlon,maxlon,cdic, humidity='Q',verbose
assert model in ('ERA5', 'ERAINT','HRES'), 'Model not recognized.'
if verbose:
print('PROGRESS: READING GRIB FILE')
if model in 'hres':
if model in 'HRES':
if verbose:
print('INFO: USING PRESSURE LEVELS OF HRES DATA')
lvls = np.array([1, 2, 3, 5, 7, 10, 20, 30, 50, 70, 100, 150,
Expand All @@ -191,7 +190,9 @@ def get_ecmwf(model,fname,minlat,maxlat,minlon,maxlon,cdic, humidity='Q',verbose
grbs.seek(gphind[0])
grb = grbs.read(1)[0]
lats,lons = grb.latlons()
g = cdic['g']
if model == 'ERA5':
lons[lons < 0.] += 360.
g = cdic['g']

mask = ((lats > minlat) & (lats < maxlat)) & ((lons > minlon) & (lons < maxlon))
#extrqct indices
Expand Down
Binary file removed examples/ECMWF/ERA-Int_20160101_00.grb
Binary file not shown.
Binary file removed examples/ECMWF/ERA-Int_20160101_6.grb
Binary file not shown.
179 changes: 171 additions & 8 deletions examples/TestECMWF.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions examples/TestPyAPS.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
import pyaps3 as pa
import numpy as np
import matplotlib.pyplot as plt
Expand Down
3 changes: 1 addition & 2 deletions model.cfg.template → model.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#####key for ECMWF in Climate Data Store Application Program Interface
#Get it from https://retostauffer.org/code/Download-ERA5/
[CDS]
key =
key = your-uid:your-api-key

#The key to the new server for ECMWF
##Get it from https://software.ecmwf.int/wiki/display/WEBAPI/Accessing+ECMWF+data+servers+in+batch
Expand All @@ -28,4 +28,3 @@ key =
[MERRA]
user = the-user-name-used-as-login@earthdata.nasa.gov
password = the-password-used-as-login@earthdata.nasa.gov

File renamed without changes.