From 6eae33226f5cb156b3f327e30ef770282dd93b10 Mon Sep 17 00:00:00 2001 From: James Chiang Date: Fri, 2 Aug 2024 14:09:16 -0700 Subject: [PATCH] use logger instead of print statements + verbose option --- skycatalogs/skyCatalogs.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/skycatalogs/skyCatalogs.py b/skycatalogs/skyCatalogs.py index f8dde55e..013e9553 100644 --- a/skycatalogs/skyCatalogs.py +++ b/skycatalogs/skyCatalogs.py @@ -261,7 +261,7 @@ class SkyCatalog(object): point sources, SSOs ''' - def __init__(self, config, mp=False, skycatalog_root=None, verbose=False, + def __init__(self, config, mp=False, skycatalog_root=None, loglevel='INFO'): ''' Parameters @@ -270,6 +270,7 @@ def __init__(self, config, mp=False, skycatalog_root=None, verbose=False, mp: boolean Default False. Set True to enable multiprocessing. skycatalog_root: If not None, overrides value in config or in environment variable SKYCATALOG_ROOT + loglevel: logging level ''' self._config = Config(config) self._global_partition = None @@ -307,7 +308,6 @@ def __init__(self, config, mp=False, skycatalog_root=None, verbose=False, # There may be more to do at this point but not too much. # In particular, don't read in anything from data files - self.verbose = verbose self._validate_config() # Outer dict: hpid for key. Value is another dict @@ -565,9 +565,8 @@ def get_objects_by_region(self, region, obj_type_set=None, mjd=None, # Take intersection of obj_type_list and available object types # Determine healpix intersecting the region - if self.verbose: - print("Region ", region) - print("obj_type_set ", obj_type_set) + self._logger.info("Region %s", region) + self._logger.info("obj_type_set %s", obj_type_set) object_list = ObjectList() if obj_type_set is None: @@ -665,8 +664,8 @@ def get_object_type_by_hp(self, hp, object_type, region=None, mjd=None, coll_class = self.cat_cxt.lookup_collection_type(object_type) - if self.verbose: - print('Working on healpix pixel ', hp) + self._logger.info('Working on healpix pixel %s', hp) + rdr_ot = dict() # maps readers to set of object types it reads if 'file_template' in self._config['object_types'][object_type]: @@ -779,7 +778,7 @@ def get_object_iterator_by_hp(self, hp, obj_type_set=None, pass -def open_catalog(config_file, mp=False, skycatalog_root=None, verbose=False): +def open_catalog(config_file, mp=False, skycatalog_root=None, loglevel="INFO"): ''' Parameters ---------- @@ -791,6 +790,7 @@ def open_catalog(config_file, mp=False, skycatalog_root=None, verbose=False): key skycatalog_root. However set, this value joined to value of the key catalog_dir will be used to find the catalog data. + loglevel logging level Returns ------- @@ -801,7 +801,7 @@ def open_catalog(config_file, mp=False, skycatalog_root=None, verbose=False): config_dict = open_config_file(config_file) cat = SkyCatalog(config_dict, skycatalog_root=skycatalog_root, mp=mp, - verbose=verbose) + loglevel=loglevel) # Get bandpasses in case we need to compute fluxes _, cat._lsst_thru_v = _load_lsst_bandpasses()