Skip to content

Commit

Permalink
bugfix for snwe in numpy.int64 or float
Browse files Browse the repository at this point in the history
  • Loading branch information
yunjunz committed Feb 16, 2025
1 parent ca1661e commit c9bf9e5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions 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

0 comments on commit c9bf9e5

Please sign in to comment.