Skip to content

Commit

Permalink
Merge pull request #178 from ptiede/ptiede-errormat
Browse files Browse the repository at this point in the history
PR to fix error matrix for circular polarization
  • Loading branch information
achael authored Dec 8, 2023
2 parents 16ec509 + 21ca986 commit 52285e1
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion ehtim/obsdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,13 @@ def reorder_baselines(self, trial_speedups=False):
lr = dat['lrvis'].copy()
dat['rlvis'] = np.conj(lr)
dat['lrvis'] = np.conj(rl)

# You also have to switch the errors for the coherency!
rlerr = dat['rlsigma'].copy()
lrerr = dat['lrsigma'].copy()
dat["rlsigma"] = lrerr
dat["lrsigma"] = rlerr

else:
raise Exception("polrep must be either 'stokes' or 'circ'")

Expand Down Expand Up @@ -439,7 +446,14 @@ def reorder_baselines_trial_speedups(self):
rl = dat['rlvis'].copy()
lr = dat['lrvis'].copy()
dat['rlvis'][ordermask] = np.conj(lr[ordermask])
dat['lrvis'][ordermask] = np.conj(rl[ordermask])
dat['lrvis'][ordermask] = np.conj(rl[ordermask])

# Also need to switch error matrix
rle = dat['rlsigma'].copy()
lre = dat['lrsigma'].copy()
dat['rlsigma'][ordermask] = lre[ordermask]
dat['lrsigma'][ordermask] = rle[ordermask]

else:
raise Exception("polrep must be either 'stokes' or 'circ'")

Expand Down Expand Up @@ -543,8 +557,15 @@ def data_conj(self):
data[f] = np.hstack((self.data['rlvis'], np.conj(self.data['lrvis'])))
elif f == 'lrvis':
data[f] = np.hstack((self.data['lrvis'], np.conj(self.data['rlvis'])))

# ALSO SWITCH THE ERRORS!
else:
raise Exception("polrep must be either 'stokes' or 'circ'")
# The conjugate baselines need the transpose error terms.
elif f == "rlsigma":
data[f] = np.hstack((self.data["rlsigma"], self.data["lrsigma"]))
elif f == "lrsigma":
data[f] = np.hstack((self.data["lrsigma"], self.data["rlsigma"]))

else:
data[f] = np.hstack((self.data[f], self.data[f]))
Expand Down

0 comments on commit 52285e1

Please sign in to comment.