aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/extragalactic/clusters.py
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2016-11-21 10:16:57 +0800
committerAaron LI <aaronly.me@outlook.com>2016-11-21 10:16:57 +0800
commit8adeeb51cca40337cce36f94d00bacc84c33731d (patch)
tree97db1ae9e7faec3375c06fdd92bc4c97603b6a7a /fg21sim/extragalactic/clusters.py
parentbc2dee6824c9507b7f73b29c0c78f6d38ac76240 (diff)
downloadfg21sim-8adeeb51cca40337cce36f94d00bacc84c33731d.tar.bz2
Update "simulate_frequency()" to also return the output file path
* Update "output()" method to return the output file path * Update "simulate()" to also return the list of output file paths
Diffstat (limited to 'fg21sim/extragalactic/clusters.py')
-rw-r--r--fg21sim/extragalactic/clusters.py25
1 files changed, 20 insertions, 5 deletions
diff --git a/fg21sim/extragalactic/clusters.py b/fg21sim/extragalactic/clusters.py
index d23ddbf..3b3262f 100644
--- a/fg21sim/extragalactic/clusters.py
+++ b/fg21sim/extragalactic/clusters.py
@@ -585,6 +585,11 @@ class GalaxyClusters:
def output(self, hpmap, frequency):
"""Write the simulated free-free map to disk with proper header
keywords and history.
+
+ Returns
+ -------
+ filepath : str
+ The (absolute) path to the output HEALPix map file.
"""
if not os.path.exists(self.output_dir):
os.mkdir(self.output_dir)
@@ -604,6 +609,7 @@ class GalaxyClusters:
write_fits_healpix(filepath, hpmap, header=header,
clobber=self.clobber, checksum=self.checksum)
logger.info("Write simulated map to file: {0}".format(filepath))
+ return filepath
def preprocess(self):
"""Perform the preparation procedures for the final simulations.
@@ -647,7 +653,10 @@ class GalaxyClusters:
Returns
-------
hpmap_f : 1D `~numpy.ndarray`
- HEALPix map data in RING ordering
+ The HEALPix map (RING ordering) at the input frequency.
+ filepath : str
+ The (absolute) path to the output HEALPix file if saved,
+ otherwise ``None``.
See Also
--------
@@ -665,8 +674,10 @@ class GalaxyClusters:
hpmap_f[hpidx] += hpval
#
if self.save:
- self.output(hpmap_f, frequency)
- return hpmap_f
+ filepath = self.output(hpmap_f, frequency)
+ else:
+ filepath = None
+ return (hpmap_f, filepath)
def simulate(self, frequencies):
"""Simulate the emission (HEALPix) maps of all Galactic SNRs for
@@ -682,12 +693,16 @@ class GalaxyClusters:
-------
hpmaps : list[1D `~numpy.ndarray`]
List of HEALPix maps (in RING ordering) at each frequency.
+ paths : list[str]
+ List of (absolute) path to the output HEALPix maps.
"""
hpmaps = []
+ paths = []
for f in np.array(frequencies, ndmin=1):
- hpmap_f = self.simulate_frequency(f)
+ hpmap_f, filepath = self.simulate_frequency(f)
hpmaps.append(hpmap_f)
- return hpmaps
+ paths.append(filepath)
+ return (hpmaps, paths)
def postprocess(self):
"""Perform the post-simulation operations before the end."""