phangs_make_jwst_images.pro
7.77 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
PRO phangs_make_jwst_images,source_name=source_name,save=save,show_images=show_images,nostop=nostop
;phangs_make_jwst_images,source_name='ngc0628',/save,/show,/nostop
use_source_name='ngc0628'
IF keyword_set(source_name) THEN use_source_name=source_name
pdp_define_la_common
;window,0
obp=[1.1,0,1.15,1]
win=0L
;data_dir='/Volumes/PILOT_FLIGHT1/PHANGS-JWST/DR1/'
NH_data_dir=!phangs_data_dir+'/phangs_drive/PHANGS-JWST/DR1/'
data_dir=!phangs_data_dir+'/phangs_drive/PHANGS-JWST/DR1/'
save_data_dir=!phangs_data_dir+'/ISRF/WORK/'
;========== get JWST reference header
file=data_dir+use_source_name+'_nircam_lv3_f300m_i2d_anchor_atgauss1.fits'
d=mrdfits(file,1,h)
ind=where(finite(d) NE 1,count)
IF count NE 0 THEN d[ind]=la_undef()
print,sxpar(h,'CDELT1')
href=cd2astro_header(h)
sxaddpar,href,'EQUINOX',2000.
IF keyword_set(show_images) THEN BEGIN
window,win & win=win+1
image_cont20,d,href,/square,imrange=[-0.1,5],image_color_table='jpbloadct',/silent,tit=tit
ENDIF
;stop
Nx=sxpar(href,'NAXIS1')
Ny=sxpar(href,'NAXIS2')
filters_names=['F200W','F300M','F335M','F360M','F0770W','F1000W','F1130W','F2100W']
filters=dustem_filter_names2filters(filters_names)
Nfilters=n_elements(filters)
jwst_images=fltarr(Nx,Ny,2,Nfilters)
IF not keyword_set(nostop) THEN stop
;========== JWST stuff
i=0L
file=data_dir+use_source_name+'_nircam_lv3_f200w_i2d_anchor_atgauss1.fits'
d=mrdfits(file,0,h0)
d=mrdfits(file,1,h)
sxaddpar,h,'EQUINOX',2000.
ind=where(finite(d) NE 1,count)
IF count NE 0 THEN d[ind]=la_undef()
IF sxpar(h,'NAXIS1') NE Nx OR sxpar(h,'NAXIS2') NE Ny THEN d=project2(h,d,href,/silent)
jwst_images[*,*,0,i]=d & i=i+1
help,d
;D DOUBLE = Array[7289, 9476]
print,sxpar(h,'EXTNAME')
filter_name=sxpar(h0,'FILTER')
print,filter_name
tit=source_name+' '+filter_name
IF keyword_set(show_images) THEN BEGIN
window,win & win=win+1
image_cont20,d,href,/square,imrange=[-0.1,5],image_color_table='jpbloadct',/silent,tit=tit
IF not keyword_set(nostop) THEN stop
ENDIF
;stop
file=data_dir+use_source_name+'_nircam_lv3_f300m_i2d_anchor_atgauss1.fits'
d=mrdfits(file,0,h0)
d=mrdfits(file,1,h)
sxaddpar,h,'EQUINOX',2000.
ind=where(finite(d) NE 1,count)
IF count NE 0 THEN d[ind]=la_undef()
IF sxpar(h,'NAXIS1') NE Nx OR sxpar(h,'NAXIS2') NE Ny THEN d=project2(h,d,href,/silent)
jwst_images[*,*,0,i]=d & i=i+1
help,d
;D DOUBLE = Array[3515, 4576]
print,sxpar(h,'EXTNAME')
filter_name=sxpar(h0,'FILTER')
print,filter_name
tit=source_name+' '+filter_name
IF keyword_set(show_images) THEN BEGIN
window,win & win=win+1
image_cont20,d,href,/square,imrange=[-0.1,5],image_color_table='jpbloadct',/silent,tit=tit
IF not keyword_set(nostop) THEN stop
ENDIF
file=data_dir+use_source_name+'_nircam_lv3_f335m_i2d_anchor_atgauss1.fits'
d=mrdfits(file,0,h0)
d=mrdfits(file,1,h)
sxaddpar,h,'EQUINOX',2000.
ind=where(finite(d) NE 1,count)
IF count NE 0 THEN d[ind]=la_undef()
IF sxpar(h,'NAXIS1') NE Nx OR sxpar(h,'NAXIS2') NE Ny THEN d=project2(h,d,href,/silent)
jwst_images[*,*,0,i]=d & i=i+1
print,sxpar(h,'EXTNAME')
filter_name=sxpar(h0,'FILTER')
print,filter_name
tit=source_name+' '+filter_name
IF keyword_set(show_images) THEN BEGIN
window,win & win=win+1
image_cont20,d,href,/square,imrange=[-0.1,5],image_color_table='jpbloadct',/silent,tit=tit
IF not keyword_set(nostop) THEN stop
ENDIF
file=data_dir+use_source_name+'_nircam_lv3_f360m_i2d_anchor_atgauss1.fits'
d=mrdfits(file,0,h0)
d=mrdfits(file,1,h)
sxaddpar,h,'EQUINOX',2000.
ind=where(finite(d) NE 1,count)
IF count NE 0 THEN d[ind]=la_undef()
IF sxpar(h,'NAXIS1') NE Nx OR sxpar(h,'NAXIS2') NE Ny THEN d=project2(h,d,href,/silent)
jwst_images[*,*,0,i]=d & i=i+1
print,sxpar(h,'EXTNAME')
filter_name=sxpar(h0,'FILTER')
print,filter_name
tit=source_name+' '+filter_name
IF keyword_set(show_images) THEN BEGIN
window,win & win=win+1
image_cont20,d,href,/square,imrange=[-0.2,5],image_color_table='jpbloadct',/silent,tit=tit
IF not keyword_set(nostop) THEN stop
ENDIF
file=data_dir+use_source_name+'_miri_lv3_f770w_i2d_anchor_atgauss1.fits'
d=mrdfits(file,0,h0)
d=mrdfits(file,1,h)
sxaddpar,h,'EQUINOX',2000.
ind=where(finite(d) NE 1,count)
IF count NE 0 THEN d[ind]=la_undef()
IF sxpar(h,'NAXIS1') NE Nx OR sxpar(h,'NAXIS2') NE Ny THEN d=project2(h,d,href,/silent)
jwst_images[*,*,0,i]=d & i=i+1
print,sxpar(h,'EXTNAME')
filter_name=sxpar(h0,'FILTER')
print,filter_name
tit=source_name+' '+filter_name
IF keyword_set(show_images) THEN BEGIN
window,win & win=win+1
image_cont20,d,href,/square,imrange=[-0.2,10],image_color_table='jpbloadct',/silent,tit=tit,off_bar=obp
IF not keyword_set(nostop) THEN stop
ENDIF
file=data_dir+use_source_name+'_miri_lv3_f1000w_i2d_anchor_atgauss1.fits'
d=mrdfits(file,0,h0)
d=mrdfits(file,1,h)
sxaddpar,h,'EQUINOX',2000.
ind=where(finite(d) NE 1,count)
IF count NE 0 THEN d[ind]=la_undef()
IF sxpar(h,'NAXIS1') NE Nx OR sxpar(h,'NAXIS2') NE Ny THEN d=project2(h,d,href,/silent)
jwst_images[*,*,0,i]=d & i=i+1
print,sxpar(h,'EXTNAME')
filter_name=sxpar(h0,'FILTER')
print,filter_name
tit=source_name+' '+filter_name
IF keyword_set(show_images) THEN BEGIN
window,win & win=win+1
image_cont20,d,href,/square,imrange=[-0.2,5],image_color_table='jpbloadct',/silent,tit=tit
IF not keyword_set(nostop) THEN stop
ENDIF
file=data_dir+use_source_name+'_miri_lv3_f1130w_i2d_anchor_atgauss1.fits'
d=mrdfits(file,0,h0)
d=mrdfits(file,1,h)
sxaddpar,h,'EQUINOX',2000.
ind=where(finite(d) NE 1,count)
IF count NE 0 THEN d[ind]=la_undef()
IF sxpar(h,'NAXIS1') NE Nx OR sxpar(h,'NAXIS2') NE Ny THEN d=project2(h,d,href,/silent)
jwst_images[*,*,0,i]=d & i=i+1
print,sxpar(h,'EXTNAME')
filter_name=sxpar(h0,'FILTER')
print,filter_name
tit=source_name+' '+filter_name
IF keyword_set(show_images) THEN BEGIN
window,win & win=win+1
image_cont20,d,href,/square,imrange=[-0.3,20],image_color_table='jpbloadct',/silent,tit=tit
IF not keyword_set(nostop) THEN stop
ENDIF
IF not keyword_set(nostop) THEN stop
file=data_dir+use_source_name+'_miri_lv3_f2100w_i2d_anchor_atgauss1.fits'
d=mrdfits(file,0,h0)
d=mrdfits(file,1,h)
sxaddpar,h,'EQUINOX',2000.
ind=where(finite(d) NE 1,count)
IF count NE 0 THEN d[ind]=la_undef()
IF sxpar(h,'NAXIS1') NE Nx OR sxpar(h,'NAXIS2') NE Ny THEN d=project2(h,d,href,/silent)
jwst_images[*,*,0,i]=d & i=i+1
print,sxpar(h,'EXTNAME')
filter_name=sxpar(h0,'FILTER')
print,filter_name
tit=source_name+' '+filter_name
IF keyword_set(show_images) THEN BEGIN
window,win & win=win+1
image_cont20,d,href,/square,imrange=[-0.5,10],image_color_table='jpbloadct',/silent,tit=tit
IF not keyword_set(nostop) THEN stop
ENDIF
IF not keyword_set(nostop) THEN stop
;Invent variances (will have to do better)
;jwst_images[*,*,1,*]=(jwst_images[*,*,0,*]*5./100.)^2 ;assumed intensity variance
perc_error=5./100.
jwst_images[*,*,1,*]=la_power(la_mul(jwst_images[*,*,0,*],perc_error),2) ;assumed intensity variance
;=== check for null variances
ind=where(jwst_images[*,*,1,*] EQ 0.,count)
IF count NE 0 THEN BEGIN
message,'There are null variances ...',/continue
stop
ENDIF
;WCO map:
file=NH_data_dir+use_source_name+'_12m+7m+tp_co21_broad_mom0.fits'
;file='/Volumes/PILOT_FLIGHT1/PHANGS-JWST/'+use_source_name+'_12m+7m+tp_co21_broad_mom0.fits'
d=readfits(file,h)
;sxaddpar,h,'CTYPE1','RA---TAN'
;sxaddpar,h,'CTYPE2','RA---TAN'
sxaddpar,h,'EQUINOX',2000.
ind=where(finite(d) NE 1,count)
IF count NE 0 THEN d[ind]=la_undef()
IF sxpar(h,'NAXIS1') NE Nx OR sxpar(h,'NAXIS2') NE Ny THEN WCO=project2(h,d,href,/silent) ELSE WCO=d
fact=4.e20/1.e21
NHCO=la_mul(WCO,fact) ;NH from CO in 1e21 H/cm2
tit=source_name+' '+'NHCO [1e21 H/cm2]'
IF keyword_set(show_images) THEN BEGIN
window,win & win=win+1
image_cont20,NHCO,href,/square,imrange=[-0.5,10],image_color_table='jpbloadct',/silent,tit=tit
IF not keyword_set(nostop) THEN stop
ENDIF
IF keyword_set(save) THEN BEGIN
save_file=save_data_dir+use_source_name+'_jwst_images.sav'
save,jwst_images,filters,href,NHCO,file=save_file
message,'Saved '+save_file,/continue
ENDIF
END