Skip to content

Commit

Permalink
autoget.ECMWFdload(): bugfix for snwe in numpy.int64 or float (
Browse files Browse the repository at this point in the history
…#45)

+ `autoget.ECMWFdload()`: bugfix for `snwe` in `numpy.int64` or `float` (#45)

+ `README`: collapse dev install note
  • Loading branch information
yunjunz authored Feb 16, 2025
1 parent cce7fa6 commit 6b01c39
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ apt install python3-pyaps3

#### b. Install the development version

<p>
<details>
<p><summary>Click to expand for more details</summary></p>

The development version can be installed via `pip` as:

```bash
Expand All @@ -56,6 +60,8 @@ Test the installation by running:
```bash
python PyAPS/tests/test_calc.py
```
</details>
</p>

### 2. Account setup for [ERA5](https://www.ecmwf.int/en/forecasts/dataset/ecmwf-reanalysis-v5)

Expand Down
13 changes: 12 additions & 1 deletion src/pyaps3/autoget.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import os.path
import configparser
import math
import urllib3
import cdsapi
import pyaps3 as pa
Expand Down Expand Up @@ -40,6 +41,17 @@ def ECMWFdload(bdate,hr,filedir,model='ERA5',datatype='fc',humidity='Q',snwe=Non
#-------------------------------------------
# Initialize

# Ensure snwe is in native int, not numpy.int32/64 or float etc.
# Note that even though cdsapi support float, we still use int
# for file naming simplicity at the cost of slightly larger file size.
if snwe is not None:
s, n, w, e = snwe
snwe = (math.floor(s), math.ceil(n), math.floor(w), math.ceil(e))
snwe = tuple(int(x) for x in snwe)
if (s, n, w, e) != snwe:
print(f'WARNING: input area ({s}, {n}, {w}, {e}) is NOT exact integer,',
f'\n\tconvert to its bounding box in integer {snwe} and continue.')

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

Expand Down Expand Up @@ -238,4 +250,3 @@ def NARRdload(bdate,hr,filedir):
urllib3.urlretrieve(weburl,dname)

return flist

0 comments on commit 6b01c39

Please sign in to comment.