Commit 8910b3fd4b07e760187f98d1a9ebdfbc588646fa

Authored by Annie Hughes
2 parents 2a4aa390 ad369def
Exists in master

Merge branch 'master' of https://gitlab.irap.omp.eu/OV-GSO-DC/dustem-wrapper_idl

src/idl/dustem_init.pro
... ... @@ -82,6 +82,29 @@ IF keyword_set(help) THEN BEGIN
82 82 goto,the_end
83 83 ENDIF
84 84  
  85 +
  86 +
  87 +;IC: JP and Annie tell me what you think about this ...
  88 +
  89 +;Adding five free pointers that the user can utilize to their liking
  90 +;especially for plugins that do not meet the (key=key,val=val) format in a straightforward way.
  91 +;ie: dustem_plugin_modify_isrf that has key=1 (so it is activated) and val=1 or 2 or 3 or 4 or 5 to refer the pointer used.
  92 +;Here (case of user-defined isrf), the user can place the directory of the isrf in one of the free pointers.
  93 +;(I believe advanced users will need something like this...)
  94 +
  95 +defsysv, '!dustem_free1', ptr_new()
  96 +defsysv, '!dustem_free2', ptr_new()
  97 +defsysv, '!dustem_free3', ptr_new()
  98 +defsysv, '!dustem_free4', ptr_new()
  99 +defsysv, '!dustem_free5', ptr_new()
  100 +defsysv, '!dustem_free6', ptr_new()
  101 +defsysv, '!dustem_free7', ptr_new()
  102 +defsysv, '!dustem_free8', ptr_new()
  103 +defsysv, '!dustem_free9', ptr_new()
  104 +defsysv, '!dustem_free10', ptr_new()
  105 +
  106 +
  107 +
