Blame view

LabTools/IRAP/JPB/make_sed_phangs_tables.pro 31.7 KB
3b79f061   Jean-Philippe Bernard   improved
1
PRO make_sed_phangs_tables,test=test,show_seds=show_seds,grid_type=grid_type,isrf_class=isrf_class
d6343d56   Jean-Philippe Bernard   First commit
2

e2ce1dee   Jean-Philippe Bernard   defined grid stru...
3
;make_sed_phangs_tables,/show   ;That's a test
ea1acf9c   Jean-Philippe Bernard   improved
4
;make_sed_phangs_tables,grid_type=1,/show_seds,/test   ;That's a test
3b79f061   Jean-Philippe Bernard   improved
5
;make_sed_phangs_tables,/test,grid_type=2,/show_seds,isrf_class=15
14ae4f23   Jean-Philippe Bernard   improved
6
;make_sed_phangs_tables,/test,grid_type=3,/show_seds
0ed148cc   Jean-Philippe Bernard   improved
7

907a3ade   Jean-Philippe Bernard   improved
8
9
;make_sed_phangs_tables,grid_type=300,/show_seds

0ed148cc   Jean-Philippe Bernard   improved
10
;=== This is needed for Phangs work
80d9cb5e   Jean-Philippe Bernard   improved pathes
11
12
;defsysv,'!phangs_data_dir','/Volumes/PILOT_FLIGHT1/PHANGS/'
;defsysv,'!phangs_data_dir','/data/projects/phangs/'
0ed148cc   Jean-Philippe Bernard   improved
13
;=== This is where the grids will be written
80d9cb5e   Jean-Philippe Bernard   improved pathes
14
;dir=!dustem_wrap_soft_dir+'/Grids/'
a1668e0f   Jean-Philippe Bernard   improved path
15
dir=!phangs_data_dir+'/ISRF/GRIDS/'
d6343d56   Jean-Philippe Bernard   First commit
16
17

dustem_define_la_common
0ed148cc   Jean-Philippe Bernard   improved
18

907a3ade   Jean-Philippe Bernard   improved
19
use_grid_type='0'
3b79f061   Jean-Philippe Bernard   improved
20
21
22
23
IF keyword_set(grid_type) THEN BEGIN
  use_grid_type=grid_type
ENDIF

581fa3e7   Jean-Philippe Bernard   improved
24
25
26
27
28
test_str=''
IF keyword_set(test) THEN BEGIN
  test_str='TEST_'
ENDIF

3b79f061   Jean-Philippe Bernard   improved
29
CASE use_grid_type OF
907a3ade   Jean-Philippe Bernard   improved
30
   '0': BEGIN ;======= This is for test only
54583f40   Jean-Philippe Bernard   improved
31
32
33
34
35
36
37
38
39
      !quiet=1
      model='DBP90'
      ;===== This is to do a small test_table
      pd = [ $
           '(*!dustem_params).G0' $  ;G0
            ]
      iv_min =   [0.1]
      iv_max =   [10]
      iv_Nvalues=[2]
e2ce1dee   Jean-Philippe Bernard   defined grid stru...
40
      plog=[1]
54583f40   Jean-Philippe Bernard   improved
41
42
43
44
45
      fpd=['(*!dustem_params).grains(0).mdust_o_mh',$          ;PAH0 mass fraction
           '(*!dustem_params).grains(1).mdust_o_mh']
      fiv=[1.e-3,1.e-2]
      table_name=dir+'TEST_'+model+'_G0.fits'
      dustem_init,model=model
e2ce1dee   Jean-Philippe Bernard   defined grid stru...
46
47
48
      ;=== select filters to be used for the grid (default=ALL)
      ;filters=[(*!dustem_filters).nircam.filter_names,(*!dustem_filters).miri.filter_names]
      dustem_make_sed_table,model,pd,iv_min,iv_max,iv_Nvalues,fpd=fpd,fiv=fiv,filename=table_name,plog=plog,show_seds=show_seds,/print_params,filters=filters
54583f40   Jean-Philippe Bernard   improved
49
   END
907a3ade   Jean-Philippe Bernard   improved
50
   '1': BEGIN ;======= This is to produce a grid with the DBP90 model + Mathis field for G0 and PAH abundance
3b79f061   Jean-Philippe Bernard   improved
51
52
      !quiet=1
      model='DBP90'
3b79f061   Jean-Philippe Bernard   improved
53
54
55
56
57
      ;===== This is to do a small test_table
      pd = [ $
           '(*!dustem_params).G0', $                           ;G0
           '(*!dustem_params).grains(0).mdust_o_mh',$          ;PAH0 mass fraction
           '(*!dustem_params).grains(1).mdust_o_mh']          ;VSG mass fraction
3b79f061   Jean-Philippe Bernard   improved
58
59
      iv_min =   [0.1,1.e-4,1.e-4]
      iv_max =   [100,1.e-1,1.e-1] 
e2ce1dee   Jean-Philippe Bernard   defined grid stru...
60
      plog=[1,1,1]
3b79f061   Jean-Philippe Bernard   improved
61
62
      fpd=[]
      fiv=[]
3b79f061   Jean-Philippe Bernard   improved
63
      IF keyword_set(test) THEN BEGIN
54583f40   Jean-Philippe Bernard   improved
64
65
         ;iv_Nvalues=[5,3,3]
         iv_Nvalues=[2,2,2]
429a6075   Jean-Philippe Bernard   improved
66
         table_name=dir+'TEST_'+model+'_JWST_G0_YPAH_YVSG_4Phangs.fits'
3b79f061   Jean-Philippe Bernard   improved
67
68
      ENDIF ELSE BEGIN
      	iv_Nvalues=[50,20,20]
429a6075   Jean-Philippe Bernard   improved
69
      	table_name=dir+model+'_JWST_G0_YPAH_YVSG_4Phangs.fits'
3b79f061   Jean-Philippe Bernard   improved
70
      ENDELSE
3b79f061   Jean-Philippe Bernard   improved
71
72
73
      dustem_init,model=model
      ;=== select filters to be used for the grid
      filters=[(*!dustem_filters).nircam.filter_names,(*!dustem_filters).miri.filter_names]
