22import os
33import time
44
5- from csep ._version import __version__
6-
75from csep .core import forecasts
86from csep .core import catalogs
97from csep .core import poisson_evaluations
3735 utc_now_epoch
3836)
3937
38+ from importlib .metadata import version as _pkg_version , PackageNotFoundError
39+
40+ try :
41+ __version__ = _pkg_version ("pycsep" )
42+ except PackageNotFoundError :
43+ __version__ = "0+unknown"
44+
4045# this defines what is imported on a `from csep import *`
4146__all__ = [
4247 'load_json' ,
@@ -80,8 +85,8 @@ def load_stochastic_event_sets(filename, type='csv', format='native',
8085 (generator): :class:`~csep.core.catalogs.AbstractBaseCatalog`
8186
8287 """
83- if type not in ('ucerf3' , 'csv' ):
84- raise ValueError ("type must be one of the following: (ucerf3)" )
88+ if type not in ('ucerf3' , 'csv' , 'csep' ):
89+ raise ValueError ("type must be one of the following: (ucerf3, csv, csep )" )
8590
8691 # use mapping to dispatch to correct function
8792 # in general, stochastic event sets are loaded with classmethods and single catalogs use the
@@ -105,7 +110,7 @@ def load_stochastic_event_sets(filename, type='csv', format='native',
105110 elif format == 'csep' :
106111 yield catalog .get_csep_format ()
107112 else :
108- raise ValueError ('format must be either "native" or "csep!' )
113+ raise ValueError ('format must be either "native" or "csep!" ' )
109114
110115
111116def load_catalog (filename , type = 'csep-csv' , format = 'native' , loader = None ,
@@ -333,7 +338,7 @@ def query_gns(start_time, end_time, min_magnitude=2.950,
333338 verbose (bool): print catalog summary statistics
334339
335340 Returns:
336- :class:`csep.core.catalogs.CSEPCatalog
341+ :class:`csep.core.catalogs.CSEPCatalog`
337342 """
338343
339344 # Timezone should be in UTC
@@ -366,7 +371,7 @@ def query_gcmt(start_time, end_time, min_magnitude=5.0,
366371 max_depth = None ,
367372 catalog_id = None ,
368373 min_latitude = None , max_latitude = None ,
369- min_longitude = None , max_longitude = None ):
374+ min_longitude = None , max_longitude = None , verbose = True ):
370375
371376 eventlist = readers ._query_gcmt (start_time = start_time ,
372377 end_time = end_time ,
@@ -381,6 +386,17 @@ def query_gcmt(start_time, end_time, min_magnitude=5.0,
381386 name = 'gCMT' ,
382387 catalog_id = catalog_id ,
383388 date_accessed = utc_now_datetime ())
389+
390+ if verbose :
391+ print ("Downloaded catalog from GCMT with following parameters" )
392+ print ("Start Date: {}\n End Date: {}" .format (str (catalog .start_time ),
393+ str (catalog .end_time )))
394+ print ("Min Latitude: {} and Max Latitude: {}" .format (catalog .min_latitude ,
395+ catalog .max_latitude ))
396+ print ("Min Longitude: {} and Max Longitude: {}" .format (catalog .min_longitude ,
397+ catalog .max_longitude ))
398+ print ("Min Magnitude: {}" .format (catalog .min_magnitude ))
399+ print (f"Found { catalog .event_count } events in the gns catalog." )
384400 return catalog
385401
386402
0 commit comments