Commit 88872c38930efcdb96ad7c88462788f9f6cc14f4
1 parent
c19cb3d1
Exists in
master
small update. Changing arguments into keywords for dustem_set_data and the subse…
…quent effects on the example procedures
Showing
13 changed files
with
259 additions
and
235 deletions
Show diff stats
src/idl/dustem_activate_plugins.pro
... | ... | @@ -76,17 +76,19 @@ endelse |
76 | 76 | ;IF /avoid is used the specified scopes are avoided. They're considered when /avoid is missing. |
77 | 77 | ;using '**' so not to write the entire scope |
78 | 78 | dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['*STELLAR*','*REPLACE*','*ISRF*'], avoid=1 |
79 | -;stop | |
79 | + | |
80 | 80 | ;=== The line below makes fawlty go Segmentation fault. st is undefined at that stage |
81 | 81 | ;=== it would run fine if avoid was set to 1 |
82 | +;IC: I think the segmentation fault comes from the fact that the user wants to use models that have the /pol keyword in the GRAIN.DAT file without being in polarization mode. | |
82 | 83 | dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['*STELLAR*','*ISRF*'] ,dustem_run=1,st=st ;dustem output is available at this step. |
83 | 84 | |
84 | 85 | ;added this small condition to ensure that dustem is run |
85 | 86 | ;(if no ISRF plugin is used) |
86 | -if ~isa(st) then begin | |
87 | - st=dustem_run(p_dim) | |
88 | - !dustem_current=ptr_new(st) | |
89 | -endif | |
87 | +; if ~isa(st) then begin | |
88 | +; st=dustem_run(p_dim) | |
89 | +; !dustem_current=ptr_new(st) | |
90 | +; endif | |
91 | +;THE ABOVE CONDITION IS UNNECESSARY SINCE DUSTEM IS CALLED ABOVE WHETHER PLUGINS ARE RUN OR NOT. | |
90 | 92 | |
91 | 93 | dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['*REPLACE*'] |
92 | 94 | ... | ... |
src/idl/dustem_check_data.pro
1 | -PRO dustem_check_data,data_sed,data_ext,sed,ext,polext,polsed,polfrac,psi_em,qsed,used,qext,uext,psi_ext,fpolext | |
1 | +PRO dustem_check_data, data_sed, $ | |
2 | + data_ext, $ | |
3 | + sed=sed, $ | |
4 | + ext=ext, $ | |
5 | + polext=polext, $ | |
6 | + polsed=polsed, $ | |
7 | + polfrac=polfrac, $ | |
8 | + psi_em=psi_em, $ | |
9 | + qsed=qsed, $ | |
10 | + used=used, $ | |
11 | + qext=qext, $ | |
12 | + uext=uext, $ | |
13 | + psi_ext=psi_ext, $ | |
14 | + fpolext=fpolext | |
2 | 15 | |
3 | 16 | ;+ |
4 | 17 | ; NAME: |
5 | 18 | ; dustem_check_data |
6 | 19 | ; |
7 | 20 | ; PURPOSE: |
8 | -; Verify that the input data conforms to what DustEMWrap requires | |
21 | +; Clean and modify the input DustEMWrap structure to meet the requirements of DustEMWrap. | |
22 | +; This is important for the subsequent internal handling/fitting of data. | |
9 | 23 | ; |
10 | 24 | ; CATEGORY: |
11 | 25 | ; DustEMWrap, Mid-Level, Distributed, Initialization |
12 | 26 | ; |
13 | 27 | ; CALLING SEQUENCE: |
14 | -; dustem_check_data,data_sed,data_ext,sed,ext,polext,polsed,polfrac,psi_em,qsed,used,qext,uext,psi_ext,fpolext,[/help] | |
28 | +; dustem_check_data,data_sed,data_ext,sed=sed,ext=ext,polext=polext,polsed=polsed,polfrac=polfrac,psi_em=psi_em,qsed=qsed,used=used,qext=qext,uext=uext,psi_ext=psi_ext,fpolext=fpolext,[/help] | |
15 | 29 | ; |
16 | 30 | ; INPUTS: |
17 | -; data_sed : Emission dustemwrap structure | |
18 | -; data_ext : Extinction dustemwrap structure | |
31 | +; data_sed : Emission DustEMWrap structure | |
32 | +; data_ext : Extinction DustEMWrap structure | |
19 | 33 | ; |
20 | 34 | ; OPTIONAL INPUT PARAMETERS: |
21 | 35 | ; None |
22 | 36 | ; |
23 | -; OUTPUTS: | |
24 | -; ## adapting the data structures to the format used by the fitting algorithm | |
25 | -; sed : emission formatted structure | |
26 | -; ext : extinction formatted structure | |
27 | -; polext : polarized extinction formatted structure | |
28 | -; polsed : polarized emission formatted structure | |
29 | -; polfrac : fractional polarized emission formatted structure | |
30 | -; psi_em : emission polarization angle formatted structure | |
31 | -; qsed : stokesQ emission formatted structure | |
32 | -; used : stokesU emission formatted structure | |
33 | -; qext : stokesQ extinction formatted structure | |
34 | -; uext : stokesU extinction formatted structure | |
35 | -; psi_ext : extinction polarization angle formatted structure | |
36 | -; fpolext : fractional extinction polarization formatted structure | |
37 | +; OUTPUTS: | |
38 | +; sed : modified emission structure | |
39 | +; ext : modified extinction structure | |
40 | +; polext : modified polarized extinction structure | |
41 | +; polsed : modified polarized emission structure | |
42 | +; polfrac : modified fractional polarized emission structure | |
43 | +; psi_em : modified emission polarization angle structure | |
44 | +; qsed : modified StokesQ emission structure | |
45 | +; used : modified StokesU emission structure | |
46 | +; qext : modified StokesQ extinction structure | |
47 | +; uext : modified StokesU extinction structure | |
48 | +; psi_ext : modified extinction polarization angle structure | |
49 | +; fpolext : modified fractional extinction polarization structure | |
37 | 50 | ; |
38 | 51 | ; OPTIONAL OUTPUT PARAMETERS: |
39 | 52 | ; None |
... | ... | @@ -53,12 +66,15 @@ PRO dustem_check_data,data_sed,data_ext,sed,ext,polext,polsed,polfrac,psi_em,qse |
53 | 66 | ; None |
54 | 67 | ; |
55 | 68 | ; EXAMPLES |
56 | -; dustem_check_data,data_sed,data_ext,sed,ext,polext,polsed,polfrac,psi_em,qsed,used,qext,uext,psi_ext,fpolext,[/help] | |
57 | -; | |
69 | +; dustem_check_data,data_sed,data_ext,sed=sed,ext=ext,polext=polext,polsed=polsed,polfrac=polfrac,psi_em=psi_em,qsed=qsed,used=used,qext=qext,uext=uext,psi_ext=psi_ext,fpolext=fpolext,[/help] | |
70 | +; dustem_check_data,/help | |
58 | 71 | ; MODIFICATION HISTORY: |
59 | -; Written I Choubani 2022 | |
72 | +; Written IC 2022 | |
60 | 73 | ; Evolution details on the DustEMWrap gitlab. |
61 | 74 | ; See http://dustemwrap.irap.omp.eu/ for FAQ and help. |
75 | +; COMMENTS: | |
76 | +; Might still need a bit of cleaning. I am unsure of the availability of covariance data in polarized extinction. | |
77 | +; Still regarding extinction, some of the error messages haven't been mirrored correctly with respect to the emission block. | |
62 | 78 | ;- |
63 | 79 | |
64 | 80 | |
... | ... | @@ -202,8 +218,7 @@ IF KEYWORD_SET(data_sed) THEN BEGIN |
202 | 218 | |
203 | 219 | ;Generation of POLFRAC,POLSED and PSI data by default |
204 | 220 | ;Testing on the presence of covariances otherwise an error is returned |
205 | - ;The testing happens here because covariances are needed for the error estimation of P,p and PSI. | |
206 | - | |
221 | + ;The testing happens here because covariances are needed for the error estimation of P,p and PSI. (Also cannot test before because we're not in !run_pol mode) | |
207 | 222 | tstcovu = where((data_sed(testu).sigmaIU) EQ la_undef() or (data_sed(testu).sigmaQU) EQ la_undef(), ctcovu) |
208 | 223 | if ctcovu NE 0 then BEGIN |
209 | 224 | ;message, 'Covariance data is missing in StokesU data. Data, errors and covariances do not match. Aborting...',/continue |
... | ... | @@ -253,11 +268,9 @@ IF KEYWORD_SET(data_sed) THEN BEGIN |
253 | 268 | ENDIF |
254 | 269 | |
255 | 270 | |
256 | -;EXTINCTION HASN'T BEEN TREATED YET | |
257 | - | |
258 | - | |
259 | -;SMALLL ISSUE .. POLEXTFRAC is not present. Let's create it for completness | |
260 | - | |
271 | +;EXTINCTION | |
272 | +; | |
273 | +;Covariances?... | |
261 | 274 | IF KEYWORD_SET(data_ext) THEN begin |
262 | 275 | |
263 | 276 | ans='' | ... | ... |
src/idl/dustem_fit_ext_example.pro
... | ... | @@ -170,7 +170,7 @@ ext=read_xcat(file,/silent) |
170 | 170 | |
171 | 171 | ;=== HERE WE SET THE DATA SO THAT THE COMPUTE_ FUNCTIONS BELOW HAVE |
172 | 172 | ;=== THE NECESSARY FIELDS AND INFORMATION |
173 | -dustem_set_data,sed,sed,ext,ext | |
173 | +dustem_set_data,m_fit=m_fit,m_show=m_show,x_fit=ext,x_show=ext | |
174 | 174 | |
175 | 175 | ;== SET INITIAL VALUES AND LIMITS OF THE PARAMETERS FOR THE FIT |
176 | 176 | ;== AND ACTIVATE ANY PLUGINS |
... | ... | @@ -217,9 +217,9 @@ IF keyword_set(fits_save_and_restore) THEN BEGIN |
217 | 217 | ;==== plot result taken from the saved fits table |
218 | 218 | res=*(*!dustem_fit).CURRENT_PARAM_VALUES |
219 | 219 | IF !dustem_noobj THEN BEGIN |
220 | - dustemwrap_plot_noobj,res,dustem_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' | |
220 | + dustemwrap_plot_noobj,res,st=dustem_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' | |
221 | 221 | ENDIF ELSE BEGIN |
222 | - dustemwrap_plot,res,dustem_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' | |
222 | + dustemwrap_plot,res,st=dustem_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' | |
223 | 223 | ENDELSE |
224 | 224 | IF keyword_set(wait) THEN BEGIN |
225 | 225 | message,'Saved the results as FITS in the file: '+fits_save_and_restore+', and made a plot using the data in this file',/info | ... | ... |
src/idl/dustem_fit_ext_pol_example.pro
... | ... | @@ -113,7 +113,7 @@ use_polarization=0. ;default is no polarization in models |
113 | 113 | use_window=2 ; default graphics window number to use for plotting the results |
114 | 114 | use_verbose=0 |
115 | 115 | if keyword_set(verbose) then use_verbose=1 |
116 | -use_Nitermax=5 ; maximum number of iterations for the fit | |
116 | +use_Nitermax=1 ; maximum number of iterations for the fit | |
117 | 117 | IF keyword_set(Nitermax) THEN use_Nitermax=Nitermax |
118 | 118 | |
119 | 119 | dustem_define_la_common |
... | ... | @@ -191,7 +191,7 @@ ENDIF |
191 | 191 | ;=== THE NECESSARY FIELDS AND INFORMATION |
192 | 192 | ;== note that m_fit and m_show do not exist -- this is deliberate |
193 | 193 | ;== since we are not treating emission data |
194 | -dustem_set_data, m_fit,m_show,ext,ext | |
194 | +dustem_set_data, m_fit=m_fit,m_show=m_show,x_fit=ext,x_show=ext | |
195 | 195 | |
196 | 196 | ;== SET INITIAL VALUES AND LIMITS OF THE PARAMETERS FOR THE FIT |
197 | 197 | ;== AND ACTIVATE ANY PLUGINS (HENCE WE NEED TO DO THIS BEFORE THE COMPUTE_ CALLS) |
... | ... | @@ -206,7 +206,7 @@ dustem_init_params,use_model,pd,iv,fpd=fpd,fiv=fiv,ulimed=ulimed,llimed=llimed,u |
206 | 206 | if not keyword_set(ext_file) then begin |
207 | 207 | ;== GENERATE THE DATA USING THE MODEL AND TRUE VALUES |
208 | 208 | ext.EXT_I = dustem_compute_ext(true_vals,st=st) |
209 | - toto = dustem_compute_stokext(true_vals,st=st,qext_spec=dustem_qext,uext_spec=dustem_uext) | |
209 | + toto = dustem_compute_stokext(true_vals,st=st) | |
210 | 210 | ext.EXT_Q = toto[0] |
211 | 211 | ext.EXT_U = toto[1] |
212 | 212 | |
... | ... | @@ -229,7 +229,7 @@ tol=1.e-10 |
229 | 229 | ;=== INFORMATION TO MAKE THE PLOTS |
230 | 230 | ;=== _x/_extinction means extinction plots, _m/_emissions means emission plots |
231 | 231 | xr_x=[0.01,30] |
232 | -yr_fpolext=[1.00E-10,30] | |
232 | +yr_fpolext=[1.00E-10,50] | |
233 | 233 | |
234 | 234 | ;yr_fpolext=[1e-4,30] |
235 | 235 | tit='Dust Optical Depth' |
... | ... | @@ -247,7 +247,7 @@ if keyword_set(wait) then begin |
247 | 247 | message,'Time taken [sec]: '+sigfig(t2-t1,2,/sci),/info |
248 | 248 | wait,wait |
249 | 249 | end |
250 | - | |
250 | +stop | |
251 | 251 | IF keyword_set(fits_save_and_restore) THEN BEGIN |
252 | 252 | message,'Writing out results structure: '+fits_save_and_restore,/info |
253 | 253 | dustem_write_fits_table,filename=fits_save_and_restore,help=help |
... | ... | @@ -257,6 +257,7 @@ IF keyword_set(fits_save_and_restore) THEN BEGIN |
257 | 257 | dustem_read_fits_table,filename=fits_save_and_restore,dustem_st=dustem_st |
258 | 258 | ;==== plot result taken from the saved fits table |
259 | 259 | res=*(*!dustem_fit).CURRENT_PARAM_VALUES |
260 | + !dustem_end=-1; subsequent calls to the fit. 0 is intialization an 1 is for the last iteration. It's initialized to 0 after the creation of the fits file. | |
260 | 261 | IF !dustem_noobj THEN BEGIN |
261 | 262 | dustemwrap_plot_noobj,res,st=dustem_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' |
262 | 263 | ENDIF ELSE BEGIN | ... | ... |
src/idl/dustem_fit_intensity_example.pro
... | ... | @@ -296,7 +296,7 @@ IF count NE 0 THEN sed[ind].sigmaII=(0.2*sed[ind].StokesI)^2 |
296 | 296 | ;== SET THE OBSERVATIONAL STRUCTURE |
297 | 297 | ;== sed is passed twice in the call -- the first occurrence is the SED that you |
298 | 298 | ;== wish to fit, the second occurrence is the SED that you wish to visualise. |
299 | -dustem_set_data,sed,sed | |
299 | +dustem_set_data,m_fit=sed,m_show=sed | |
300 | 300 | |
301 | 301 | ;== SET INITIAL VALUES AND LIMITS OF THE PARAMETERS THAT WILL BE |
302 | 302 | ;== ADJUSTED DURING THE FIT | ... | ... |
src/idl/dustem_fit_intensity_mbb_example.pro
... | ... | @@ -194,7 +194,7 @@ IF count NE 0 THEN sed[ind].sigmaII=(0.2*sed[ind].StokesI)^2 |
194 | 194 | ;== SET THE OBSERVATIONAL STRUCTURE |
195 | 195 | ;== sed is passed twice -- the first occurrence is the SED that you |
196 | 196 | ;== wish to fit, the second occurrence is the SED that you wish to visualise. |
197 | -dustem_set_data,sed,sed | |
197 | +dustem_set_data,m_fit=sed,m_show=sed | |
198 | 198 | |
199 | 199 | ;== SET INITIAL VALUES AND LIMITS OF THE PARAMETERS THAT WILL BE |
200 | 200 | dustem_init_params,use_model,pd,iv,fpd=fpd,fiv=fiv $ | ... | ... |
src/idl/dustem_fit_polarization_example.pro
... | ... | @@ -164,7 +164,7 @@ sed=read_xcat(file,/silent) |
164 | 164 | ;== SET THE OBSERVATIONAL STRUCTURE |
165 | 165 | ;== sed is passed twice -- the first occurrence is the SED that you |
166 | 166 | ;== wish to fit, the second occurrence is the SED that you wish to visualise. |
167 | -dustem_set_data,sed,sed | |
167 | +dustem_set_data,m_fit=sed,m_show=sed | |
168 | 168 | |
169 | 169 | |
170 | 170 | ... | ... |
src/idl/dustem_fit_sed_ext_pol_example.pro
... | ... | @@ -217,7 +217,7 @@ ENDIF |
217 | 217 | |
218 | 218 | ;=== HERE WE SET THE DATA SO THAT THE COMPUTE_ FUNCTIONS BELOW HAVE |
219 | 219 | ;=== THE NECESSARY FIELDS AND INFORMATION |
220 | -dustem_set_data,sed,sed,ext,ext | |
220 | +dustem_set_data,m_fit=sed,m_show=sed,x_fit=ext,x_show=ext | |
221 | 221 | |
222 | 222 | ;== SET INITIAL VALUES AND LIMITS OF THE PARAMETERS FOR THE FIT |
223 | 223 | ;== AND ACTIVATE ANY PLUGINS (HENCE WE NEED TO DO THIS BEFORE THE COMPUTE_ CALLS) | ... | ... |
src/idl/dustem_mask_data.pro
1 | - FUNCTION dustem_mask_data,data_struct,omit=omit,data_set=data_set,help=help | |
1 | +FUNCTION dustem_mask_data, data_struct, $ | |
2 | + filters, $ | |
3 | + data_set=data_set, $ | |
4 | + default=default, $ | |
5 | + help=help | |
6 | + | |
2 | 7 | ;+ |
3 | 8 | ; NAME: |
4 | 9 | ; dustem_mask_data |
5 | 10 | ; PURPOSE: |
6 | -; Removing filters from a data structure. | |
11 | +; Set dataset values to la_undef() for specified filter/spectrum data in an input DustEmWrap data structure. | |
7 | 12 | ; CATEGORY: |
8 | 13 | ; DUSTEM Wrapper |
9 | 14 | ; CALLING SEQUENCE: |
10 | -; data_struct=dustem_mask_data(data_struct,omit=,data_set=) | |
15 | +; data_struct=dustem_mask_data(data_struct,filters,data_set=,/default) | |
11 | 16 | ; INPUTS: |
12 | -; data_struct : SED Data structure formatted as outlined in the DustermWrap Users' Guide | |
13 | -; data_set : Array of character strings containing the different data sets to be filtered. | |
14 | -; ie: ['SED'],['QSED'],'USED'] or just ['QSED'] for example. The use of ['STOKESI','STOKESQ','STOKESU'] instead is equivalent. | |
15 | -; omit : Can be an array or list. In both cases it should contain the filter names as character strings. | |
16 | -; ie: omit=['SPIRE1','SPIRE2'] for an array or omit=list(['SPIRE2','SPIRE1','PACS2'],['HFI5','HFI4']) for a list. | |
17 | -; When using a list, its shape (dimension) should be the number of elements of the data_set array. | |
18 | -; ie: Each dimension is an array of filters to be removed from the corresponding data set in the data_set array. | |
17 | +; data_struct : SED Data structure following the format explained in the DustermWrap Users' Guide | |
18 | +; | |
19 | +; filters : Can be an array or list. In both cases it should contain the filter names as character strings. | |
20 | +; ie: filters=['SPIRE1','SPIRE2'] for an array or filters=list(['SPIRE2','SPIRE1','PACS2'],['HFI5','HFI4']) for a list. | |
21 | +; When using a list, its shape (dimension) and the number of elements of the data_set array should be equal. | |
22 | +; Each dimension is an array of filters to be removed from the corresponding data set in the data_set array. | |
23 | +; ie: filters=list(['SPIRE2','SPIRE1','PACS2'],['LFI2','LFI3']) for datas_set=['STOKESI','STOKESQ'] | |
19 | 24 | ; OPTIONAL INPUT PARAMETERS: |
20 | -; None | |
25 | +; data_set : Array of character strings containing the different data sets to be filtered. | |
26 | +; ie: ['STOKESI','STOKESQ','STOKESU'] or just ['STOKESQ'] for example. | |
21 | 27 | ; OUTPUTS: |
22 | 28 | ; data_struct |
23 | 29 | ; OPTIONAL OUTPUT PARAMETERS: |
24 | 30 | ; None |
25 | 31 | ; ACCEPTED KEY-WORDS: |
26 | -; help = if set, prints this help | |
32 | +; help = if set, print this help | |
33 | +; | |
34 | +; default = if set, remove targeted filter/spectrum point(s) from datasets that depend on the filtered dataset(s). | |
35 | +; EAMPLE | |
36 | +; masked_structure = dustem_mask_data(data_struct,['IRAS1','IRAS2'],data_set=['STOKESI']) | |
27 | 37 | ; COMMENTS |
28 | -; Both list and array entries for omit and hide keywords are allowed. | |
38 | +; IC: | |
39 | +; If a wavelength value is supplied instead of a filter name, the procedure masks for a spectrum point with that corresponding wavelength | |
40 | +; If the dataset array isn't supplied, all the datasets in the input data structure will be considered. | |
41 | +; If both filters and dataset are arrays, all mentioned filters will be masked from all mentioned datasets. | |
42 | +; This procedure does not change the shape of the output structure partly because dustem_check_data.pro does. | |
29 | 43 | ; MODIFICATION HISTORY: |
30 | -; Written by IC | |
44 | +; Written by IC 2022 | |
31 | 45 | ;- |
32 | 46 | |
33 | 47 | |
34 | 48 | IF keyword_set(help) THEN BEGIN |
35 | - doc_library,'dustem_filter_data' | |
49 | + doc_library,'dustem_mask_data' | |
36 | 50 | goto,the_end |
37 | 51 | ENDIF |
38 | 52 | |
39 | -IF keyword_set(data_struct) and keyword_set(omit) THEN BEGIN | |
40 | - | |
41 | - ;Array of filters present in dustem | |
42 | - filters_dustem=[((*!dustem_filters).(0).filter_names)] | |
53 | +IF arg_present(data_struct) and arg_present(filters) THEN BEGIN | |
43 | 54 | |
55 | + ;Array of filters present in dustem | |
56 | + filters_dustem=[((*!dustem_filters).(0).filter_names)] | |
44 | 57 | for i=1L,n_elements(tag_names(*!dustem_filters))-1 do begin |
45 | 58 | filters_dustem=[filters_dustem,((*!dustem_filters).(i).filter_names)] |
46 | 59 | endfor |
47 | - | |
48 | 60 | ;Array of filters present in data_struct |
49 | 61 | filters_data = data_struct.filter |
50 | - | |
51 | 62 | ;Tag names present in data_struct (to be able to test on the different data sets) |
52 | - tagnames = tag_names(data_struct) | |
53 | - | |
54 | - | |
55 | - if typename(omit) EQ 'LIST' then ind0 = omit[*] else ind0=intarr(n_elements(omit)) ; this is a better condition because it is also valid for when the user wants to omit 'spectrum' (non-filter) data points. | |
63 | + tagnames = tag_names(data_struct) | |
64 | + if typename(filters) EQ 'LIST' then ind0 = filters[*] else ind0=intarr(n_elements(filters)) | |
56 | 65 | ;because types can be float or double but not long. |
57 | - | |
58 | - for i=0L,n_elements(omit)-1 do begin | |
59 | - dim_i = n_elements(omit(i)) ;getting the dimension of each element of the list/array | |
66 | + for i=0L,n_elements(filters)-1 do begin | |
67 | + dim_i = n_elements(filters(i)) ;getting the dimension of each element of the list/array | |
60 | 68 | ind0[i] = intarr(dim_i) + la_undef() ;initializing to la_undef() |
61 | - endfor | |
62 | - | |
69 | + endfor | |
63 | 70 | ;Gathering the indices of the filters to remove. |
64 | - | |
65 | - for i=0L,n_elements(omit)-1 do begin | |
66 | - | |
67 | - dim_i=n_elements(omit(i)) ;Getting the dimension of each element of the list | |
68 | - | |
69 | - arr_i=intarr(dim_i) + la_undef() ;initializing to la_undef() | |
70 | - | |
71 | + for i=0L,n_elements(filters)-1 do begin | |
72 | + dim_i=n_elements(filters(i)) ;Getting the dimension of each element of the list | |
73 | + arr_i=intarr(dim_i) + la_undef() ;initializing to la_undef() | |
71 | 74 | for j=0L,dim_i-1 do begin |
72 | - | |
73 | 75 | ;testing whether the element corresponds to a specific wavelength. |
74 | - ;accepts both numbers/strings | |
75 | - | |
76 | - if valid_num((omit[i])[j]) then begin | |
77 | - | |
78 | - ind=where(float((omit[i])[j]) EQ data_struct.wave,test0) | |
79 | - if test0 ne 0 then arr_i[j] = ind else message, 'WAVELENGTH '+strtrim((omit[i])[j],2)+' does not correspond to any spectrum point in the supplied data strucure.' | |
80 | - endif else begin | |
81 | - | |
82 | - ind = where((omit[i])[j] EQ filters_dustem,test1) ;Test if the filter is in the wrapper's database | |
83 | - if test1 eq 0 then message, 'Filter '+strtrim((omit[i])[j],2)+' cannot be found in the DustemWrap database.' | |
84 | - | |
85 | - ind = where((omit[i])[j] EQ filters_data,test2) ;Test if the filter in in the data itself | |
86 | - if test2 ne 0 then arr_i[j] = ind else message, 'Filter '+strtrim((omit[i])[j],2)+' cannot be found in the data supplied.' | |
87 | - | |
76 | + ;accepts both numbers/strings | |
77 | + if valid_num((filters[i])[j]) then begin | |
78 | + ind=where(float((filters[i])[j]) EQ data_struct.wave,test0) | |
79 | + if test0 ne 0 and data_struct[ind].filter EQ 'SPECTRUM' then arr_i[j] = ind else message, 'WAVELENGTH '+strtrim((filters[i])[j],2)+' does not correspond to any spectrum point in the supplied data strucure.' | |
80 | + endif else begin | |
81 | + ind = where((filters[i])[j] EQ filters_dustem,test1) | |
82 | + if test1 eq 0 then message, "Filter "+strtrim((filters[i])[j],2)+" isn't in the DustEMWrap Filters' list" | |
83 | + ind = where((filters[i])[j] EQ filters_data,test2) ;Test if the filter in in the data itself | |
84 | + if test2 ne 0 then arr_i[j] = ind else message, 'Filter '+strtrim((filters[i])[j],2)+' cannot be found in the supplied data structure.' | |
88 | 85 | endelse |
89 | - | |
90 | - endfor | |
91 | - | |
86 | + endfor | |
92 | 87 | ind0[i] = arr_i ;Indices of the filters to be removed in the data structure |
93 | - | |
94 | 88 | endfor |
95 | 89 | |
90 | + If typename(ind0) EQ 'LIST' then indices = ind0[i] ELSE indices = ind0 | |
91 | + | |
92 | + ;If default isn't set, errors in dustem_check_data.pro can occur because of differences in tag values. A common behavior of dustem_check_data.pro | |
93 | + ;example: filter removed for StokesI but not for SIGMAII | |
94 | + IF keyword_set(default) THEN BEGIN | |
96 | 95 | |
97 | - eq_tags = ['STOKESI','EXT_I','STOKESQ','STOKESU','LARGEP','SMALLP','PSI','EXT_Q','EXT_U','EXT_P','EXT_smallp','PSI'] | |
98 | - | |
99 | - errvec = ['SIGMAII','SIGEXTI','SIGMAQQ','SIGMAUU','SIGMA_LARGEP','SIGMA_SMALLP','SIGMA_PSI','SIGEXTQ','SIGEXTU','SIGEXTP','SIGEXTsmallp', 'SIGEXT_PSI'] | |
100 | - | |
96 | + ;Part pertainig to the /default keyword | |
97 | + ;bunch of tests to locate datasets depending on STOKESI, STOKESQ, STOKESU, LARGEP, SMALLP and PSI | |
98 | + ;is it an emission or extinction structure? | |
99 | + ind_m = where(tagnames EQ 'STOKESI', ctm) | |
100 | + ind_x = where(tagnames EQ 'EXT_I', ctx) | |
101 | + IF ctm NE 0 THEN BEGIN ;no counters are used in the following because it's a consequence of the test being valid. | |
102 | + ;Getting the indices this way because it allows for an easy modification if/when tagnames in the xcat emission/extinction file change | |
103 | + ind_set_StokesI = fix([where(strmatch(tagnames,'STOKESI')), $ | |
104 | + where(strmatch(tagnames,'SIGMAII'))]) | |
105 | + ind_set_StokesQ = fix([where(strmatch(tagnames,'STOKESQ')), $ | |
106 | + where(strmatch(tagnames,'SIGMAQQ')), $ | |
107 | + where(strmatch(tagnames,'SIGMAIQ')) ]) | |
108 | + ind_set_StokesU = fix([where(strmatch(tagnames,'STOKESU')), $ | |
109 | + where(strmatch(tagnames,'SIGMAUU')), $ | |
110 | + where(strmatch(tagnames,'SIGMAIU')) ]) | |
111 | + ind_set_LargeP = fix([where(strmatch(tagnames,'LARGEP')), $ | |
112 | + where(strmatch(tagnames,'SIGMA_LARGEP'))]) | |
113 | + ind_set_smallp = fix([where(strmatch(tagnames,'SMALLP')), $ | |
114 | + where(strmatch(tagnames,'SIGMA_SMALLP'))]) | |
115 | + ind_set_psi = fix([where(strmatch(tagnames,'PSI')), $ | |
116 | + where(strmatch(tagnames,'SIGMA_PSI'))]) | |
117 | + ENDIF | |
118 | + IF ctx NE 0 THEN BEGIN | |
119 | + ind_set_EXT_I = fix([where(strmatch(tagnames,'EXT_I')), $ | |
120 | + where(strmatch(tagnames,'SIGEXTII')) ]) | |
121 | + ind_set_EXT_Q = fix([where(strmatch(tagnames,'EXT_Q')), $ | |
122 | + where(strmatch(tagnames,'SIGEXTQQ')), $ | |
123 | + where(strmatch(tagnames,'SIGEXTIQ')) ]) | |
124 | + ind_set_EXT_U = fix([where(strmatch(tagnames,'EXT_U')), $ | |
125 | + where(strmatch(tagnames,'SIGEXTUU')), $ | |
126 | + where(strmatch(tagnames,'SIGEXTIU')) ]) | |
127 | + ind_set_EXT_P = fix([where(strmatch(tagnames,'EXT_P')), $ | |
128 | + where(strmatch(tagnames,'SIGEXTP'))]) | |
129 | + ind_set_EXT_smallp = fix([where(strmatch(tagnames,'EXT_SMALLP')), $ | |
130 | + where(strmatch(tagnames,'SIGEXTSMALLP'))]) | |
131 | + ind_set_psi = fix([where(strmatch(tagnames,'PSI')), $ | |
132 | + where(strmatch(tagnames,'SIGEXTPSI'))]) | |
133 | + ENDIF | |
134 | + ENDIF | |
135 | + | |
136 | + ;setting filters' data to la_undef() | |
101 | 137 | IF keyword_set(data_set) then begin |
102 | - | |
103 | - for i=0L,n_elements(data_set)-1 do begin | |
104 | - ind_set = where(tagnames EQ data_set(i),ctset) | |
105 | - ;here using eq_tags and errvec for another purpose | |
106 | - ;because I need to locate the associated errors | |
107 | 138 | |
139 | + FOR i=0L,n_elements(data_set)-1 DO BEGIN | |
140 | + ind_set = where(tagnames EQ data_set(i),ctset) | |
108 | 141 | if ctset ne 0 then begin |
109 | - | |
110 | - inderr = where(eq_tags EQ data_set(i)) ;no need for counters this is supposedly true at all times plus the error message is below in the next test | |
111 | - ind_errset = where(tagnames EQ errvec[inderr[0]]) | |
112 | - | |
113 | - ;in the case of PSI for emission and for absorption | |
114 | - ;I need to know the different cases: | |
115 | - | |
116 | - ;EMISSION | |
117 | - | |
118 | - if data_set(i) EQ 'PSI' and tagnames[3] EQ 'STOKESI' then ind_errset = where(tagnames EQ errvec[6]) | |
119 | - | |
120 | - | |
121 | - ;EXTINCION | |
122 | - | |
123 | - if data_set(i) EQ 'PSI' and tagnames[3] EQ 'EXT_I' then ind_errset = where(tagnames EQ errvec[11]) | |
124 | - | |
125 | - ;stop | |
126 | - endif else begin | |
127 | - ind_set1 = where(tag_names(*!dustem_data) EQ data_set(i),ctset) | |
128 | - if ctset eq 0 then message, 'Aborting. The supplied data set is not found in the DustemWrap database.' | |
129 | - ind_set = where(tagnames EQ eq_tags(ind_set1[0])) | |
130 | - ind_errset = where(tagnames EQ errvec(ind_set1[0])) | |
131 | - ;stop | |
132 | - endelse | |
133 | 142 | |
134 | - if typename(ind0) EQ 'LIST' then begin | |
135 | - data_struct(ind0[i]).(ind_set) = la_undef() | |
136 | - data_struct(ind0[i]).(ind_errset) = la_undef() | |
137 | - endif else begin | |
138 | - data_struct(ind0).(ind_set) = la_undef() | |
139 | - data_struct(ind0).(ind_errset) = la_undef() | |
140 | - endelse | |
141 | - | |
142 | - endfor | |
143 | - endif else begin | |
143 | + ;the requires the default keyword to be set | |
144 | + IF keyword_set(default) THEN BEGIN | |
145 | + ;EMISSION CASE | |
146 | + IF ctm NE 0 THEN BEGIN | |
147 | + ;testing data_set(i) against the above strings. | |
148 | + test_StokesI = where(ind_set_StokesI EQ ind_set, ct_StokesI) | |
149 | + IF ct_StokesI NE 0 THEN data_struct(indices).(ind_set_StokesI) = la_undef() | |
150 | + test_StokesQ = where(ind_set_StokesQ EQ ind_set, ct_StokesQ) | |
151 | + IF ct_StokesQ NE 0 THEN data_struct(indices).(ind_set_StokesQ) = la_undef() | |
152 | + test_StokesU = where(ind_set_StokesU EQ ind_set, ct_StokesU) | |
153 | + IF ct_StokesU NE 0 THEN data_struct(indices).(ind_set_StokesU) = la_undef() | |
154 | + test_LargeP = where(ind_set_LargeP EQ ind_set, ct_LargeP) | |
155 | + IF ct_LargeP NE 0 THEN data_struct(indices).(ind_set_LargeP) = la_undef() | |
156 | + test_smallp = where(ind_set_smallp EQ ind_set, ct_smallp) | |
157 | + IF ct_smallp NE 0 THEN data_struct(indices).(ind_set_smallp) = la_undef() | |
158 | + test_psi = where(ind_set_psi EQ ind_set, ct_psi) | |
159 | + IF ct_psi NE 0 THEN data_struct(indices).(ind_set_psi) = la_undef() | |
160 | + ENDIF | |
161 | + ;EXTINCTION CASE | |
162 | + IF ctx NE 0 THEN BEGIN | |
163 | + ;testing data_set(i) against the above strings. | |
164 | + test_EXT_I = where(ind_set_EXT_I EQ ind_set, ct_EXT_I) | |
165 | + IF ct_EXT_I NE 0 THEN data_struct(indices).(ind_set_EXT_I) = la_undef() | |
166 | + test_EXT_Q = where(ind_set_EXT_Q EQ ind_set, ct_EXT_Q) | |
167 | + IF ct_EXT_Q NE 0 THEN data_struct(indices).(ind_set_EXT_Q) = la_undef() | |
168 | + test_EXT_U = where(ind_set_EXT_U EQ ind_set, ct_EXT_U) | |
169 | + IF ct_EXT_U NE 0 THEN data_struct(indices).(ind_set_EXT_U) = la_undef() | |
170 | + test_EXT_P = where(ind_set_EXT_P EQ ind_set, ct_EXT_P) | |
171 | + IF ct_EXT_P NE 0 THEN data_struct(indices).(ind_set_EXT_P) = la_undef() | |
172 | + test_EXT_smallp = where(ind_set_EXT_smallp EQ ind_set, ct_EXT_smallp) | |
173 | + IF ct_EXT_smallp NE 0 THEN data_struct(indices).(ind_set_EXT_smallp) = la_undef() | |
174 | + test_psi = where(ind_set_psi EQ ind_set, ct_psi) | |
175 | + IF ct_psi NE 0 THEN data_struct(indices).(ind_set_psi) = la_undef() | |
176 | + ENDIF | |
177 | + ENDIF ELSE data_struct(indices).(ind_set) = la_undef() | |
178 | + ENDIF | |
179 | + ENDFOR | |
180 | + ENDIF ELSE BEGIN ;If no datasets are supplied, all tag values are set to la_undef() | |
144 | 181 | ind_tags = where(tagnames ne 'INSTRU' and tagnames ne 'FILTER' and tagnames ne 'WAVE') |
145 | - for j=0L,n_elements(ind_tags)-1 do begin | |
146 | - data_struct(ind0).(ind_tags(j)) = la_undef() | |
147 | - endfor | |
182 | + FOR j=0L,n_elements(ind_tags)-1 DO BEGIN | |
183 | + data_struct(indices).(ind_tags(j)) = la_undef() | |
184 | + ENDFOR | |
148 | 185 | endelse |
149 | - | |
150 | - | |
151 | 186 | ENDIF ELSE message, 'Cannot proceed. Keyword(s) missing. Refer to help for keyword options.' |
152 | 187 | |
153 | -return, data_struct | |
154 | - | |
188 | +RETURN, data_struct | |
155 | 189 | the_end: |
156 | 190 | |
157 | 191 | ... | ... |
src/idl/dustem_myisrf_example.pro
... | ... | @@ -229,7 +229,7 @@ end |
229 | 229 | ;== SET THE OBSERVATIONAL STRUCTURE |
230 | 230 | ;== sed is passed twice -- the first occurrence is the SED that you |
231 | 231 | ;== wish to fit, the second occurrence is the SED that you wish to visualise. |
232 | -dustem_set_data,sed,sed | |
232 | +dustem_set_data,m_fit=sed,m_show=sed | |
233 | 233 | |
234 | 234 | ; ;== SET INITIAL VALUES AND LIMITS OF THE PARAMETERS THAT WILL BE |
235 | 235 | ; ;== ADJUSTED DURING THE FIT | ... | ... |
src/idl/dustem_set_data.pro
1 | -PRO dustem_set_data,m_fit,m_show,x_fit,x_show,rchi2_weight=rchi2_weight,f_HI=f_HI,help=help | |
1 | +PRO dustem_set_data,m_fit=m_fit,m_show=m_show,x_fit=x_fit,x_show=x_show,rchi2_weight=rchi2_weight,f_HI=f_HI,help=help | |
2 | 2 | |
3 | 3 | ;+ |
4 | 4 | ; NAME: |
5 | 5 | ; dustem_set_data |
6 | 6 | ; |
7 | 7 | ; PURPOSE: |
8 | -; Initializes the dustem data structure (*!dustem_data) used in the fitting | |
9 | -; Initializes the !dustem_show structure which is either a copy or a more detailed version of !dustem_data | |
10 | -; | |
8 | +; Set the *!dustem data (and *!dustem_show) datasets in emission and/or extinction from input data structures | |
9 | +; *!dustem_data is important for the fitting of data and its general handling by DustEMWrap. | |
11 | 10 | ; CATEGORY: |
12 | 11 | ; DustEMWrap, Mid-Level, Distributed, Initialization |
13 | 12 | ; |
14 | 13 | ; CALLING SEQUENCE: |
15 | -; dustem_set_data[,m_fit,x_fit][,m_show,x_show][,rchi2_weight=][,f_HI=][,/help] | |
14 | +; dustem_set_data,[,m_fit=,x_fit=][,m_show=,x_show=],[,rchi2_weight=][,f_HI=][,/help] | |
16 | 15 | ; |
17 | 16 | ; INPUTS: |
18 | 17 | ; None |
19 | 18 | ; |
20 | 19 | ; OPTIONAL INPUT PARAMETERS: |
21 | -; m_fit : dustemwrap structure contaning emission data to be fitted | |
22 | -; x_fit : dustemwrap structure containing extinction data to be fitted | |
23 | -; m_show : dustemwrap structure containing emission data to be displayed | |
24 | -; x_show : dustemwrap structure containing extinctiond data to be displayed | |
25 | -; rchi2_weight : dustemwrap structure containing the wieghts for chi2 calculation | |
20 | +; m_fit : DustEMWrap structure contaning emission data to be fitted | |
21 | +; m_show : DustEMWrap structure containing emission data to be displayed | |
22 | +; x_fit : DusteEMWrap structure containing extinction data to be fitted | |
23 | +; x_show : DustEMWrap structure containing extinctiond data to be displayed | |
24 | +; rchi2_weight : DustEMWrap structure containing the wieghts for chi2 calculation | |
26 | 25 | ; f_HI : multiplicative factor for the SED values (extinction and emission) |
27 | 26 | ; |
28 | 27 | ; OUTPUTS: |
29 | -; None | |
28 | +; None/ALL OF THE ABOVE? | |
30 | 29 | ; |
31 | 30 | ; OPTIONAL OUTPUT PARAMETERS: |
32 | 31 | ; None |
... | ... | @@ -52,15 +51,14 @@ PRO dustem_set_data,m_fit,m_show,x_fit,x_show,rchi2_weight=rchi2_weight,f_HI=f_H |
52 | 51 | ; dir=!dustem_wrap_soft_dir+'/Data/EXAMPLE_OBSDATA/' |
53 | 52 | ; file=dir+'example_SED_1.xcat' |
54 | 53 | ; spec=read_xcat(file,/silent) |
55 | -; dustem_set_data,spec,x_fit,spec,x_show) | |
56 | -; #in this example !dustem_data and !dustem_show are identical | |
54 | +; dustem_set_data,m_fit=spec,m_show=spec | |
55 | +; nb: in this example *!dustem_data and *!dustem_show end up identical | |
57 | 56 | ; |
58 | 57 | ; MODIFICATION HISTORY: |
59 | 58 | ; Written by J.-Ph. Bernard 2007 |
60 | 59 | ; V. Guillet (2012) : dustem_set_data is turned into a function which can be used |
61 | 60 | ; indifferently for sed, ext, polext |
62 | -; I. Choubani (2022): dustem_check_data is introduced and the data structure format of the latest release is respected. | |
63 | -; dustem_set_data is turned into a procedure. | |
61 | +; I. Choubani (2022): dustem_set_data is turned into a procedure for emission/extinction with/without polarization. | |
64 | 62 | ; Evolution details on the DustEMWrap gitlab. |
65 | 63 | ; See http://dustemwrap.irap.omp.eu/ for FAQ and help. |
66 | 64 | ;- |
... | ... | @@ -76,25 +74,18 @@ for i=0L,n_tags(*!dustem_data)-1 do begin |
76 | 74 | (*!dustem_show).(i) = ptr_new() |
77 | 75 | endfor |
78 | 76 | |
79 | -;#FITTING STRUCTURE | |
80 | - | |
81 | -;To me this is unnecessary... as dustem_check_data is always needed as it shapes the output structures (that would otherwise not exist) | |
82 | -;in order to prepare them for the mpfit run. | |
83 | -;the *!dustem_data tags are always cleaned so data will never exist if this keyword is used. | |
84 | -;commenting the use of nocheck_data for now | |
85 | - | |
86 | -;IF not keyword_set(nocheck_data) THEN BEGIN | |
87 | - dustem_check_data,m_fit,x_fit,sed,ext,polext,polsed,polfrac,psi_em,qsed,used,qext,uext,psi_ext,fpolext | |
88 | -;ENDIF | |
89 | - | |
90 | -;outputs whatever the input structure has, into organized seperate structures formatted for the fitting process. | |
77 | +;Outputs have the format required by !dustem_data and the subsequent fitting process. | |
78 | +dustem_check_data, m_fit,x_fit,sed=sed,ext=ext,polext=polext, $ | |
79 | + polsed=polsed,polfrac=polfrac,psi_em=psi_em, $ | |
80 | + qsed=qsed,used=used,qext=qext,uext=uext, $ | |
81 | + psi_ext=psi_ext,fpolext=fpolext | |
91 | 82 | |
92 | 83 | ;FITTING STRUCTURE INITIALIZATION |
93 | 84 | IF isa(sed) THEN (*!dustem_data).sed = ptr_new(sed) |
94 | 85 | IF isa(ext) THEN (*!dustem_data).ext = ptr_new(ext) |
95 | 86 | |
96 | 87 | ;#################### |
97 | -;OLD VARIABLE. KEPT IT. | |
88 | +;RELIC. For Annie to judge if this is necessary | |
98 | 89 | ; If f_HI is specified, multiply the data by f_HI |
99 | 90 | If keyword_set(f_HI) and ptr_valid((*!dustem_data).sed) then begin |
100 | 91 | if f_HI gt 0 then (*(*!dustem_data).sed).values *= f_HI else f_HI = 1. |
... | ... | @@ -105,27 +96,33 @@ endif else f_HI = 1. |
105 | 96 | defsysv,'!dustem_f_HI',f_HI |
106 | 97 | ;#################### |
107 | 98 | |
99 | +;Problem here is that the user can activate !run_pol without wanting to be in polarization mode. | |
100 | +;reinitialze !run_pol here? | |
101 | + | |
102 | +If !run_pol THEN BEGIN | |
103 | + If tag_exist(*!dustem_show,'QSED') THEN BEGIN | |
104 | + IF ~isa((*!dustem_data).qsed) THEN !run_pol=0 | |
105 | + ENDIF ELSE !run_pol=0 | |
106 | +ENDIF | |
107 | + | |
108 | 108 | if !run_pol then begin |
109 | 109 | |
110 | 110 | if keyword_set(m_fit) then begin |
111 | 111 | |
112 | 112 | teststks = isa(qsed) and isa(used) |
113 | - ;stop | |
114 | 113 | IF ~teststks then message, 'Stokes parameters are not set correctly. Please check the input structure. Aborting...' |
115 | - | |
116 | - ;☆EMISSION | |
117 | 114 | message, 'Polarization component(s) to fit: QSED and USED' ,/continue |
118 | 115 | |
119 | - | |
120 | - ;☆Mandatory presence in polar mode | |
121 | 116 | IF isa(qsed) THEN BEGIN |
122 | 117 | (*!dustem_data).qsed = ptr_new(qsed) |
118 | + ;RELIC | |
123 | 119 | if keyword_set(f_HI) then if f_HI gt 0 then $ |
124 | 120 | (*(*!dustem_data).qsed).values *= f_HI |
125 | 121 | ENDIF |
126 | - ;☆Mandatory presence in polar mode | |
122 | + | |
127 | 123 | if isa(used) then BEGIN |
128 | 124 | (*!dustem_data).used = ptr_new(used) |
125 | + ;RELIC | |
129 | 126 | if keyword_set(f_HI) then if f_HI gt 0 then $ |
130 | 127 | (*(*!dustem_data).used).values *= f_HI |
131 | 128 | ENDIF |
... | ... | @@ -133,6 +130,7 @@ if !run_pol then begin |
133 | 130 | if isa(polsed) then BEGIN |
134 | 131 | |
135 | 132 | (*!dustem_data).polsed = ptr_new(polsed) |
133 | + ;RELIC | |
136 | 134 | if keyword_set(f_HI) then if f_HI gt 0 then $ |
137 | 135 | (*(*!dustem_data).polsed).values *= f_HI |
138 | 136 | |
... | ... | @@ -141,6 +139,7 @@ if !run_pol then begin |
141 | 139 | if isa(polfrac) then BEGIN |
142 | 140 | |
143 | 141 | (*!dustem_data).polfrac = ptr_new(polfrac) |
142 | + ;RELIC | |
144 | 143 | if keyword_set(f_HI) then if f_HI gt 0 then $ |
145 | 144 | (*(*!dustem_data).polfrac).values *= f_HI |
146 | 145 | |
... | ... | @@ -149,23 +148,22 @@ if !run_pol then begin |
149 | 148 | if isa(psi_em) then BEGIN |
150 | 149 | |
151 | 150 | (*!dustem_data).psi_em = ptr_new(psi_em) |
151 | + ;RELIC | |
152 | 152 | if keyword_set(f_HI) then if f_HI gt 0 then $ |
153 | 153 | (*(*!dustem_data).psi_em).values *= f_HI |
154 | 154 | |
155 | 155 | ENDIF |
156 | 156 | |
157 | - | |
158 | 157 | endif |
159 | 158 | |
160 | 159 | if keyword_set(x_fit) then begin |
161 | 160 | |
162 | - ;Two tests that determine what the user will eventually fit | |
163 | 161 | testexstks = isa(qext) and isa(uext) |
164 | 162 | |
165 | 163 | IF ~testexstks then message, 'Extinction stokes parameters/Polarization data is not set correctly. Please check the input structure. Aborting...' |
166 | 164 | |
167 | - ;EXTINCTION - allowed for the default fitting of both because I do not know if the same formalism should be applied to the extinction data because it also implies deviding extinction data into two components. | |
168 | - | |
165 | + ;EXTINCTION - | |
166 | + | |
169 | 167 | message, 'Extinction polarization component(s) to fit: QEXT and UEXT',/continue |
170 | 168 | |
171 | 169 | if isa(polext) then BEGIN |
... | ... | @@ -200,22 +198,22 @@ if !run_pol then begin |
200 | 198 | endif |
201 | 199 | endif |
202 | 200 | |
203 | -;#SHOWING STRUCTURE | |
201 | +;SHOWING STRUCTURE / IT IS NEEDED TO BE ABLE TO LOCATE THE HIDDEN DATA POINTS WHEN COMPARING WITH !dustem_data. | |
202 | +;when creating the HUGE system variable JP wants to create. We'll be able to omit it from DusteEMWrap for good. | |
204 | 203 | |
205 | 204 | if keyword_set(m_fit) and not keyword_set(m_show) then m_show=m_fit |
206 | 205 | if keyword_set(x_fit) and not keyword_set(x_show) then x_show = x_fit |
207 | 206 | |
208 | - | |
209 | -;Setting of the structure that will be displayed | |
210 | -;IF not keyword_set(nocheck_data) THEN BEGIN | |
211 | - dustem_check_data,m_show,x_show,sed,ext,polext,polsed,polfrac,psi_em,qsed,used,qext,uext,psi_ext,fpolext | |
212 | -;ENDIF | |
207 | +dustem_check_data, m_show,x_show,sed=sed,ext=ext,polext=polext, $ | |
208 | + polsed=polsed,polfrac=polfrac,psi_em=psi_em, $ | |
209 | + qsed=qsed,used=used,qext=qext,uext=uext, $ | |
210 | + psi_ext=psi_ext,fpolext=fpolext | |
213 | 211 | |
214 | 212 | IF isa(sed) THEN (*!dustem_show).sed = ptr_new(sed) |
215 | 213 | IF isa(ext) THEN (*!dustem_show).ext = ptr_new(ext) |
216 | 214 | |
217 | 215 | ;#################### |
218 | -;OLD VARIABLE. KEPT IT. | |
216 | +;RELIC | |
219 | 217 | ; If f_HI is specified, multiply the data by f_HI |
220 | 218 | If keyword_set(f_HI) and ptr_valid((*!dustem_show).sed) then begin |
221 | 219 | if f_HI gt 0 then (*(*!dustem_show).sed).values *= f_HI else f_HI = 1. |
... | ... | @@ -234,19 +232,6 @@ if !run_pol then begin |
234 | 232 | |
235 | 233 | IF (~teststks and ~isa(polsed)) or (~teststks and ~isa(polfrac)) then message, 'Stokes parameters/Polarization showing data is not set correctly. Please check the input structure. Aborting...' |
236 | 234 | |
237 | - if teststks and isa(polsed) and ~(isa(polfrac)) and ~(isa(psi_em)) then nowshowing = 'QSED, USED and POLSED' | |
238 | - if teststks and isa(polsed) and ~(isa(polfrac)) and isa(psi_em) then nowshowing = 'QSED, USED, POLSED and PSI_EM' | |
239 | - if teststks and ~(isa(polsed)) and isa(polfrac) and ~(isa(psi_em)) then nowshowing = 'QSED, USED and POLFRAC' | |
240 | - if teststks and ~(isa(polsed)) and isa(polfrac) and isa(psi_em) then nowshowing = 'QSED, USED, POLFRAC and PSI_EM' | |
241 | - if teststks and ~(isa(polsed)) and ~(isa(polfrac)) and ~(isa(psi_em)) then nowshowing = 'QSED and USED' | |
242 | - if teststks and isa(polsed) and isa(polfrac) and ~(isa(psi_em)) then nowshowing = 'QSED, USED, POLSED and POLFRAC' | |
243 | - if teststks and isa(polsed) and isa(polfrac) and isa(psi_em) then nowshowing = 'QSED, USED, POLFRAC, POLSED and PSI_EM' | |
244 | - if teststks and ~(isa(polsed)) and ~(isa(polfrac)) and isa(psi_em) then nowshowing = 'QSED, USED and PSI_EM' | |
245 | - | |
246 | - | |
247 | - message, 'Polarization component(s) to show: '+nowshowing ,/continue | |
248 | - | |
249 | - | |
250 | 235 | If isa(polsed) then BEGIN ;Apply changes to !dustem_data here. |
251 | 236 | (*!dustem_show).polsed = ptr_new(polsed) |
252 | 237 | if keyword_set(f_HI) then if f_HI gt 0 then $ |
... | ... | @@ -277,19 +262,7 @@ if !run_pol then begin |
277 | 262 | teststks = isa(qext) and isa(uext) |
278 | 263 | |
279 | 264 | IF (~teststks) then message, 'Extinction stokes parameters/Polarization data is not set correctly. Please check the input structure. Aborting...' |
280 | - | |
281 | - if teststks and isa(polext) and ~(isa(polextfrac)) and ~(isa(psi_ext)) then nowshowing = 'QEXT, UEXT and POLEXT' | |
282 | - if teststks and isa(polext) and ~(isa(polextfrac)) and isa(psi_ext) then nowshowing = 'QEXT, UEXT, POLEXT and PSI_EXT' | |
283 | - if teststks and ~(isa(polext)) and isa(polextfrac) and ~(isa(psi_ext)) then nowshowing = 'QEXT, UEXT and POLEXTFRAC' | |
284 | - if teststks and ~(isa(polext)) and isa(polextfrac) and isa(psi_ext) then nowshowing = 'QEXT, UEXT, POLEXTFRAC and PSI_EXT' | |
285 | - if teststks and ~(isa(polext)) and ~(isa(polextfrac)) and ~(isa(psi_ext)) then nowshowing = 'QEXT and UEXT' | |
286 | - if teststks and isa(polext) and isa(polextfrac) and ~(isa(psi_ext)) then nowshowing = 'QEXT, UEXT, POLEXT and POLEXTFRAC' | |
287 | - if teststks and isa(polext) and isa(polextfrac) and isa(psi_ext) then nowshowing = 'QEXT, UEXT, POLEXTFRAC, POLEXT and PSI_EXT' | |
288 | - if teststks and ~(isa(polext)) and ~(isa(polextfrac)) and isa(psi_ext) then nowshowing = 'QEXT, UEXT and PSI_EXT' | |
289 | - | |
290 | - | |
291 | - message, 'Polarization component(s) to show: '+nowshowing ,/continue | |
292 | - | |
265 | + | |
293 | 266 | ;EXTINCTION |
294 | 267 | if isa(polext) then BEGIN |
295 | 268 | (*!dustem_show).polext = ptr_new(polext) |
... | ... | @@ -364,10 +337,4 @@ ENDIF |
364 | 337 | |
365 | 338 | the_end: |
366 | 339 | |
367 | -; | |
368 | -; return,0. | |
369 | - | |
370 | - | |
371 | - | |
372 | - | |
373 | 340 | END | ... | ... |
src/idl/dustem_stellarpopisrf_example.pro
... | ... | @@ -218,7 +218,7 @@ end |
218 | 218 | for i=4l,n_tags(sed)-1 do begin |
219 | 219 | sed.(i) = sed.sigmaii |
220 | 220 | endfor |
221 | -dustem_set_data,sed,sed | |
221 | +dustem_set_data,m_fit=sed,m_show=sed | |
222 | 222 | |
223 | 223 | ;;== SET INITIAL VALUES AND LIMITS OF THE PARAMETERS THAT WILL BE |
224 | 224 | ;;== ADJUSTED DURING THE FIT | ... | ... |
src/idl/dustemwrap_plot.pro
... | ... | @@ -154,8 +154,7 @@ if not keyword_set(dustem_ext) and isa((*!dustem_data).ext) then begin |
154 | 154 | dustem_ext = dustem_compute_ext(p_dim,st=st,EXT_spec=EXT_spec) |
155 | 155 | |
156 | 156 | if !run_pol and tag_exist(*!dustem_show,'qext') && !run_lin then begin ;any polarization tag (qsed,used,qext,usext,polfrac) can be used for this test |
157 | - | |
158 | - ;stop | |
157 | + | |
159 | 158 | dustem_polext = dustem_compute_polext(p_dim,st=st,POLEXT_spec=POLEXT_spec,SPEXT_spec=SPEXT_spec,dustem_fpolext=dustem_fpolext) |
160 | 159 | toto = dustem_compute_stokext(p_dim,st=st,QEXT_spec=QEXT_spec,UEXT_spec=UEXT_spec,PSIEXT_spec=PSIEXT_spec,dustem_psi_ext=dustem_psi_ext) |
161 | 160 | dustem_qext = toto[0] |
... | ... | @@ -260,6 +259,14 @@ endif else begin |
260 | 259 | rchi2 = la_undef();maybe not the best initialization |
261 | 260 | endelse |
262 | 261 | |
262 | +;changing tag_exist() by isa() because the user can mistakenly activate the !run_pol keyword | |
263 | + | |
264 | +If !run_pol THEN BEGIN | |
265 | + If tag_exist(*!dustem_show,'QSED') THEN BEGIN | |
266 | + IF ~isa((*!dustem_data).qsed) THEN !run_pol=0 | |
267 | + ENDIF ELSE !run_pol = 0 | |
268 | +ENDIF | |
269 | + | |
263 | 270 | ;===========Window positionning parameters |
264 | 271 | if !run_pol and tag_exist(*!dustem_show,'qsed') then BEGIN ;qsed tag is sufficient for the test |
265 | 272 | wdelta_x=60 |
... | ... | @@ -500,7 +507,7 @@ if test_m then begin |
500 | 507 | |
501 | 508 | dustem_interp = list(dustem_sed) ;DustEmWrap SED predictions . |
502 | 509 | dustem_spec = list(SED_spec) ;DustEM spectra predictions |
503 | - position = list(p_sed,np_sed);list(list(p_sed,np_sed)) ; I think I need this ... | |
510 | + position = list(p_sed,np_sed) ;list(list(p_sed,np_sed)) ; I think I need this ... | |
504 | 511 | ;position_n =list(np_sed) |
505 | 512 | datasets = ['SED'] |
506 | 513 | ;replace by one keyword? |
... | ... | @@ -516,7 +523,7 @@ if test_m then begin |
516 | 523 | |
517 | 524 | endif else begin |
518 | 525 | |
519 | - ; PLOTTING OF DATA THAT IS UNCHAED | |
526 | + ; PLOTTING OF DATA THAT IS UNCHANGED | |
520 | 527 | cgwindow,'dustem_plot_dataset', st, dataset=datasets, position=position,positive_only=positiveonly,negative_only=negativeonly, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1 |
521 | 528 | ; REFRESHING DATA - to plot the refreshed data for the first time. |
522 | 529 | cgwindow,'dustem_plot_dataset', st, dustem_interp,dustem_spec,extra_spec=extra_spec,dataset=datasets,positive_only=positiveonly,negative_only=negativeonly, /refresh ,position=position, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1 | ... | ... |