Skip to content

Commit

Permalink
tests dont break localy
Browse files Browse the repository at this point in the history
  • Loading branch information
PFLeget committed May 24, 2024
1 parent ec85c61 commit 2ff5c78
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions python/lsst/meas/algorithms/gp_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from jax import jit
import jax.numpy as jnp

import warnings

__all__ = ["interpolateOverDefectsGP"]


Expand Down Expand Up @@ -307,7 +309,7 @@ def interpolate_sub_masked_image(self, sub_masked_image):
sub_masked_image, self.defects, buffer=cut
)
# Do nothing if bad pixel is None.
if np.shape(bad_pixel)[0] == 0:
if bad_pixel.size == 0 or good_pixel.size == 0:
return sub_masked_image
# Do GP interpolation if bad pixel found.
else:
Expand All @@ -318,7 +320,10 @@ 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:])
good_pixel = self._good_pixel_binning(copy.deepcopy(good_pixel))
try:
good_pixel = self._good_pixel_binning(copy.deepcopy(good_pixel))
except:
warnings.warn('Binning failed, use original good pixel array in interpolate over.')

gp = self.GaussianProcess(
std=np.sqrt(kernel_amplitude),
Expand Down Expand Up @@ -355,19 +360,21 @@ 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:
return
gp = InterpolateOverDefectGaussianProcess(image, defects=badList, method=method,
fwhm=fwhm, bin_spacing=bin_spacing,
threshold_subdivide=threshold_subdivide)
Expand Down

0 comments on commit 2ff5c78

Please sign in to comment.