Commit a4c9699a6f35a35846dd1cdff17cd8da123cc367
1 parent
84fd3e7e
Exists in
master
first commit
Showing
1 changed file
with
180 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,180 @@ |
1 | +PRO dustem_init_params,model,pd,iv, $ | |
2 | + fpd=fpd,fiv=fiv $ | |
3 | + ,ulimed=ulimed,llimed=llimed,ulims=ulims,llims=llims $ | |
4 | + ,tied=tied,fixed=fixed $ | |
5 | + ,polarization=polarization | |
6 | +;+ | |
7 | +; NAME: | |
8 | +; dustem_init_params | |
9 | +; | |
10 | +; PURPOSE: | |
11 | +; This routine initialises the free and fixed parameters of both the | |
12 | +; dust models and plugins. It does some basic sanity checking. | |
13 | +; | |
14 | +; CATEGORY: | |
15 | +; DustEMWrap, Distributed, Mid-Level, Initialization | |
16 | +; | |
17 | +; CALLING SEQUENCE: | |
18 | +; dustem_init_params, pd, iv, [,fpd=fpd,fiv=fiv,ulimed=ulimed,llimed=llimed,ulims=ulims,lolims=llims,tied=tied,fixed=fixed] | |
19 | +; | |
20 | +; INPUTS: | |
21 | +; model -- the dust model | |
22 | +; pd -- the parameter description vector | |
23 | +; iv -- the initial values of the free parameters | |
24 | +; | |
25 | +; OPTIONAL INPUT PARAMETERS: | |
26 | +; | |
27 | +; | |
28 | +; OUTPUTS: | |
29 | +; None | |
30 | +; | |
31 | +; OPTIONAL OUTPUT PARAMETERS: | |
32 | +; None | |
33 | +; | |
34 | +; ACCEPTED KEY-WORDS: | |
35 | +; model = specifies the interstellar dust mixture used by DustEM | |
36 | +; 'MC10' model from Compiegne et al 2010 (default) | |
37 | +; 'DBP90' model from Desert et al 1990 | |
38 | +; 'DL01' model from Draine & Li 2001 | |
39 | +; 'WD01_RV5p5B' model from Weingartner & Draine 2002 with Rv=5.5 | |
40 | +; 'DL07' model from Draine & Li 2007 | |
41 | +; 'J13' model from Jones et al 2013, as updated in | |
42 | +; Koehler et al 2014 | |
43 | +; 'G17_ModelA' model A from Guillet et al (2018). Includes | |
44 | +; polarisation. See Tables 2 and 3 of that paper for details. | |
45 | +; 'G17_ModelB' model B from Guillet et al (2018) | |
46 | +; 'G17_ModelC' model C from Guillet et al (2018) | |
47 | +; 'G17_ModelD' model A from Guillet et al (2018) | |
48 | +; help = if set, print this help | |
49 | +; | |
50 | +; COMMON BLOCKS: | |
51 | +; None | |
52 | +; | |
53 | +; SIDE EFFECTS: | |
54 | +; None | |
55 | +; | |
56 | +; RESTRICTIONS: | |
57 | +; The DustEM fortran code must be installed | |
58 | +; The DustEMWrap IDL code must be installed | |
59 | +; | |
60 | +; PROCEDURES AND SUBROUTINES USED: | |
61 | +; dustem_init_parinfo | |
62 | +; dustem_init_plugins | |
63 | +; dustem_init_fixed_params | |
64 | +; | |
65 | +; EXAMPLES | |
66 | +; | |
67 | +; MODIFICATION HISTORY: | |
68 | +; Written by AH October-2022 | |
69 | +; Evolution details on the DustEMWrap gitlab. | |
70 | +; See http://dustemwrap.irap.omp.eu/ for FAQ and help. | |
71 | +;- | |
72 | + | |
73 | +IF keyword_set(help) THEN BEGIN | |
74 | + doc_library,'dustem_init_params' | |
75 | + goto,the_end | |
76 | +END | |
77 | + | |
78 | +Npar=n_elements(pd) | |
79 | +Niv=n_elements(iv) | |
80 | + | |
81 | +if Npar ne Niv then begin | |
82 | + message, 'Number of parameters does not equal number of initial values provided',/info | |
83 | + stop | |
84 | +end | |
85 | + | |
86 | +if keyword_set(ulimed) then begin | |
87 | + Nulimed=n_elements(ulimed) | |
88 | + if Npar ne Nulimed then begin | |
89 | + message, 'Number of parameters does not equal number of upper limit flags',/info | |
90 | + stop | |
91 | + end | |
92 | +end | |
93 | + | |
94 | +if keyword_set(ulims) then begin | |
95 | + Nulims=n_elements(ulims) | |
96 | + if Npar ne Nulims then begin | |
97 | + message, 'Number of upper limits must equal number of parameters (use ulimed to specify ON/OFF for each parameter)',/info | |
98 | + stop | |
99 | + end | |
100 | +end | |
101 | + | |
102 | +if keyword_set(llimed) then begin | |
103 | + Nllimed=n_elements(llimed) | |
104 | + if Npar ne Nllimed then begin | |
105 | + message, 'Number of parameters does not equal number of lower limit flags',/info | |
106 | + stop | |
107 | + end | |
108 | +end | |
109 | + | |
110 | +if keyword_set(llims) then begin | |
111 | + Nllims=n_elements(llims) | |
112 | + if Npar ne Nllims then begin | |
113 | + message, 'Number of lower limits must equal number of parameters (use llimed to specify ON/OFF for each parameter)',/info | |
114 | + stop | |
115 | + end | |
116 | +end | |
117 | + | |
118 | + | |
119 | +if keyword_set(fpd) then begin | |
120 | + Nfpar=n_elements(fpd) | |
121 | + Nfiv=n_elements(fiv) | |
122 | + if Nfpar ne Nfiv then begin | |
123 | + message, 'Number of fixed parameters does not equal number of fixed initial values',/info | |
124 | + stop | |
125 | + end | |
126 | +;== CHECK IF USER HAS MADE SOMETHING FIXED AND FREE | |
127 | + match,pd,fpd,a,b,count=ct | |
128 | + if ct ne 0 then begin | |
129 | + message, 'Parameter that is both free and fixed?',/info | |
130 | + print,'Matching free parameters: '+pd[a] | |
131 | + print,'Matching fixed parameters: '+fpd[b] | |
132 | + stop | |
133 | + end | |
134 | +end | |
135 | + | |
136 | +; basic sanity checking of models | |
137 | + | |
138 | +known_mdls=['MC10','DBP90','DL01','WD01_RV5P5B','DL07','J13','G17_MODELA','G17_MODELB','G17_MODELC','G17_MODELD'] | |
139 | +pol_mdls=['G17_MODELA','G17_MODELB','G17_MODELC','G17_MODELD'] | |
140 | +test_model = where(known_mdls eq model,ct) | |
141 | +if ct eq 0 then begin | |
142 | + message,'ISM dust model '+use_model+' unknown',/continue | |
143 | + message,'Known models are MC10,DBP90,DL01,WD01_RV5P5B,DL07,J13,G17_MODELA,G17_MODELB,G17_MODELC,G17_MODELD',/continue | |
144 | + stop | |
145 | +end | |
146 | + | |
147 | +if keyword_set(polarization) then begin | |
148 | + test_model = where(pol_mdls eq model,ct) | |
149 | + if ct eq 0 then begin | |
150 | + message,'The only models with polarisation are G17_MODELA,G17_MODELB,G17_MODELC,G17_MODELD',/continue | |
151 | + stop | |
152 | + end | |
153 | +end else begin | |
154 | + test_model = where(pol_mdls eq model,ct) | |
155 | + if ct eq 1 then begin | |
156 | + message,'You have requested a dust model with polarisation '+model+' but DustEMWrap is not initialized in polarisation mode',/info | |
157 | + message,'You should set >dustem_init,model=use_model,polarization=1',/info | |
158 | + stop | |
159 | + end | |
160 | +end | |
161 | + | |
162 | +; basic sanity checking of plugins | |
163 | + | |
164 | + | |
165 | + | |
166 | +;== INITIALIZE DUST MODEL PARAMETERS and PLUGIN FREE PARAMETERS | |
167 | +dustem_init_parinfo,pd,iv,up_limited=ulimed,lo_limited=llimed,up_limits=ulims,lo_limits=llims,fixed=fixed,tied=tied | |
168 | + | |
169 | +;== INITIALIZE ANY PLUGINS | |
170 | +dustem_init_plugins,pd,fpd=fpd | |
171 | + | |
172 | +;== INITIALIZE ANY FIXED PARAMETERS FOR DUST MODOEL AND PLUGINS | |
173 | +if keyword_set(fpd) then dustem_init_fixed_params,fpd,fiv | |
174 | + | |
175 | +message,'Finished initializing free and fixed parameters of dust model and plugins',/info | |
176 | + | |
177 | + | |
178 | +the_end: | |
179 | + | |
180 | +END | ... | ... |