Skip to content

Commit 6336676

Browse files
committed
flake8 fixes for utils_findsat_mrt
1 parent b4e0301 commit 6336676

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

acstools/utils_findsat_mrt.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from skimage.transform._warps import warp
2222
from skimage._shared.utils import convert_to_float
2323
except ImportError as e:
24-
warnings.warn(f'skimage not installed. MRT calculation will not work: {repr(e)}')
24+
warnings.warn(f'skimage not installed. MRT calculation will not work: {repr(e)}') # noqa
2525

2626
# check for scipy
2727
try:
@@ -108,8 +108,8 @@ def merge_tables(tbls, theta_sep=10, rho_sep=10):
108108
drho = np.abs(t['ycentroid'] - s['ycentroid'])
109109
sel = (dtheta < theta_sep) & (drho < rho_sep)
110110
keep[sel] = False
111-
# Silence MergeConflictWarning for "date" metadata because
112-
# the tables were created with different timestamps. The last entry is kept.
111+
# Silence MergeConflictWarning for "date" metadata because the tables
112+
# were created with different timestamps. The last entry is kept.
113113
src = vstack([src, t[keep]], metadata_conflicts="silent")
114114
return src
115115

@@ -1203,23 +1203,23 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True,
12031203
expand_mask: bool, optional
12041204
Allows the mask to be expanded to match the size of the original mask.
12051205
This is relevant for masks that were generated used binned versions of
1206-
the original image.
1206+
the original image.
12071207
12081208
"""
12091209
with fits.open(filename, mode='update') as pf:
12101210
dqarr = pf[ext].data
12111211

12121212
# check that the old mask and new mask are the same size
12131213
same_size = mask.shape == dqarr.shape
1214-
mask_larger = np.any([mask.shape[i] > dqarr.shape[i]
1214+
mask_larger = np.any([mask.shape[i] > dqarr.shape[i]
12151215
for i in range(mask.ndim)])
12161216

12171217
# provide informative error messages depending on mask/dqarr size
12181218
if not same_size:
12191219
LOG.info('Inconsistent mask sizes: \n'
12201220
'Input mask: {} \n'
12211221
'DQ array: {}'.format(mask.shape, dqarr.shape))
1222-
1222+
12231223
if mask_larger:
12241224
LOG.error('Mask is larger than the DQ array in one or more '
12251225
'dimensions.\nThis routine cannot currently rescale'
@@ -1228,27 +1228,27 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True,
12281228

12291229
elif not mask_larger and not expand_mask:
12301230
LOG.error('Cannot proceed due to size mismatch.\n'
1231-
'Set expand_mask=True if the mask was generated '
1232-
'with binned data and needs to be enlarged to the '
1233-
'original size.')
1231+
'Set expand_mask=True if the mask was generated '
1232+
'with binned data and needs to be enlarged to the '
1233+
'original size.')
12341234
return
12351235
else:
12361236
LOG.info('Enlarging mask to original size.')
12371237

1238-
# Determine factor by which to scale-up the image. Scales should
1238+
# Determine factor by which to scale-up image. Scales should
12391239
# be the same for the x and y dimensions, after we round down
1240-
# to the nearest integer in case there are extra rows/columns
1241-
# that do not divide evenly. These extra rows/columns will be
1240+
# to the nearest integer in case there are extra rows/columns
1241+
# that do not divide evenly. These extra rows/columns will be
12421242
# added back at the end. This approach is the reverse of
12431243
# astropy.nddata.block_reduce, which trims extra rows/cols
1244-
# first.
1244+
# first.
12451245

12461246
factor_x = np.floor(dqarr.shape[1]/mask.shape[1]).astype(int)
12471247
factor_y = np.floor(dqarr.shape[0]/mask.shape[0]).astype(int)
12481248
if factor_x != factor_y:
12491249
raise ValueError('Mask dimensions require scaling by'
1250-
'different amounts in order to match the DQ'
1251-
'array but this is not allowed.')
1250+
'different amounts in order to match the'
1251+
'DQ array but this is not allowed.')
12521252
else:
12531253
factor = factor_x
12541254

@@ -1267,8 +1267,7 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True,
12671267
if extra_cols > 0:
12681268
LOG.info('Duplicating end columns to match orig size')
12691269
while mask.shape[1] != dqarr.shape[1]:
1270-
mask = np.hstack([mask,
1271-
mask[:, -1].reshape(mask.shape[0],1)])
1270+
mask = np.hstack([mask, mask[:, -1].reshape(mask.shape[0], 1)]) # noqa
12721271

12731272
old_mask = (dqval & dqarr) != 0 # Existing flagged trails
12741273
new_mask = mask & ~old_mask # Only flag previously unflagged trails

0 commit comments

Comments
 (0)