e2ce1dee   Jean-Philippe Bernard   defined grid stru...
74
      dustem_make_sed_table,model,pd,iv_min,iv_max,iv_Nvalues,fpd=fpd,fiv=fiv,filename=table_name,filters=filters,plog=plog,show_seds=show_seds
3b79f061   Jean-Philippe Bernard   improved
75
   END
907a3ade   Jean-Philippe Bernard   improved
76
   '2': BEGIN          ;This is DPB90 model with PHANGS ISRF classes
3b79f061   Jean-Philippe Bernard   improved
77
      !quiet=1
429a6075   Jean-Philippe Bernard   improved
78
      model='DBP90'   ;This is to use the DBP90 dust model
429a6075   Jean-Philippe Bernard   improved
79
80
      ;======= This is to produce a grid with the above model for G0 and PAH abundance and ISRF from the Muse data
      ;======= Note that g0 is fixed parameters is actually not used, replaced by dustem_plugin_phangs_class_isrf_2
3b79f061   Jean-Philippe Bernard   improved
81
82
83
84
85
86
      pd = [ $
           'dustem_plugin_phangs_class_isrf_2', $             ;G0 factor for Phangs ISRF classes
           '(*!dustem_params).grains(0).mdust_o_mh',$         ;PAH0 mass fraction
           '(*!dustem_params).grains(1).mdust_o_mh']          ;VSG mass fraction
      iv_min =   [0.1,1.e-4,1.e-4]
      iv_max =   [100,1.e-1,1.e-1] 
e2ce1dee   Jean-Philippe Bernard   defined grid stru...
87
      plog=[1,1,1]
3b79f061   Jean-Philippe Bernard   improved
88
      Nclass=31L
ccfa6760   Jean-Philippe Bernard   corrected ISRF cl...
89
      fpd=['(*!dustem_params).gas.g0','(*!dustem_params).g0','dustem_plugin_phangs_class_isrf_1','dustem_plugin_phangs_class_isrf_4']             ;ISRF class to be used
3b79f061   Jean-Philippe Bernard   improved
90
      dustem_init,model=model
b099d16c   Jean-Philippe Bernard   using set up fortran
91
      fortran_user=dustem_set_up_fortran(/random_name)   ;use a random fortran number
1dfe610a   Jean-Philippe Bernard   improved
92
93
      !dustem_verbose=0
      (*!dustem_params).KEYWORDS='quiet '+(*!dustem_params).KEYWORDS    ;This makes Fortran be quiet too
eb7ea183   Jean-Philippe Bernard   included stellar ...
94
      ;=== select filters to be used for the grid (HOOPS, we need MUSE also, and maybe all filters ...)
3b79f061   Jean-Philippe Bernard   improved
95
      filters=[(*!dustem_filters).nircam.filter_names,(*!dustem_filters).miri.filter_names, $
429a6075   Jean-Philippe Bernard   improved
96
               (*!dustem_filters).iras.filter_names,(*!dustem_filters).pacs.filter_names,(*!dustem_filters).spire.filter_names]
3b79f061   Jean-Philippe Bernard   improved
97
      IF keyword_set(isrf_class) THEN BEGIN  ;do just one table
429a6075   Jean-Philippe Bernard   improved
98
         use_isrf_class=isrf_class
3b79f061   Jean-Philippe Bernard   improved
99
      ENDIF ELSE BEGIN
429a6075   Jean-Philippe Bernard   improved
100
         use_isrf_class=0  ;This is for Mathis field
3b79f061   Jean-Philippe Bernard   improved
101
      ENDELSE
ccfa6760   Jean-Philippe Bernard   corrected ISRF cl...
102
      fiv=[-1.,1.,use_isrf_class,0.]     ;This sets the ISRF class to the requested value. alos removes ionising photons.
429a6075   Jean-Philippe Bernard   improved
103
104
105
      isrf_class_str='_isrfclass'+strtrim(use_isrf_class,2)
      ;define the number of free parameters in the grid and the grid fits table name
      IF keyword_set(test) THEN BEGIN
3933a191   Jean-Philippe Bernard   improved
106
107
         ;iv_Nvalues=[2,2,2]
         iv_Nvalues=[4,4,6,10]
ccfa6760   Jean-Philippe Bernard   corrected ISRF cl...
108
         table_name=dir+'TEST_'+model+'_MuseISRF_JWST_G0_YPAH_YVSG_4Phangs_noionis'+isrf_class_str+'.fits'
429a6075   Jean-Philippe Bernard   improved
109
110
      ENDIF ELSE BEGIN
         iv_Nvalues=[50,20,20]
ccfa6760   Jean-Philippe Bernard   corrected ISRF cl...
111
         table_name=dir+model+'_MuseISRF_JWST_G0_YPAH_YVSG_4Phangs_noionis'+isrf_class_str+'.fits'
429a6075   Jean-Philippe Bernard   improved
112
      ENDELSE
e2ce1dee   Jean-Philippe Bernard   defined grid stru...
113
      dustem_make_sed_table,model,pd,iv_min,iv_max,iv_Nvalues,fpd=fpd,fiv=fiv,filename=table_name,filters=filters,plog=plog,show_seds=show_seds
3b79f061   Jean-Philippe Bernard   improved
114
   END
907a3ade   Jean-Philippe Bernard   improved
115
   '3': BEGIN          ;This is DPB90 model with DL07 ISRF prescription (a la Chastanet)
14ae4f23   Jean-Philippe Bernard   improved
116
117
118
119
120
      !quiet=1
      model='DBP90'   ;This is to use the DBP90 dust model
      ;======= This is to produce a grid with the above model for G0 and PAH abundance and ISRF from the Muse data
      ;======= Note that g0 is fixed parameters is actually not used, replaced by dustem_plugin_phangs_class_isrf_2
      pd = [ $
c2457c07   Jean-Philippe Bernard   improved
121
122
123
124
           'dustem_plugin_dl07_isrf_model_3', $             ;Umin factor [0.1-100] 6 values
           'dustem_plugin_dl07_isrf_model_1', $             ;gamma factor [0.0,0.02] 5 values
           '(*!dustem_params).grains(0).mdust_o_mh',$       ;PAH0 mass fraction [1.e-4,1.e-1] 20 values
           '(*!dustem_params).grains(1).mdust_o_mh' $       ;VSG mass fraction [1.e-4,1.e-1] 20 values
14ae4f23   Jean-Philippe Bernard   improved
125
            ]
