Commit 1f71e1370a17aa89156c89ce414c9cf548ac9dac

Authored by Annie Hughes
1 parent 52a3c8dc
Exists in master

first commit

src/idl/dustem_fit_sed_ext_stokesi_example.pro 0 → 100644
... ... @@ -0,0 +1,300 @@
  1 +PRO dustem_fit_sed_ext_stokesi_example,model=model $
  2 + ,sed_file=sed_file $
  3 + ,ext_file=ext_file $
  4 + ,Nitermax=Nitermax $
  5 + ,fits_save=fits_save $
  6 + ,wait=wait $
  7 + ,noobj=noobj $
  8 + ,help=help $
  9 + ,verbose=verbose
  10 +
  11 +;+
  12 +; NAME:
  13 +; dustem_fit_sed_ext_stokesi_example
  14 +;
  15 +; PURPOSE: This routine is an example of how to fit an observational
  16 +; data in emission + extinction SED (StokesI only) with DustEM and
  17 +; DustEMWrap.
  18 +;
  19 +; See the DustEMWrap User Guide for more information.
  20 +;
  21 +; CATEGORY:
  22 +; DustEMWrap, Distributed, High-Level, User Example
  23 +;
  24 +; CALLING SEQUENCE:
  25 +; dustem_fit_sed_ext_stokesi_example[,model=][sed_file=][ext_file=][,Nitermax=][,fits_save=][,/help,/wait,/verbose,/noobj]
  26 +;
  27 +; INPUTS:
  28 +; None
  29 +;
  30 +; OPTIONAL INPUT PARAMETERS:
  31 +; None
  32 +;
  33 +; OUTPUTS:
  34 +; None
  35 +;
  36 +; OPTIONAL OUTPUT PARAMETERS:
  37 +; Plots, results structure in binary FITS table format
  38 +;
  39 +; ACCEPTED KEY-WORDS:
  40 +; model = specifies the interstellar dust mixture used by
  41 +; DustEM. See userguide or dustem_test_model_exists.pro
  42 +; for more details about available models in current
  43 +; release. Default for this example is J13.
  44 +; sed_file = string naming the path to text file in .xcat format that
  45 +; describes the observational SED. If not set, the file
  46 +; 'Data/EXAMPLE_OBSDATA/example_SED_3.xcat' is used to
  47 +; identify the filters, and the model is used to generate a
  48 +; predicted SED.
  49 +; ext_file = string naming the path to text file in .xcat format that
  50 +; describes the observational extinction SED. If not set, the file
  51 +; 'Data/EXAMPLE_OBSDATA/Mathis90Fitz99_DISM_NH20.xcat' is
  52 +; used to identify the wavelength range, and the dust model
  53 +; is used to generate the corresponding extinction.
  54 +; Nitermax = maximum number of fit iterations. Default is 5.
  55 +; fits_save = if set, save the fit results in a binary
  56 +; FITS file. The code then restore this file and plots
  57 +; the results using the saved results information.
  58 +; help = if set, print this help
  59 +; wait = if set, wait this many seconds between each step of
  60 +; the code (for illustration purposes)
  61 +; verbose = if set, subroutines will run in verbose mode
  62 +; noobj = if set, runs with no object graphics
  63 +;
  64 +; COMMON BLOCKS:
  65 +; None
  66 +;
  67 +; SIDE EFFECTS:
  68 +; None
  69 +;
  70 +; RESTRICTIONS:
  71 +; The DustEM fortran code must be installed
  72 +; The DustEMWrap IDL code must be installed
  73 +;
  74 +; PROCEDURES AND SUBROUTINES USED:
  75 +;
  76 +; EXAMPLES
  77 +; dustem_fit_sed_ext_stokesi_example
  78 +; dustem_fit_sed_ext_stokesi_example,Nitermax=1,fits_save='/tmp/mysavefile.fits'
  79 +; dustem_fit_sed_ext_stokesi_example,model='MC10'
  80 +;
  81 +; MODIFICATION HISTORY:
  82 +; Written by JPB Apr-2011
  83 +; Evolution details on the DustEMWrap gitlab.
  84 +; See http://dustemwrap.irap.omp.eu/ for FAQ and help.
  85 +;-
  86 +
  87 +IF keyword_set(help) THEN BEGIN
  88 + doc_library,'dustem_fit_sed_ext_stokesi_example'
  89 + goto,the_end
  90 +END
  91 +
  92 +IF keyword_set(model) THEN BEGIN
  93 + use_model=strupcase(model)
  94 +ENDIF ELSE BEGIN
  95 + use_model='J13'
  96 +ENDELSE
  97 +
  98 +exists=dustem_test_model_exists(use_model)
  99 +if exists ne 1 then $
  100 + message,'Unknown dust model: '+use_model
  101 +
  102 +use_polarization=0 ;default is no polarization in models
  103 +use_window=2 ; default graphics window number to use for plotting the results
  104 +use_verbose=0
  105 +if keyword_set(verbose) then use_verbose=1
  106 +use_Nitermax=5 ; maximum number of iterations for the fit
  107 +IF keyword_set(Nitermax) THEN use_Nitermax=Nitermax
  108 +
  109 +dustem_define_la_common
  110 +
  111 +;=== Set the (model-dependent) parameters that you want to fit
  112 +;=== Refer to the DustEM and DustEMWrap userguides for an explanation
  113 +; of the different grain types
  114 +
  115 +;=== Set the (model-dependent) parameters that you want to fit (pd),
  116 +;=== their initial values (iv)
  117 +;=== and whether they are bounded (ulimed,llimed,llims,ulims).
  118 +;=== Fixed parameters (fpd) and their values (fiv) are also set here.
  119 +;=== Refer to the DustEM and DustEMWrap User guides for an explanation
  120 +;=== of the physical meaning of dust model and plug-in parameters, and
  121 +;=== how to specify them.
  122 +
  123 +;; ;=== AN EXAMPLE FOR J13
  124 +;; ;=== Here we fit the dust abundances of the J13 model, the
  125 +;; ;=== intensity of the dust-heating radiation field as well as two plug-ins:
  126 +;; ;=== (i) free-free emission
  127 +;; ;=== (ii)continuum due to a blackbody
  128 +;; ;=== The temperature of the blackbody is fixed to 1000K
  129 +;; ;=== The free parameters in the fit are all lower-bounded at zero.
  130 +
  131 +;=== If you choose a different dust model, you will need to adjust the
  132 +;=== parameter information accordingly.
  133 +
  134 +pd = [ $
  135 + '(*!dustem_params).G0' $ ;G0
  136 + ,'(*!dustem_params).grains(0).mdust_o_mh'$ ;CM20 -- power law size distribution
  137 + ,'(*!dustem_params).grains(1).mdust_o_mh'$ ;CM20 -- logN size distribution
  138 + ,'(*!dustem_params).grains(2).mdust_o_mh' $ ;aPyM5
  139 + ,'(*!dustem_params).grains(3).mdust_o_mh' $ ;aOlM5
  140 + ,'dustem_plugin_continuum_2'] ;Intensity at peak of the BB continuum
  141 +true_vals = [1.5,1.8e-3, 6.e-4, 3.5e-3, 3.55e-3, 0.003]
  142 +iv = [1.2,1.7e-3, 6.3e-4, 2.55e-3, 2.55e-3, 0.001]
  143 +Npar=n_elements(pd)
  144 +ulimed=replicate(0,Npar)
  145 +llimed=replicate(1,Npar)
  146 +llims=replicate(1.e-15,Npar)
  147 +fpd=[ 'dustem_plugin_continuum_1'] ; Temperature of the BB
  148 +fiv=[1000.]
  149 +
  150 +
  151 +
  152 +if keyword_set(wait) then begin
  153 + message,'Finished setting dust model and plug-in parameters: '+use_model,/info
  154 + wait,wait
  155 +end
  156 +
  157 +;== INITIALISE DUSTEM
  158 +dustem_init,model=use_model,polarization=use_polarization
  159 +!dustem_nocatch=1
  160 +!dustem_verbose=use_verbose
  161 +IF keyword_set(noobj) THEN !dustem_noobj=1
  162 +!EXCEPT=2 ; for debugging
  163 +
  164 +
  165 +;=== READ TEMPLATE EXTINCTION DATA
  166 +;=== IF THE USER DOES NOT PROVIDE AN EXTINCTION CURVE FILE , WE READ MATHIS TO INITIALISE THE OBSERVATIONAL STRUCTURE.
  167 +dir=!dustem_wrap_soft_dir+'/Data/EXAMPLE_OBSDATA/'
  168 +use_ext_file=dir+'Mathis90Fitz99_DISM_NH20.xcat'
  169 +IF keyword_set(ext_file) THEN use_ext_file=ext_file
  170 +ext=read_xcat(use_ext_file,/silent)
  171 +IF not keyword_set(ext_file) THEN BEGIN
  172 + message, 'You have not provided an extinction curve. I will generate one from the '+use_model+' dust model',/info
  173 + ext.EXT_I=1.
  174 +ENDIF
  175 +
  176 +
  177 +
  178 +;=== READ TEMPLATE EMISSION DATA
  179 +;=== IF THE USER DOES NOT PROVIDE A SED FILE , WE READ AN EXAMPLE_SED FILE TO INITIALISE THE OBSERVATIONAL STRUCTURE.
  180 +dir=!dustem_wrap_soft_dir+'/Data/EXAMPLE_OBSDATA/'
  181 +file=dir+'example_SED_2.xcat'
  182 +if keyword_set(sed_file) then file=sed_file
  183 +sed=read_xcat(file,/silent)
  184 +IF not keyword_set(sed_file) THEN BEGIN
  185 + message, 'You have not provided an SED. I will generate one from the '+use_model+' dust model',/info
  186 + sed.StokesI=1.
  187 +ENDIF
  188 +
  189 +
  190 +;=== HERE WE SET THE DATA SO THAT THE COMPUTE_ FUNCTIONS BELOW HAVE
  191 +;=== THE NECESSARY FIELDS AND INFORMATION
  192 +dustem_set_data,m_fit=sed,m_show=sed,x_fit=ext,x_show=ext
  193 +
  194 +;== SET INITIAL VALUES AND LIMITS OF THE PARAMETERS FOR THE FIT
  195 +;== AND ACTIVATE ANY PLUGINS (HENCE WE NEED TO DO THIS BEFORE THE COMPUTE_ CALLS)
  196 +dustem_init_params,use_model,pd,iv,fpd=fpd,fiv=fiv,ulimed=ulimed,llimed=llimed,ulims=ulims,llims=llims,polarization=use_polarization
  197 +
  198 +if keyword_set(wait) then begin
  199 + message,'Finished initializing DustEMWrap, including plugins and fixed parameters',/info
  200 + wait,wait
  201 +end
  202 +
  203 +;== GENERATE THE EXTINCTION DATA USING THE MODEL AND TRUE VALUES
  204 +if not keyword_set(ext_file) then $
  205 + ext.EXT_I = dustem_compute_ext(true_vals,st=st)
  206 +
  207 +;== GENERATE THE EMISSION DATA USING THE MODEL AND TRUE VALUES
  208 +IF not keyword_set(sed_file) THEN $
  209 + sed.StokesI = dustem_compute_sed(true_vals,st=st)
  210 +
  211 +;=== RESET THE OBSERVATIONAL STRUCTURE IF WE HAVE GENERATED DATA USING
  212 +;=== A MODEL
  213 +if not keyword_set(ext_file) or not keyword_set(sed_file) THEN BEGIN
  214 + dustem_set_data, m_fit=sed,m_show=sed,x_fit=ext,x_show=ext
  215 + if keyword_set(wait) then begin
  216 + message,'Finished generating data from the model '+use_model,/info
  217 + wait,wait
  218 + end
  219 +end
  220 +
  221 +
  222 +;== INFORMATION TO RUN THE FIT
  223 +tol=1.e-10 ;fit tolerence
  224 +
  225 +;=== INFORMATION TO MAKE THE PLOT
  226 +;=== _x/_extinction means extinction plots, _m/_emissions means emission plots
  227 +xr_x = [0.01,30]
  228 +yr_x = [5.00E-8,10]
  229 +xr_m = [1.,5e5]
  230 +yr_m = [5e-8,1.00e6]
  231 +tit_m='Spectral Energy Distribution'
  232 +tit_x='Dust Optical Depth'
  233 +
  234 +;=== RUN THE FIT
  235 +t1=systime(0,/sec)
  236 +res=dustem_mpfit_data(tol=tol,Nitermax=use_Nitermax,gtol=gtol $
  237 + ,/xlog,/ylog,xr_m=xr_m,yr_m=yr_m,xr_x=xr_x,yr_x=yr_x,xtit=xtit,ytit=ytit,tit_m=tit_m,tit_x=tit_x $
  238 + ,legend_xpos=legend_xpos,legend_ypos=legend_ypos $
  239 + ,errors=errors,chi2=chi2,rchi2=rchi2,show_plot=show_plot)
  240 +t2=systime(0,/sec)
  241 +
  242 +if keyword_set(wait) then begin
  243 + message,'Finished running DustEMWrap, using Niters: '+strtrim(string(use_Nitermax),2),/info
  244 + message,'Time taken [sec]: '+sigfig(t2-t1,2,/sci),/info
  245 + wait,wait
  246 +end
  247 +
  248 +
  249 +;=== MAKE THE FINAL PLOT
  250 +IF keyword_set(postscript) THEN BEGIN
  251 + dir_ps='./'
  252 + set_plot,'PS'
  253 + ps_file=dir_ps+postscript
  254 + device,filename=ps_file,/color
  255 +ENDIF
  256 +
  257 +IF !dustem_noobj THEN BEGIN
  258 + dustemwrap_plot_noobj,(*(*!dustem_fit).CURRENT_PARAM_VALUES),st=dummy,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,tit_m=tit_m+' (Final fit)',tit_x=tit_x+' (Final fit)'
  259 +ENDIF ELSE BEGIN
  260 + dustemwrap_plot,(*(*!dustem_fit).CURRENT_PARAM_VALUES),st=dummy,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,tit_m=tit_m+' (Final fit)',tit_x=tit_x+' (Final fit)'
  261 +ENDELSE
  262 +
  263 +IF keyword_set(postscript) THEN BEGIN
  264 + set_plot,'X'
  265 + device,/close
  266 + message,'Wrote '+ps_file,/info
  267 +ENDIF
  268 +
  269 +if keyword_set(wait) then begin
  270 + message,'Made the plot of the final results',/info
  271 + wait,wait
  272 +end
  273 +
  274 +
  275 +IF keyword_set(fits_save) THEN BEGIN
  276 + message,'Writing out results structure: '+fits_save,/info
  277 + dustem_write_fits_table,filename=fits_save,help=help
  278 +;=== At this point, you could erase all dustem system variables, or exit idl... all the
  279 +;=== information needed to recover the results and remake the plots has been saved in the FITS table
  280 +
  281 +;; dustem_read_fits_table,filename=fits_save,dustem_st=dustem_spectra_st
  282 +;; ;==== plot result taken from the saved fits table
  283 +;; res=*(*!dustem_fit).CURRENT_PARAM_VALUES
  284 +;; ;If the user prefers non-OOP plotting then reset !dustem_noobj=1 here since dustem_init is called in reads_fits_table.
  285 +;; IF !dustem_noobj THEN BEGIN
  286 +;; dustemwrap_plot_noobj,res,st=dustem_spectra_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,tit_m=tit_m+' (From Saved FITS file)',tit_x=tit_x+' (From Saved FITS file)'
  287 +;; ENDIF ELSE BEGIN
  288 +;; dustemwrap_plot,res,st=dustem_spectra_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,tit_m=tit_m+' (From Saved FITS file)',tit_x=tit_x+' (From Saved FITS file)'
  289 +;; ENDELSE
  290 +
  291 + IF keyword_set(wait) THEN BEGIN
  292 + message,'Saved the results as FITS in the file: '+fits_save,/info
  293 + wait,wait
  294 + ENDIF
  295 +ENDIF
  296 +
  297 +the_end:
  298 +message,'Finished dustem_fit_sed_ext_stokesi_example',/info
  299 +
  300 +END
