forked from akleroy/phangs_imaging_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage_data_with_taper.py
151 lines (111 loc) · 5.07 KB
/
image_data_with_taper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# This script carries out the imaging. It makes a dirty image, reads
# and aligns the user-supplied clean mask, carries out multiscale
# imaging down to S/N ~ 4, builds a mask of bright emission, carries
# out a single scale clean down to low S/N within this mask, and then
# exports the output to FITS.
# Right now it should work well for CO21 and C18O21. Imaging of the
# two-d products is still TBD.
# Edit the "Control Flow" section to use the script.
# WARNING! Right now a bug prevents the script from stopping and
# starting effectively, so it needs to be run end-to-end to work. This
# shouldn't be a big problem for the 7m data.
import os
import phangsPipeline as pp
import analysisUtils as au
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Control Flow
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# ... a text list. The script will process only these galaxies.
only = []
# ... skip these galaxies
skip = []
# ... set as '12m', '7m', or '12m+7m' to process only data from that
# array. Leave it as None to process all data.
just_array = ['7m']
# ... set as the products to be handled. Valid choices for the basic
# PHANGS data are 'co21', 'c18o21', 'cont', 'co21_chan0', and
# 'c18o21_chan0'. Note that right now cont and chan0 are not tested.
just_product = ['co21']
# ... set these variables to indicate what steps of the script should
# be performed. The steps do:
# make_dirty_image - make a niter=0 image cube. Useful for checking
# mosaic parameters and that sort of thing. Used as a template for the
# clean mask, so this needs to be done first.
# revert_to_dirty - (DOES NOT WORK RIGHT NOW) reset the whole process
# so that the cube is now the dirty cube. Unfortunately there's some
# 'memory' related to the clean call in CASA that is causing a bug so
# that things don't cleanly resume from here.
# read_in_clean_mask - if a clean mask is found in the ../clean_masks/
# directory, read it in and align it to the astrometric grid of the
# dirty image. This is now the .mask file and will be used in future
# imaging.
# run_multiscale_clean - run a multiscale clean using a set of scales
# selected for that array combination. By default, clean down to a
# signal to noise of 4 in the residuals or stop when successive
# iterations of clean change the flux in the model by less than 2%.
# revert_to_multiscale - (DOES NOT WORK RIGHT NOW) reset the process
# to just after the multiscale clean. See revert_to_dirty above.
# make_singlescale_mask - construct a signal-to-noise based mask for
# use in single scale clean. Uses the .image to do this, so that
# bright regions in the image so far get more cleaning. This maks is
# joined with the clean mask, so no regions are included outside the
# clean mask.
# run_singlescale_clean - run a single scale hogbom clean inside the
# bright regions defined above. Clean with a very low (S/N ~ 1)
# threshold and stop based on convergence in flux between successive
# model images.
# export_to_fits - export the dirt, multiscale, and final images and
# associated products to FITS files for subsequent processing.
# Right now I recommend to not change the flow, and to rerun imaging
# from beginning to end when using the script.
make_dirty_image=True
revert_to_dirty=False
read_in_clean_mask=True
run_multiscale_clean=True
revert_to_multiscale=False
make_singlescale_mask=True
run_singlescale_clean=True
export_to_fits=True
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Loop
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
gals = pp.list_gal_names()
array_list = ['12m', '7m', '12m+7m']
product_list = ['co21','c18o21','cont','co21_chan0','c18o21_chan0']
for gal in gals:
if len(only) > 0:
if only.count(gal) == 0:
print "Skipping "+gal
continue
if len(skip) > 0:
if skip.count(gal) > 0:
print "Skipping "+gal
continue
for array in array_list:
if len(just_array) > 0:
if just_array.count(array) == 0:
print "Skipping "+array
continue
for product in product_list:
if len(just_product) > 0:
if just_product.count(product) == 0:
print "Skipping "+product
continue
print gal, array, product
clean_call = pp.buildPhangsCleanCall(
gal=gal,
array=array,
product=product,
tag='tapered')
clean_call.uvtaper = 8.
pp.phangsImagingRecipe(
clean_call=clean_call,
make_dirty_image=make_dirty_image,
revert_to_dirty=revert_to_dirty,
read_in_clean_mask=read_in_clean_mask,
run_multiscale_clean=run_multiscale_clean,
revert_to_multiscale=revert_to_multiscale,
make_singlescale_mask=make_singlescale_mask,
run_singlescale_clean=run_singlescale_clean,
do_export_to_fits=export_to_fits,
)