d339db1c   Jean-Philippe Bernard   improved
126
127
      ;iv_min =   [0.1,0.  ,1.e-4,1.e-4]      ;does not run for values =0., because of use of pmin (division by initial value)
      iv_min =   [0.1,1.e-10  ,1.e-4,1.e-4]
c190c44c   Jean-Philippe Bernard   improved
128
      iv_max =   [100.,0.02,1.e-1,1.e-1]
e2ce1dee   Jean-Philippe Bernard   defined grid stru...
129
      plog=[1,0,1,1]
d339db1c   Jean-Philippe Bernard   improved
130
      fpd=['dustem_plugin_dl07_isrf_model_2', $ ;alpha=1
c2457c07   Jean-Philippe Bernard   improved
131
132
           'dustem_plugin_dl07_isrf_model_4' $  ;Umax=1.e7
           ]
d339db1c   Jean-Philippe Bernard   improved
133
      fiv=[2.,1.e7]     ;This sets the fixed parameters
14ae4f23   Jean-Philippe Bernard   improved
134
135
      dustem_init,model=model
      fortran_user=dustem_set_up_fortran(/random_name)   ;use a random fortran number
d339db1c   Jean-Philippe Bernard   improved
136
137
138
139
140
      !dustem_verbose=1
      !quiet=0
      !dustem_nocatch=1
      ;!dustem_verbose=0
      ;(*!dustem_params).KEYWORDS='quiet '+(*!dustem_params).KEYWORDS    ;This makes Fortran be quiet too
ea2707c1   Jean-Philippe Bernard   improved
141
142
143
      ;=== select filters to be used for the grid (no definition -> all known filters used)
      ;filters=[(*!dustem_filters).nircam.filter_names,(*!dustem_filters).miri.filter_names, $
      ;         (*!dustem_filters).iras.filter_names,(*!dustem_filters).pacs.filter_names,(*!dustem_filters).spire.filter_names]
14ae4f23   Jean-Philippe Bernard   improved
144
145
      ;define the number of free parameters in the grid and the grid fits table name
      IF keyword_set(test) THEN BEGIN
ea2707c1   Jean-Philippe Bernard   improved
146
         ;iv_Nvalues=[2,2,3,3]
3933a191   Jean-Philippe Bernard   improved
147
148
         iv_Nvalues=[2,2,3,3]
         ;iv_Nvalues=[4,4,6,10]
c2457c07   Jean-Philippe Bernard   improved
149
         table_name=dir+'TEST_'+model+'_DL07ISRF_YPAH_YVSG_Umin_gamma_4Phangs'+'.fits'
14ae4f23   Jean-Philippe Bernard   improved
150
151
      ENDIF ELSE BEGIN
         iv_Nvalues=[6,5,20,20]
c2457c07   Jean-Philippe Bernard   improved
152
         table_name=dir+model+'_DL07ISRF_YPAH_YVSG_Umin_gamma_4Phangs'+'.fits'
14ae4f23   Jean-Philippe Bernard   improved
153
      ENDELSE
e2ce1dee   Jean-Philippe Bernard   defined grid stru...
154
      dustem_make_sed_table,model,pd,iv_min,iv_max,iv_Nvalues,fpd=fpd,fiv=fiv,filename=table_name,filters=filters,plog=plog,show_seds=show_seds
14ae4f23   Jean-Philippe Bernard   improved
155
   END
907a3ade   Jean-Philippe Bernard   improved
156
   '4': BEGIN          ;This is DL07 model with PHANGS ISRF classes
c190c44c   Jean-Philippe Bernard   improved
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
      !quiet=1
      model='DL07'   ;This is to use the DBP90 dust model
      ;======= This is to produce a grid with the above model for G0 and PAH abundance and ISRF from the Muse data
      ;======= Note that g0 is fixed parameters is actually not used, replaced by dustem_plugin_phangs_class_isrf_2
      pd = [ $
           'dustem_plugin_phangs_class_isrf_2', $             ;G0 factor for Phangs ISRF classes
           '(*!dustem_params).grains(0).mdust_o_mh',$         ;PAH0 mass fraction
           '(*!dustem_params).grains(1).mdust_o_mh']          ;VSG mass fraction
      ;iv_min =   [0.1,1.e-4,1.e-4]
      ;iv_max =   [100,1.e-1,1.e-1] 
      iv_min =   [0.1,5.e-5,5.e-5]
      iv_max =   [1.e6,5.e-1,5.e-1]
      plog=[1,1,1]
      Nclass=31L
      fpd=['(*!dustem_params).gas.g0','(*!dustem_params).g0','dustem_plugin_phangs_class_isrf_1','dustem_plugin_phangs_class_isrf_4']             ;ISRF class to be used
      dustem_init,model=model
      fortran_user=dustem_set_up_fortran(/random_name)   ;use a random fortran number
      !dustem_verbose=0
      (*!dustem_params).KEYWORDS='quiet '+(*!dustem_params).KEYWORDS    ;This makes Fortran be quiet too
      ;=== select filters to be used for the grid (HOOPS, we need MUSE also, and maybe all filters ...)
      filters=dustem_get_all_filter_names()
      ;filters=[(*!dustem_filters).nircam.filter_names,(*!dustem_filters).miri.filter_names, $
      ;         (*!dustem_filters).iras.filter_names,(*!dustem_filters).pacs.filter_names,(*!dustem_filters).spire.filter_names]
      IF keyword_set(isrf_class) THEN BEGIN  ;do just one table
         use_isrf_class=isrf_class
      ENDIF ELSE BEGIN
         use_isrf_class=0  ;This is for Mathis field
      ENDELSE
      fiv=[-1.,1.,use_isrf_class,0.]     ;This sets the ISRF class to the requested value. alos removes ionising photons.
      isrf_class_str='_isrfclass'+strtrim(use_isrf_class,2)
      ;define the number of free parameters in the grid and the grid fits table name
      IF keyword_set(test) THEN BEGIN
         ;iv_Nvalues=[2,2,2]
         iv_Nvalues=[2,2,3,5]
         table_name=dir+'TEST_'+model+'_MuseISRF_JWST_G0_YPAH_YVSG_4Phangs_noionis'+isrf_class_str+'.fits'
      ENDIF ELSE BEGIN
