Commit 177bd97a16e58177822337580f25f7ec83db20be
1 parent
11e52e98
Exists in
master
NOT NEEDED
Showing
1 changed file
with
0 additions
and
150 deletions
Show diff stats
src/idl/dustem_fit_sed deleted
... | ... | @@ -1,150 +0,0 @@ |
1 | -PRO dustem_fit_sed&polsed&polext_NY | |
2 | - | |
3 | - | |
4 | -;Thanks for this! You're the first user that can give me actual feedback. | |
5 | -;I realized that there is plenty of work that still needs to be done. | |
6 | -;The wrapper is a war zone at the moment but we're getting there. | |
7 | - | |
8 | - | |
9 | -dustem_define_la_common ;Enables the wrapper to use a value called la_undef() | |
10 | -;which is how the wrapper recognizes undefined values. | |
11 | -;This value equals -32768 and should be present in your xcat files for all the values that you wish to omit from the fit. | |
12 | -;Setting unused/unwanted values/errors to zero is highly unrecommended (unless your case makes it reasonable to assume a null flux value. ie StokesQ = 0. for some band) | |
13 | -;I'm still working w/ JP on this so you shouldn't really worry about this. | |
14 | - | |
15 | - | |
16 | -;☆☆☆DUSTEM INITIALIZATION☆☆☆ | |
17 | -model='THEMIS' | |
18 | -dustem_init,mode=model,/pol | |
19 | - | |
20 | -!dustem_verbose=1 | |
21 | -!dustem_show_plot=1 | |
22 | - | |
23 | -;☆☆☆READING THE DATA☆☆☆ | |
24 | -dir_seds = '/Users/ilyeschoubani/Downloads/test_wrap_NY/' | |
25 | - | |
26 | -;###README### | |
27 | -;If the format of the SED is the new one (the current one), one just needs to read the xcat file. | |
28 | -;Otherwise, a procedure called dustem_old2new_sed_format.pro does the trick. That is what I used for your SED xcat file. | |
29 | -;This new format has been adjusted so that the data pertaining to the polarized emission is included in the SED (primary/main) structure. | |
30 | -;In other words, the polarization SED should also be there, which isn't our case since the polarization SED is in a seperate xcat file. | |
31 | -;Because of that, we will be reading the SED (which has the new format now) and fill the polarization-related tags (ie: P,p,their associated variances etc...) by reading their xcat files first (in our case we just have polsed). | |
32 | - | |
33 | -;☆☆☆Reading the SED xcat that has the new format☆☆☆ | |
34 | -str_sed = dir_seds+'SED_HD21.xcat' ;It has the same name because the old one has 'old' attached to its string now (after running the aforementioned procedure). | |
35 | -sed = read_xcat(str_sed,/silent) | |
36 | - | |
37 | -;☆☆☆Reading the POLSED xcat and including its data in the (primary/main) sed structure☆☆☆ | |
38 | - | |
39 | -;☆☆☆reading polsed xcat file☆☆☆ | |
40 | -str_polsed = dir_seds+'POLSED_HD21.xcat' | |
41 | -polsed = read_xcat(str_polsed,/silent) | |
42 | - | |
43 | -;☆☆☆now adding its content to the SED main structure☆☆☆ | |
44 | -match, sed.wave, polsed.wave, subsed, subpolsed | |
45 | -sed(subsed).LARGEP = polsed(subpolsed).spec | |
46 | -sed(subsed).sigma_LARGEP = polsed(subpolsed).error^2 ;The squared error value here is because the wrapper uses variances now. When preparing to fit,the wrapper computes the square root of this value so don't be alarmed as the error remains the same. | |
47 | - | |
48 | -;###README: | |
49 | -;The wrapper follows the same formalism when it comes to the handling of the extinction data. | |
50 | -;Meaning there is also a (primary/main) structure for extinction that also contains data pertaining to polarization (cross-section in the case of polext). | |
51 | -;Since we do not have extinction data (only Serkowski), we should read the Serkowski xcat file, and use its content to create a fake extinction (primary/main) procedure. | |
52 | -;The creation of this fake extinction procedure is necessary for dustem to be aware of the polext data. | |
53 | -;However I never implemented this before. By 'this' I mean the way the wrapper fits polext without the presence of ext. | |
54 | -;This means that your work has enabled us to think about a very important issue. | |
55 | - | |
56 | - | |
57 | -;☆☆☆The first thing we do is read the Serkowski xcat file that has the new format☆☆☆ | |
58 | -;###README: | |
59 | -;I used a procedure called dustem_old2new_sed_format.pro that does the job. | |
60 | -;This means that I have created the (primary/main) extinction structure with the Serkowski xcat file. | |
61 | -;The lines below are witness to the necessary changes that need to be made so that said structure includes the polext data. | |
62 | - | |
63 | -;☆☆☆Reading the POLEXT xcat file☆☆☆ | |
64 | -str_polext = dir_seds+'Serkowski_HD21.xcat' | |
65 | -ext = read_xcat(str_polext,/silent) | |
66 | - | |
67 | - | |
68 | -;☆☆☆Modifying the extinction structure and placing the polext data inside it☆☆☆ | |
69 | -ext.instru = 'EXTINCTION' | |
70 | -ext.EXT_P = ext.EXT_I | |
71 | -ext.SIGEXTP = ext.SIGEXTII | |
72 | -ext.EXT_I = la_undef(4) | |
73 | -ext.SIGEXTII = la_undef(4) | |
74 | - | |
75 | -;=== Set which parameters you want to fit | |
76 | -pd = [ $ | |
77 | - '(*!dustem_params).gas.G0', $ ;G0 | |
78 | - '(*!dustem_params).grains(0).mdust_o_mh', $ | |
79 | - '(*!dustem_params).grains(1).mdust_o_mh', $ | |
80 | - '(*!dustem_params).grains(2).mdust_o_mh' $ | |
81 | - ] | |
82 | - | |
83 | - | |
84 | -iv = [0.17E-02,0.63E-03,0.51E-02] | |
85 | - | |
86 | -Npar=n_elements(pd) | |
87 | - | |
88 | -ulimed=replicate(0,Npar) | |
89 | - | |
90 | -llimed=replicate(1,Npar) | |
91 | -llims=replicate(0,Npar) | |
92 | - | |
93 | -dustem_init_parinfo,pd,iv,up_limited=ulimed,lo_limited=llimed,up_limits=ulims,lo_limits=llims | |
94 | - | |
95 | -dustem_init_plugins,pd | |
96 | - | |
97 | -st=dustem_set_data(sed=sed,ext=ext,rchi2_weight=rchi2_weight,f_HI=f_HI) | |
98 | - | |
99 | - | |
100 | -;=== RUN fit | |
101 | -tol=1.e-6 | |
102 | -xtol=1.e-6 | |
103 | -Nitermax=30; just an initialization | |
104 | - | |
105 | -xr=[1.,5e5] | |
106 | -yr=[1e-2,1.00e8] | |
107 | - | |
108 | -loadct,13 | |
109 | - | |
110 | -title=textoidl('TEST_SED') | |
111 | -ytit=textoidl('I_\nu (MJy/sr) for N_H=10^{20} H/cm^2') | |
112 | -t1=systime(0,/sec) | |
113 | -res=dustem_mpfit_data(tol=tol,xtol=xtol,Nitermax=Nitermax,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,xtit=xtit,ytit=ytit,title=title) | |
114 | -t2=systime(0,/sec) | |
115 | - | |
116 | - | |
117 | -;=== SAVE FIT RESULTS | |
118 | -file_out='/tmp/DUSTEM_polsed_fit_example.sav' | |
119 | -dustem_save_system_variables,file_out | |
120 | -message,'Saved '+file_out,/continue | |
121 | - | |
122 | -;====================================== | |
123 | -;====You can exit IDL here and re-enter - THIS PART APPEARS TO BE FAULTY. NEEDS INVESTIGATION | |
124 | -;====================================== | |
125 | -file='/tmp/DUSTEM_polsed_fit_example.sav' | |
126 | -dustem_restore_system_variables,file | |
127 | - | |
128 | -;=== Plot best fit | |
129 | -win=1 | |
130 | -window,win & win=win+1 | |
131 | - | |
132 | -;=== recover best fit values | |
133 | -res=*(*!dustem_fit).current_param_values | |
134 | -chi2=(*!dustem_fit).chi2 | |
135 | -rchi2=(*!dustem_fit).rchi2 | |
136 | -;errors=*(*!dustem_fit).current_param_errors | |
137 | -;errors=(*(*!dustem_fit).current_param_errors)*(*(*!dustem_fit).param_init_values) | |
138 | - | |
139 | -;=== Plot best fit | |
140 | - | |
141 | -loadct,13 | |
142 | - | |
143 | -dustem_sed_plot,*(*!dustem_fit).current_param_values,ytit=ytit,xtit=xtit,title=title,yr=yr,xr=xr,/ysty,/xsty,res=res,chi2=chi2,rchi2=rchi2,/xlog,/ylog,/pol,ps=ps,png=png | |
144 | - | |
145 | -print,'dustem_mpfit_sed executed in ',t2-t1,' sec' | |
146 | - | |
147 | -the_end: | |
148 | - | |
149 | -END | |
150 | - |