diff --git a/ObservationSim/PSF/PSFInterp.py b/ObservationSim/PSF/PSFInterp.py index 058acca032f174f0dcaf36d75f7f146937e7e29d..60dbf267eb4cddca0bed4cf35a2d9dd6181bc3fb 100644 --- a/ObservationSim/PSF/PSFInterp.py +++ b/ObservationSim/PSF/PSFInterp.py @@ -305,7 +305,19 @@ class PSFInterp(PSFModel): if bandpass.blue_limit < bandwave and bandwave < bandpass.red_limit: return twave return -1 - + def _findWave_sencondary(self, bandpass): + w_dist = np.zeros(self.nwave) + for twave in range(self.nwave): + bandwave = self.PSF_data[twave][0]['wavelength'] + d1 = bandwave - bandpass.blue_limit + d2 = bandwave - bandpass.red_limit + if d1 * d2 <= 0: + w_dist[twave] = 0 + else: + w_dist[twave] = np.min([abs(d1), abs(d2)]) + + minTwawe = np.where(w_dist == np.min(w_dist)) + return minTwawe[0][0] def get_PSF(self, chip, pos_img, bandpass, galsimGSObject=True, findNeighMode='treeFind', folding_threshold=5.e-3, pointing_pa=0.0): """ @@ -325,8 +337,7 @@ class PSFInterp(PSFModel): assert self.iccd == int(chip.getChipLabel(chipID=chip.chipID)), 'ERROR: self.iccd != chip.chipID' twave = self._findWave(bandpass) if twave == -1: - print("!!!PSF bandpass does not match.") - exit() + twave = self._findWave_sencondary(bandpass) PSFMat = self.psfMat[twave] cen_col= self.cen_col[twave] cen_row= self.cen_row[twave]