aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/hpx2healpix20
-rw-r--r--fg21sim/galactic/synchrotron.py9
2 files changed, 7 insertions, 22 deletions
diff --git a/bin/hpx2healpix b/bin/hpx2healpix
index ce83553..ac65fbd 100755
--- a/bin/hpx2healpix
+++ b/bin/hpx2healpix
@@ -18,18 +18,7 @@ from astropy.io import fits
import fg21sim
from fg21sim.configs import configs
-from fg21sim.utils import hpx2healpix, setup_logging
-
-
-# Reference:
-# http://docs.astropy.org/en/stable/io/fits/usage/table.html#column-creation
-FITS_COLUMN_FORMATS = {
- np.dtype("int16"): "I",
- np.dtype("int32"): "J",
- np.dtype("int64"): "K",
- np.dtype("float32"): "E",
- np.dtype("float64"): "D",
-}
+from fg21sim.utils import hpx2healpix, write_fits_healpix, setup_logging
def main():
@@ -82,11 +71,8 @@ def main():
if args.float:
logger.info("HEALPix data: use single-precision float numbers")
hp_data = hp_data.astype(np.float32)
- hdu = fits.BinTableHDU.from_columns([
- fits.Column(name="I", array=hp_data,
- format=FITS_COLUMN_FORMATS.get(hp_data.dtype))
- ], header=hp_header)
- hdu.writeto(args.outfile, clobber=args.clobber, checksum=True)
+ write_fits_healpix(args.outfile, hpmap=hp_data, header=hp_header,
+ clobber=args.clobber)
logger.info("HEALPix data write to FITS file: %s" % args.outfile)
diff --git a/fg21sim/galactic/synchrotron.py b/fg21sim/galactic/synchrotron.py
index 614aae9..44716f9 100644
--- a/fg21sim/galactic/synchrotron.py
+++ b/fg21sim/galactic/synchrotron.py
@@ -14,6 +14,8 @@ from astropy.io import fits
import astropy.units as au
import healpy as hp
+from ..utils import write_fits_healpix
+
logger = logging.getLogger(__name__)
@@ -203,11 +205,8 @@ class Synchrotron:
)
if self.use_float:
hpmap = hpmap.astype(np.float32)
- hdu = fits.BinTableHDU.from_columns([
- fits.Column(name="I", array=hpmap,
- format=FITS_COLUMN_FORMATS.get(hpmap.dtype))
- ], header=header)
- hdu.writeto(filepath, clobber=self.clobber, checksum=True)
+ write_fits_healpix(filepath, hpmap, header=header,
+ clobber=self.clobber)
logger.info("Write simulated map to file: {0}".format(filepath))
def simulate(self, frequencies):