Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use logger instead of print statements + verbose option #116

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions skycatalogs/skyCatalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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]:
Expand Down Expand Up @@ -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
----------
Expand All @@ -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
-------
Expand All @@ -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()
Expand Down