diff options
author | Aaron LI <aly@aaronly.me> | 2017-12-03 19:46:35 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2017-12-03 19:46:35 +0800 |
commit | e6085558dae8594ab309ade6d9772e79b5cc746a (patch) | |
tree | e580ddc9debdd887ad995565534eba53105f0d57 /astro/21cm | |
parent | 4f8e6fb7201fcb85b19131d9dc9886a4647682f0 (diff) | |
download | atoolbox-e6085558dae8594ab309ade6d9772e79b5cc746a.tar.bz2 |
astro/make_lightcone.py: allow variables in "outfile" option
Diffstat (limited to 'astro/21cm')
-rwxr-xr-x | astro/21cm/make_lightcone.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/astro/21cm/make_lightcone.py b/astro/21cm/make_lightcone.py index 2c428ae..cb38f86 100755 --- a/astro/21cm/make_lightcone.py +++ b/astro/21cm/make_lightcone.py @@ -57,8 +57,8 @@ Lside: Nside: # Filename pattern of the input coeval cubes infiles_pattern: "deltaTb_z{z:05.3f}_N{Nside:d}_L{Lside:.1f}.dat" -# Filename of output light-cone cube (required) -outfile: deltaTb_lightcone.fits +# Filename of output light-cone cube +outfile: "deltaTb_z{zmin:.1f}-{zmax:.1f}_lightcone.fits" --------------------------------------------------------------------------- """ @@ -120,6 +120,12 @@ class Configs: else: raise OSError("requested file does not exists: %s" % filename) + def get_outfile(self): + data = {"zmin": self.zmin, "zmax": self.zmax, "dz": self.dz, + "Nside": self.Nside, "Lside": self.Lside} + filename = self.outfile.format(**data) + return filename + def get_cubepair(self, z): """ Get the consecutive two cubes enclosing the given redshift. @@ -281,7 +287,7 @@ class LightCone: def write(self, outfile=None, clobber=None): if outfile is None: - outfile = self.configs.outfile + outfile = self.get_outfile() if clobber is None: clobber = self.configs.clobber @@ -300,7 +306,7 @@ def main(): args = parser.parse_args() configs = Configs(args.config) - if os.path.exists(configs.outfile) and (not configs.clobber): + if os.path.exists(configs.get_outfile()) and (not configs.clobber): raise OSError("output file already exists: %s" % configs.outfile) cubepair = CubePair(Nside=configs.Nside, dtype=configs.dtype) |