From cbbd8eec608ac6d1b037e33ecbe0b76c4bfa6ccc Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sun, 9 Oct 2016 22:42:27 +0800 Subject: Use newly added "read_fits_healpix()" Also remove a unused variable in "galactic/synchrotron.py" --- fg21sim/galactic/synchrotron.py | 17 +++++------------ fg21sim/utils/healpix.py | 6 +++--- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/fg21sim/galactic/synchrotron.py b/fg21sim/galactic/synchrotron.py index 44716f9..dacec8f 100644 --- a/fg21sim/galactic/synchrotron.py +++ b/fg21sim/galactic/synchrotron.py @@ -14,7 +14,7 @@ from astropy.io import fits import astropy.units as au import healpy as hp -from ..utils import write_fits_healpix +from ..utils import read_fits_healpix, write_fits_healpix logger = logging.getLogger(__name__) @@ -75,9 +75,8 @@ class Synchrotron: def _load_template(self): """Load the template map""" - self.template, header = hp.read_map(self.template_path, - nest=False, h=True, verbose=False) - self.template_header = fits.header.Header(header) + self.template, header = read_fits_healpix(self.template_path) + self.template_header = header self.template_nside = self.template_header["NSIDE"] self.template_ordering = self.template_header["ORDERING"] logger.info("Loaded template map from {0} (Nside={1})".format( @@ -85,9 +84,8 @@ class Synchrotron: def _load_indexmap(self): """Load the spectral index map""" - self.indexmap, header = hp.read_map(self.indexmap_path, - nest=False, h=True, verbose=False) - self.indexmap_header = fits.header.Header(header) + self.indexmap, header = read_fits_healpix(self.indexmap_path) + self.indexmap_header = header self.indexmap_nside = self.indexmap_header["NSIDE"] self.indexmap_ordering = self.indexmap_header["ORDERING"] logger.info("Loaded spectral index map from {0} (Nside={1})".format( @@ -182,11 +180,6 @@ class Synchrotron: """Write the simulated synchrotron map to disk with proper header keywords and history. """ - FITS_COLUMN_FORMATS = { - np.dtype("float32"): "E", - np.dtype("float64"): "D", - } - # if not os.path.exists(self.output_dir): os.mkdir(self.output_dir) logger.info("Created output dir: {0}".format(self.output_dir)) diff --git a/fg21sim/utils/healpix.py b/fg21sim/utils/healpix.py index 294c588..0307f08 100644 --- a/fg21sim/utils/healpix.py +++ b/fg21sim/utils/healpix.py @@ -31,6 +31,8 @@ import numpy as np import healpy as hp from astropy.io import fits +from . import read_fits_healpix + logger = logging.getLogger(__name__) @@ -57,9 +59,7 @@ def healpix2hpx(data, header=None, append_history=None, append_comment=None): (hpx_data, hpx_header) : (2D numpy array, astropy.io.fits header) """ if isinstance(data, str) or isinstance(data, fits.BinTableHDU): - hp_data, hp_header = hp.read_map(data, nest=False, h=True, - verbose=False) - hp_header = fits.header.Header(hp_header) + hp_data, hp_header = read_fits_healpix(data) logger.info("Read HEALPix data from file or HDU") else: hp_data, hp_header = np.asarray(data), fits.header.Header(header) -- cgit v1.2.2