5b756407   Jean-Philippe Bernard   changed
193
         iv_Nvalues=[100,20,20]
c190c44c   Jean-Philippe Bernard   improved
194
195
196
197
         table_name=dir+model+'_MuseISRF_JWST_G0_YPAH_YVSG_4Phangs_noionis'+isrf_class_str+'.fits'
      ENDELSE
      dustem_make_sed_table,model,pd,iv_min,iv_max,iv_Nvalues,fpd=fpd,fiv=fiv,filename=table_name,filters=filters,plog=plog,show_seds=show_seds
   END
907a3ade   Jean-Philippe Bernard   improved
198
   '5': BEGIN          ;This is DL07 model with PHANGS ISRF classes, with only G0 as free parameter. This takes way too long
feb46599   Jean-Philippe Bernard   improved
199
200
201
202
203
204
205
206
207
208
      !quiet=1
      model='DL07'   ;This is to use the DBP90 dust model
      ;======= This is to produce a grid with the above model for G0 and PAH abundance and ISRF from the Muse data
      ;======= Note that g0 is fixed parameters is actually not used, replaced by dustem_plugin_phangs_class_isrf_2
      pd = [ $
           'dustem_plugin_phangs_class_isrf_2' $             ;G0 factor for Phangs ISRF classes
           ]          
      iv_min =   [0.1]
      iv_max =   [1.e6]
      plog=[1]
581fa3e7   Jean-Philippe Bernard   improved
209
210
211
212
213
      IF keyword_set(test) THEN BEGIN
         iv_min =   [1.]
         iv_max =   [3.]
         plog=[1]
      ENDIF
feb46599   Jean-Philippe Bernard   improved
214
215
216
217
218
219
220
      ;Nclass=31L
      fpd=['(*!dustem_params).gas.g0','(*!dustem_params).g0','dustem_plugin_phangs_class_isrf_1','dustem_plugin_phangs_class_isrf_4'] ;ISRF class to be used
      dustem_init,model=model
      fortran_user=dustem_set_up_fortran(/random_name)   ;use a random fortran number
      !dustem_verbose=0
      (*!dustem_params).KEYWORDS='quiet '+(*!dustem_params).KEYWORDS    ;This makes Fortran be quiet too
      ;=== select filters to be used for the grid (HOOPS, we need MUSE also, and maybe all filters ...)
14188148   Jean-Philippe Bernard   improved
221
222
      ;filters=dustem_get_all_filter_names()
      filters=get_phangs_filter_names(/order_by_wavelengths)
feb46599   Jean-Philippe Bernard   improved
223
224
225
226
227
228
229
230
231
232
      IF keyword_set(isrf_class) THEN BEGIN  ;do just one table
         use_isrf_class=isrf_class
      ENDIF ELSE BEGIN
         use_isrf_class=0  ;This is for Mathis field
      ENDELSE
      fiv=[-1.,1.,use_isrf_class,0.]     ;This sets the ISRF class to the requested value. also removes ionising photons.
      isrf_class_str='_isrfclass'+strtrim(use_isrf_class,2)
      ;define the number of free parameters in the grid and the grid fits table name
      IF keyword_set(test) THEN BEGIN
         iv_Nvalues=[2]
581fa3e7   Jean-Philippe Bernard   improved
233
         ;table_name=dir+test_str+model+'_MuseISRF_JWST_G0_4Phangs_noionis'+isrf_class_str+'.fits'
feb46599   Jean-Philippe Bernard   improved
234
235
      ENDIF ELSE BEGIN
         iv_Nvalues=[100]
feb46599   Jean-Philippe Bernard   improved
236
      ENDELSE
581fa3e7   Jean-Philippe Bernard   improved
237
      table_name=dir+test_str+model+'_MuseISRF_JWST_G0_4Phangs_noionis'+isrf_class_str+'.fits'
feb46599   Jean-Philippe Bernard   improved
238
      dustem_make_sed_table,model,pd,iv_min,iv_max,iv_Nvalues,fpd=fpd,fiv=fiv,filename=table_name,filters=filters,plog=plog,show_seds=show_seds
581fa3e7   Jean-Philippe Bernard   improved
239

e983bf0b   Jean-Philippe Bernard   tried to optimize...
240
      ;goto,one_by_one
581fa3e7   Jean-Philippe Bernard   improved
241
242
243
244
245
246
      ;adding linear parameters abundance
      message,'Adding Dust abundances to grid',/continue
      pd=['(*!dustem_params).grains[0].MDUST_O_MH','(*!dustem_params).grains[1].MDUST_O_MH','(*!dustem_params).grains[2].MDUST_O_MH']
      default_value=(dustem_get_param_values_default(pd))
      ;iv_min=[default_value/10.] & iv_max=[default_value*100.]
      iv_min=[default_value/10.]
b4d3bf71   Jean-Philippe Bernard   modified
247
248
      iv_max=[default_value*10.]
      iv_Nvalues=[20,20,20]
581fa3e7   Jean-Philippe Bernard   improved
249
250
251
252
253
254
255
      plog=[1,1,1]
      IF keyword_set(test) THEN BEGIN
         iv_min=[default_value/2.] & iv_max=[default_value*2.]
         iv_Nvalues=[3,3,3]
         plog=[0,0,0]
      ENDIF
      output_table_name=dir+test_str+model+'_MuseISRF_JWST_G0_Ypah1added_Ypah2added_Yvsgadded_4Phangs_noionis'+isrf_class_str+'.fits'
efbec04c   Jean-Philippe Bernard   improved
256
      dustem_add_linear_params2grid,table_name,pd,iv_min,iv_max,iv_Nvalues,out_filename=output_table_name,plog=plog,show_seds=show_seds
e983bf0b   Jean-Philippe Bernard   tried to optimize...
257
258
259
260
      goto,the_end

      one_by_one:

581fa3e7   Jean-Philippe Bernard   improved
261
      ;adding linear parameters abundance