85 108 dustem_define_la_common
86 109  
87 110 ;define which code is running, idl, gdl or fawlty
... ...
src/idl/dustem_plugin_modify_isrf.pro 0 → 100644
... ... @@ -0,0 +1,153 @@
  1 +Function dustem_plugin_modify_isrf, key=key, val=val, scope=scope, paramtag=paramtag,help=help
  2 +
  3 +;+
  4 +; NAME:
  5 +; dustem_plugin_modify_isrf
  6 +; PURPOSE:
  7 +; REPLACES THE DEFAULT DUSTEM ISRF with a user-defined one
  8 +; CATEGORY:
  9 +; DUSTEM Wrapper
  10 +; CALLING SEQUENCE:
  11 +; dustem_plugin_modify_isrf(key=key,val=val)
  12 +; INPUTS:
  13 +; None
  14 +; OPTIONAL INPUT PARAMETERS:
  15 +; key = input parameter number
  16 +; val = input parameter value
  17 +; key = 1 sets the ISRF file path. The call is placed in the fixed parameters vector.
  18 +; It can also mean that G0 or gas.GO is present in PD vector and is thus not handled here.
  19 +; key = 2 means G0/gas.G0 isn't present in the PD vector and is handled here.
  20 +; The plugin is placed in the parameters vector and G0 is fitted through this plugin.
  21 +; if key=1, val = 1 means the !dustem_free1 pointer (containing the user-defined file's directory) is used.
  22 +; if key=2, val = value of G0. The file path has supposedly already been defined.
  23 +; OUTPUTS:
  24 +; None
  25 +; OPTIONAL OUTPUT PARAMETERS:
  26 +; None
  27 +; ACCEPTED KEY-WORDS:
  28 +; help = if set, print this help
  29 +; COMMON BLOCKS:
  30 +; None
  31 +; SIDE EFFECTS:
  32 +; None
  33 +; RESTRICTIONS:
  34 +; The dustem fortran code must be installed
  35 +; The dustem idl wrapper must be installed
  36 +; The path of the ISRF must be assigned to one of the dustemwrap free pointers.
  37 +; Two calls of the plugin are necessary if fitting of G0 through this plugin is done.
  38 +; The user-defined ISRF needs to be on the same dustem ISRF grid.
  39 +; PROCEDURE:
  40 +; This is a dustem plugin
  41 +;-
  42 +;-
  43 +
  44 +IF keyword_set(help) THEN BEGIN
  45 + doc_library,'dustem_plugin_modify_isrf'
  46 + goto,the_end
  47 +ENDIF
  48 +
  49 +IF keyword_set(scope) THEN BEGIN
  50 + out=0
  51 + goto, the_end
  52 +ENDIF
  53 +
  54 +IF keyword_set(paramtag) THEN BEGIN
  55 + out=0
  56 + goto, the_end
  57 +ENDIF
  58 +
  59 +out=0;?
  60 +G0=1.
  61 +IF keyword_set(key) THEN BEGIN
  62 +
  63 + ind1=where(key EQ 1,count1) ;G0/gas.GO is present in PD vector
  64 + ind2=where(key EQ 2,count2) ;G0/gas.GO is not present in PD vector
  65 +
  66 + IF count1 NE 0 then begin
  67 +
  68 + file_idx=val[ind1[0]]
  69 + file_str = 'file=(*!dustem_free'+strtrim(string(fix(file_idx)),2)+')'
  70 + toto = execute(file_str)
  71 +
  72 + ENDIF
  73 +
  74 + IF count2 NE 0 then begin
  75 +
  76 + G0=val[ind2[0]]
  77 +
  78 + ENDIF
  79 +
  80 +ENDIF
  81 +
  82 +;This is because the mathis ISRF is automatically read and written.
  83 +;We just need the wavelengths. This means that this wavelength vector is the dustem (IAS) provided one.
  84 +;We don't use the ISRF values in this structure to read the mathis ISRF because
  85 +;the ISRF in this structure might be the altered one.
  86 +st=((*!dustem_params).isrf) ;this is just to read the wavelengths
  87 +
  88 +;storing the mathis isrf in variable mathis_isrf - if the user wants to use
  89 +ma_isrf_dir=!dustem_soft_dir+'data/ISRF_MATHIS.DAT'
  90 +ma_isrf=dustem_read_isrf(ma_isrf_dir)
  91 +
  92 +if isa(file) then user_ISRF = dustem_read_isrf(file)
  93 +
  94 +
  95 +IF isa(ma_isrf) THEN Ncomments=5 ELSE Ncomments=4
  96 +
  97 +c = strarr(Ncomments)
  98 +
  99 +;First and last lines of the new composite ISRF.DAT file
  100 +c(0)='# DUSTEM: exciting radiation field featuring'
  101 +IF isa(ma_isrf) THEN BEGIN
  102 +
  103 + c(1)='# Mathis ISRF'
  104 + c(2)='# User ISRF'
  105 +
  106 +ENDIF ELSE c(1)='# User ISRF'
  107 +c(Ncomments-2)='# Nbr of points'
  108 +c(Ncomments-1)='# wave (microns), 4*pi*Inu (erg/cm2/s/Hz)'
  109 +
  110 +;decided to do something else:
  111 +IF G0 EQ 1. THEN BEGIN
  112 + IF ((*!dustem_params).g0) NE 1. THEN G0 = ((*!dustem_params).g0)
  113 + IF ((*!dustem_params).gas.g0) NE 1. THEN G0 = ((*!dustem_params).gas.g0)
  114 +ENDIF
  115 +
  116 +IF isa(ma_isrf) THEN st.isrf=ma_isrf.isrf+user_ISRF/(G0) ELSE st.isrf=user_ISRF
  117 +
  118 +;TEST IF THE PLUGIN WORKSs
  119 +; print,'The user_ISRF is:'
  120 +;
  121 +; print, user_isrf
  122 +;
  123 +; print, 'Final isrf is:'
  124 +; print, st.isrf
  125 +
  126 +
  127 +file=!dustem_dat+'data/ISRF.DAT'
  128 +openw,unit,file,/get_lun
  129 +
  130 +FOR i=0,Ncomments-1 DO BEGIN
  131 + printf,unit,c(i)
  132 +ENDFOR
  133 +
  134 +n_waves=n_elements(st)
  135 +printf,unit,n_waves
  136 +
  137 +FOR i=0L,n_waves-1 DO BEGIN
  138 + printf,unit,st(i).lambisrf,st(i).isrf
  139 +ENDFOR
  140 +
  141 +close,unit
  142 +free_lun,unit
  143 +
  144 +out=st.isrf
  145 +
  146 +the_end:
  147 +scope='USER_ISRF'
  148 +
  149 +;paramtag will only matter if G0 is fitted through the plugin.
  150 +paramtag=['G0']
  151 +
  152 +return, out
  153 +end
0 154 \ No newline at end of file
... ...