@@ -362,7 +362,7 @@ def from_custom(cls, func, func_args=(), **kwargs):
362
362
return cls (data = data , region = region , magnitudes = magnitudes , ** kwargs )
363
363
364
364
@classmethod
365
- def load_ascii (cls , ascii_fname , start_date = None , end_date = None , name = None ):
365
+ def load_ascii (cls , ascii_fname , start_date = None , end_date = None , name = None , swap_latlon = False ):
366
366
""" Reads Forecast file from CSEP1 ascii format.
367
367
368
368
The ascii format from CSEP1 testing centers. The ASCII format does not contain headers. The format is listed here:
@@ -376,6 +376,7 @@ def load_ascii(cls, ascii_fname, start_date=None, end_date=None, name=None):
376
376
377
377
Args:
378
378
ascii_fname: file name of csep forecast in .dat format
379
+ swap_latlon (bool): if true, read forecast spatial cells as lat_0, lat_1, lon_0, lon_1
379
380
"""
380
381
# Load data
381
382
data = numpy .loadtxt (ascii_fname )
@@ -393,6 +394,8 @@ def load_ascii(cls, ascii_fname, start_date=None, end_date=None, name=None):
393
394
mws = all_mws [sorted_idx ]
394
395
# csep1 stores the lat lons as min values and not (x,y) tuples
395
396
bboxes = [tuple (itertools .product (bbox [:2 ], bbox [2 :])) for bbox in unique_poly ]
397
+ if swap_latlon :
398
+ bboxes = [tuple (itertools .product (bbox [2 :], bbox [:2 ])) for bbox in unique_poly ]
396
399
# the spatial cells are arranged fast in latitude, so this only works for the specific csep1 file format
397
400
dh = float (unique_poly [0 ,3 ] - unique_poly [0 ,2 ])
398
401
# create CarteisanGrid of points
0 commit comments