diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 87f36cfa5..4fdfc4c3f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -20,6 +20,15 @@ number of the code change for that issue. These PRs can be viewed at: 3.7.1 (unreleased) ====================== +- Addressed bugs caught by SonarQube static code analysis. Interface + changes listed here: Added missing input data parameter to the create_output + calls, Added missing log level to run function, Removed the deprecated + parameter, dao_threshold, from astrometric_utils.py/extract_sources, removed + "ivmlist" parameter from the interface of multiple functions in processInput.py + as it is an output parameter (buildFileListOrig, buildFileList, checkMultipleFiles, + and process_input), and addressed missing parameters in the calls to + get_ci_info and get_ci_from_file.. [#1802] + - Exclude single filter images from the generation of the total detection image to minimize cosmic ray contamination, unless there are only single filter images in the visit. [#1797] diff --git a/drizzlepac/haputils/align_utils.py b/drizzlepac/haputils/align_utils.py index fce047371..aca1a90fe 100755 --- a/drizzlepac/haputils/align_utils.py +++ b/drizzlepac/haputils/align_utils.py @@ -714,7 +714,6 @@ def find_alignment_sources(self, output=True, dqname='DQ', crclean=False, outroot=outroot, kernel=self.kernel, segment_threshold=self.threshold[chip], - dao_threshold=self.bkg_rms_mean[chip], fwhm=self.kernel_fwhm, **extract_pars) if crclean and crmap is not None: diff --git a/drizzlepac/haputils/astrometric_utils.py b/drizzlepac/haputils/astrometric_utils.py index c223c5387..a55f60118 100644 --- a/drizzlepac/haputils/astrometric_utils.py +++ b/drizzlepac/haputils/astrometric_utils.py @@ -958,8 +958,7 @@ def build_gaussian_kernel(fwhm, npixels): def extract_sources(img, dqmask=None, fwhm=3.0, kernel=None, photmode=None, - segment_threshold=None, dao_threshold=None, - dao_nsigma=3.0, source_box=7, + segment_threshold=None, dao_nsigma=3.0, source_box=7, classify=True, centering_mode="starfind", nlargest=None, outroot=None, plot=False, vmax=None, deblend=False, log_level=logutil.logging.INFO): @@ -988,10 +987,6 @@ def extract_sources(img, dqmask=None, fwhm=3.0, kernel=None, photmode=None, segment_threshold : ndarray or None Value from the image which serves as the limit for determining sources. If None, compute a default value of (background+5*rms(background)). - dao_threshold : float, optional - [Deprecated] This parameter is not used. In fact, it now gets computed - internally using the ``sigma_clipped_bkg()`` function which uses the - ``dao_nsigma`` parameter. dao_nsigma : float This number gets used to determine the threshold for detection of point sources. The threshold gets computed using a simple ``mean + dao_nsigma * rms``, @@ -1456,7 +1451,6 @@ def generate_source_catalog(image, dqname="DQ", output=False, fwhm=3.0, bkg_ra, bkg_median, bkg_rms_ra, bkg_rms_median = compute_2d_background(imgarr, box_size, win_size) threshold = nsigma * bkg_rms_ra - dao_threshold = nsigma * bkg_rms_median (kernel, kernel_psf), kernel_fwhm = build_auto_kernel(imgarr - bkg_ra, whtarr, threshold=threshold, @@ -1470,7 +1464,6 @@ def generate_source_catalog(image, dqname="DQ", output=False, fwhm=3.0, outroot=outroot, kernel=kernel, photmode=photmode, segment_threshold=threshold, - dao_threshold=dao_threshold, fwhm=kernel_fwhm, **detector_pars) del crmap source_cats[chip] = seg_tab diff --git a/drizzlepac/haputils/ci_table.py b/drizzlepac/haputils/ci_table.py index e2c90c9a6..e462865b0 100644 --- a/drizzlepac/haputils/ci_table.py +++ b/drizzlepac/haputils/ci_table.py @@ -207,10 +207,10 @@ def get_ci_from_file(drzfile, ci_lookup_file_path, log_level, **kw): inst, detect, filt = parse_file(drzfile) return get_ci_info(inst, detect, filt, ci_lookup_file_path, **kw) - if __name__ == '__main__': + ci_lookup_file_path = 'svm_parameters/any' inst, detect, filt = ('wfc3', 'uvis', 'f606w') - ciap_dict = get_ci_info(inst, detect, filt) + ciap_dict = get_ci_info(inst, detect, filt, ci_lookup_file_path) log.info("configuration: {}".format(inst, detect, filt)) log.info("eff_wave: {}".format(ciap_dict['eff_wave'])) log.info("ci_lower: {}".format(ciap_dict['ci_lower_limit'])) @@ -220,7 +220,7 @@ def get_ci_from_file(drzfile, ci_lookup_file_path, log_level, **kw): drizzled_image = 'hst_12311_03_wfc3_uvis_f275w_drz.fits' inst, detect, filt = parse_file(drizzled_image) - ciap_dict = get_ci_from_file(drizzled_image) + ciap_dict = get_ci_from_file(drizzled_image, ci_lookup_file_path, logutil.logging.INFO) log.info("drizzled image: {}".format(drizzled_image)) log.info("configuration: {}".format(inst, detect, filt)) log.info("eff_wave: {}".format(ciap_dict['eff_wave'])) @@ -231,7 +231,7 @@ def get_ci_from_file(drzfile, ci_lookup_file_path, log_level, **kw): drizzled_image = 'hst_11969_04_wfpc2_f606w_pc_drz.fits' inst, detect, filt = parse_file(drizzled_image) - ciap_dict = get_ci_from_file(drizzled_image) + ciap_dict = get_ci_from_file(drizzled_image, ci_lookup_file_path, logutil.logging.INFO) log.info("drizzled image: {}".format(drizzled_image)) log.info("configuration: {}".format(inst, detect, filt)) log.info("eff_wave: {}".format(ciap_dict['eff_wave'])) diff --git a/drizzlepac/haputils/hapcut_utils.py b/drizzlepac/haputils/hapcut_utils.py index e6b6c9bee..489a401b4 100644 --- a/drizzlepac/haputils/hapcut_utils.py +++ b/drizzlepac/haputils/hapcut_utils.py @@ -113,11 +113,6 @@ def mvm_id_filenames(sky_coord, cutout_size, log_level=logutil.logging.INFO): del acs_query_table del wfc3_query_table - # Catch the case where no files are found which satisfied the Query - if not query_table: - log.warning("Query for objects within {} of {} returned NO RESULTS!".format(radius, (str_ra, str_dec))) - return query_table - # Compute the limits of the cutout region deg_cutout_size = cutout_size.to(u.deg) ra_min = sky_coord.ra.degree - deg_cutout_size.value[0] @@ -127,6 +122,11 @@ def mvm_id_filenames(sky_coord, cutout_size, log_level=logutil.logging.INFO): str_ra = "{:.4f}".format(sky_coord.ra.degree) str_dec = "{:.4f}".format(sky_coord.dec.degree) + # Catch the case where no files are found which satisfied the Query + if not query_table: + log.warning("Query for objects within {} of {} returned NO RESULTS!".format(radius, (str_ra, str_dec))) + return query_table + # Filter the output as necessary to include only MVM filenames (MVM prefix: hst_skycell). # Also, filter out images which are not actually in the requested cutout region as the # archive search had to be done using a radius. diff --git a/drizzlepac/haputils/product.py b/drizzlepac/haputils/product.py index 2362d23c0..98222d16d 100755 --- a/drizzlepac/haputils/product.py +++ b/drizzlepac/haputils/product.py @@ -199,7 +199,6 @@ def align_to_gaia( exposure_filenames = [] headerlet_filenames = {} - align_table = None crclean = [] # If no catalog list has been provided, use the list defined in the configuration file diff --git a/drizzlepac/nicmosData.py b/drizzlepac/nicmosData.py index 893ad10c6..816ac97f9 100644 --- a/drizzlepac/nicmosData.py +++ b/drizzlepac/nicmosData.py @@ -423,10 +423,10 @@ def fromcalfile(filename): hdulist = fileutil.openImage(filename) if 'TEMPFILE' in hdulist[0].header: + tddfile = hdulist[0].header['TEMPFILE'] if tddfile == 'N/A': return None else: - tddfile = hdulist[0].header['TEMPFILE'] tddhdulist = fileutil.openImage(tddfile) return darkobject(tddhdulist) else: diff --git a/drizzlepac/processInput.py b/drizzlepac/processInput.py index 9312bea36..805ef135a 100644 --- a/drizzlepac/processInput.py +++ b/drizzlepac/processInput.py @@ -533,7 +533,7 @@ def processFilenames(input=None,output=None,infilesOnly=False): return filelist, output, ivmlist, oldasndict -def process_input(input, output=None, ivmlist=None, updatewcs=True, +def process_input(input, output=None, updatewcs=True, prodonly=False, wcskey=None, **workinplace): """ Create the full input list of filenames after verifying and converting @@ -541,7 +541,7 @@ def process_input(input, output=None, ivmlist=None, updatewcs=True, """ newfilelist, ivmlist, output, oldasndict, origflist = buildFileListOrig( - input, output=output, ivmlist=ivmlist, wcskey=wcskey, + input, output=output, wcskey=wcskey, updatewcs=updatewcs, **workinplace) if not newfilelist: @@ -655,19 +655,19 @@ def _process_input_wcs_single(fname, wcskey, updatewcs): wcscorr.init_wcscorr(fname) -def buildFileList(input, output=None, ivmlist=None, +def buildFileList(input, output=None, wcskey=None, updatewcs=True, **workinplace): """ Builds a file list which has undergone various instrument-specific checks for input to MultiDrizzle, including splitting STIS associations. """ newfilelist, ivmlist, output, oldasndict, filelist = \ - buildFileListOrig(input=input, output=output, ivmlist=ivmlist, + buildFileListOrig(input=input, output=output, wcskey=wcskey, updatewcs=updatewcs, **workinplace) return newfilelist, ivmlist, output, oldasndict -def buildFileListOrig(input, output=None, ivmlist=None, +def buildFileListOrig(input, output=None, wcskey=None, updatewcs=True, **workinplace): """ Builds a file list which has undergone various instrument-specific