Skip to content

Commit

Permalink
pass unit test in ip_isr
Browse files Browse the repository at this point in the history
  • Loading branch information
PFLeget committed May 29, 2024
1 parent 864b8af commit 035ae2e
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions python/lsst/meas/algorithms/gp_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,14 @@ def interpolate_sub_masked_image(self, sub_masked_image):
np.mean(sub_image_array[np.isfinite(sub_image_array)])
)
kernel_amplitude = np.std(good_pixel[:, 2:])
if np.isnan(kernel_amplitude):
filtre_nan = np.isnan(good_pixel[:, 2:])
good_pixel = good_pixel[~filtre_nan]
if not np.isfinite(kernel_amplitude):
filter_finite = np.isfinite(good_pixel[:, 2:]).T[0]
good_pixel = good_pixel[filter_finite]
if good_pixel.size == 0:
warnings.warn('No bad or good pixels found. No interpolation performed.')
return sub_masked_image
kernel_amplitude = np.std(good_pixel[:, 2:])
mean = np.mean(good_pixel[:, 2:])
try:
good_pixel = self._good_pixel_binning(copy.deepcopy(good_pixel))
except:
Expand All @@ -353,7 +354,7 @@ def interpolate_sub_masked_image(self, sub_masked_image):
gp_predict = gp.predict(bad_pixel[:, :2])
bad_pixel[:, 2:] = gp_predict.reshape(np.shape(bad_pixel[:, 2:]))
else:
print('sub-divide bad pixel array to avoid memory error.')
warnings.warn('sub-divide bad pixel array to avoid memory error.')
for i in range(0, len(bad_pixel), self.threshold_subdivide):
end = min(i + self.threshold_subdivide, len(bad_pixel))
gp_predict = gp.predict(bad_pixel[i : end, :2])
Expand All @@ -378,20 +379,20 @@ def interpolateOverDefectsGP(image, fwhm, badList, method="treegp", bin_spacing=
Returns:
None
"""
import pickle
dic = {
'image': image,
'fwhm': fwhm,
'badList': badList,
'method': method,
'bin_spacing': bin_spacing,
'threshold_subdivide':threshold_subdivide,
}
file_name_out = get_name_pkl()
fileout = open(file_name_out, 'wb')
print(f'JE PASSE PAR LA | {file_name_out}')
pickle.dump(dic, fileout)
fileout.close()
#import pickle
#dic = {
# 'image': image,
# 'fwhm': fwhm,
# 'badList': badList,
# 'method': method,
# 'bin_spacing': bin_spacing,
# 'threshold_subdivide':threshold_subdivide,
# }
#file_name_out = get_name_pkl()
#fileout = open(file_name_out, 'wb')
#print(f'JE PASSE PAR LA | {file_name_out}')
#pickle.dump(dic, fileout)
#fileout.close()
if badList == [] or badList is None:
warnings.warn('WARNING: no defects found. No interpolation performed.')
return
Expand Down

0 comments on commit 035ae2e

Please sign in to comment.