e983bf0b   Jean-Philippe Bernard   tried to optimize...
262
263
264
265
266
267
268
      message,'Adding PAH0 abundances to grid',/continue
      pd=['(*!dustem_params).grains[0].MDUST_O_MH']
      default_value=(dustem_get_param_values_default(pd))[0]
      iv_min=[default_value/10.] & iv_max=[default_value*100.] & iv_Nvalues=[100] & plog=[1]
      IF keyword_set(test) THEN iv_Nvalues=[3]
      output_table_name=dir+test_str+model+'_MuseISRF_JWST_G0_Ypahadded_4Phangs_noionis'+isrf_class_str+'.fits'
      dustem_add_linear_params2grid,table_name,pd,iv_min,iv_max,iv_Nvalues,out_filename=output_table_name,plog=plog,show_seds=show_seds
581fa3e7   Jean-Philippe Bernard   improved
269
      
4225a53d   Jean-Philippe Bernard   improved
270
      ;adding linear parameter PAH1 abundance
e983bf0b   Jean-Philippe Bernard   tried to optimize...
271
272
273
274
275
276
277
278
      message,'Adding PAH1 abundances to grid',/continue
      table_name=dir+test_str+model+'_MuseISRF_JWST_G0_Ypahadded_4Phangs_noionis'+isrf_class_str+'.fits'
      pd=['(*!dustem_params).grains[1].MDUST_O_MH']
      default_value=(dustem_get_param_values_default(pd))[0]
      iv_min=[default_value/10.] & iv_max=[default_value*100.] & iv_Nvalues=[100] & plog=[1]
      IF keyword_set(test) THEN iv_Nvalues=[3]
      output_table_name=dir+test_str+model+'_MuseISRF_JWST_G0_Ypah1added_Ypah2added_4Phangs_noionis'+isrf_class_str+'.fits'
      dustem_add_linear_params2grid,table_name,pd,iv_min,iv_max,iv_Nvalues,out_filename=output_table_name,plog=plog,show_seds=show_seds
9ccecb69   Jean-Philippe Bernard   improved
279
      
4225a53d   Jean-Philippe Bernard   improved
280
      ;adding linear parameter VSG abundance
e983bf0b   Jean-Philippe Bernard   tried to optimize...
281
282
283
284
285
286
287
288
      message,'Adding VSG abundances to grid',/continue
      table_name=dir+test_str+model+'_MuseISRF_JWST_G0_Ypah1added_Ypah2added_4Phangs_noionis'+isrf_class_str+'.fits'
      pd=['(*!dustem_params).grains[3].MDUST_O_MH']
      default_value=(dustem_get_param_values_default(pd))[0]
      iv_min=[default_value/10.] & iv_max=[default_value*100.] & iv_Nvalues=[100] & plog=[1]
      IF keyword_set(test) THEN iv_Nvalues=[3]
      output_table_name=dir+test_str+model+'_MuseISRF_JWST_G0_Ypah1added_Ypah2added_Yvsgadded_4Phangs_noionis'+isrf_class_str+'.fits'
      dustem_add_linear_params2grid,table_name,pd,iv_min,iv_max,iv_Nvalues,out_filename=output_table_name,plog=plog,show_seds=show_seds
feb46599   Jean-Philippe Bernard   improved
289
   END
907a3ade   Jean-Philippe Bernard   improved
290
   '22': BEGIN          ;This is DL07 model with PHANGS ISRF classes, with only G0 as free parameter. Same as 2, but for DL07 model
14188148   Jean-Philippe Bernard   improved
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
      !quiet=1
      model='DL07'   ;This is to use the DBP90 dust model
      ;======= This is to produce a grid with the above model for G0 and PAH abundance and ISRF from the Muse data
      ;======= Note that g0 is fixed parameters is actually not used, replaced by dustem_plugin_phangs_class_isrf_2
      pd = [ $
           'dustem_plugin_phangs_class_isrf_2' $             ;G0 factor for Phangs ISRF classes
           ]          
      iv_min =   [0.1]
      iv_max =   [100.]
      plog=[1]
      IF keyword_set(test) THEN BEGIN
         iv_min =   [.1]
         iv_max =   [100.]
         plog=[1]
      ENDIF
      fpd=['(*!dustem_params).gas.g0','(*!dustem_params).g0','dustem_plugin_phangs_class_isrf_1','dustem_plugin_phangs_class_isrf_4'] ;ISRF class to be used
      dustem_init,model=model
      fortran_user=dustem_set_up_fortran(/random_name)   ;use a random fortran number
      !dustem_verbose=0
      (*!dustem_params).KEYWORDS='quiet '+(*!dustem_params).KEYWORDS    ;This makes Fortran be quiet too
      ;=== select filters to be used for the grid (HOOPS, we need MUSE also, and maybe all filters ...)
      ;filters=dustem_get_all_filter_names()
      filters=get_phangs_filter_names(/order_by_wavelengths)
      IF keyword_set(isrf_class) THEN BEGIN  ;do just one table
         use_isrf_class=isrf_class
      ENDIF ELSE BEGIN
         use_isrf_class=0  ;This is for Mathis field
      ENDELSE
      fiv=[-1.,1.,use_isrf_class,0.]     ;This sets the ISRF class to the requested value. also removes ionising photons.
      isrf_class_str='_isrfclass'+strtrim(use_isrf_class,2)
      ;define the number of free parameters in the grid and the grid fits table name
      IF keyword_set(test) THEN BEGIN
         iv_Nvalues=[4]
         ;table_name=dir+test_str+model+'_MuseISRF_JWST_G0_4Phangs_noionis'+isrf_class_str+'.fits'
      ENDIF ELSE BEGIN
6e36c82b   Jean-Philippe Bernard   improved
326
327
         ;iv_Nvalues=[19]
         iv_Nvalues=[22]
