From 1f6411576763e20e515e78b92d31fa2ac26a9390 Mon Sep 17 00:00:00 2001 From: Zach Burnett Date: Mon, 20 May 2024 10:41:38 -0400 Subject: [PATCH] fix (some) SonarQube issues (#1800) --- drizzlepac/ablot.py | 2 +- drizzlepac/adrizzle.py | 6 +++--- drizzlepac/devutils/comparison_tools/starmatch_hist.py | 2 +- drizzlepac/findobj.py | 2 +- drizzlepac/hapmultisequencer.py | 5 ++++- drizzlepac/haputils/astrometric_utils.py | 2 +- drizzlepac/haputils/config_utils.py | 2 +- drizzlepac/haputils/starmatch_hist.py | 2 +- drizzlepac/imgclasses.py | 2 +- drizzlepac/pixreplace.py | 2 +- drizzlepac/updatehdr.py | 2 +- 11 files changed, 16 insertions(+), 13 deletions(-) diff --git a/drizzlepac/ablot.py b/drizzlepac/ablot.py index ca4f4bd54..8f009aa0c 100644 --- a/drizzlepac/ablot.py +++ b/drizzlepac/ablot.py @@ -29,7 +29,7 @@ from . import __version__ -__all__ = ['blot', 'runBlot', 'help', 'getHelpAsString'] +__all__ = ['blot', 'runBlot', 'help'] __taskname__ = 'ablot' _blot_step_num_ = 5 diff --git a/drizzlepac/adrizzle.py b/drizzlepac/adrizzle.py index 67f053cc4..140f619b0 100644 --- a/drizzlepac/adrizzle.py +++ b/drizzlepac/adrizzle.py @@ -242,7 +242,7 @@ def run(configObj, wcsmap=None): fillval=scale_pars['fillval'], stepsize=configObj['stepsize'], wcsmap=None) - out_sci_handle, outextn = create_output(configObj['outdata']) + out_sci_handle, outextn = create_output(configObj['outdata'], outsci) if not output_exists: # Also, define default header based on input image Primary header out_sci_handle[outextn].header = in_sci_phdr.copy() @@ -309,13 +309,13 @@ def run(configObj, wcsmap=None): out_sci_handle.close() if not util.is_blank(configObj['outweight']): - out_wht_handle, outwhtext = create_output(configObj['outweight']) + out_wht_handle, outwhtext = create_output(configObj['outweight'], outwht) out_wht_handle[outwhtext].header = out_sci_handle[outextn].header.copy() out_wht_handle[outwhtext].data = outwht out_wht_handle.close() if keep_con: - out_con_handle, outconext = create_output(configObj['outcontext']) + out_con_handle, outconext = create_output(configObj['outcontext'], outcon) out_con_handle[outconext].data = outcon out_con_handle.close() diff --git a/drizzlepac/devutils/comparison_tools/starmatch_hist.py b/drizzlepac/devutils/comparison_tools/starmatch_hist.py index cc00b375a..b7833fbb4 100755 --- a/drizzlepac/devutils/comparison_tools/starmatch_hist.py +++ b/drizzlepac/devutils/comparison_tools/starmatch_hist.py @@ -867,7 +867,7 @@ def usage(msg=None): source_list_dict = {} for cooname in args: source_list_dict[cooname] = len(open(cooname).readlines()) - matched=run(source_list_dict, xref=xref, yref=yref) + matched=run(source_list_dict, log_level=20, xref=xref, yref=yref) # print >> msgunit, 'matched keys' # print >> msgunit, matched.keys() # print "x1 y1 x2 y2" diff --git a/drizzlepac/findobj.py b/drizzlepac/findobj.py index 5637e3309..a588677fc 100644 --- a/drizzlepac/findobj.py +++ b/drizzlepac/findobj.py @@ -20,7 +20,7 @@ 'findstars', 'apply_nsigma_separation', 'xy_round', 'precompute_sharp_round', 'sharp_round', 'roundness', 'immoments', 'nmoment', 'centroid', 'cmoment', 'central_moments', 'covmat', - 'help', 'getHelpAsString'] + 'help'] #def gaussian(amplitude, xcen, ycen, xsigma, ysigma): diff --git a/drizzlepac/hapmultisequencer.py b/drizzlepac/hapmultisequencer.py index 610fcd955..4b7817d16 100644 --- a/drizzlepac/hapmultisequencer.py +++ b/drizzlepac/hapmultisequencer.py @@ -563,7 +563,10 @@ def run_align_to_gaia(total_obj_list, custom_limits=None, log_level=logutil.logg # - migrate updated WCS solutions to exp_obj instances, if necessary (probably not?) # - re-run tot_obj.generate_metawcs() method to recompute total object meta_wcs based on updated # input exposure's WCSs - catalog_list = [gaia_obj.configobj_pars.pars['alignment'].pars_multidict['all']['run_align']['catalog_list'][0]] # For now, just pass in a single catalog name as list + if gaia_obj.configobj_pars is not None: + catalog_list = [gaia_obj.configobj_pars.pars['alignment'].pars_multidict['all']['run_align']['catalog_list'][0]] # For now, just pass in a single catalog name as list + else: + catalog_list = [] align_table, filt_exposures = gaia_obj.align_to_gaia(catalog_list=catalog_list, output=diagnostic_mode, fit_label='MVM') diff --git a/drizzlepac/haputils/astrometric_utils.py b/drizzlepac/haputils/astrometric_utils.py index 0c6777fdb..c223c5387 100644 --- a/drizzlepac/haputils/astrometric_utils.py +++ b/drizzlepac/haputils/astrometric_utils.py @@ -606,7 +606,7 @@ def find_gsc_offset(image, input_catalog='GSC1', output_catalog='GAIA'): serviceUrl = "{}/{}?{}".format(SERVICELOCATION, serviceType, spec) rawcat = requests.get(serviceUrl) if not rawcat.ok: - log.info("Problem accessing service with:\n{{}".format(serviceUrl)) + log.info(f"Problem accessing service with:\n{serviceUrl}") raise ValueError delta_ra = delta_dec = None diff --git a/drizzlepac/haputils/config_utils.py b/drizzlepac/haputils/config_utils.py index 441e65fd1..6a5fbf79e 100644 --- a/drizzlepac/haputils/config_utils.py +++ b/drizzlepac/haputils/config_utils.py @@ -59,7 +59,7 @@ def __init__(self, prod_obj, hap_pipeline_name='svm', log_level=logutil.logging. Nothing. """ log.setLevel(log_level) - if input_custom_pars_file and input_custom_pars_file and input_custom_pars_file == output_custom_pars_file: + if input_custom_pars_file and input_custom_pars_file == output_custom_pars_file: log.error("ERROR: Input and output parameter files must have unique names!") sys.exit(1) self.label = "hap_config" diff --git a/drizzlepac/haputils/starmatch_hist.py b/drizzlepac/haputils/starmatch_hist.py index 22ede9041..2de2f282b 100755 --- a/drizzlepac/haputils/starmatch_hist.py +++ b/drizzlepac/haputils/starmatch_hist.py @@ -867,7 +867,7 @@ def usage(msg=None): source_list_dict = {} for cooname in args: source_list_dict[cooname] = len(open(cooname).readlines()) - matched=run(source_list_dict, xref=xref, yref=yref) + matched=run(source_list_dict, log_level=20, xref=xref, yref=yref) # print >> msgunit, 'matched keys' # print >> msgunit, matched.keys() # print "x1 y1 x2 y2" diff --git a/drizzlepac/imgclasses.py b/drizzlepac/imgclasses.py index 9a86cb8db..615bc9c59 100644 --- a/drizzlepac/imgclasses.py +++ b/drizzlepac/imgclasses.py @@ -1049,7 +1049,7 @@ def __init__(self, wcs_list, catalog, xycatalog=None, cat_origin=None, **kwargs) im_fmode='readonly') fi[0].release_all_images() if len(fi) != 1: - ValueError('Reference image file name must contain a single ' + raise ValueError('Reference image file name must contain a single ' 'file name specification.') froot = fi[0].image if len(fi[0].fext) == 0: diff --git a/drizzlepac/pixreplace.py b/drizzlepac/pixreplace.py index f91832bee..d6aa8ab5b 100644 --- a/drizzlepac/pixreplace.py +++ b/drizzlepac/pixreplace.py @@ -14,7 +14,7 @@ from . import util -__all__ = ['replace', 'help', 'getHelpAsString'] +__all__ = ['replace', 'help'] __taskname__ = 'pixreplace' diff --git a/drizzlepac/updatehdr.py b/drizzlepac/updatehdr.py index f32919e98..9ef983c4f 100644 --- a/drizzlepac/updatehdr.py +++ b/drizzlepac/updatehdr.py @@ -515,7 +515,7 @@ def interpret_wcsname_type(wcsname): else: if 'FIT' not in fit_term: wcstype += default_fit.format(fit_term) - else: + elif fit_term is not None: wcstype += post_fit postfit_type = fit_term.split('_') wcstype += fit_terms[postfit_type[1]].format(postfit_type[2])