Skip to content

Commit

Permalink
add warnings for BeamGrid depends on its beam solid angle.
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuke-takase committed Apr 23, 2024
1 parent fc7f80f commit 9171ad3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ cd grasp2alm
pip install -e .
```

## Dependency

- `numpy`
- `healpy`
- `matplotlib`

## Class Descriptions

### Class: BeamGrid
Expand Down
10 changes: 8 additions & 2 deletions grasp2alm/beam_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from dataclasses import dataclass
import numpy as np
import matplotlib.pyplot as plt
import warnings
from .beam_polar import BeamPolar

@dataclass
Expand Down Expand Up @@ -77,16 +78,18 @@ def __post_init__(self):
self.freq = float(fi.readline().strip())
else:
self.header += "\n" + line

self.ktype = int(fi.readline())
assert self.ktype == 1, "Unknown Grasp grid format, ktype != 1"

line = fi.readline().split()
self.nset = int(line[0])
self.icomp = int(line[1])
self.ncomp = int(line[2])
self.igrid = int(line[3])

if self.nset > 1:
print("Warning: nset > 1, only reading first beam in file")
warnings.warn("Warning: nset > 1, only reading first beam in file")

line = fi.readline().split()
self.ix = int(line[0])
Expand All @@ -102,6 +105,10 @@ def __post_init__(self):
self.xe = float(line[2])
self.ye = float(line[3])

beam_solid_angle_rad = (np.cos(np.deg2rad(self.ys)) - np.cos(np.deg2rad(self.ye))) * (np.deg2rad(self.xe) - np.deg2rad(self.xs))
if not np.isclose(beam_solid_angle_rad, 2.0*np.pi) and not np.isclose(beam_solid_angle_rad, 4.0*np.pi):
warnings.warn("Warning: beam solid angle is not 2pi or 4pi because BeamGrid has xs={xs}, xe={xe}, ys={ys} and ye={ye}. The header should be checked.")

line = fi.readline().split()
self.nx = int(line[0])
self.ny = int(line[1])
Expand Down Expand Up @@ -157,7 +164,6 @@ def to_polar(self, copol_axis="x"):
if swaptheta:
print("Warning: swapping theta direction")
theta_rad_min = np.deg2rad(self.ye)

theta_rad_max = np.deg2rad(self.ys)
beam_polar = BeamPolar(nphi, ntheta, theta_rad_min, theta_rad_max, self.filename)

Expand Down

0 comments on commit 9171ad3

Please sign in to comment.