14188148   Jean-Philippe Bernard   improved
328
329
330
331
332
333
334
335
336
      ENDELSE
      table_name=dir+test_str+model+'_MuseISRF_JWST_G0_4Phangs_noionis'+isrf_class_str+'.fits'
      dustem_make_sed_table,model,pd,iv_min,iv_max,iv_Nvalues,fpd=fpd,fiv=fiv,filename=table_name,filters=filters,plog=plog,show_seds=show_seds
      ;adding linear parameters (small grains abundances)
      message,'Adding Dust abundances to grid',/continue
      pd=['(*!dustem_params).grains[0].MDUST_O_MH','(*!dustem_params).grains[1].MDUST_O_MH','(*!dustem_params).grains[2].MDUST_O_MH']
      default_value=(dustem_get_param_values_default(pd))
      iv_min=[default_value/10.]
      iv_max=[default_value*10.]
6e36c82b   Jean-Philippe Bernard   improved
337
338
      ;iv_Nvalues=[11,11,11]
      iv_Nvalues=[13,13,13]
14188148   Jean-Philippe Bernard   improved
339
340
341
342
343
344
345
346
347
348
349
      plog=[1,1,1]
      IF keyword_set(test) THEN BEGIN
         iv_min=[default_value/2.]
         iv_max=[default_value*2.]
         iv_Nvalues=[3,3,3]
         plog=[1,1,1]
      ENDIF
      output_table_name=dir+test_str+model+'_MuseISRF_JWST_G0_Ypah1added_Ypah2added_Yvsgadded_4Phangs_noionis'+isrf_class_str+'.fits'
      dustem_add_linear_params2grid,table_name,pd,iv_min,iv_max,iv_Nvalues,out_filename=output_table_name,plog=plog,show_seds=show_seds
      goto,the_end
   END
907a3ade   Jean-Philippe Bernard   improved
350
   '221': BEGIN          ;This is same as 22, but adapted for observed range in NGC0628
934cfd91   Jean-Philippe Bernard   improved custom g...
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
      !quiet=1
      model='DL07'   ;This is to use the DBP90 dust model
      ;======= This is to produce a grid with the above model for G0 and PAH abundance and ISRF from the Muse data
      ;======= Note that g0 is fixed parameters is actually not used, replaced by dustem_plugin_phangs_class_isrf_2
      pd = [ $
           'dustem_plugin_phangs_class_isrf_2' $             ;G0 factor for Phangs ISRF classes
           ]          
      iv_min =   [0.1]
      iv_max =   [10.]
      plog=[1]
      IF keyword_set(test) THEN BEGIN
         iv_min =   [.1]
         iv_max =   [10.]
         plog=[1]
      ENDIF
      fpd=['(*!dustem_params).gas.g0','(*!dustem_params).g0','dustem_plugin_phangs_class_isrf_1','dustem_plugin_phangs_class_isrf_4'] ;ISRF class to be used
      dustem_init,model=model
      fortran_user=dustem_set_up_fortran(/random_name)   ;use a random fortran number
      !dustem_verbose=0
      (*!dustem_params).KEYWORDS='quiet '+(*!dustem_params).KEYWORDS    ;This makes Fortran be quiet too
      ;=== select filters to be used for the grid (HOOPS, we need MUSE also, and maybe all filters ...)
      ;filters=dustem_get_all_filter_names()
      filters=get_phangs_filter_names(/order_by_wavelengths)
      IF keyword_set(isrf_class) THEN BEGIN  ;do just one table
         use_isrf_class=isrf_class
      ENDIF ELSE BEGIN
         use_isrf_class=0  ;This is for Mathis field
      ENDELSE
      fiv=[-1.,1.,use_isrf_class,0.]     ;This sets the ISRF class to the requested value. also removes ionising photons.
      isrf_class_str='_isrfclass'+strtrim(use_isrf_class,2)
      ;define the number of free parameters in the grid and the grid fits table name
      IF keyword_set(test) THEN BEGIN
         iv_Nvalues=[4]
         ;table_name=dir+test_str+model+'_MuseISRF_JWST_G0_4Phangs_noionis'+isrf_class_str+'.fits'
      ENDIF ELSE BEGIN
         ;iv_Nvalues=[19]
         iv_Nvalues=[12]
      ENDELSE
      table_name=dir+test_str+model+'_MuseISRF_JWST_adaptedG0_4Phangs_noionis'+isrf_class_str+'.fits'
      dustem_make_sed_table,model,pd,iv_min,iv_max,iv_Nvalues,fpd=fpd,fiv=fiv,filename=table_name,filters=filters,plog=plog,show_seds=show_seds
      ;adding linear parameters (small grains abundances)
      message,'Adding Dust abundances to grid',/continue
      pd=['(*!dustem_params).grains[0].MDUST_O_MH','(*!dustem_params).grains[1].MDUST_O_MH','(*!dustem_params).grains[2].MDUST_O_MH']
      default_value=(dustem_get_param_values_default(pd))
      iv_min=[default_value/10.]
      iv_max=[default_value[0:1]*10.,default_value[2]*100.]
      ;iv_Nvalues=[11,11,11]
      iv_Nvalues=[13,13,13]
      plog=[1,1,1]
      IF keyword_set(test) THEN BEGIN
         iv_min=[default_value/2.]
         iv_max=[default_value*2.]
         iv_Nvalues=[3,3,3]
         plog=[1,1,1]
      ENDIF
      output_table_name=dir+test_str+model+'_MuseISRF_JWST_adaptedG0_Ypah1added_Ypah2added_adaptedYvsgadded_4Phangs_noionis'+isrf_class_str+'.fits'
      dustem_add_linear_params2grid,table_name,pd,iv_min,iv_max,iv_Nvalues,out_filename=output_table_name,plog=plog,show_seds=show_seds
      goto,the_end
   END
907a3ade   Jean-Philippe Bernard   improved
410
   '222': BEGIN          ;This is same as 221, but using the standard DL07 GRAIN.DAT, ie, Ypah+ set by Fortran and PAH keywords set to mix-logn
