aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/galactic
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-08-14 15:46:00 +0800
committerAaron LI <aly@aaronly.me>2017-08-14 15:47:28 +0800
commit2d706a137c45c53dbb721a805bdc741cb5971a41 (patch)
tree8076f04369087a2509ef06d4d2e41b61f79e3355 /fg21sim/galactic
parentb9697f8e8c10ab80f4c24652833f33ab1a8b620b (diff)
downloadfg21sim-2d706a137c45c53dbb721a805bdc741cb5971a41.tar.bz2
Make "frequencies" optional in the simulate() method
XXX: foregrounds.py needs update! Signed-off-by: Aaron LI <aly@aaronly.me>
Diffstat (limited to 'fg21sim/galactic')
-rw-r--r--fg21sim/galactic/freefree.py19
-rw-r--r--fg21sim/galactic/snr.py20
-rw-r--r--fg21sim/galactic/synchrotron.py19
3 files changed, 46 insertions, 12 deletions
diff --git a/fg21sim/galactic/freefree.py b/fg21sim/galactic/freefree.py
index 9c9424f..a1fcf6d 100644
--- a/fg21sim/galactic/freefree.py
+++ b/fg21sim/galactic/freefree.py
@@ -86,6 +86,7 @@ class FreeFree:
self.use_float = self.configs.getn("output/use_float")
self.checksum = self.configs.getn("output/checksum")
self.clobber = self.configs.getn("output/clobber")
+ self.frequencies = self.configs.frequencies # [MHz]
self.freq_unit = au.Unit(self.configs.getn("frequency/unit"))
#
logger.info("Loaded and set up configurations")
@@ -292,10 +293,17 @@ class FreeFree:
filepath = None
return (skymap_f, filepath)
- def simulate(self, frequencies):
+ def simulate(self, frequencies=None):
"""
Simulate the synchrotron map at the specified frequencies.
+ Parameters
+ ----------
+ frequencies : float, or list[float]
+ The frequencies where to simulate the foreground map.
+ Unit: [MHz]
+ Default: None (i.e., use ``self.frequencies``)
+
Returns
-------
skymaps : list[1D `~numpy.ndarray`]
@@ -303,10 +311,15 @@ class FreeFree:
paths : list[str]
List of (absolute) path to the output sky maps.
"""
+ if frequencies is not None:
+ frequencies = np.array(frequencies, ndmin=1)
+ else:
+ frequencies = self.frequencies
+
skymaps = []
paths = []
- for f in np.array(frequencies, ndmin=1):
- skymap_f, outfile = self.simulate_frequency(f)
+ for freq in frequencies:
+ skymap_f, outfile = self.simulate_frequency(freq)
skymaps.append(skymap_f)
paths.append(outfile)
return (skymaps, paths)
diff --git a/fg21sim/galactic/snr.py b/fg21sim/galactic/snr.py
index cffbbe2..18d8262 100644
--- a/fg21sim/galactic/snr.py
+++ b/fg21sim/galactic/snr.py
@@ -90,6 +90,7 @@ class SuperNovaRemnants:
self.use_float = self.configs.getn("output/use_float")
self.checksum = self.configs.getn("output/checksum")
self.clobber = self.configs.getn("output/clobber")
+ self.frequencies = self.configs.frequencies # [MHz]
self.freq_unit = au.Unit(self.configs.getn("frequency/unit"))
logger.info("Loaded and set up configurations")
@@ -454,16 +455,18 @@ class SuperNovaRemnants:
filepath = None
return (skymap_f, filepath)
- def simulate(self, frequencies):
+ def simulate(self, frequencies=None):
"""
Simulate the sky maps of all Galactic SNRs emission at every
specified frequency.
Parameters
----------
- frequency : list[float]
- List of frequencies (unit: `self.freq_unit`) where the
- simulation performed.
+ frequencies : float, or list[float]
+ The frequencies where to simulate the foreground map.
+ Unit: [MHz]
+ Default: None (i.e., use ``self.frequencies``)
+
Returns
-------
@@ -472,10 +475,15 @@ class SuperNovaRemnants:
paths : list[str]
List of (absolute) path to the output sky maps.
"""
+ if frequencies is not None:
+ frequencies = np.array(frequencies, ndmin=1)
+ else:
+ frequencies = self.frequencies
+
skymaps = []
paths = []
- for f in np.array(frequencies, ndmin=1):
- skymap_f, outfile = self.simulate_frequency(f)
+ for freq in frequencies:
+ skymap_f, outfile = self.simulate_frequency(freq)
skymaps.append(skymap_f)
paths.append(outfile)
return (skymaps, paths)
diff --git a/fg21sim/galactic/synchrotron.py b/fg21sim/galactic/synchrotron.py
index f6b1db8..96f4df1 100644
--- a/fg21sim/galactic/synchrotron.py
+++ b/fg21sim/galactic/synchrotron.py
@@ -66,6 +66,7 @@ class Synchrotron:
self.use_float = self.configs.getn("output/use_float")
self.checksum = self.configs.getn("output/checksum")
self.clobber = self.configs.getn("output/clobber")
+ self.frequencies = self.configs.frequencies # [MHz]
self.freq_unit = au.Unit(self.configs.getn("frequency/unit"))
#
logger.info("Loaded and setup configurations")
@@ -230,10 +231,17 @@ class Synchrotron:
filepath = None
return (skymap_f, filepath)
- def simulate(self, frequencies):
+ def simulate(self, frequencies=None):
"""
Simulate the synchrotron map at the specified frequencies.
+ Parameters
+ ----------
+ frequencies : float, or list[float]
+ The frequencies where to simulate the foreground map.
+ Unit: [MHz]
+ Default: None (i.e., use ``self.frequencies``)
+
Returns
-------
skymaps : list[1D `~numpy.ndarray`]
@@ -241,10 +249,15 @@ class Synchrotron:
paths : list[str]
List of (absolute) path to the output sky maps.
"""
+ if frequencies is not None:
+ frequencies = np.array(frequencies, ndmin=1)
+ else:
+ frequencies = self.frequencies
+
skymaps = []
paths = []
- for f in np.array(frequencies, ndmin=1):
- skymap_f, outfile = self.simulate_frequency(f)
+ for freq in frequencies:
+ skymap_f, outfile = self.simulate_frequency(freq)
skymaps.append(skymap_f)
paths.append(outfile)
return (skymaps, paths)