Commit 049156edef2ea7b7482561e25419bd503a1d6fe7
1 parent
5f7a3e9b
Exists in
master
restored accidental delete
Showing
1 changed file
with
203 additions
and
1 deletions
Show diff stats
src/idl/dustem_init.pro
1 | 1 | PRO dustem_init,model=model $ |
2 | - ,wraptest=wraptest | |
2 | + ,wraptest=wraptest $ | |
3 | + ,plot_it=plot_it $ | |
4 | + ,noerase=noerase $ | |
5 | + ,noobj=noobj $ | |
6 | + ,st_model=st_model $ | |
7 | + ,polarization=polarization $ | |
8 | + ,verbose=verbose $ | |
9 | + ,help=help $ | |
10 | + ,grain_keywords=grain_keywords | |
11 | + | |
12 | +;+ | |
13 | +; NAME: | |
14 | +; dustem_init | |
15 | +; | |
16 | +; PURPOSE: | |
17 | +; Defines system variables to run the DUSTEM code | |
18 | +; | |
19 | +; CATEGORY: | |
20 | +; DustEMWrap, Distributed, HighLevel, Initialization | |
21 | +; | |
22 | +; CALLING SEQUENCE: | |
23 | +; dustem_init,model=model, | |
24 | +; | |
25 | +; INPUTS: | |
26 | +; None | |
27 | +; | |
28 | +; OPTIONAL INPUT PARAMETERS: | |
29 | +; None | |
30 | +; | |
31 | +; OUTPUTS: | |
32 | +; None | |
33 | +; | |
34 | +; OPTIONAL OUTPUT PARAMETERS: | |
35 | +; ; st_model | |
36 | +; | |
37 | +; ACCEPTED KEY-WORDS: | |
38 | +; model = specifies the interstellar dust mixture used by DustEM | |
39 | +; 'MC10' model from Compiegne et al 2010 (default) | |
40 | +; 'DBP90' model from Desert et al 1990 | |
41 | +; 'DL01' model from Draine & Li 2001 | |
42 | +; 'WD01_RV5P5B' model from Weingartner & Draine 2002 with Rv=5.5 | |
43 | +; 'DL07' model from Draine & Li 2007 | |
44 | +; 'J13' model from Jones et al 2013, as updated in | |
45 | +; Koehler et al 2014 | |
46 | +; 'G17_ModelA' model A from Guillet et al (2018). Includes | |
47 | +; polarisation. See Tables 2 and 3 of that paper for details. | |
48 | +; 'G17_ModelB' model B from Guillet et al (2018) | |
49 | +; 'G17_ModelC' model C from Guillet et al (2018) | |
50 | +; 'G17_ModelD' model A from Guillet et al (2018) | |
51 | +; wraptest = test running dustem f90 through the wrapper | |
52 | +; plot_it = plots result of wraptest (ignored if wraptest not set) | |
53 | +; help = if set, print this help | |
54 | +; verbose = if set, output code diagnostic info (default OFF) | |
55 | +; polarization = set this variables for runs taking polarization into account | |
56 | +; noerase : set this keyword to not erase the temporary DAT files used by dustemwrap | |
57 | +; noobj : set this keyword to turn off object-oriented | |
58 | +; graphical output when using IDL. Object-oriented | |
59 | +; graphics are OFF by default for GDL and Fawlty. | |
60 | +; grain_keywords : Fortran grain keywords. Must be an array of Ngrains strings. Use '?' to keep default values. | |
61 | +; | |
62 | +; COMMON BLOCKS: | |
63 | +; None | |
64 | +; | |
65 | +; SIDE EFFECTS: | |
66 | +; 1/ The following system variables are initialized to null values | |
67 | +; or empty pointers: | |
68 | +; !dustem_fit | |
69 | +; !dustem_data | |
70 | +; !dustem_inputs | |
71 | +; !dustem_params | |
72 | +; !run_ionfrac | |
73 | +; !dustem_idl_continuum | |
74 | +; !dustem_filters | |
75 | +; !dustem_verbose | |
76 | +; !dustem_show_plot | |
77 | +; 2/ optionally runs the fortran code (if wraptest) | |
78 | +; This step calls the Fortran code to run a standard model | |
79 | +; 3/ !dustem_filters is initialized calling dustem_filter_init.pro. | |
80 | +; | |
81 | +; RESTRICTIONS: | |
82 | +; The DustEM fortran code must be installed | |
83 | +; The DustEMWrap idl code must be installed | |
84 | +; | |
85 | +; PROCEDURES AND SUBROUTINES USED: | |
86 | +; | |
87 | +; EXAMPLES | |
88 | +; dustem_init,model="MC10",/wrap,/plot_it | |
89 | +; | |
90 | +; MODIFICATION HISTORY: | |
91 | +; Written by JPB,NF,DP Jan-2007 | |
92 | +; Evolution details on the DustEMWrap gitlab. | |
93 | +; See http://dustemwrap.irap.omp.eu/ for FAQ and help. | |
94 | +;- | |
95 | + | |
96 | + | |
97 | +IF keyword_set(help) THEN BEGIN | |
98 | + doc_library,'dustem_init' | |
99 | + goto,the_end | |
100 | +ENDIF | |
101 | + | |
102 | +dustem_define_la_common | |
103 | + | |
104 | +;define which code is running, idl, gdl or fawlty | |
105 | +defsysv,'!fl',exist=fawlty | |
106 | +defsysv,'!gdl',exist=gdl | |
107 | +IF fawlty THEN defsysv,'!dustemwrap_which_language','fawlty' | |
108 | +IF gdl THEN defsysv,'!dustemwrap_which_language','gdl' | |
109 | +IF not fawlty and not gdl THEN defsysv,'!dustemwrap_which_language','idl' | |
110 | + | |
111 | +;Control of object-oriented graphics | |
112 | +IF fawlty OR gdl THEN defsysv,'!dustem_noobj',1 ELSE defsysv,'!dustem_noobj',0 | |
113 | +IF keyword_set(noobj) then defsysv,'!dustem_noobj',1 | |
114 | + | |
115 | +;see if the user has set their dustem_which | |
116 | +defsysv,'!dustem_which',exist=dwhich | |
117 | +if not dwhich then begin | |
118 | + defsysv,'!dustem_which','RELEASE' | |
119 | + message,'!dustem_which not known from idl_startup, using RELEASE version',/info | |
120 | +end | |
121 | + | |
122 | +un_mouchard={iteration:0L, $ | |
123 | + chi2:0.d0,rchi2:0.d0, $ | |
124 | + qchi2:0.d0,qrchi2:0.d0, $ | |
125 | + uchi2:0.d0,urchi2:0.d0, $ | |
126 | + parameters_descriptions:ptr_new(),parameters_values:ptr_new()} | |
127 | +mouchard=ptr_new(replicate(un_mouchard,1)) | |
128 | +defsysv,'!iteration_mouchard',mouchard | |
129 | + | |
130 | +defsysv,'!dustem_verbose',0 ;1=verbose | |
131 | +IF keyword_set(verbose) THEN !dustem_verbose=1 | |
132 | + | |
133 | +defsysv,'!run_pol',0 ;0=no polar | |
134 | +IF keyword_set(polarization) THEN !run_pol=1 | |
135 | +IF not keyword_set(polarization) THEN !run_pol=0 | |
136 | + | |
137 | +;=== color correction system variables | |
138 | +defsysv,'!dustem_previous_cc',ptr_new() ;store previous color correction values | |
139 | +defsysv,'!dustem_do_cc',1 ;indicates to dustem if color corrections are needed. Will be changed when fitting | |
140 | +defsysv,'!dustem_never_do_cc',0 ;set to 1 to never do color corrections (not recommanded, but faster). | |
141 | + | |
142 | +;=== polarization system variables | |
143 | +defsysv, '!run_circ', 0. | |
144 | +defsysv, '!run_anis', 0. | |
145 | +defsysv, '!run_rrf', 0. | |
146 | +defsysv, '!run_univ', 0. | |
147 | +defsysv, '!run_lin', 0. | |
148 | + | |
149 | +defsysv, '!dustem_redshift', 0. ;in case the SED needs to be shifted for a non zero redshift | |
150 | + | |
151 | +;This is just to make sure that plugin system variables are created even if no plugins are used | |
152 | +pd_bidon=['NONE'] | |
153 | +dustem_init_plugins,pd_bidon | |
154 | + | |
155 | +defsysv,'!dustem_nocatch',0 ;set to catch errors in SED fitting. | |
156 | + | |
157 | + | |
158 | +defsysv,'!indef', exists=exists_indef | |
159 | +IF NOT exists_indef THEN defsysv,'!indef',32768. | |
160 | + | |
161 | + | |
162 | +;=== read info about instrument | |
163 | +file=!dustem_wrap_soft_dir+'instrument_description.xcat' | |
164 | +st=read_xcat(file,/silent) | |
165 | +defsysv,'!dustem_instrument_description',st | |
166 | + | |
167 | +defsysv, '!dustem_isrf_file', ptr_new() ;but there is only one system variable for this... Is this ok? | |
168 | + | |
169 | +defsysv, '!dustem_iter', {prv:1,act:1} | |
170 | + | |
171 | +;define !dustem_fit | |
172 | +dustem_fit_st={data:ptr_new(), $ ;,wavelength:ptr_new(), ;because wavelength arrays in the different datasets (data) can be different | |
173 | + param_descs:ptr_new(),param_init_values:ptr_new(),param_func:ptr_new(), $ | |
174 | + fixed_param_descs:ptr_new(),fixed_param_init_values:ptr_new(), $ | |
175 | + chi2:0.D0,rchi2:0.D0, $ | |
176 | + qchi2:0.D0,qrchi2:0.D0, $ | |
177 | + uchi2:0.D0,urchi2:0.D0, $ | |
178 | + current_param_values:ptr_new(), current_param_errors:ptr_new() $ | |
179 | + } | |
180 | +defsysv, '!dustem_fit', ptr_new(dustem_fit_st) ;Data to fit | |
181 | + | |
182 | +dustem_data_st = dustem_define_dustem_data(polarization=polarization,rchi2_weight =rchi2_weight) | |
183 | +defsysv, '!dustem_data', ptr_new(dustem_data_st) | |
184 | +defsysv,'!dustem_show', ptr_new(dustem_data_st) | |
185 | + | |
186 | +if !run_pol then begin | |
187 | + tagnames=tag_names(*!dustem_data) | |
188 | + testpol = tagnames EQ 'POLSED' or tagnames EQ 'POLEXT' or tagnames EQ 'POLFRAC' or tagnames EQ 'FPOLEXT' or tagnames EQ 'PSI_EM' or tagnames EQ 'PSI_EXT' | |
189 | + ind_data=where(~testpol,ctestpol) | |
190 | + if ctestpol ne 0 then tagnames =(tag_names(*!dustem_data))[ind_data] | |
191 | + | |
192 | +endif else tagnames=tag_names(*!dustem_data) | |
193 | + | |
194 | +;instr="defsysv, '!fit_rchi2_weight', {" | |
195 | +instr="fit_rchi2_weight_str={" | |
196 | +FOR i = 0, n_elements(tagnames)-1 DO BEGIN | |
197 | + instr+=tagnames(i)+': rchi2_weight.'+tagnames(i) | |
198 | + IF i NE n_elements(tagnames)-1 THEN instr+=',' | |
199 | +ENDFOR | |
200 | +instr+='}' | |
201 | +toto=execute(instr) | |
202 | +defsysv, '!fit_rchi2_weight',ptr_new(fit_rchi2_weight_str) | |
203 | + | |
204 | + | |
3 | 205 | ;#########system variables necessary for cgwindow plotting########## |
4 | 206 | defsysv, '!dustemcgwin_id', { $ ;IDs of windows to plot |
5 | 207 | sed: la_undef(), $ | ... | ... |