Commit 1be775fe8cacc249bacf619d5351ee34aa67c320

Authored by Jean-Philippe Bernard
1 parent 0211d44a
Exists in master

First commit

Showing 1 changed file with 67 additions and 0 deletions   Show diff stats
src/idl/dustem_first_guess.pro 0 → 100644
... ... @@ -0,0 +1,67 @@
  1 +FUNCTION dustem_first_guess,pd,pval,sed,pd_to_update,pd_filter_names, $
  2 + fpd=fpd, $
  3 + fiv=fpval, $
  4 + pol=pol, $
  5 + verbose=verbose, $
  6 + use_previous_fortran=use_previous_fortran, $
  7 + dustem_predicted_sed=dustem_predicted_sed, $
  8 + output_dustem_st=output_dustem_st, $
  9 + input_dustem_st=input_dustem_st, $
  10 + no_reset_plugin_structure=no_reset_plugin_structure
  11 +
  12 +;computes new parameter initial values, based on provided SED and provided filter names associated to parameters
  13 +;where a linear calculation can be done
  14 +
  15 +;sed is actually not used. Uses sed in !dustem_data instead.
  16 +
  17 +Npd=n_elements(pd_to_update)
  18 +Nfilters=n_elements(pd_filter_names)
  19 +IF Npd NE Nfilters THEN BEGIN
  20 + message,'pd_to_update and pd_filter_names must be of same length',/continue
  21 + stop
  22 +ENDIF
  23 +
  24 +new_pval=pval ;defaults is no change to provideid initial values
  25 +
  26 +;==== compute SED on pd_filter_names with provided pd,iv
  27 +;dummy=0 ;otherwise model is not recomputed !!
  28 +IF not keyword_set(input_dustem_st) THEN st=0 ELSE st=input_dustem_st
  29 +dustem_init_params,!dustem_model,pd,pval,fpd=fpd,fiv=fpval,pol=pol,no_reset_plugin_structure=no_reset_plugin_structure
  30 +dustem_Ised=dustem_compute_sed(pval,st=st,use_previous_fortran=use_previous_fortran)
  31 +output_dustem_st=st ;This is to output the Fortran structure
  32 +;=== for keyword_output. Caution, this is the SED for the input parameter values, not the output ones
  33 +dustem_predicted_sed=dustem_Ised
  34 +
  35 +;=== The above two are not used
  36 +;sed_filters=(*(*!dustem_data).sed).filt_names
  37 +;sed_values=(*(*!dustem_data).sed).filt_names
  38 +
  39 +;Caution: below, dustem_Ised and sed.filter can have different size, leading to an error,
  40 +;in particular when use_previous_fortran, due to filtering by dustem_set_data. Below is a (very dirty) fix
  41 +data_filter_names=(*(*!dustem_data).sed).filt_names ;CAUTION can be different from sed.filter
  42 +use_sed=sed
  43 +;use_sed=(*(*!dustem_data).sed).values
  44 +
  45 +FOR i=0L,Nfilters-1 DO BEGIN
  46 + ;dirty fix
  47 + ;ind1=where(sed.filter EQ pd_filter_names[i],count1)
  48 + ind1=where(data_filter_names EQ pd_filter_names[i],count1)
  49 + ;stop
  50 + IF count1 NE 0 THEN BEGIN
  51 + ;rap=dustem_Ised[ind1[0]]/sed[ind1[0]].stokesI
  52 + rap=dustem_Ised[ind1[0]]/use_sed[ind1[0]].stokesI
  53 + ind2=where(pd EQ pd_to_update[i],count2)
  54 + new_pval[ind2[0]]=pval[ind2[0]]/rap
  55 + ENDIF
  56 +ENDFOR
  57 +
  58 +IF keyword_set(verbose) THEN BEGIN
  59 + print,pdverbose
  60 + print,pval
  61 + print,new_pval
  62 +ENDIF
  63 +;stop
  64 +
  65 +RETURN,new_pval
  66 +
  67 +END
0 68 \ No newline at end of file
... ...