Commit 11c71cbbe6e9051cf545f9729faee2fb8f9d1fad
Exists in
master
Merge branch 'master' of https://gitlab.irap.omp.eu/OV-GSO-DC/dustem-wrapper_idl
Showing
17 changed files
with
143 additions
and
178 deletions
Show diff stats
... | ... | @@ -0,0 +1,16 @@ |
1 | +FUNCTION DUSTEM_CUT_OFF, x, par | |
2 | +; generates the large size cut-off | |
3 | +; from Weingartner & Draine 2001 | |
4 | +; x : grain size | |
5 | +; par(0) : threshold for cut-off (At) | |
6 | +; par(1) : shape As (roughly the size where cut_off=0.5) | |
7 | + | |
8 | + y = 0.d0*x + 1.d0 | |
9 | + ix = WHERE( x GT par(0), cnt ) | |
10 | + if CNT GT 0 then begin | |
11 | + y(ix) = exp( -( (x(ix)-par(0)) / par(1))^3. ) | |
12 | + endif else begin | |
13 | + print,'(W) DUSTEM_CUT_OFF: no size larger than At found' | |
14 | + endelse | |
15 | +RETURN, y | |
16 | +END | ... | ... |
src/idl/dustem_fit_modified_bb_readme.pro deleted
... | ... | @@ -1,178 +0,0 @@ |
1 | -PRO dustem_fit_modified_bb_readme,postcript=postcript,mode=mode,help=help | |
2 | - | |
3 | -;This Readme describes how to fit SEDs with a modified Black-Body | |
4 | -;It runs on the SED stored into the file sample_SED.xcat | |
5 | -;Remember that the goal here is just to illustrate the method. | |
6 | -;Note that its is not necessary to use the .xcat file format, and data SED can be provided | |
7 | -;manually, but the observation structure must have the structure shown below. | |
8 | -;Obviously, the dustem package must have been installed succesfully | |
9 | -;see DustemWrap documentation for install instructions. | |
10 | - | |
11 | -;+ | |
12 | -; NAME: | |
13 | -; dustem_fit_modified_bb_readme | |
14 | -; PURPOSE: | |
15 | -; This is an example of how to fit SEDs with a modified Black-Body | |
16 | -; using the dustem wrapper. | |
17 | -; It is meant to be an example to follow when writing your own | |
18 | -; programs using the dustem IDL wrapper. | |
19 | -; The SED used here is in sample_SED.xcat | |
20 | -; CATEGORY: | |
21 | -; Dustem | |
22 | -; CALLING SEQUENCE: | |
23 | -; dustem_fit_modified_bb_readme,postcript=postcript,help=help | |
24 | -; INPUTS: | |
25 | -; None | |
26 | -; OPTIONAL INPUT PARAMETERS: | |
27 | -; None | |
28 | -; OUTPUTS: | |
29 | -; None | |
30 | -; OPTIONAL OUTPUT PARAMETERS: | |
31 | -; None | |
32 | -; ACCEPTED KEY-WORDS: | |
33 | -; postcript = if set plot is done in DUSTEM/Docs/Figures/Last_dustem_fit.ps | |
34 | -; help = If set print this help | |
35 | -; COMMON BLOCKS: | |
36 | -; None | |
37 | -; SIDE EFFECTS: | |
38 | -; None | |
39 | -; RESTRICTIONS: | |
40 | -; The dustem idl wrapper must be installed | |
41 | -; PROCEDURE: | |
42 | -; None | |
43 | -; EXAMPLES | |
44 | -; dustem_fit_modified_bb_readme | |
45 | -; MODIFICATION HISTORY: | |
46 | -; Written by J.P. Bernard June 9th 2011 | |
47 | -; see evolution details on the dustem cvs maintained at CESR | |
48 | -; Contact J.-Ph. Bernard (Jean-Philippe.Bernard@cesr.fr) in case of problems. | |
49 | -;- | |
50 | - | |
51 | -message,'This is obsolete.See dustem_fit_intensity_mbb_example.pro',/continue | |
52 | -stop | |
53 | - | |
54 | -IF keyword_set(help) THEN BEGIN | |
55 | - doc_library,'dustem_fit_modified_bb_readme' | |
56 | - goto,the_end | |
57 | -ENDIF | |
58 | - | |
59 | -;=== initialise dustem | |
60 | -dustem_init | |
61 | -!dustem_verbose=1 | |
62 | -!dustem_show_plot=1 | |
63 | - | |
64 | -;=== Read sample SED | |
65 | -;=== Composite SED from Compiegne et al 2010, gathered by C. Bot | |
66 | -;dir=getenv('DUSTEM_SOFT_DIR')+'/src/dustem3.8_web/SEDs/' | |
67 | -;dir=!dustem_wrap_soft_dir+'/Data/SEDs/' | |
68 | -;file=dir+'Gal_composite_spectrum.xcat' | |
69 | -;sed=read_xcat(file,/silent) | |
70 | -;=== Or make a fake one out for given filters | |
71 | -;filters=['IRAS4','HFI1','HFI2','HFI3'] | |
72 | -filters=['IRAS4','PACS3','SPIRE1','SPIRE2','SPIRE3','HFI2','HFI3'] | |
73 | -Nfilt=n_elements(filters) | |
74 | -sed=dustem_initialize_sed(Nfilt) | |
75 | -sed.filter=filters | |
76 | -sed.wave=dustem_filter2wav(filters) | |
77 | -sed.instru=dustem_filter2instru(filters) | |
78 | - | |
79 | -;VG : dustem_set_data turned into a function to be used indifferently for sed, ext, polext | |
80 | -;dustem_set_data,sed ;This is to set filters in !dustem_data.sed. Needed by dustem_compute_gb_sed | |
81 | -;!dustem_data.sed=dustem_set_data(sed) ;This is to set filters in !dustem_data.sed. Needed by dustem_compute_gb_sed | |
82 | -st=dustem_set_data(sed=sed) | |
83 | - | |
84 | -;p_truth=[0.5D0,22.D0,1.8D0] | |
85 | -p_truth=[0.5,19.,1.8] | |
86 | -;sed.spec=dustem_compute_gb_sed(p_truth,_extra=extra) | |
87 | -sed.stokesI=dustem_compute_gb_sed(p_truth,_extra=extra) | |
88 | -;sed.error=sed.spec*0.05 | |
89 | -sed.sigmaII=(sed.stokesI*0.05)^2 | |
90 | - | |
91 | -;=== SET THE OBSERVATION STRUCTURE | |
92 | - | |
93 | -ind=where(sed.wave GE 100.) | |
94 | -;VG : dustem_set_data turned into a function to be used indifferently for sed, ext, polext | |
95 | -;dustem_set_data,sed(ind) | |
96 | -st=dustem_set_data(sed=sed(ind)) | |
97 | -;!dustem_data.sed=dustem_set_data(sed(ind)) | |
98 | - | |
99 | -;=== Set which parameters you want to fit | |
100 | -pd = ['Amplitude','T','beta'] | |
101 | -;=== set initial value of parameters you want to fit | |
102 | -;iv = [1.,20.,2.] | |
103 | -;iv = [0.5,22.D0,1.5D0] | |
104 | -iv=[0.5,22.,1.8] | |
105 | -ulimed=[0 , 0 ,0] | |
106 | -llimed=[1 , 1 ,1] | |
107 | -llims =[0. ,0. ,0.] | |
108 | - | |
109 | -;== SET THE FITTED PARAMETERS (now done in dustem_init_parinfo) | |
110 | -dustem_init_parinfo,pd,iv,up_limited=ulimed,lo_limited=llimed,up_limits=ulims,lo_limits=llims | |
111 | - | |
112 | - | |
113 | -;=== RUN fit | |
114 | -;tol=1.e-20 | |
115 | -tol=1.e-20 | |
116 | -xtol=1.e-10 | |
117 | -Nitermax=100 ;maximum number of iteration. This is the criterium which will stop the fit procedure | |
118 | - | |
119 | -loadct,13 | |
120 | -!y.range=[1e-4,10] ;This is to ajust plot range from outside the routine | |
121 | -t1=systime(0,/sec) | |
122 | -res=dustem_mpfit_data(tol=tol,xtol=xtol,Nitermax=Nitermax,function_name='dustem_greybody_mpfit',/xlog,/ylog) | |
123 | -t2=systime(0,/sec) | |
124 | - | |
125 | -;=== SAVE FIT RESULTS | |
126 | -;file_out=getenv('DUSTEM_RES')+'DUSTEM_fit_example.sav' | |
127 | -file_out='/tmp/DUSTEM_bb_fit_example.sav' | |
128 | -dustem_save_system_variables,file_out | |
129 | -message,'Saved '+file_out,/continue | |
130 | - | |
131 | - | |
132 | -;stop | |
133 | - | |
134 | -;====================================== | |
135 | -;====You can exit IDL here and re-enter | |
136 | -;====================================== | |
137 | - | |
138 | -file='/tmp/DUSTEM_bb_fit_example.sav' | |
139 | -dustem_restore_system_variables,file | |
140 | - | |
141 | -window,1 | |
142 | - | |
143 | -;=== RESTORE FIT RESULTS | |
144 | -;=== initialise dustem | |
145 | -;dustem_init | |
146 | - | |
147 | -;=== recover best fit values | |
148 | -res=*(*!dustem_fit).current_param_values | |
149 | -chi2=(*!dustem_fit).chi2 | |
150 | -rchi2=(*!dustem_fit).rchi2 | |
151 | -errors=*(*!dustem_fit).current_param_errors | |
152 | - | |
153 | -;=== Plot best fit | |
154 | -yr=[1e-3,100] | |
155 | -xr=[50,4000] | |
156 | -tit='DUSTEM Modified BB Example (Saved)' | |
157 | -ytit=textoidl('I_\nu (MJy/sr) for N_H=10^{20} H/cm^2') | |
158 | -xtit=textoidl('\lambda (\mum)') | |
159 | - | |
160 | -loadct,13 | |
161 | -IF keyword_set(postcript) THEN BEGIN | |
162 | - set_plot,'PS' | |
163 | - ps_file=!dustem_wrap_soft_dir+'/Docs/Figures/'+'Last_dustem_bb_fit.ps' | |
164 | - device,filename=ps_file,/color | |
165 | -ENDIF | |
166 | -dustem_sed_plot,*(*!dustem_fit).current_param_values, $ | |
167 | - ytit=ytit,xtit=xtit,title=tit,yr=yr,xr=xr,/ysty,/xsty,res=res,errors=errors,chi2=chi2,rchi2=rchi2,function_name='dustem_greybody_mpfit',/xlog,/ylog | |
168 | -IF keyword_set(postcript) THEN BEGIN | |
169 | - device,/close | |
170 | - set_plot,'X' | |
171 | - message,'wrote '+ps_file,/info | |
172 | -ENDIF | |
173 | - | |
174 | -print,'dustem_mpfit_sed executed in ',t2-t1,' sec' | |
175 | - | |
176 | -the_end: | |
177 | - | |
178 | -END |
... | ... | @@ -0,0 +1,33 @@ |
1 | +FUNCTION DUSTEM_HABING_FIELD, x, unit=unit | |
2 | +; computes the Habing interstellar radiation field SED (ISRF) | |
3 | +; in W/m2 (4*!pi*nu*I_nu) | |
4 | +; (from Draine & Bertoldi 1996) | |
5 | +; X (I): X-grid for the ISRF | |
6 | +; UNIT (I): unit of the ISRF. Choices are | |
7 | +; 'W': wave in um [Default] | |
8 | +; 'F': frequency in cm-1 | |
9 | +; 'E': energy in eV | |
10 | + | |
11 | + if n_elements( UNIT ) EQ 0 then unit = 'W' $ | |
12 | + else unit = strupcase( strcompress( unit,/rem) ) | |
13 | + | |
14 | + x = double( x ) | |
15 | + | |
16 | + CASE unit of | |
17 | + | |
18 | + 'W': x3 = 1.d1 * x | |
19 | + | |
20 | + 'F': x3 = 1.d5 / x | |
21 | + | |
22 | + 'E': x3 = 12.4 / x | |
23 | + | |
24 | + ENDCASE | |
25 | + | |
26 | + field = - x3^3*4.1667 + x3^2*12.5 - x3*4.3333 | |
27 | + field = 1.d-1 * 3.d8 * 1.d-14 * field | |
28 | + | |
29 | + i_neg = where( field LT 0.d0, c_neg ) | |
30 | + field( i_neg ) = 0.d0 | |
31 | + | |
32 | + RETURN, field | |
33 | +END ;FUNCTION DUSTEM_HABING_FIELD | ... | ... |
... | ... | @@ -0,0 +1,20 @@ |
1 | +FUNCTION DUSTEM_LOGN_VDIST, x, par | |
2 | +; generates a volume normalized log-normal law | |
3 | +; returns distribution in nr of grains : dn/da | |
4 | +; x : grain size | |
5 | +; par(0) : centroid of log-normal | |
6 | +; par(1) : sigma of log-normal | |
7 | +; par(2) : VOLUME normalization | |
8 | + | |
9 | + np = n_elements(x) | |
10 | + x0 = par(0) | |
11 | + sigma = par(1) | |
12 | + y = exp(- 0.5 * ( alog(x/x0) / sigma )^2 ) / x | |
13 | + vy = x^4 * y | |
14 | + xm = par(0) * exp( -par(1)^2 ) ; x of max in dn/da | |
15 | + print,'(W) DUSTEM_LOGN_VDIST: dn/da max @',xm*1e7,' nm' | |
16 | + dx = alog(x(1:np-1)) - alog(x(0:np-2)) | |
17 | + yi = TOTAL( (vy(1:np-1) + vy(0:np-2))*0.5*dx ) | |
18 | + y = par(2) * y / yi | |
19 | +RETURN, y | |
20 | +END | ... | ... |
... | ... | @@ -0,0 +1,52 @@ |
1 | +FUNCTION DUSTEM_MATHIS_FIELD, x, unit=unit | |
2 | +; computes the Mathis interstellar radiation field SED (ISRF) | |
3 | +; in W/m2 (4*!pi*nu*I_nu) | |
4 | +; from Mathis et al. 1983, A&A 128, 212 | |
5 | +; X (I): X-grid for the ISRF | |
6 | +; UNIT (I): unit of the ISRF. Choices are | |
7 | +; 'W': wave in um [Default] | |
8 | +; 'F': frequency in cm-1 | |
9 | +; 'E': energy in eV | |
10 | + | |
11 | + if n_elements( UNIT ) EQ 0 then unit = 'W' $ | |
12 | + else unit = strupcase( strcompress( unit,/rem) ) | |
13 | + | |
14 | + ly_limit = 9.11267101235d-2 | |
15 | + | |
16 | + x = double( x ) | |
17 | + | |
18 | +; | |
19 | +; visible part | |
20 | +; | |
21 | + wdil = 4.d0 * [ 4.d-13, 1.d-13, 1.d-14] ; Mathis definition | |
22 | + ; 4*!pi*Wdil*B_nu | |
23 | + field = !pi * x * DUSTEM_BLACKBODY( x, [ 3.d3, 4.d3, 7.5d3 ], wdil=wdil, unit=unit ) | |
24 | + | |
25 | +; | |
26 | +; UV part | |
27 | +; | |
28 | + | |
29 | +; first convert to (lambda / 1e3 AA) | |
30 | + CASE unit of | |
31 | + | |
32 | + 'W': x3 = 1.d1 * x | |
33 | + | |
34 | + 'F': x3 = 1.d5 / x | |
35 | + | |
36 | + 'E': x3 = 12.4 / x | |
37 | + | |
38 | + ENDCASE | |
39 | + | |
40 | + il = where( x3 LE 2.46, cl ) | |
41 | + if cl GT 0 then field(il) = 0.D0 | |
42 | + | |
43 | + il = where( x3 GE 1d1*ly_limit AND x3 LT 1.11, cl ) | |
44 | + if cl GT 0 then field(il) = 1.4817d-6 * x3(il)^(4.4172) | |
45 | + il = where( x3 GE 1.11 AND x3 LT 1.34, cl ) | |
46 | + if cl GT 0 then field(il) = 2.0456d-6 * x3(il) | |
47 | + il = where( x3 GE 1.34 AND x3 LT 2.46, cl ) | |
48 | + if cl GT 0 then field(il) = 3.3105d-6 * x3(il)^(-0.6678) | |
49 | + | |
50 | + | |
51 | + RETURN, field | |
52 | +END ;FUNCTION DUSTEM_MATHIS_FIELD | ... | ... |
... | ... | @@ -0,0 +1,22 @@ |
1 | +FUNCTION DUSTEM_PLAW_VDIST, x, par | |
2 | +; generates a volume normalized power law x^par(0) | |
3 | +; returns distribution in nr of grains : dn/da | |
4 | +; x : grain size | |
5 | +; par(0) : power law index | |
6 | +; par(1) : VOLUME normalization | |
7 | +; par(2) : curvature parameter beta | |
8 | +; par(3) : large size threshold At | |
9 | + | |
10 | + np = n_elements(x) | |
11 | + y = x^par(0) | |
12 | +; curvature term | |
13 | + if ((par(2) NE 0) AND (par(3) NE 0)) then begin | |
14 | + psgn = par(2)/ABS(par(2)) | |
15 | + y = y * ( 1.d0 + ABS(par(2))*x/par(3) )^psgn | |
16 | + endif | |
17 | + vy = x^4 * y | |
18 | + dx = ALOG(x(1:np-1)) - ALOG(x(0:np-2)) | |
19 | + yi = TOTAL( (vy(1:np-1) + vy(0:np-2))*0.5*dx ) | |
20 | + y = par(1) * y / yi | |
21 | +RETURN, y | |
22 | +END | ... | ... |
src/idl_extern/ICE_for_Dustemwrap/modifications_for_pilot.txt renamed to src/idl_extern/ICE_for_Dustemwrap/modifications_log.txt
src/idl/dustem_fit_polextsed_readme.pro renamed to src/idl_retired/dustem_fit_polextsed_readme.pro
src/idl/dustem_fit_redshift_readme.pro renamed to src/idl_retired/dustem_fit_redshift_readme.pro
src/idl/dustem_fit_sed_extsed_readme.pro renamed to src/idl_retired/dustem_fit_sed_extsed_readme.pro
src/idl/dustem_fit_sed_polsed_readme.pro renamed to src/idl_retired/dustem_fit_sed_polsed_readme.pro
src/idl/dustem_fit_sed_qsed_used_readme.pro renamed to src/idl_retired/dustem_fit_sed_qsed_used_readme.pro
src/idl/dustem_fit_sed_readme.pro renamed to src/idl_retired/dustem_fit_sed_readme.pro
src/idl/dustem_fit_sed_spinning_readme.pro renamed to src/idl_retired/dustem_fit_sed_spinning_readme.pro
src/idl/dustem_fit_spin_test_readme.pro renamed to src/idl_retired/dustem_fit_spin_test_readme.pro
src/idl/dustem_run_readme.pro renamed to src/idl_retired/dustem_run_readme.pro
src/idl/dustem_variational_study_readme.pro renamed to src/idl_retired/dustem_variational_study_readme.pro