Skip to content

Commit

Permalink
change loading name
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuke-takase committed Aug 8, 2024
1 parent 3b43c9f commit e24ad5f
Show file tree
Hide file tree
Showing 9 changed files with 3,589 additions and 352 deletions.
2 changes: 1 addition & 1 deletion notebooks/diff_gain_boresight.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"source": [
"# Load single detector map\n",
"base_path = \"../maps\"\n",
"scan_field = ScanFields.load_det(base_path, \"nside128_boresight.h5\")\n",
"scan_field = ScanFields.load_det(base_path, \"nside128_boresight\")\n",
"fiducial_map = hp.read_map(\"../maps/cmb_0000_nside_128_seed_33.fits\", field=(0,1,2)) * 1e6\n",
"\n",
"fwhm = np.deg2rad(1.0)\n",
Expand Down
12 changes: 6 additions & 6 deletions notebooks/diff_gain_channel.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion notebooks/diff_pointing_boresight.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"source": [
"# Load single detector map\n",
"base_path = \"../maps\"\n",
"scan_field = ScanFields.load_det(base_path, \"nside128_boresight.h5\")\n",
"scan_field = ScanFields.load_det(base_path, \"nside128_boresight\")\n",
"fiducial_map = hp.read_map(\"../maps/cmb_0000_nside_128_seed_33.fits\", field=(0,1,2)) * 1e6\n",
"\n",
"fwhm = np.deg2rad(1.0)\n",
Expand Down
38 changes: 9 additions & 29 deletions notebooks/diff_pointing_channel.ipynb

Large diffs are not rendered by default.

88 changes: 22 additions & 66 deletions notebooks/load_crosslink.ipynb

Large diffs are not rendered by default.

3,783 changes: 3,537 additions & 246 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ numpy = "^1.23"
healpy = "^1.15.0"
matplotlib = "^3.1"
h5py = "^3.11.0"
pytest = "^8.1.1"
pytest = "^7.4"
litebird_sim = "^0.13.0"

[build-system]
requires = ["poetry-core"]
Expand Down
Binary file modified sbm/__pycache__/sbm.cpython-310.pyc
Binary file not shown.
13 changes: 11 additions & 2 deletions sbm/sbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(self):
self.fwhms = [70.5,58.5,51.1,41.6,47.1,36.9,43.8,33.0,41.5,30.2,26.3,23.7,37.8,33.6,30.8,28.9,28.0,28.6,24.7,22.5,20.9,17.9]

@classmethod
def load_det(cls, base_path: str, filename: str):
def load_det(cls, base_path: str, det_name: str):
""" Load the scan fields data of a detector from a .h5 file
Args:
Expand All @@ -93,9 +93,13 @@ def load_det(cls, base_path: str, filename: str):
Returns:
instance (ScanFields): instance of the ScanFields class containing the scan fields data of the detector
"""
assert filename.endswith('.h5'), "Invalid file path. Must be a .h5 file"
instance = cls()
instance.ndet = 1
t2b = None
if det_name[-1] == "B":
t2b = True
det_name = det_name[:-1] + "T"
filename = det_name + ".h5"
with h5py.File(os.path.join(base_path, filename), 'r') as f:
instance.ss = {key: value[()] for key, value in zip(f['ss'].keys(), f['ss'].values()) if key != "quat"}
instance.hitmap = f['hitmap'][:]
Expand All @@ -104,6 +108,8 @@ def load_det(cls, base_path: str, filename: str):
instance.spins = f['quantify']['n'][()]
instance.nside = hp.npix2nside(len(instance.hitmap))
instance.npix = hp.nside2npix(instance.nside)
if t2b == True:
instance = instance.t2b()
return instance

@classmethod
Expand All @@ -120,6 +126,7 @@ def load_channel(cls, base_path: str, channel: str):
"""
dirpath = os.path.join(base_path, channel)
filenames = os.listdir(dirpath)
filenames = [os.path.splitext(filename)[0] for filename in filenames]
first_sf = cls.load_det(dirpath, filenames[0])
instance = cls()
instance.ndet = len(filenames)
Expand Down Expand Up @@ -298,6 +305,7 @@ def sim_diff_gain_channel(
):
dirpath = os.path.join(base_path, channel)
filenames = os.listdir(dirpath)
filenames = [os.path.splitext(filename)[0] for filename in filenames]
assert len(filenames) == len(gain_a) == len(gain_b)
total_sf = cls.load_det(dirpath, filenames[0])
total_sf.initialize(mdim)
Expand Down Expand Up @@ -361,6 +369,7 @@ def sim_diff_pointing_channel(

dirpath = os.path.join(base_path, channel)
filenames = os.listdir(dirpath)
filenames = [os.path.splitext(filename)[0] for filename in filenames]
assert len(filenames) == len(rho) == len(chi)
total_sf = cls.load_det(dirpath, filenames[0])
total_sf.initialize(mdim)
Expand Down

0 comments on commit e24ad5f

Please sign in to comment.