78db85de   Jean-Philippe Bernard   modified for diff...
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
                        ;Note: This does not really work, because PAH+ contribution does not get multiplied linearly by abundance ...
      !quiet=1
      model='DL07'   ;This is to use the DBP90 dust model
      ;======= This is to produce a grid with the above model for G0 and PAH abundance and ISRF from the Muse data
      ;======= Note that g0 is fixed parameters is actually not used, replaced by dustem_plugin_phangs_class_isrf_2
      pd = [ $
           'dustem_plugin_phangs_class_isrf_2' $             ;G0 factor for Phangs ISRF classes
           ]          
      iv_min =   [0.1]
      iv_max =   [10.]
      plog=[1]
      IF keyword_set(test) THEN BEGIN
         iv_min =   [.1]
         iv_max =   [10.]
         plog=[1]
      ENDIF
      fpd=['(*!dustem_params).gas.g0','(*!dustem_params).g0','dustem_plugin_phangs_class_isrf_1','dustem_plugin_phangs_class_isrf_4'] ;ISRF class to be used
      dustem_init,model=model
      fortran_user=dustem_set_up_fortran(/random_name)   ;use a random fortran number
      !dustem_verbose=0
      (*!dustem_params).KEYWORDS='quiet '+(*!dustem_params).KEYWORDS    ;This makes Fortran be quiet too
      ;stop
      (*!dustem_params).grains[0].TYPE_KEYWORDS='logn-mix'
      (*!dustem_params).grains[1].TYPE_KEYWORDS='logn-mix'
      ;(*!dustem_params).grains[0].TYPE_KEYWORDS='logn'
      ;(*!dustem_params).grains[1].TYPE_KEYWORDS='logn'
      grain_keywords=[(*!dustem_params).grains.TYPE_KEYWORDS]   ;This is to inform dustem_make_sed_table, which actually runs the models
      ;=== select filters to be used for the grid (HOOPS, we need MUSE also, and maybe all filters ...)
      ;filters=dustem_get_all_filter_names()
      filters=get_phangs_filter_names(/order_by_wavelengths)
      IF keyword_set(isrf_class) THEN BEGIN  ;do just one table
         use_isrf_class=isrf_class
      ENDIF ELSE BEGIN
         use_isrf_class=0  ;This is for Mathis field
      ENDELSE
      fiv=[-1.,1.,use_isrf_class,0.]     ;This sets the ISRF class to the requested value. also removes ionising photons.
      isrf_class_str='_isrfclass'+strtrim(use_isrf_class,2)
      ;define the number of free parameters in the grid and the grid fits table name
      IF keyword_set(test) THEN BEGIN
         iv_Nvalues=[4]
         ;table_name=dir+test_str+model+'_MuseISRF_JWST_G0_4Phangs_noionis'+isrf_class_str+'.fits'
      ENDIF ELSE BEGIN
         ;iv_Nvalues=[19]
         iv_Nvalues=[12]
      ENDELSE
      table_name=dir+test_str+model+'_orig_MuseISRF_JWST_adaptedG0_4Phangs_noionis'+isrf_class_str+'.fits'
      ;stop
      dustem_make_sed_table,model,pd,iv_min,iv_max,iv_Nvalues,fpd=fpd,fiv=fiv,filename=table_name,filters=filters,plog=plog,show_seds=show_seds, $
                           grain_keywords=grain_keywords
      ;adding linear parameters (small grains abundances)
      message,'Adding Dust abundances to grid',/continue
      ;pd=['(*!dustem_params).grains[0].MDUST_O_MH','(*!dustem_params).grains[1].MDUST_O_MH','(*!dustem_params).grains[2].MDUST_O_MH']
      pd=['(*!dustem_params).grains[0].MDUST_O_MH','(*!dustem_params).grains[2].MDUST_O_MH']
      default_value=(dustem_get_param_values_default(pd))
      iv_min=[default_value/10.]
      ;iv_max=[default_value[0:1]*10.,default_value[2]*100.]
      iv_max=[default_value[0]*10.,default_value[1]*100.]
      ;iv_Nvalues=[11,11,11]
      ;iv_Nvalues=[13,13,13]
      iv_Nvalues=[13,13]
      ;plog=[1,1,1]
      plog=[1,1]
      IF keyword_set(test) THEN BEGIN
         iv_min=[default_value/2.]
         iv_max=[default_value*2.]
         ;iv_Nvalues=[3,3,3]
         ;plog=[1,1,1]
         iv_Nvalues=[3,3]
         plog=[1,1]
      ENDIF
      output_table_name=dir+test_str+model+'_orig_MuseISRF_JWST_adaptedG0_Ypah1added_Yvsgadded_4Phangs_noionis'+isrf_class_str+'.fits'
      dustem_add_linear_params2grid,table_name,pd,iv_min,iv_max,iv_Nvalues,out_filename=output_table_name,plog=plog,show_seds=show_seds
      goto,the_end
   END
907a3ade   Jean-Philippe Bernard   improved
485
   '223': BEGIN          ;This is same as 221, but using the standard DL07 GRAIN.DAT, ie, YPAH0 and Ypah1 keywords set to logn
