aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-05-31 22:51:26 +0800
committerAaron LI <aly@aaronly.me>2017-05-31 22:51:26 +0800
commitd023383ebb31fa4750237ae5c63c59c616a3b88f (patch)
tree0f5ac087225be82d6160dc6aedfe4598ffc3c098 /bin
parent6f286557c1cd0dd3948d8199123d0820e2b9e65e (diff)
downloadfg21sim-d023383ebb31fa4750237ae5c63c59c616a3b88f.tar.bz2
Add uvsim/telescope.py and bin/make-ska1low-model
The `bin/make-ska1low-model` executable uses `telescope.py` to generate the SKA1-low telescope model for OSKAR simulation usage.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/make-ska1low-model63
1 files changed, 63 insertions, 0 deletions
diff --git a/bin/make-ska1low-model b/bin/make-ska1low-model
new file mode 100755
index 0000000..9ef0034
--- /dev/null
+++ b/bin/make-ska1low-model
@@ -0,0 +1,63 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2017 Weitian LI <weitian@aaronly.me>
+# MIT license
+#
+
+"""
+Make SKA1-low telescope model for OSKAR[1] simulation usage.
+
+[1] OSKAR: https://github.com/OxfordSKA/OSKAR
+"""
+
+import os
+import sys
+import argparse
+import logging
+
+from pkg_resources import resource_exists, resource_filename
+
+from fg21sim.configs import configs
+from fg21sim.utils import setup_logging
+from fg21sim.uvsim import telescope
+
+
+def main():
+ layoutfile = "ska1low.layout.txt"
+ layoutfile_required = True
+ if resource_exists(telescope.__package__, layoutfile):
+ layoutfile = resource_filename(telescope.__package__, layoutfile)
+ layoutfile_required = False
+ else:
+ layoutfile = None
+
+ parser = argparse.ArgumentParser(
+ description="Make SKA1-low telescope model for OSKAR")
+ parser.add_argument("-d", "--debug", dest="debug", action="store_true",
+ help="show verbose debug information")
+ parser.add_argument("-C", "--clobber", dest="clobber",
+ action="store_true",
+ help="overwrite the existing output files")
+ parser.add_argument("-l", "--layout-file", dest="layoutfile",
+ required=layoutfile_required,
+ default=layoutfile,
+ help="SKA1-low layout configuration " +
+ "(default: %s)" % layoutfile)
+ parser.add_argument("-o", "--outdir", dest="outdir",
+ required=True,
+ help="output telescope model directory")
+ args = parser.parse_args()
+
+ loglevel = "DEBUG" if args.debug else "INFO"
+ setup_logging(dict_config=configs.logging, level=loglevel)
+ tool = os.path.basename(sys.argv[0])
+ logger = logging.getLogger(tool)
+ logger.info("COMMAND: {0}".format(" ".join(sys.argv)))
+
+ ska1low = telescope.SKA1Low(args.layoutfile)
+ ska1low.generate_stations()
+ ska1low.make_oskar_model(args.outdir, clobber=args.clobber)
+
+
+if __name__ == "__main__":
+ main()