Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions mk_template.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
"""
mk_template.py

Usage:
> python mk_template.py <template_name>
Usage:
> python mk_template.py <template_name>

Settings are edited by the user in 'tconfig_<template_name>.py'.

Outputs:
- see CASA_scripts/mock_obs.py
- see CASA_scripts/mock_obs.py
"""
import os, sys, time, importlib
import numpy as np
import const as const
import os
import sys
from importlib import import_module

# Parse the template name.

template_name = sys.argv[-1]

# Load template inputs
inp = importlib.import_module('tconfig_'+sys.argv[-1])

inp = import_module('tconfig_{}'.format(template_name))

# Set up template storage space (if necessary)
if inp.template_dir[-1] != '/': inp.template_dir += '/'
if not os.path.exists(inp.template_dir):
os.system('mkdir '+inp.template_dir)
os.system('mkdir '+inp.template_dir+'sims')
elif not os.path.exists(inp.template_dir+'sims'):
os.system('mkdir '+inp.template_dir+'sims')

inp.template_dir += '/' if inp.template_dir[-1] != '/' else ''
if not os.path.exists(inp.template_dir):
os.system('mkdir {}'.format(inp.template_dir))
if not os.path.exists(inp.template_dir+'sims'):
os.system('mkdir {}sims'.format(inp.template_dir))

# Generate the template
os.system('rm -rf CASA_logs/mock_obs_'+sys.argv[-1]+'.log')
os.system('casa --nologger --logfile CASA_logs/mock_obs_'+sys.argv[-1]+\
'.log -c CASA_scripts/mock_obs.py '+sys.argv[-1])

os.system('rm -rf CASA_logs/mock_obs_{}.log'.format(template_name))
os.system('casa --nologger --logfile '
+ 'CASA_logs/mock_obs_{}.log '.format(template_name)
+ '-c CASA_scripts/mock_obs.py {}'.format(template_name))