From 2ccc748339526ae43d5cb0e2114c5722c2c59cd7 Mon Sep 17 00:00:00 2001 From: Marshall Perrin Date: Mon, 5 Feb 2024 23:01:03 -0500 Subject: [PATCH] some pep8 cleanup --- webbpsf/mast_wss.py | 6 +++--- webbpsf/match_data.py | 4 ++-- webbpsf/trending.py | 11 +++++------ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/webbpsf/mast_wss.py b/webbpsf/mast_wss.py index b1821a11..d640770a 100644 --- a/webbpsf/mast_wss.py +++ b/webbpsf/mast_wss.py @@ -598,7 +598,6 @@ def get_visit_nrc_ta_image(visitid, verbose=True, kind='cal'): from astroquery.mast import Mast keywords = { 'visit_id': [visitid[1:]], # note: drop the initial character 'V' - #'category': ['CAL'], 'exp_type': ['NRC_TACQ'] } @@ -616,7 +615,7 @@ def set_params(parameters): filename = t[0]['filename'] # If user manually specifies rate or uncal, retrieve that instead - if kind=='rate' or kind=='uncal': + if kind == 'rate' or kind == 'uncal': filename = filename.replace('_cal.fits', f'_{kind}.fits') if verbose: @@ -629,7 +628,8 @@ def set_params(parameters): except urllib.error.HTTPError as err: if err.code == 401: # Unauthorized # Use MAST API to allow retrieval of exclusive access data, if relevant - import astroquery, tempfile + import astroquery + import tempfile mast_api_token = os.environ.get('MAST_API_TOKEN', None) mast_obs = astroquery.mast.ObservationsClass(mast_api_token) uri = f"mast:JWST/product/{filename}" diff --git a/webbpsf/match_data.py b/webbpsf/match_data.py index eefbe11f..73368104 100644 --- a/webbpsf/match_data.py +++ b/webbpsf/match_data.py @@ -39,8 +39,8 @@ def setup_sim_to_match_file(filename_or_HDUList, verbose=True, plot=False): if header['PUPIL'].startswith('MASK'): inst.pupil_mask = header['PUPIL'] if 'CORONMSK' in header: - inst.image_mask = header['CORONMSK'].replace('MASKA', 'MASK') # note, have to modify the value slightly for - # consistency with the labels used in webbpsf + inst.image_mask = header['CORONMSK'].replace('MASKA', 'MASK') # note, have to modify the value slightly for + # consistency with the labels used in webbpsf inst.set_position_from_aperture_name(header['APERNAME']) # Redo this, in case the image_mask setting auto switched it to something else elif inst.name == 'MIRI': if inst.filter in ['F1065C', 'F1140C', 'F1550C']: diff --git a/webbpsf/trending.py b/webbpsf/trending.py index 0c2c7496..0a8e10fd 100644 --- a/webbpsf/trending.py +++ b/webbpsf/trending.py @@ -1597,7 +1597,7 @@ def vprint(*args, **kwargs): #### Functions for image comparisons def show_nrc_ta_img(visitid, ax=None, return_handles=False): - """ Retrieve and display a WFS target acq image""" + """ Retrieve and display a NIRCam target acq image""" hdul = webbpsf.mast_wss.get_visit_nrc_ta_image(visitid) @@ -1624,6 +1624,7 @@ def show_nrc_ta_img(visitid, ax=None, return_handles=False): if return_handles: return hdul, ax, norm, cmap, bglevel + def nrc_ta_image_comparison(visitid, verbose=False, show_centroid=False): """ Retrieve a NIRCam target acq image and compare to a simulation @@ -1645,7 +1646,7 @@ def nrc_ta_image_comparison(visitid, verbose=False, show_centroid=False): im_obs_clean = im_obs.copy() im_obs_clean[im_obs_dq & 1] = np.nan # Mask out any DO_NOT_USE pixels. - im_obs_clean = astropy.convolution.interpolate_replace_nans(im_obs_clean, kernel=np.ones((5,5))) + im_obs_clean = astropy.convolution.interpolate_replace_nans(im_obs_clean, kernel=np.ones((5, 5))) # Make a matching sim nrc = webbpsf.setup_sim_to_match_file(hdul, verbose=False) @@ -1681,7 +1682,7 @@ def nrc_ta_image_comparison(visitid, verbose=False, show_centroid=False): try: oss_cen = misc_jwst.engdb.extract_oss_TA_centroids(osslog, 'V' + hdul[0].header['VISIT_ID']) # Convert from full-frame (as used by OSS) to detector subarray coords: - oss_cen_sci = nrc._detector_geom_info.aperture.det_to_sci( *oss_cen) + oss_cen_sci = nrc._detector_geom_info.aperture.det_to_sci(*oss_cen) oss_cen_sci_pythonic = np.asarray(oss_cen_sci) - 1 # convert from 1-based pixel indexing to 0-based oss_centroid_text = f"\n OSS centroid: {oss_cen_sci_pythonic[0]:.2f}, {oss_cen_sci_pythonic[1]:.2f}" axes[0].scatter(oss_cen_sci_pythonic[0], oss_cen_sci_pythonic[1], color='0.5', marker='+', s=50) @@ -1710,13 +1711,11 @@ def nrc_ta_image_comparison(visitid, verbose=False, show_centroid=False): transform=axes[0].transAxes, color='white') - if verbose: print(f"Star coords from WCS: {targ_coords_pix}") if oss_cen_sci_pythonic is not None: print(f"WCS offset = {np.asarray(targ_coords_pix) - oss_cen_sci_pythonic} pix") - #print(oss_cen_sci_pythonic) except ImportError: oss_centroid_text = "" @@ -1750,6 +1749,6 @@ def nrc_ta_image_comparison(visitid, verbose=False, show_centroid=False): plt.tight_layout() - outname = f'wfs_ta_comparison_{visitid}.pdf' + outname = f'nrc_ta_comparison_{visitid}.pdf' plt.savefig(outname) print(f" => {outname}")