@@ -362,7 +362,7 @@ def from_custom(cls, func, func_args=(), **kwargs):
362362 return cls (data = data , region = region , magnitudes = magnitudes , ** kwargs )
363363
364364 @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 ):
366366 """ Reads Forecast file from CSEP1 ascii format.
367367
368368 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):
376376
377377 Args:
378378 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
379380 """
380381 # Load data
381382 data = numpy .loadtxt (ascii_fname )
@@ -393,6 +394,8 @@ def load_ascii(cls, ascii_fname, start_date=None, end_date=None, name=None):
393394 mws = all_mws [sorted_idx ]
394395 # csep1 stores the lat lons as min values and not (x,y) tuples
395396 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 ]
396399 # the spatial cells are arranged fast in latitude, so this only works for the specific csep1 file format
397400 dh = float (unique_poly [0 ,3 ] - unique_poly [0 ,2 ])
398401 # create CarteisanGrid of points
0 commit comments