From 1be775fe8cacc249bacf619d5351ee34aa67c320 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Bernard Date: Fri, 9 Feb 2024 12:56:08 +0100 Subject: [PATCH] First commit --- src/idl/dustem_first_guess.pro | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+), 0 deletions(-) create mode 100644 src/idl/dustem_first_guess.pro diff --git a/src/idl/dustem_first_guess.pro b/src/idl/dustem_first_guess.pro new file mode 100644 index 0000000..e1a0284 --- /dev/null +++ b/src/idl/dustem_first_guess.pro @@ -0,0 +1,67 @@ +FUNCTION dustem_first_guess,pd,pval,sed,pd_to_update,pd_filter_names, $ + fpd=fpd, $ + fiv=fpval, $ + pol=pol, $ + verbose=verbose, $ + use_previous_fortran=use_previous_fortran, $ + dustem_predicted_sed=dustem_predicted_sed, $ + output_dustem_st=output_dustem_st, $ + input_dustem_st=input_dustem_st, $ + no_reset_plugin_structure=no_reset_plugin_structure + +;computes new parameter initial values, based on provided SED and provided filter names associated to parameters +;where a linear calculation can be done + +;sed is actually not used. Uses sed in !dustem_data instead. + +Npd=n_elements(pd_to_update) +Nfilters=n_elements(pd_filter_names) +IF Npd NE Nfilters THEN BEGIN + message,'pd_to_update and pd_filter_names must be of same length',/continue + stop +ENDIF + +new_pval=pval ;defaults is no change to provideid initial values + +;==== compute SED on pd_filter_names with provided pd,iv +;dummy=0 ;otherwise model is not recomputed !! +IF not keyword_set(input_dustem_st) THEN st=0 ELSE st=input_dustem_st +dustem_init_params,!dustem_model,pd,pval,fpd=fpd,fiv=fpval,pol=pol,no_reset_plugin_structure=no_reset_plugin_structure +dustem_Ised=dustem_compute_sed(pval,st=st,use_previous_fortran=use_previous_fortran) +output_dustem_st=st ;This is to output the Fortran structure +;=== for keyword_output. Caution, this is the SED for the input parameter values, not the output ones +dustem_predicted_sed=dustem_Ised + +;=== The above two are not used +;sed_filters=(*(*!dustem_data).sed).filt_names +;sed_values=(*(*!dustem_data).sed).filt_names + +;Caution: below, dustem_Ised and sed.filter can have different size, leading to an error, +;in particular when use_previous_fortran, due to filtering by dustem_set_data. Below is a (very dirty) fix +data_filter_names=(*(*!dustem_data).sed).filt_names ;CAUTION can be different from sed.filter +use_sed=sed +;use_sed=(*(*!dustem_data).sed).values + +FOR i=0L,Nfilters-1 DO BEGIN + ;dirty fix + ;ind1=where(sed.filter EQ pd_filter_names[i],count1) + ind1=where(data_filter_names EQ pd_filter_names[i],count1) + ;stop + IF count1 NE 0 THEN BEGIN + ;rap=dustem_Ised[ind1[0]]/sed[ind1[0]].stokesI + rap=dustem_Ised[ind1[0]]/use_sed[ind1[0]].stokesI + ind2=where(pd EQ pd_to_update[i],count2) + new_pval[ind2[0]]=pval[ind2[0]]/rap + ENDIF +ENDFOR + +IF keyword_set(verbose) THEN BEGIN + print,pdverbose + print,pval + print,new_pval +ENDIF +;stop + +RETURN,new_pval + +END \ No newline at end of file -- libgit2 0.21.2