Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HEALPix unit conversion at load time #795

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix another place where unit conversion might have failed
keskitalo committed Oct 28, 2024
commit 4c058c627f1efbc93f0bab904db2965304f40da2
5 changes: 2 additions & 3 deletions src/toast/pixels_io_healpix.py
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
from .io import have_hdf5_parallel
from .mpi import MPI, use_mpi
from .timing import Timer, function_timer
from .utils import Logger, memreport
from .utils import Logger, memreport, unit_conversion


@function_timer
@@ -76,8 +76,7 @@ def read_healpix_fits(pix, path, nest=True, comm_bytes=10000000):
log.info(msg)
funits = pix.units
if funits != pix.units:
scale = 1.0 * funits
fscale = scale.to_value(pix.units)
fscale = unit_conversion(funits, pix.units)

if nside_map != nside:
errors += f"Wrong NSide: {path} has {nside_map}, expected {nside}\n"
5 changes: 2 additions & 3 deletions src/toast/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015-2020 by the parties listed in the AUTHORS file.
# Copyright (c) 2015-2024 by the parties listed in the AUTHORS file.
# All rights reserved. Use of this source code is governed by
# a BSD-style license that can be found in the LICENSE file.

@@ -773,8 +773,7 @@ def unit_conversion(source, target):

"""
scale = 1.0 * source
scale.to(target)
return scale.to(target).value
return scale.to_value(target)


class SetDict(UserDict):