Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compatability edits #2

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
38 changes: 20 additions & 18 deletions CASA_imaging/casa_image_ms.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import collections
import json
import argparse
import sys
sys.path.insert(0, '')
from process_ms import CASA_Imaging

def create_model(infile, cal_sources, model_name):
Expand Down Expand Up @@ -95,7 +97,7 @@ def set_mask(ra, dec, srcs, path, mask_size='32000arcsec', imsize=512, cell_size
final_srcs = {k: src for k,src in srcs.iteritems() if ra-fov/2 <= src['RA'] <= ra+fov/2} # check if sources cross into the FOV
if len(final_srcs) > 0:
fname = 'mask.rgn'
fname = os.path.join(path,fname)
fname = os.path.join(path,fname)
with open(fname,'w') as f:
f.write('#CRTFv0\n')
f.write(mask+'\n')
Expand All @@ -106,27 +108,27 @@ def set_mask(ra, dec, srcs, path, mask_size='32000arcsec', imsize=512, cell_size

if __name__ == '__main__':

args = sys.argv[3:]
args = sys.argv[:]
folders = [folder for folder in args if folder.endswith('ms')]
folders.sort()

config = [arg for arg in args if arg.endswith('json')][0]

with open(config) as f:
config_data = convert_json(json.load(f))

ci = CASA_Imaging(config_data)

if config_data['new_calibration'] == 'True':
cal_params = config_data['new_cal_params']
infile = cal_params['file_to_calibrate']
model_name = os.path.join(config_data['data_path']['run_folder'],cal_params['model_name'])
cal_sources = cal_params['cal_sources']
if type(cal_sources.values()[0]) is not dict:
with open(cal_sources.values()[0],'r') as fp:
cal_sources = convert_json(json.load(fp))
create_model(infile,cal_sources,model_name)
ci.create_cal_files()
infile = cal_params['file_to_calibrate']
model_name = os.path.join(config_data['data_path']['run_folder'],cal_params['model_name'])
cal_sources = cal_params['cal_sources']
if type(cal_sources.values()[0]) is not dict:
with open(cal_sources.values()[0],'r') as fp:
cal_sources = convert_json(json.load(fp))
create_model(infile,cal_sources,model_name)
ci.create_cal_files()

sources_file = config_data['clean_mask_sources']['file_name']
mask_dec = config_data['base_mask_params']['dec']
Expand All @@ -141,11 +143,11 @@ def set_mask(ra, dec, srcs, path, mask_size='32000arcsec', imsize=512, cell_size
ra, _ = find_ra_dec(folder)
mask = set_mask(ra, mask_dec, sources, path=ci.run_folder, mask_size=mask_radius)

if mask.endswith('rgn'):
print mask
ci.final_clean_params['mask'] = mask
else:
print mask
ci.final_clean_params['mask'] = mask
if mask.endswith('rgn'):
print mask
ci.final_clean_params['mask'] = mask
else:
print mask
ci.final_clean_params['mask'] = mask

ci.make_image(folder)
ci.make_image(folder)
Binary file not shown.
10 changes: 5 additions & 5 deletions CASA_imaging/imaging_runs/2458042/run_15/run_15.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"data_path" : {
"run_folder": "/data6/HERA/data/2458042/HERA_imaging/run_3",
"run_folder": "/data6/HERA/data/2458042/HERA_imaging/lmb",
"image_folder": "imgs"
},

Expand Down Expand Up @@ -32,7 +32,7 @@
},

"clean_1" : {
"niter":500,
"niter":100,
"weighting":"briggs",
"robust":-0.5,
"imsize":[512,512],
Expand All @@ -43,7 +43,7 @@
},

"clean_2" : {
"niter":500,
"niter":100,
"weighting":"briggs",
"robust":-0.5,
"imsize":[512,512],
Expand All @@ -54,7 +54,7 @@
},

"clean_final" : {
"niter": 6000,
"niter": 600,
"weighting": "briggs",
"robust" : -0.5,
"imsize" : [512,512],
Expand Down Expand Up @@ -108,7 +108,7 @@
},

"clean" : {
"niter" : 6000,
"niter" : 600,
"weighting" : "briggs",
"robust" : -0.5,
"imsize" : [512,512],
Expand Down
10 changes: 5 additions & 5 deletions CASA_imaging/imaging_runs/2458042/run_3/run_3.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"data_path" : {
"run_folder": "/data6/HERA/HERA_imaging/2458042/run_3",
"run_folder": "/data6/HERA/HERA_imaging/2458042/run_lmb2",
"image_folder": "imgs"
},

Expand Down Expand Up @@ -31,7 +31,7 @@
},

"clean_1" : {
"niter":500,
"niter":100,
"weighting":"briggs",
"robust":-0.5,
"imsize":[512,512],
Expand All @@ -42,7 +42,7 @@
},

"clean_2" : {
"niter":500,
"niter":100,
"weighting":"briggs",
"robust":-0.5,
"imsize":[512,512],
Expand All @@ -53,7 +53,7 @@
},

"clean_final" : {
"niter": 6000,
"niter": 1000,
"weighting": "briggs",
"robust" : -0.5,
"imsize" : [512,512],
Expand Down Expand Up @@ -107,7 +107,7 @@
},

"clean" : {
"niter" : 6000,
"niter" : 1000,
"weighting" : "briggs",
"robust" : -0.5,
"imsize" : [512,512],
Expand Down
Loading