78db85de   Jean-Philippe Bernard   modified for diff...
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
                        ;Note: This assumes a variable Xion which is different from DL07 and no size depednence of Xion
      !quiet=1
      model='DL07'   ;This is to use the DBP90 dust model
      ;======= This is to produce a grid with the above model for G0 and PAH abundance and ISRF from the Muse data
      ;======= Note that g0 is fixed parameters is actually not used, replaced by dustem_plugin_phangs_class_isrf_2
      pd = [ $
           'dustem_plugin_phangs_class_isrf_2' $             ;G0 factor for Phangs ISRF classes
           ]          
      iv_min =   [0.1]
      iv_max =   [10.]
      plog=[1]
      IF keyword_set(test) THEN BEGIN
         iv_min =   [.1]
         iv_max =   [10.]
         plog=[1]
      ENDIF
      fpd=['(*!dustem_params).gas.g0','(*!dustem_params).g0','dustem_plugin_phangs_class_isrf_1','dustem_plugin_phangs_class_isrf_4'] ;ISRF class to be used
      dustem_init,model=model
      fortran_user=dustem_set_up_fortran(/random_name)   ;use a random fortran number
      !dustem_verbose=0
      (*!dustem_params).KEYWORDS='quiet '+(*!dustem_params).KEYWORDS    ;This makes Fortran be quiet too
      ;stop
      (*!dustem_params).grains[0].TYPE_KEYWORDS='logn'
      (*!dustem_params).grains[1].TYPE_KEYWORDS='logn'
      grain_keywords=[(*!dustem_params).grains.TYPE_KEYWORDS]   ;This is to inform dustem_make_sed_table, which actually runs the models
      ;=== select filters to be used for the grid (HOOPS, we need MUSE also, and maybe all filters ...)
      ;filters=dustem_get_all_filter_names()
      filters=get_phangs_filter_names(/order_by_wavelengths)
      IF keyword_set(isrf_class) THEN BEGIN  ;do just one table
         use_isrf_class=isrf_class
      ENDIF ELSE BEGIN
         use_isrf_class=0  ;This is for Mathis field
      ENDELSE
      fiv=[-1.,1.,use_isrf_class,0.]     ;This sets the ISRF class to the requested value. also removes ionising photons.
      isrf_class_str='_isrfclass'+strtrim(use_isrf_class,2)
      ;define the number of free parameters in the grid and the grid fits table name
      IF keyword_set(test) THEN BEGIN
         iv_Nvalues=[4]
      ENDIF ELSE BEGIN
         iv_Nvalues=[12]
      ENDELSE
      table_name=dir+test_str+model+'_logn_MuseISRF_JWST_adaptedG0_4Phangs_noionis'+isrf_class_str+'.fits'
      ;stop
      dustem_make_sed_table,model,pd,iv_min,iv_max,iv_Nvalues,fpd=fpd,fiv=fiv,filename=table_name,filters=filters,plog=plog,show_seds=show_seds, $
                           grain_keywords=grain_keywords
      ;adding linear parameters (small grains abundances)
      message,'Adding Dust abundances to grid',/continue
      pd=['(*!dustem_params).grains[0].MDUST_O_MH','(*!dustem_params).grains[1].MDUST_O_MH','(*!dustem_params).grains[2].MDUST_O_MH']
      ;pd=['(*!dustem_params).grains[0].MDUST_O_MH','(*!dustem_params).grains[2].MDUST_O_MH']
      default_value=(dustem_get_param_values_default(pd))
      iv_min=[default_value/10.]
      iv_max=[default_value[0:1]*10.,default_value[2]*100.]
      iv_Nvalues=[13,13,13]
      plog=[1,1,1]
      IF keyword_set(test) THEN BEGIN
         iv_min=[default_value/2.]
         iv_max=[default_value*2.]
         iv_Nvalues=[3,3,3]
         plog=[1,1,1]
      ENDIF
      output_table_name=dir+test_str+model+'_logn_MuseISRF_JWST_adaptedG0_Ypah1added_Yvsgadded_4Phangs_noionis'+isrf_class_str+'.fits'
      dustem_add_linear_params2grid,table_name,pd,iv_min,iv_max,iv_Nvalues,out_filename=output_table_name,plog=plog,show_seds=show_seds
      goto,the_end
   END
907a3ade   Jean-Philippe Bernard   improved
550
   '0-200': BEGIN          ;This is to extend the range of YG1 by 2 values lower values
7d6bf3f2   Jean-Philippe Bernard   improved
551
      fortran_user=dustem_set_up_fortran(/random_name)   ;use a random fortran number
907a3ade   Jean-Philippe Bernard   improved
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
      IF keyword_set(isrf_class) THEN BEGIN  ;do just one table
         use_isrf_class=isrf_class
      ENDIF ELSE BEGIN
         use_isrf_class=0  ;This is for Mathis field
      ENDELSE
      model='DL07'
      !quiet=1
      isrf_class_str='_isrfclass'+strtrim(use_isrf_class,2)
      input_table_name=dir+model+'_logn_MuseISRF_JWST_adaptedG0_Ypah1added_Yvsgadded_4Phangs_noionis'+isrf_class_str+'.fits'
      output_table_name=dir+test_str+model+'_logn_MuseISRF_JWST_adaptedG0_Ypah1added_Yvsgadded_4Phangs_noionis_YG1lowext'+isrf_class_str+'.fits'
      add_param_desc='(*!dustem_params).grains[1].MDUST_O_MH'
      what_do_we_add='lower'
      Nvalues=2
      force_grain_keywords=['logn','logn',replicate('?',3)]
      dustem_grids_extend_parameter_range,input_table_name,add_param_desc,Nvalues $
                                         ,force_grain_keywords=force_grain_keywords $
                                         ,output_table_name=output_table_name $
                                         ,what_do_we_add=what_do_we_add

      goto,the_end
   END
   '+2000': BEGIN          ;This is to extend the range of F0 parameter by 2 values above max.
7d6bf3f2   Jean-Philippe Bernard   improved
574
      fortran_user=dustem_set_up_fortran(/random_name)   ;use a random fortran number
907a3ade   Jean-Philippe Bernard   improved
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
      IF keyword_set(isrf_class) THEN BEGIN  ;do just one table
         use_isrf_class=isrf_class
      ENDIF ELSE BEGIN
         use_isrf_class=0  ;This is for Mathis field
      ENDELSE
      model='DL07'
      !quiet=1
      isrf_class_str='_isrfclass'+strtrim(use_isrf_class,2)
      input_table_name=dir+model+'_logn_MuseISRF_JWST_adaptedG0_Ypah1added_Yvsgadded_4Phangs_noionis'+isrf_class_str+'.fits'
      output_table_name=dir+test_str+model+'_logn_MuseISRF_JWST_adaptedG0_Ypah1added_Yvsgadded_4Phangs_noionis_F0upext'+isrf_class_str+'.fits'
      add_param_desc='dustem_plugin_phangs_class_isrf_2'
      what_do_we_add='larger'
      Nvalues=2
      force_grain_keywords=['logn','logn',replicate('?',3)]
      dustem_grids_extend_parameter_range,input_table_name,add_param_desc,Nvalues $
                                         ,force_grain_keywords=force_grain_keywords $
                                         ,output_table_name=output_table_name $
                                         ,what_do_we_add=what_do_we_add

      goto,the_end
   END

3b79f061   Jean-Philippe Bernard   improved
597
ENDCASE
0ed148cc   Jean-Philippe Bernard   improved
598

d6343d56   Jean-Philippe Bernard   First commit
599

0ed148cc   Jean-Philippe Bernard   improved
600
601
the_end:

d6343d56   Jean-Philippe Bernard   First commit
602
END