correct photflam when rebinning

This commit is contained in:
2024-12-04 18:30:48 +01:00
parent 83e58d6a26
commit 50c73f245f
3 changed files with 9 additions and 2 deletions

View File

@@ -141,6 +141,7 @@ def save_Stokes(
header["TELESCOP"] = (header_stokes["TELESCOP"] if "TELESCOP" in list(header_stokes.keys()) else "HST", "telescope used to acquire data")
header["INSTRUME"] = (header_stokes["INSTRUME"] if "INSTRUME" in list(header_stokes.keys()) else "FOC", "identifier for instrument used to acuire data")
header["PHOTPLAM"] = (header_stokes["PHOTPLAM"], "Pivot Wavelength")
header["PHOTBW"] = (header_stokes["PHOTBW"], "RMS Bandwidth of the Filter and Detector")
header["PHOTFLAM"] = (header_stokes["PHOTFLAM"], "Inverse Sensitivity in DN/sec/cm**2/Angst")
header["EXPTIME"] = (header_stokes["EXPTIME"], "Total exposure time in sec")
header["PROPOSID"] = (header_stokes["PROPOSID"], "PEP proposal identifier for observation")

View File

@@ -97,7 +97,7 @@ def plot_obs(data_array, headers, rectangle=None, shifts=None, savename=None, pl
plt.rcParams.update({"font.size": 10})
nb_obs = np.max([np.sum([head["filtnam1"] == curr_pol for head in headers]) for curr_pol in ["POL0", "POL60", "POL120"]])
shape = np.array((3, nb_obs))
fig, ax = plt.subplots(shape[0], shape[1], figsize=(3 * shape[1], 3 * shape[0]), layout="constrained", sharex=True, sharey=True)
fig, ax = plt.subplots(shape[0], shape[1], figsize=(3 * shape[1], 3 * shape[0]), layout="compressed", sharex=True, sharey=True)
used = np.zeros(shape, dtype=bool)
r_pol = dict(pol0=0, pol60=1, pol120=2)
c_pol = dict(pol0=0, pol60=0, pol120=0)
@@ -317,9 +317,9 @@ def polarization_map(
for j in range(3):
stk_cov[i][j][np.logical_not(data_mask)] = np.nan
wcs = WCS(Stokes[0]).deepcopy()
pivot_wav = Stokes[0].header["photplam"]
convert_flux = Stokes[0].header["photflam"]
wcs = WCS(Stokes[0]).deepcopy()
# Plot Stokes parameters map
if display is None or display.lower() in ["default"]:
@@ -3275,6 +3275,7 @@ class pol_map(object):
str_conf = ""
if self.region is None:
s_I = np.sqrt(self.IQU_cov[0, 0])
N_pix = self.I.size
I_reg = self.I.sum()
I_reg_err = np.sqrt(np.sum(s_I**2))
P_reg = self.Stokes[0].header["P_int"]
@@ -3289,6 +3290,7 @@ class pol_map(object):
s_IU = self.IQU_cov[0, 2]
s_QU = self.IQU_cov[1, 2]
N_cut = self.cut.sum()
I_cut = self.I[self.cut].sum()
Q_cut = self.Q[self.cut].sum()
U_cut = self.U[self.cut].sum()
@@ -3324,6 +3326,7 @@ class pol_map(object):
s_IU = self.IQU_cov[0, 2]
s_QU = self.IQU_cov[1, 2]
N_pix = self.region.sum()
I_reg = self.I[self.region].sum()
Q_reg = self.Q[self.region].sum()
U_reg = self.U[self.region].sum()
@@ -3356,6 +3359,7 @@ class pol_map(object):
)
new_cut = np.logical_and(self.region, self.cut)
N_cut = new_cut.sum()
I_cut = self.I[new_cut].sum()
Q_cut = self.Q[new_cut].sum()
U_cut = self.U[new_cut].sum()
@@ -3385,6 +3389,7 @@ class pol_map(object):
if hasattr(self, "cont"):
self.cont.remove()
del self.cont
if fig is None:
fig = self.fig
if ax is None:

View File

@@ -676,6 +676,7 @@ def rebin_array(data_array, error_array, headers, pxsize=2, scale="px", operatio
nw.wcs.crpix /= Dxy
nw.array_shape = new_shape
new_header["NAXIS1"], new_header["NAXIS2"] = nw.array_shape
new_header["PHOTFLAM"] = header["PHOTFLAM"] * (Dxy[0] * Dxy[1])
for key, val in nw.to_header().items():
new_header.set(key, val)
new_header["SAMPLING"] = (str(pxsize) + scale, "Resampling performed during reduction")