Added correct units to SkyImages result['exposure'] and result['flux'].
@@ -92,6 +92,7 @@ class BasicImageEstimator(object):
with np.errstate(invalid='ignore', divide='ignore'):
flux.data = (excess / images['exposure'].data)
+ flux.unit = (1 / images['exposure'].unit).unit
is_zero = images['exposure'].data == 0
flux.data[is_zero] = 0
@@ -191,19 +192,10 @@ class IACTBasicImageEstimator(BasicImageEstimator):
exposure_cube.data = exposure_cube.data * weights.reshape(-1, 1, 1)
exposure = exposure_cube.sky_image_integral(emin=p['emin'], emax=p['emax'])
- print ('_exposure() being executed!!!')
- print ('type(exposure) =', type(exposure))
- print ('type(exposure.data) =', type(exposure.data))
- print ('exposure.data.unit =', exposure.data.unit)
- print ('exposure.unit =', exposure.unit)
exposure.name = 'exposure'
exposure.unit = exposure.data.unit
exposure.data = np.nan_to_num(exposure.data.value)
- print ('\nAfter fix:')
- print('type(exposure) =', type(exposure))
- print('type(exposure.data) =', type(exposure.data))
- print('exposure.unit =', exposure.unit)
return exposure
def psf(self, observations):
@@ -314,7 +306,9 @@ class IACTBasicImageEstimator(BasicImageEstimator):
if 'exposure' in which:
exposure = self._exposure(observation)
result['exposure'].paste(exposure)
- # TODO: fix so that exposure units are carried over to results['exposure']
+ # TODO: improve SkyImage.paste() so that it enforces compatibility
+ # of units when doing the sum. The fix below can then be removed.
+ result['exposure'].unit = exposure.unit
if 'counts' in which:
counts = self._counts(observation)
@@ -338,7 +332,9 @@ class IACTBasicImageEstimator(BasicImageEstimator):
if 'flux' in which:
flux = self.flux(SkyImageList([counts, background, exposure]))
result['flux'].paste(flux)
- # TODO: fix so that flux units are carried over to results['flux']
+ # TODO: improve SkyImage.paste() so that it enforces compatibility
+ # of units when doing the sum. The fix below can then be removed.
+ result['flux'].unit = flux.unit
if 'psf' in which:
result['psf'] = self.psf(observations)
