Skip to content

Commit

Permalink
Fixing output orientations and expectations for input to flux calcula…
Browse files Browse the repository at this point in the history
…tion.
  • Loading branch information
nenasedk committed May 9, 2022
1 parent f0986d6 commit f161440
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 197 deletions.
268 changes: 75 additions & 193 deletions docs/source/tutorials/03_psfsub.ipynb

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions vip_hci/invprob/paco.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ def run(self,
x, y = np.meshgrid(np.arange(0, self.height),
np.arange(0, self.width))
phi0s = np.column_stack((x.flatten(), y.flatten()))
print(phi0s)
# Compute a,b
a, b = self.PACOCalc(np.array(phi0s), cpu=cpu)

Expand Down Expand Up @@ -550,7 +549,8 @@ def flux_estimate(self,
----------
phi0s : numpy.ndarray
List of locations of sources to compute unbiased flux estimate in pixel units.
Origin is at the bottom left.
Origin is at the bottom left. Should be a list of (x,y) tuples, or a 2D numpy
array.
eps : float
Precision requirement for iteration (0,1)
initial_est : float
Expand Down Expand Up @@ -602,6 +602,7 @@ def flux_estimate(self,
ests = []
stds = []
for i, p0 in enumerate(phi0s):
p0 = (p0[1],p0[0])
angles_px = np.array(get_rotated_pixel_coords(x, y, p0, self.angles))
hon = []
for l, ang in enumerate(angles_px):
Expand Down Expand Up @@ -887,6 +888,7 @@ def PACOCalc(self,

a = np.zeros(npx) # Setup output arrays
b = np.zeros(npx)
phi0s = np.array([phi0s[:,1],phi0s[:,0]]).T

if cpu == 1:
Cinv, m, patches = self.compute_statistics(phi0s)
Expand Down Expand Up @@ -1034,6 +1036,10 @@ def compute_statistics_parallel(self,
self.width,
self.patch_area_pixels,
self.patch_area_pixels))
patches = np.swapaxes(patches,0,1)
m = np.swapaxes(m,0,1)
Cinv = np.swapaxes(Cinv,0,1)

return Cinv, m, patches


Expand Down Expand Up @@ -1122,7 +1128,7 @@ def PACOCalc(self,
# i is the same as theta_k in the PACO paper
for i, p0 in enumerate(phi0s):
# Get list of pixels for each rotation angle
angles_px = get_rotated_pixel_coords(x, y, (p0[0],p0[1]), self.angles)
angles_px = get_rotated_pixel_coords(x, y, (p0[1],p0[0]), self.angles)

# Ensure within image bounds
if(int(np.max(angles_px.flatten())) >= self.width or
Expand All @@ -1140,7 +1146,6 @@ def PACOCalc(self,
for l, ang in enumerate(angles_px):
# Get the column of patches at this point
if np.max(patch[int(ang[0]),int(ang[1])]) == 0:
# For some black magic reason this needs to be inverted here.
apatch = self.get_patch((int(ang[1]),int(ang[0])))
patch[int(ang[0]),int(ang[1])] = apatch
m[int(ang[0]),int(ang[1])], Cinv[int(ang[0]),int(ang[1])] = compute_statistics_at_pixel(apatch)
Expand Down

0 comments on commit f161440

Please sign in to comment.