Skip to content

Commit

Permalink
Final removal of ra and subtraction of ra in scan.py
Browse files Browse the repository at this point in the history
  • Loading branch information
FeGeyer committed Jul 22, 2024
1 parent eeaac67 commit add7e77
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
12 changes: 3 additions & 9 deletions pyvisgen/simulation/observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,12 @@ def create_rd_grid(self):
# define resolution
res = fov / self.img_size

ra = torch.deg2rad(self.ra)
dec = torch.deg2rad(self.dec)

r = (
torch.arange(self.img_size, device=self.device, dtype=torch.float64)
- self.img_size / 2
) * res + ra
) * res
d = (
torch.arange(self.img_size, device=self.device, dtype=torch.float64)
- self.img_size / 2
Expand All @@ -391,18 +390,13 @@ def create_lm_grid(self):
3d array
Returns a 3d array with every pixel containing a l and m value
"""
ra = torch.deg2rad(self.ra)
dec = torch.deg2rad(self.dec)

lm_grid = torch.zeros(self.rd.shape, device=self.device, dtype=torch.float64)
lm_grid[:, :, 0] = (
torch.cos(self.rd[..., 1]) * torch.sin(self.rd[..., 0] - ra)
).T
lm_grid[:, :, 0] = (torch.cos(self.rd[..., 1]) * torch.sin(self.rd[..., 0])).T
lm_grid[:, :, 1] = (
torch.sin(self.rd[..., 1]) * torch.cos(dec)
- torch.cos(self.rd[..., 1])
* torch.sin(dec)
* torch.cos(self.rd[..., 0] - ra)
- torch.cos(self.rd[..., 1]) * torch.sin(dec) * torch.cos(self.rd[..., 0])
).T
return lm_grid

Expand Down
2 changes: 1 addition & 1 deletion pyvisgen/simulation/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def angularDistance(rd, ra, dec):
Returns angular Distance for every pixel in rd grid with respect
to source position
"""
r = rd[..., 0] - torch.deg2rad(ra.to(rd.device))
r = rd[..., 0]

Check warning on line 118 in pyvisgen/simulation/scan.py

View check run for this annotation

Codecov / codecov/patch

pyvisgen/simulation/scan.py#L118

Added line #L118 was not covered by tests
d = rd[..., 1] - torch.deg2rad(dec.to(rd.device))
theta = torch.arcsin(torch.sqrt(r**2 + d**2))
return theta
Expand Down

0 comments on commit add7e77

Please sign in to comment.