... ...
src/idl/dustem_fitsio_example.pro 0 → 100644
... ... @@ -0,0 +1,176 @@
  1 +PRO dustem_fitsio_example,help=help
  2 +
  3 +;+
  4 +; NAME:
  5 +; dustem_fitsio_example
  6 +;
  7 +; PURPOSE:
  8 +; Testing the save/restore FITS files
  9 +;
  10 +; CATEGORY:
  11 +; DustEMWrap, Distributed, Low-Level, Development
  12 +;
  13 +; CALLING SEQUENCE:
  14 +; dustem_fitsio_example
  15 +;
  16 +; INPUTS:
  17 +; None
  18 +;
  19 +; OPTIONAL INPUT PARAMETERS:
  20 +;
  21 +; OUTPUTS:
  22 +;
  23 +; OPTIONAL OUTPUT PARAMETERS:
  24 +;
  25 +; ACCEPTED KEY-WORDS:
  26 +; help = print this help
  27 +;
  28 +; COMMON BLOCKS:
  29 +; None
  30 +;
  31 +; SIDE EFFECTS:
  32 +; None
  33 +;
  34 +; RESTRICTIONS:
  35 +; The DustEM fortran code must be installed
  36 +; The DustEMWrap IDL code must be installed
  37 +;
  38 +; PROCEDURES AND SUBROUTINES USED:
  39 +;
  40 +; EXAMPLES
  41 +;
  42 +; MODIFICATION HISTORY:
  43 +; Written by AH Apr-2023
  44 +; Evolution details on the DustEMWrap gitlab.
  45 +; See http://dustemwrap.irap.omp.eu/ for FAQ and help.
  46 +;+
  47 +
  48 +if keyword_set(help) then begin
  49 + doc_library,'dustem_fitsio_example'
  50 + goto,the_end
  51 +END
  52 +
  53 +
  54 +dustem_fit_intensity_example,Nitermax=2,fits_save='/tmp/example_fit_intensity_only.fits'
  55 +;exit/.reset
  56 +dustem_read_fits_table,filename='/tmp/example_fit_intensity_only.fits',dustem_st=dustem_spectra_st
  57 +
  58 +yr=[1.00e-4,1.00E2] ; y-axis limits
  59 +xr=[1.00E0,6.00e4] ; x-axis limits
  60 +tit='FIT INTENSITY EXAMPLE' ; plot title
  61 +ytit=textoidl('I_\nu (MJy/sr) for N_H=10^{20} H/cm^2') ; y-axis title
  62 +xtit=textoidl('\lambda (\mum)') ; x-axis title
  63 +res=*(*!dustem_fit).CURRENT_PARAM_VALUES
  64 +dustemwrap_plot,res,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)'
  65 +
  66 +
  67 +stop
  68 +dustem_fit_spectro_example,Nitermax=2,fits_save='/tmp/example_fit_spectro.fits'
  69 +;exit/.reset
  70 +dustem_read_fits_table,filename='/tmp/example_fit_spectro_only.fits',dustem_st=dustem_spectra_st
  71 +xr = [1.,5e5]
  72 +yr = [5e-8,1.00e6]
  73 +tit='FIT SPECTRO EXAMPLE' ; plot title
  74 +res=*(*!dustem_fit).CURRENT_PARAM_VALUES
  75 +dustemwrap_plot,res,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)'
  76 +
  77 +
  78 +stop
  79 +
  80 +dustem_fit_intensity_mbb_example,Nitermax=2,fits_save='/tmp/example_fit_mbb.fits'
  81 +;exit/.reset
  82 +dustem_read_fits_table,filename='/tmp/example_fit_mbb.fits',dustem_st=dustem_spectra_st
  83 +yr=[1.00e-4,1.00E2] ; y-axis limits
  84 +xr=[1.00E0,6.00e4] ; x-axis limits
  85 +tit='MBB FIT EXAMPLE' ; plot title
  86 +ytit=textoidl('I_\nu (MJy/sr) for N_H=10^{20} H/cm^2') ; y-axis title
  87 +xtit=textoidl('\lambda (\mum)') ; x-axis title
  88 +res=*(*!dustem_fit).CURRENT_PARAM_VALUES
  89 +dustemwrap_plot,res,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)'
  90 +
  91 +
  92 +stop
  93 +dustem_fit_polarization_example,Nitermax=2,fits_save='/tmp/example_fit_polar.fits'
  94 +;exit/.reset
  95 +dustem_read_fits_table,filename='/tmp/example_fit_polar.fits',dustem_st=dustem_spectra_st
  96 +yr=[1.00e-4,1.00E2] ; y-axis limits
  97 +xr=[1.00E0,6.00e4] ; x-axis limits
  98 +tit='FIT POLARISATION SED EXAMPLE' ; plot title
  99 +res=*(*!dustem_fit).CURRENT_PARAM_VALUES
  100 +dustemwrap_plot,res,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)'
  101 +
  102 +
  103 +stop
  104 +dustem_fit_ext_example,Nitermax=2,fits_save='/tmp/example_fit_ext.fits'
  105 +;exit/.reset
  106 +dustem_read_fits_table,filename='/tmp/example_fit_ext.fits',dustem_st=dustem_spectra_st
  107 +xr=[0.01,30]
  108 +yr=[1.00E-10,10]
  109 +tit='FIT EXTINCTION EXAMPLE' ; plot title
  110 +res=*(*!dustem_fit).CURRENT_PARAM_VALUES
  111 +dustemwrap_plot,res,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)'
  112 +
  113 +
  114 +stop
  115 +dustem_fit_ext_pol_example,Nitermax=2,fits_save='/tmp/example_fit_ext_polar.fits'
  116 +;exit/.reset
  117 +dustem_read_fits_table,filename='/tmp/example_fit_ext_polar.fits',dustem_st=dustem_spectra_st
  118 +xr=[0.01,30]
  119 +yr=[1.00E-10,50]
  120 +tit='FIT POLARISED EXTINCTION EXAMPLE' ; plot title
  121 +res=*(*!dustem_fit).CURRENT_PARAM_VALUES
  122 +dustemwrap_plot,res,st=dustem_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)'
  123 +
  124 +stop
  125 +dustem_fit_sed_ext_stokesi_example,Nitermax=2,fits_save='/tmp/example_fit_sed_ext_stokesi.fits'
  126 +;exit/.reset
  127 +dustem_read_fits_table,filename='/tmp/example_fit_sed_ext_stokesi.fits',dustem_st=dustem_spectra_st
  128 +xr_x = [0.01,30]
  129 +yr_x = [5.00E-8,10]
  130 +xr_m = [1.,5e5]
  131 +yr_m = [5e-8,1.00e6]
  132 +tit_m='Spectral Energy Distribution'
  133 +tit_x='Dust Optical Depth'
  134 +tit='FIT STOKESI EXTINCTION AND EMISSION EXAMPLE' ; plot title
  135 +res=*(*!dustem_fit).CURRENT_PARAM_VALUES
  136 +dustemwrap_plot,res,st=dustem_st,xr_x=xr_x,xr_m=xr_m,/xstyle,yr_x=yr_x,yr_m=yr_m,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)'
  137 +
  138 +
  139 +stop
  140 +dustem_fit_sed_ext_pol_example,Nitermax=2,fits_save='/tmp/example_fit_sed_ext_polar.fits'
  141 +;exit/.reset
  142 +dustem_read_fits_table,filename='/tmp/example_fit_sed_ext_polar.fits',dustem_st=dustem_spectra_st
  143 +xr_x = [0.01,30]
  144 +yr_x = [5.00E-8,10]
  145 +xr_m = [1.,5e5]
  146 +yr_m = [5e-8,1.00e6]
  147 +tit_m='Spectral Energy Distribution'
  148 +tit_x='Dust Optical Depth'
  149 +tit='FIT POLARISED EXTINCTION AND EMISSION EXAMPLE' ; plot title
  150 +res=*(*!dustem_fit).CURRENT_PARAM_VALUES
  151 +dustemwrap_plot,res,st=dustem_st,xr_x=xr_x,xr_m=xr_m,/xstyle,yr_x=yr_x,yr_m=yr_m,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)'
  152 +
  153 +stop
  154 +dustem_myisrf_example,Nitermax=2,fits_save='/tmp/example_fit_isrf.fits'
  155 +;exit/.reset
  156 +dustem_read_fits_table,filename='/tmp/example_fit_isrf.fits',dustem_st=dustem_spectra_st
  157 +xr_m = [1.,5e5]
  158 +yr_m = [5e-8,1.00e6]
  159 +tit_m='Spectral Energy Distribution'
  160 +tit='FIT WITH USER ISRF EXAMPLE' ; plot title
  161 +res=*(*!dustem_fit).CURRENT_PARAM_VALUES
  162 +dustemwrap_plot,res,st=dustem_st,xr_m=xr_m,/xstyle,yr_m=yr_m,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)'
  163 +
  164 +
  165 +
  166 +
  167 +
  168 +;=== fails when run with only the minimal dustemwrap installed (stellar . txt file is missing)
  169 +dustem_stellarpopisrf_example,Nitermax=3
  170 +
  171 +
  172 +
  173 +
  174 +; END LIST OF TOP-LEVEL ROUTINES
  175 +
  176 +end
... ...