21
21
from skimage .transform ._warps import warp
22
22
from skimage ._shared .utils import convert_to_float
23
23
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
25
25
26
26
# check for scipy
27
27
try :
@@ -108,8 +108,8 @@ def merge_tables(tbls, theta_sep=10, rho_sep=10):
108
108
drho = np .abs (t ['ycentroid' ] - s ['ycentroid' ])
109
109
sel = (dtheta < theta_sep ) & (drho < rho_sep )
110
110
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.
113
113
src = vstack ([src , t [keep ]], metadata_conflicts = "silent" )
114
114
return src
115
115
@@ -1203,23 +1203,23 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True,
1203
1203
expand_mask: bool, optional
1204
1204
Allows the mask to be expanded to match the size of the original mask.
1205
1205
This is relevant for masks that were generated used binned versions of
1206
- the original image.
1206
+ the original image.
1207
1207
1208
1208
"""
1209
1209
with fits .open (filename , mode = 'update' ) as pf :
1210
1210
dqarr = pf [ext ].data
1211
1211
1212
1212
# check that the old mask and new mask are the same size
1213
1213
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 ]
1215
1215
for i in range (mask .ndim )])
1216
1216
1217
1217
# provide informative error messages depending on mask/dqarr size
1218
1218
if not same_size :
1219
1219
LOG .info ('Inconsistent mask sizes: \n '
1220
1220
'Input mask: {} \n '
1221
1221
'DQ array: {}' .format (mask .shape , dqarr .shape ))
1222
-
1222
+
1223
1223
if mask_larger :
1224
1224
LOG .error ('Mask is larger than the DQ array in one or more '
1225
1225
'dimensions.\n This routine cannot currently rescale'
@@ -1228,27 +1228,27 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True,
1228
1228
1229
1229
elif not mask_larger and not expand_mask :
1230
1230
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.' )
1234
1234
return
1235
1235
else :
1236
1236
LOG .info ('Enlarging mask to original size.' )
1237
1237
1238
- # Determine factor by which to scale-up the image. Scales should
1238
+ # Determine factor by which to scale-up image. Scales should
1239
1239
# 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
1242
1242
# added back at the end. This approach is the reverse of
1243
1243
# astropy.nddata.block_reduce, which trims extra rows/cols
1244
- # first.
1244
+ # first.
1245
1245
1246
1246
factor_x = np .floor (dqarr .shape [1 ]/ mask .shape [1 ]).astype (int )
1247
1247
factor_y = np .floor (dqarr .shape [0 ]/ mask .shape [0 ]).astype (int )
1248
1248
if factor_x != factor_y :
1249
1249
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.' )
1252
1252
else :
1253
1253
factor = factor_x
1254
1254
@@ -1267,8 +1267,7 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True,
1267
1267
if extra_cols > 0 :
1268
1268
LOG .info ('Duplicating end columns to match orig size' )
1269
1269
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
1272
1271
1273
1272
old_mask = (dqval & dqarr ) != 0 # Existing flagged trails
1274
1273
new_mask = mask & ~ old_mask # Only flag previously unflagged trails
0 commit comments