diff --git a/src/idl/dustem_fit_ext_example.pro b/src/idl/dustem_fit_ext_example.pro index 76d73c0..ea7212e 100644 --- a/src/idl/dustem_fit_ext_example.pro +++ b/src/idl/dustem_fit_ext_example.pro @@ -1,7 +1,8 @@ PRO dustem_fit_ext_example,model=model $ ,ext_file=ext_file $ ,Nitermax=Nitermax $ - ,fits_save=fits_save $ + ,postscript=postscript $ + ,fits_save=fits_save $ ,wait=wait $ ,noobj=noobj $ ,help=help $ @@ -21,7 +22,7 @@ PRO dustem_fit_ext_example,model=model $ ; DustEMWrap, Distributed, High-Level, User Example ; ; CALLING SEQUENCE: -; dustem_fit_ext_example[,model=][ext_file=][,Nitermax=][,fits_save=][,/help,/wait,/verbose,/noobj] +; dustem_fit_ext_example[,model=][ext_file=][,postscript=][,Nitermax=][,fits_save=][,/help,/wait,/verbose,/noobj] ; ; INPUTS: ; None @@ -42,10 +43,10 @@ PRO dustem_fit_ext_example,model=model $ ; ext_file = string naming the path to text file in .xcat format that ; describes the observational extinction SED. If not set, the file ; 'Data/EXAMPLE_OBSDATA/Mathis90Fitz99_DISM_NH20.xcat' is used. +; postscript = if set, final plot is saved as postscript file ; Nitermax = maximum number of fit iterations. Default is 5. ; fits_save = if set, save the fit results in a binary -; FITS file. The code then restore this file and plots -; the results using the saved results information. +; FITS file. ; help = if set, print this help ; wait = if set, wait this many seconds between each step of ; the code (for illustration purposes) @@ -193,6 +194,28 @@ if keyword_set(wait) then begin wait,wait end +;=== MAKE THE FINAL PLOT +IF keyword_set(postscript) THEN BEGIN +; dir_ps='./' + mydevice=!d.name + set_plot,'PS' +; ps_file=dir_ps+postscript + ps_file=postscript + device,filename=ps_file,/color +ENDIF + +IF !dustem_noobj THEN BEGIN + dustemwrap_plot_noobj,*(*!dustem_fit).CURRENT_PARAM_VALUES,st=dummy,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (Final fit)' + ENDIF ELSE BEGIN + dustemwrap_plot,*(*!dustem_fit).CURRENT_PARAM_VALUES,st=dummy,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (Final fit)' +ENDELSE + +IF keyword_set(postscript) THEN BEGIN + device,/close + set_plot,mydevice + message,'Wrote '+ps_file,/info +ENDIF + IF keyword_set(fits_save) THEN BEGIN message,'Writing out results structure: '+fits_save,/info dustem_write_fits_table,filename=fits_save,help=help diff --git a/src/idl/dustem_fit_ext_pol_example.pro b/src/idl/dustem_fit_ext_pol_example.pro index bd184cb..c34d580 100755 --- a/src/idl/dustem_fit_ext_pol_example.pro +++ b/src/idl/dustem_fit_ext_pol_example.pro @@ -1,7 +1,8 @@ PRO dustem_fit_ext_pol_example,model=model $ ,ext_file=ext_file $ ,Nitermax=Nitermax $ - ,fits_save=fits_save $ + ,postscript=postscript $ + ,fits_save=fits_save $ ,wait=wait $ ,noobj=noobj $ ,help=help $ @@ -21,7 +22,7 @@ PRO dustem_fit_ext_pol_example,model=model $ ; DustEMWrap, Distributed, High-Level, User Example ; ; CALLING SEQUENCE: -; dustem_fit_ext_pol_example[,model=][ext_file=][,Nitermax=][,fits_save=][,/help,/wait,/verbose,/noobj] +; dustem_fit_ext_pol_example[,model=][ext_file=][,postscript=][,Nitermax=][,fits_save=][,/help,/wait,/verbose,/noobj] ; ; INPUTS: ; None @@ -46,10 +47,9 @@ PRO dustem_fit_ext_pol_example,model=model $ ; used to define the observational structure, and a synthetic ; observation is generated using the dust model. ; Nitermax = maximum number of fit iterations. Default is 5. +; postscript = if set, final plot is saved as postscript file ; fits_save = if set, save the fit results in a binary -; FITS file. The code then restore this file and plots -; the results using the saved results information. -; help = if set, print this help +; FITS file. ; wait = if set, wait this many seconds between each step of ; the code (for illustration purposes) ; verbose = if set, subroutines will run in verbose mode @@ -240,6 +240,33 @@ if keyword_set(wait) then begin wait,wait end +;=== MAKE THE FINAL PLOT +IF keyword_set(postscript) THEN BEGIN +; dir_ps='./' + mydevice=!d.name + set_plot,'PS' +; ps_file=dir_ps+postscript + ps_file=postscript + device,filename=ps_file,/color +ENDIF + +;stop + +IF !dustem_noobj THEN BEGIN + dustemwrap_plot_noobj,*(*!dustem_fit).CURRENT_PARAM_VALUES,st=dummy,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (Final fit)' + ENDIF ELSE BEGIN + dustemwrap_plot,*(*!dustem_fit).CURRENT_PARAM_VALUES,st=dummy,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (Final fit)' +ENDELSE + +IF keyword_set(postscript) THEN BEGIN + device,/close + set_plot,mydevice + message,'Wrote '+ps_file,/info +ENDIF + + + + IF keyword_set(fits_save) THEN BEGIN message,'Writing out results structure: '+fits_save,/info dustem_write_fits_table,filename=fits_save,help=help @@ -262,8 +289,8 @@ IF keyword_set(fits_save) THEN BEGIN ENDIF ENDIF -message,'Finished dustem_fit_ext_pol_example',/info the_end: +message,'Finished dustem_fit_ext_pol_example',/info END diff --git a/src/idl/dustem_fit_intensity_example.pro b/src/idl/dustem_fit_intensity_example.pro index 50487f9..1be4180 100644 --- a/src/idl/dustem_fit_intensity_example.pro +++ b/src/idl/dustem_fit_intensity_example.pro @@ -52,8 +52,7 @@ PRO dustem_fit_intensity_example,model=model $ ; sed_file = string naming the path to text file in .xcat format that ; describes the observational SED. If not set, the file ; 'Data/EXAMPLE_OBSDATA/example_SED_1.xcat' is used. -; postscript = if set, final plot is saved as postscript in the -; current working directory +; postscript = if set, final plot is saved as postscript file ; Nitermax = maximum number of fit iterations. Default is 5. ; fits_save = if set, save the fit results in a binary ; FITS file. @@ -319,12 +318,13 @@ if keyword_set(wait) then begin wait,wait end - ;=== MAKE THE FINAL PLOT IF keyword_set(postscript) THEN BEGIN - dir_ps='./' +; dir_ps='./' + mydevice=!d.name set_plot,'PS' - ps_file=dir_ps+postscript +; ps_file=dir_ps+postscript + ps_file=postscript device,filename=ps_file,/color ENDIF @@ -337,8 +337,8 @@ IF !dustem_noobj THEN BEGIN ENDELSE IF keyword_set(postscript) THEN BEGIN - set_plot,'X' device,/close + set_plot,mydevice message,'Wrote '+ps_file,/info ENDIF diff --git a/src/idl/dustem_fit_intensity_mbb_example.pro b/src/idl/dustem_fit_intensity_mbb_example.pro index 5715ff2..1acdaaf 100644 --- a/src/idl/dustem_fit_intensity_mbb_example.pro +++ b/src/idl/dustem_fit_intensity_mbb_example.pro @@ -3,6 +3,7 @@ PRO dustem_fit_intensity_mbb_example,model=model $ ,Nitermax=Nitermax $ ,postscript=postscript $ ,fits_save=fits_save $ + ,noobj=noobj $ ,help=help $ ,wait=wait $ ,verbose=verbose @@ -53,8 +54,7 @@ PRO dustem_fit_intensity_mbb_example,model=model $ ; sed_file = string naming the path to text file in .xcat format that ; describes the observational SED. If not set, the file ; 'Data/EXAMPLE_OBSDATA/example_SED_1.xcat' is used. -; postscript = if set, final plot is saved as postscript in the -; current working directory +; postscript = if set, final plot is saved as postscript ; Nitermax = maximum number of fit iterations. Default is 5. ; fits_save = if set, save the fit results in a binary ; FITS file. @@ -62,6 +62,7 @@ PRO dustem_fit_intensity_mbb_example,model=model $ ; wait = if set, wait this many seconds between each step of ; the code (for illustration purposes) ; verbose = if set, subroutines will run in verbose mode +; noobj = if set, runs with no object graphics ; ; COMMON BLOCKS: ; None @@ -164,7 +165,7 @@ end dustem_init,model=use_model,polarization=use_polarization !dustem_nocatch=1 !dustem_verbose=use_verbose -;!dustem_show_plot=1 +IF keyword_set(noobj) THEN !dustem_noobj=1 ;=== READ EXAMPLE SED DATA @@ -224,11 +225,13 @@ ENDIF ;=== MAKE THE FINAL PLOT IF keyword_set(postscript) THEN BEGIN ;dir_ps='./' + mydevice=!d.name set_plot,'PS' ;ps_file=dir_ps+postscript ps_file=postscript device,filename=ps_file,/color -ENDIF + ENDIF + IF !dustem_noobj THEN BEGIN dustemwrap_plot_noobj,*(*!dustem_fit).CURRENT_PARAM_VALUES,st=dummy,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (Final fit)' ENDIF ELSE BEGIN @@ -236,8 +239,8 @@ ENDIF ELSE BEGIN ENDELSE IF keyword_set(postscript) THEN BEGIN - device,/close set_plot,'X' + set_plot,mydevice message,'Wrote '+ps_file,/info ENDIF diff --git a/src/idl/dustem_fit_polarization_example.pro b/src/idl/dustem_fit_polarization_example.pro index dea00a6..62db683 100644 --- a/src/idl/dustem_fit_polarization_example.pro +++ b/src/idl/dustem_fit_polarization_example.pro @@ -4,6 +4,7 @@ PRO dustem_fit_polarization_example,model=model $ ,postscript=postscript $ ,fits_save=fits_save $ ,help=help $ + ,noobj=noobj $ ,wait=wait $ ,verbose=verbose ;+ @@ -41,10 +42,9 @@ PRO dustem_fit_polarization_example,model=model $ ; sed_file = string naming the path to text file in .xcat format that ; describes the observational SED. If not set, the file ; 'Data/EXAMPLE_OBSDATA/example_SED_3.xcat' is used. -; postscript = if set, final plot is saved as postscript in the -; current working directory +; postscript = if set, final plot is saved as postscript file ; Nitermax = maximum number of fit iterations. Default is 5. -; fits_save = if set, saves results in a fits file, +; fits_save = if set, saves results in a FITS file. ; help = if set, print this help ; wait = if set, wait this many seconds between each step of ; the code (for illustration purposes) @@ -141,6 +141,7 @@ dustem_init,model=use_model,pol=use_polarization !dustem_verbose=1 ;!dustem_show_plot=1 !dustem_nocatch=1 +IF keyword_set(noobj) THEN !dustem_noobj=1 ;=== READ EXAMPLE SED DATA dir=!dustem_wrap_soft_dir+'/Data/EXAMPLE_OBSDATA/' @@ -189,9 +190,11 @@ end ;=== MAKE THE FINAL PLOT IF keyword_set(postscript) THEN BEGIN - dir_ps='./' +; dir_ps='./' + mydevice=!d.name set_plot,'PS' - ps_file=dir_ps+postscript +; ps_file=dir_ps+postscript + ps_file=postscript device,filename=ps_file,/color ENDIF @@ -202,8 +205,8 @@ ENDIF ELSE BEGIN ENDELSE IF keyword_set(postscript) THEN BEGIN - set_plot,'X' device,/close + set_plot,mydevice message,'Wrote '+ps_file,/info ENDIF @@ -237,11 +240,9 @@ IF keyword_set(fits_save) THEN BEGIN end ENDIF -message,'Finished dustem_polarization_example',/info - -;stop the_end: +message,'Finished dustem_polarization_example',/info END diff --git a/src/idl/dustem_fit_sed_ext_pol_example.pro b/src/idl/dustem_fit_sed_ext_pol_example.pro index caaf08c..41c3737 100755 --- a/src/idl/dustem_fit_sed_ext_pol_example.pro +++ b/src/idl/dustem_fit_sed_ext_pol_example.pro @@ -3,6 +3,7 @@ PRO dustem_fit_sed_ext_pol_example,model=model $ ,ext_file=ext_file $ ,Nitermax=Nitermax $ ,fits_save=fits_save $ + ,postscript=postscript $ ,wait=wait $ ,noobj=noobj $ ,help=help $ @@ -22,7 +23,7 @@ PRO dustem_fit_sed_ext_pol_example,model=model $ ; DustEMWrap, Distributed, High-Level, User Example ; ; CALLING SEQUENCE: -; dustem_fit_sed_ext_pol_example[,model=][sed_file=][ext_file=][,Nitermax=][,fits_save=][,/help,/wait,/verbose,/noobj] +; dustem_fit_sed_ext_pol_example[,model=][sed_file=][ext_file=][postscript=][,Nitermax=][,fits_save=][,/help,/wait,/verbose,/noobj] ; ; INPUTS: ; None @@ -46,6 +47,7 @@ PRO dustem_fit_sed_ext_pol_example,model=model $ ; ext_file = string naming the path to text file in .xcat format that ; describes the observational extinction SED. If not set, the file ; 'Data/EXAMPLE_OBSDATA/Mathis90Fitz99_DISM_NH20.xcat' is used. +; postscript = if set, final plot is saved as postscript file ; Nitermax = maximum number of fit iterations. Default is 5. ; fits_save = if set, save the fit results in a binary ; FITS file. The code then restore this file and plots @@ -269,9 +271,10 @@ end ;=== MAKE THE FINAL PLOT IF keyword_set(postscript) THEN BEGIN - dir_ps='./' +; dir_ps='./' + mydevice=!d.name set_plot,'PS' - ps_file=dir_ps+postscript + ps_file=postscript device,filename=ps_file,/color ENDIF @@ -282,8 +285,8 @@ ENDIF ELSE BEGIN ENDELSE IF keyword_set(postscript) THEN BEGIN - set_plot,'X' device,/close + set_plot,mydevice message,'Wrote '+ps_file,/info ENDIF diff --git a/src/idl/dustem_fit_sed_ext_stokesi_example.pro b/src/idl/dustem_fit_sed_ext_stokesi_example.pro index a6a19f7..8a7e9d6 100644 --- a/src/idl/dustem_fit_sed_ext_stokesi_example.pro +++ b/src/idl/dustem_fit_sed_ext_stokesi_example.pro @@ -2,6 +2,7 @@ PRO dustem_fit_sed_ext_stokesi_example,model=model $ ,sed_file=sed_file $ ,ext_file=ext_file $ ,Nitermax=Nitermax $ + ,postscript=postscript $ ,fits_save=fits_save $ ,wait=wait $ ,noobj=noobj $ @@ -22,7 +23,7 @@ PRO dustem_fit_sed_ext_stokesi_example,model=model $ ; DustEMWrap, Distributed, High-Level, User Example ; ; CALLING SEQUENCE: -; dustem_fit_sed_ext_stokesi_example[,model=][sed_file=][ext_file=][,Nitermax=][,fits_save=][,/help,/wait,/verbose,/noobj] +; dustem_fit_sed_ext_stokesi_example[,model=][sed_file=][ext_file=][postscript=][,Nitermax=][,fits_save=][,/help,/wait,/verbose,/noobj] ; ; INPUTS: ; None @@ -52,9 +53,9 @@ PRO dustem_fit_sed_ext_stokesi_example,model=model $ ; used to identify the wavelength range, and the dust model ; is used to generate the corresponding extinction. ; Nitermax = maximum number of fit iterations. Default is 5. +; postscript = if set, final plot is saved as postscript file ; fits_save = if set, save the fit results in a binary -; FITS file. The code then restore this file and plots -; the results using the saved results information. +; FITS file. ; help = if set, print this help ; wait = if set, wait this many seconds between each step of ; the code (for illustration purposes) @@ -248,9 +249,10 @@ end ;=== MAKE THE FINAL PLOT IF keyword_set(postscript) THEN BEGIN - dir_ps='./' +; dir_ps='./' + mydevice=!d.name set_plot,'PS' - ps_file=dir_ps+postscript + ps_file=postscript device,filename=ps_file,/color ENDIF @@ -261,8 +263,8 @@ ENDIF ELSE BEGIN ENDELSE IF keyword_set(postscript) THEN BEGIN - set_plot,'X' device,/close + set_plot,mydevice message,'Wrote '+ps_file,/info ENDIF diff --git a/src/idl/dustem_fit_spectro_example.pro b/src/idl/dustem_fit_spectro_example.pro index a8914d3..985999f 100644 --- a/src/idl/dustem_fit_spectro_example.pro +++ b/src/idl/dustem_fit_spectro_example.pro @@ -1,5 +1,6 @@ PRO dustem_fit_spectro_example,model=model $ ,sed_file=sed_file $ + ,postscript=postscript $ ,Nitermax=Nitermax $ ,fits_save=fits_save $ ,ucfactor=ucfactor $ @@ -13,9 +14,8 @@ PRO dustem_fit_spectro_example,model=model $ ; dustem_fit_spectro_example ; ; PURPOSE: -; This routine is an example of how to fit an observational -; spectrometer data in emission (StokesI) with DustEM and -; DustEMWrap. +; This routine is an example of how to fit spectrometer data in +; emission (StokesI only) with DustEM and DustEMWrap. ; ; See the DustEMWrap User Guide for more information. ; @@ -23,7 +23,7 @@ PRO dustem_fit_spectro_example,model=model $ ; DustEMWrap, Distributed, High-Level, User Example ; ; CALLING SEQUENCE: -; dustem_fit_spectro_example[,model=][sed_file=][ext_file=][,Nitermax=][,fits_save=][,/help,/wait,/verbose,/noobj] +; dustem_fit_spectro_example[,model=][sed_file=][ext_file=][postscript=][,Nitermax=][,fits_save=][,/help,/wait,/verbose,/noobj] ; ; INPUTS: ; None @@ -49,6 +49,7 @@ PRO dustem_fit_spectro_example,model=model $ ; spectrometer data. Default is 1. ; fits_save = if set, save the fit results in a binary ; FITS file. +; postscript = if set, final plot is saved as postscript file ; help = if set, print this help ; wait = if set, wait this many seconds between each step of ; the code (for illustration purposes) @@ -185,6 +186,7 @@ tol=1.e-10 ;fit tolerance xr_m = [1.,5e5] yr_m = [5e-8,1.00e6] tit_m='FIT SPECTRO EXAMPLE' ; plot title +tit=tit_m ;=== RUN THE FIT t1=systime(0,/sec) @@ -200,6 +202,29 @@ if keyword_set(wait) then begin wait,wait end +;=== MAKE THE FINAL PLOT +IF keyword_set(postscript) THEN BEGIN +; dir_ps='./' + mydevice=!d.name + set_plot,'PS' +; ps_file=dir_ps+postscript + ps_file=postscript + device,filename=ps_file,/color +ENDIF + +;stop + +IF !dustem_noobj THEN BEGIN + dustemwrap_plot_noobj,*(*!dustem_fit).CURRENT_PARAM_VALUES,st=dummy,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (Final fit)' + ENDIF ELSE BEGIN + dustemwrap_plot,*(*!dustem_fit).CURRENT_PARAM_VALUES,st=dummy,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (Final fit)' +ENDELSE + +IF keyword_set(postscript) THEN BEGIN + device,/close + set_plot,mydevice + message,'Wrote '+ps_file,/info +ENDIF IF keyword_set(fits_save) THEN BEGIN diff --git a/src/idl/dustem_fitsio_example.pro b/src/idl/dustem_fitsio_example.pro index 214a320..7107c7e 100644 --- a/src/idl/dustem_fitsio_example.pro +++ b/src/idl/dustem_fitsio_example.pro @@ -1,11 +1,11 @@ -PRO dustem_fitsio_example,help=help +PRO dustem_fitsio_example,help=help,nostop=nostop ;+ ; NAME: ; dustem_fitsio_example ; ; PURPOSE: -; Testing the save/restore FITS files +; Testing the save/restore of FITS files ; ; CATEGORY: ; DustEMWrap, Distributed, Low-Level, Development @@ -24,6 +24,7 @@ PRO dustem_fitsio_example,help=help ; ; ACCEPTED KEY-WORDS: ; help = print this help +; nostop = if set, do not stop between code blocks ; ; COMMON BLOCKS: ; None @@ -50,32 +51,34 @@ if keyword_set(help) then begin goto,the_end END +goto,spectro -dustem_fit_intensity_example,Nitermax=2,fits_save='/tmp/example_fit_intensity_only.fits' +stokesi: +dustem_fit_intensity_example,Nitermax=10,fits_save='/tmp/example_fit_intensity_only.fits' ;exit/.reset dustem_read_fits_table,filename='/tmp/example_fit_intensity_only.fits',dustem_st=dustem_spectra_st - yr=[1.00e-4,1.00E2] ; y-axis limits xr=[1.00E0,6.00e4] ; x-axis limits tit='FIT INTENSITY EXAMPLE' ; plot title ytit=textoidl('I_\nu (MJy/sr) for N_H=10^{20} H/cm^2') ; y-axis title xtit=textoidl('\lambda (\mum)') ; x-axis title res=*(*!dustem_fit).CURRENT_PARAM_VALUES -dustemwrap_plot,res,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' +dustemwrap_plot,res,st=dustem_spectra_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' -stop +if not keyword_set(nostop) then stop +spectro: dustem_fit_spectro_example,Nitermax=2,fits_save='/tmp/example_fit_spectro.fits' ;exit/.reset -dustem_read_fits_table,filename='/tmp/example_fit_spectro_only.fits',dustem_st=dustem_spectra_st +dustem_read_fits_table,filename='/tmp/example_fit_spectro.fits',dustem_st=dustem_spectra_st xr = [1.,5e5] yr = [5e-8,1.00e6] tit='FIT SPECTRO EXAMPLE' ; plot title res=*(*!dustem_fit).CURRENT_PARAM_VALUES -dustemwrap_plot,res,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' +dustemwrap_plot,res,st=dustem_spectra_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' -stop +if not keyword_set(nostop) then stop dustem_fit_intensity_mbb_example,Nitermax=2,fits_save='/tmp/example_fit_mbb.fits' ;exit/.reset @@ -86,10 +89,10 @@ tit='MBB FIT EXAMPLE' ; plot title ytit=textoidl('I_\nu (MJy/sr) for N_H=10^{20} H/cm^2') ; y-axis title xtit=textoidl('\lambda (\mum)') ; x-axis title res=*(*!dustem_fit).CURRENT_PARAM_VALUES -dustemwrap_plot,res,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' +dustemwrap_plot,res,st=dustem_spectra_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' -stop +if not keyword_set(nostop) then stop dustem_fit_polarization_example,Nitermax=2,fits_save='/tmp/example_fit_polar.fits' ;exit/.reset dustem_read_fits_table,filename='/tmp/example_fit_polar.fits',dustem_st=dustem_spectra_st @@ -97,10 +100,10 @@ yr=[1.00e-4,1.00E2] ; y-axis limits xr=[1.00E0,6.00e4] ; x-axis limits tit='FIT POLARISATION SED EXAMPLE' ; plot title res=*(*!dustem_fit).CURRENT_PARAM_VALUES -dustemwrap_plot,res,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' +dustemwrap_plot,res,st=dustem_spectra_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' -stop +if not keyword_set(nostop) then stop dustem_fit_ext_example,Nitermax=2,fits_save='/tmp/example_fit_ext.fits' ;exit/.reset dustem_read_fits_table,filename='/tmp/example_fit_ext.fits',dustem_st=dustem_spectra_st @@ -108,10 +111,10 @@ xr=[0.01,30] yr=[1.00E-10,10] tit='FIT EXTINCTION EXAMPLE' ; plot title res=*(*!dustem_fit).CURRENT_PARAM_VALUES -dustemwrap_plot,res,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' +dustemwrap_plot,res,st=dustem_spectra_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' -stop +if not keyword_set(nostop) then stop dustem_fit_ext_pol_example,Nitermax=2,fits_save='/tmp/example_fit_ext_polar.fits' ;exit/.reset dustem_read_fits_table,filename='/tmp/example_fit_ext_polar.fits',dustem_st=dustem_spectra_st @@ -119,9 +122,9 @@ xr=[0.01,30] yr=[1.00E-10,50] tit='FIT POLARISED EXTINCTION EXAMPLE' ; plot title res=*(*!dustem_fit).CURRENT_PARAM_VALUES -dustemwrap_plot,res,st=dustem_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' +dustemwrap_plot,res,st=dustem_spectra_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' -stop +if not keyword_set(nostop) then stop dustem_fit_sed_ext_stokesi_example,Nitermax=2,fits_save='/tmp/example_fit_sed_ext_stokesi.fits' ;exit/.reset dustem_read_fits_table,filename='/tmp/example_fit_sed_ext_stokesi.fits',dustem_st=dustem_spectra_st @@ -133,10 +136,10 @@ tit_m='Spectral Energy Distribution' tit_x='Dust Optical Depth' tit='FIT STOKESI EXTINCTION AND EMISSION EXAMPLE' ; plot title res=*(*!dustem_fit).CURRENT_PARAM_VALUES -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)' +dustemwrap_plot,res,st=dustem_spectra_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)' -stop +if not keyword_set(nostop) then stop dustem_fit_sed_ext_pol_example,Nitermax=2,fits_save='/tmp/example_fit_sed_ext_polar.fits' ;exit/.reset dustem_read_fits_table,filename='/tmp/example_fit_sed_ext_polar.fits',dustem_st=dustem_spectra_st @@ -148,9 +151,9 @@ tit_m='Spectral Energy Distribution' tit_x='Dust Optical Depth' tit='FIT POLARISED EXTINCTION AND EMISSION EXAMPLE' ; plot title res=*(*!dustem_fit).CURRENT_PARAM_VALUES -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)' +dustemwrap_plot,res,st=dustem_spectra_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)' -stop +if not keyword_set(nostop) then stop dustem_myisrf_example,Nitermax=2,fits_save='/tmp/example_fit_isrf.fits' ;exit/.reset dustem_read_fits_table,filename='/tmp/example_fit_isrf.fits',dustem_st=dustem_spectra_st @@ -159,18 +162,20 @@ yr_m = [5e-8,1.00e6] tit_m='Spectral Energy Distribution' tit='FIT WITH USER ISRF EXAMPLE' ; plot title res=*(*!dustem_fit).CURRENT_PARAM_VALUES -dustemwrap_plot,res,st=dustem_st,xr_m=xr_m,/xstyle,yr_m=yr_m,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' - - - - - -;=== fails when run with only the minimal dustemwrap installed (stellar . txt file is missing) -dustem_stellarpopisrf_example,Nitermax=3 - +dustemwrap_plot,res,st=dustem_spectra_st,xr_m=xr_m,/xstyle,yr_m=yr_m,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' +if not keyword_set(nostop) then stop +dustem_stellarpopisrf_example,Nitermax=3,fits_save='/tmp/example_fit_stellarpop.fits' +;exit/.reset +dustem_read_fits_table,filename='/tmp/example_fit_stellarpop.fits',dustem_st=dustem_spectra_st +xr_m = [1.,5e5] +yr_m = [5e-8,1.00e6] +tit_m='Spectral Energy Distribution' +tit='FIT WITH STELLARPOP ISRF EXAMPLE' ; plot title +res=*(*!dustem_fit).CURRENT_PARAM_VALUES +dustemwrap_plot,res,st=dustem_spectra_st,xr_m=xr_m,/xstyle,yr_m=yr_m,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' -; END LIST OF TOP-LEVEL ROUTINES +the_end: end diff --git a/src/idl/dustem_make_polarization_ext_example.pro b/src/idl/dustem_make_polarization_ext_example.pro index 5fc4929..94c1598 100644 --- a/src/idl/dustem_make_polarization_ext_example.pro +++ b/src/idl/dustem_make_polarization_ext_example.pro @@ -11,7 +11,8 @@ PRO dustem_make_polarization_ext_example,model=model $ ; dustem_make_polarization_ext_example ; ; PURPOSE: -; This is an example of how to generate an extinction curve using DustEMWrap. +; This is an example of how to generate an extinction curve (Stokes +; IQU) using one of the physical dust models in DustEMWrap. ; It is meant to be an example to follow when writing your own ; programs using DustEMWrap ; @@ -124,7 +125,7 @@ ext.SIGEXTQU=ext.EXT_I/1000. ;=== Set which model parameters to use for the EXT, this will depend ;=== on the selected dust model. For model parameters not specified -;=== here, the default Dustem fortran values will be used +;=== here, the default DustEM fortran values will be used pd = [ $ '(*!dustem_params).grains(0).mdust_o_mh', $ ;PAH0_MC10 mass fraction '(*!dustem_params).grains(1).mdust_o_mh', $ ;amCBE_0.3333x mass fraction @@ -173,11 +174,12 @@ ext=dustem_fill_ext_dependent_columns(ext) write_xcat,ext,use_outfile message,'Wrote '+use_outfile,/continue -;======== move the file to the Data/EXAMPLE_OBSDATA/ subdirectory -;filename_final=!dustem_wrap_soft_dir+'/Data/EXAMPLE_OBSDATA/my_example_EXT_###.xcat' +;======== example of how to move the file to the Data/EXAMPLE_OBSDATA/ subdirectory +;filename_final=!dustem_wrap_soft_dir+'/Data/EXAMPLE_OBSDATA/my_example_EXT_G17MDL_D.xcat' ;str='cp '+use_outfile+' '+filename_final ;message,'Do '+str+' to make change permanent',/continue the_end: +message,'Finished dustem_make_polarization_ext_example',/info END diff --git a/src/idl/dustem_make_polarization_sed_example.pro b/src/idl/dustem_make_polarization_sed_example.pro index bf9697c..c1dbbfe 100644 --- a/src/idl/dustem_make_polarization_sed_example.pro +++ b/src/idl/dustem_make_polarization_sed_example.pro @@ -9,7 +9,7 @@ PRO dustem_make_polarization_sed_example,model=model $ ; dustem_make_polarization_sed_example ; ; PURPOSE: -; This is an example of how to generate an SED using DustEMWrap. +; This is an example of how to generate an SED (StokesIQU) using DustEMWrap. ; It is meant to be an example to follow when writing your own ; programs using DustEMWrap ; @@ -173,5 +173,6 @@ message,'Wrote '+use_outfile,/continue ;message,'Do '+str+' to make change permanent',/continue the_end: +message,'Finished dustem_make_polarization_sed_example',/info END diff --git a/src/idl/dustem_myisrf_example.pro b/src/idl/dustem_myisrf_example.pro index f417351..445a82a 100644 --- a/src/idl/dustem_myisrf_example.pro +++ b/src/idl/dustem_myisrf_example.pro @@ -49,12 +49,10 @@ PRO dustem_myisrf_example,model=model $ ; describes the observational SED. If not set, the file ; 'Data/EXAMPLE_OBSDATA/example_SED_1.xcat' is used. ; isrf_file = text file describing ISRF -; postscript = if set, final plot is saved as postscript in the -; current working directory +; postscript = if set, final plot is saved as postscript file ; Nitermax = maximum number of fit iterations. Default is 5. ; fits_save = if set, save the fit results in a binary -; FITS file. The code then restore this file and plots -; the results using the saved results information. +; FITS file. ; help = if set, print this help ; wait = if set, wait this many seconds between each step of ; the code (for illustration purposes) @@ -187,7 +185,7 @@ endif ;=== PLOT AS A SANITY CHECK xtit=textoidl('\lambda (\mum)') ytit=textoidl('log ISRF [4 \pi I_\nu (erg/cm^2/s/Hz)]') -tit='DUSTEM MYISRF EXAMPLE' +tit='MYISRF EXAMPLE' yr=[min(st_model.isrf.isrf) < min(myisrf),5.*(max(st_model.isrf.isrf)>max(myisrf))] xr=[0.001,1e6] window,use_window,xs=600,ys=400,tit=tit & use_window=use_window+2 @@ -242,7 +240,7 @@ IF keyword_set(Nitermax) THEN use_Nitermax=Nitermax xr = [1.,5e5] yr = [5e-8,1.00e6] -tit='MYISRF EXAMPLE' +tit='FIT WITH MYISRF EXAMPLE' ytit=textoidl('I_\nu (MJy/sr) for N_H=10^{20} H/cm^2') xtit=textoidl('\lambda (\mum)') @@ -260,12 +258,11 @@ if keyword_set(wait) then begin wait,wait end - ;=== MAKE THE FINAL PLOT IF keyword_set(postscript) THEN BEGIN - dir_ps='./' - set_plot,'PS' - ps_file=dir_ps+postscript + mydevice=!d.name + set_plot,'PS' + ps_file=postscript device,filename=ps_file,/color ENDIF @@ -276,8 +273,8 @@ IF !dustem_noobj THEN BEGIN ENDELSE IF keyword_set(postscript) THEN BEGIN - set_plot,'X' device,/close + set_plot,mydevice message,'Wrote '+ps_file,/info ENDIF @@ -308,9 +305,9 @@ IF keyword_set(fits_save) THEN BEGIN ENDIF ENDIF -message,'Finished dustem_myisrf_example',/info the_end: +message,'Finished dustem_myisrf_example',/info END diff --git a/src/idl/dustem_run_example.pro b/src/idl/dustem_run_example.pro index 610613d..5939df6 100755 --- a/src/idl/dustem_run_example.pro +++ b/src/idl/dustem_run_example.pro @@ -197,5 +197,6 @@ goto,the_end ;; dustem_plot_extinction,st,st_model,xr=xr,yr=yr,/xsty,/ysty,xtit=xtit,ytit=ytit,title=tit,post=postscript the_end: +message,'Finished dustem_run_example',/info END diff --git a/src/idl/dustem_stellarpopisrf_example.pro b/src/idl/dustem_stellarpopisrf_example.pro index 313281a..4fe821c 100644 --- a/src/idl/dustem_stellarpopisrf_example.pro +++ b/src/idl/dustem_stellarpopisrf_example.pro @@ -2,7 +2,8 @@ PRO dustem_stellarpopisrf_example,model=model $ ,sed_file=sed_file $ ,isrf_file=isrf_file $ ,Nitermax=Nitermax $ - ,fits_save_and_restore=fits_save_and_restore $ + ,postscript=postscript $ + ,fits_save=fits_save $ ,wait=wait $ ,noobj=noobj $ ,verbose=verbose $ @@ -30,7 +31,7 @@ PRO dustem_stellarpopisrf_example,model=model $ ; DustEMWrap, Distributed, High-Level, User Example ; ; CALLING SEQUENCE: -; dustem_fit_stellarpopisrf_example[,model=][sed_file=][isrf_file=][,postscript=][,Nitermax=][,fits_save_and_restore=][,/help,/wait,/verbose] +; dustem_fit_stellarpopisrf_example[,model=][sed_file=][isrf_file=][,postscript=][,Nitermax=][,fits_save=][,/help,/wait,/verbose] ; ; INPUTS: ; None @@ -52,12 +53,11 @@ PRO dustem_stellarpopisrf_example,model=model $ ; describes the observational SED. If not set, the file ; 'Data/EXAMPLE_OBSDATA/example_SED_2.xcat' is used. ; isrf_file = text file describing ISRF -; postscript = if set, final plot is saved as postscript in the -; current working directory +; postscript = if set, final plot is saved as postscript file ; Nitermax = maximum number of fit iterations. Default is 5. -; fits_save_and_restore = if set, save the fit results in a binary -; FITS file. The code then restore this file and plots -; the results using the saved results information. +; fits_save = if set, save the fit results in a binary +; FITS file. +; postscript = if set, final plot is saved as postscript file ; help = if set, print this help ; wait = if set, wait this many seconds between each step of ; the code (for illustration purposes) @@ -76,10 +76,9 @@ PRO dustem_stellarpopisrf_example,model=model $ ; ; PROCEDURES AND SUBROUTINES USED: ; -; ; EXAMPLES ; dustem_fit_stellarpopisrf_example -; dustem_fit_stellarpopisrf_example,Nitermax=10,fits_save_and_restore='/tmp/mysavefile.fits' +; dustem_fit_stellarpopisrf_example,Nitermax=10,fits_save='/tmp/mysavefile.fits' ; dustem_fit_stellarpopisrf_example,model='DBP90',isrf_file='./myisrf_habing.dat',sed_file='./mysed.xcat' ; ; MODIFICATION HISTORY: @@ -117,8 +116,8 @@ dustem_define_la_common ;;=============================== ;; example parameter initialisation 1 -;; Here we aim to fit the distance to a single O7V star -;; other ISRF contributions are fixed to ~zero +;; Here we attempt to fit the distance to a single O7V star +;; Other ISRF contributions are fixed to ~zero pd = ['dustem_plugin_stellar_population_O7V3']; ;distance to O7V star true_vals = [20] ; true distance to the star @@ -174,11 +173,6 @@ dustem_init,model=use_model,polarization=use_polarization !dustem_nocatch=1 !dustem_verbose=1 IF keyword_set(noobj) THEN !dustem_noobj=1 -;; ;!dustem_dim=1 ; this option is to dim the stellar population ISRF with the current Dustem extinction -;; ;We're fitting total optical depths so the dimmed-ISRF scenario is a reasonable assumption. -;; ;Because of this the final parameter values are slightly lower than the initial (real) values. -;; ;But this is because the first run was not extinct with the current dustem extinction -;; ;since it comes prior to the dustem run. Meaning the first ISRF has to be extinct to see if the paramters are retrieved. if keyword_set(isrf_file) then begin message,'Setting ISRF component from file: '+isrf_file,/info @@ -199,7 +193,6 @@ if keyword_set(wait) then begin wait,wait end - ;=== initializing IQU and associated errors to avoid problems when checking SED in dustem_set_data.pro for i=4l,n_tags(sed)-1 do begin sed.(i) = sed.sigmaii @@ -215,7 +208,7 @@ sed.StokesI = dustem_compute_sed(true_vals,st=st) sed.SigmaII = sed.StokesI*0.01 ;== SET THE OBSERVATIONAL STRUCTURE -dustem_set_data, sed, sed +dustem_set_data, m_fit=sed, m_show=sed if keyword_set(wait) then begin @@ -230,7 +223,7 @@ xr_m = [1.,5e5] yr_m = [5e-8,1.00e6] -tit='Spectral Energy Distribution' +tit='FIT WITH STELLAR POP ISRF EXAMPLE' ytit=textoidl('I_\nu (MJy/sr) for N_H=10^{20} H/cm^2') xtit=textoidl('\lambda (\mum)') ;Set show_plot to 0 to hide plot @@ -251,33 +244,52 @@ if keyword_set(wait) then begin end +;=== MAKE THE FINAL PLOT +IF keyword_set(postscript) THEN BEGIN +; dir_ps='./' + mydevice=!d.name + set_plot,'PS' +; ps_file=dir_ps+postscript + ps_file=postscript + device,filename=ps_file,/color +ENDIF + IF !dustem_noobj THEN BEGIN - dustemwrap_plot_noobj,*(*!dustem_fit).CURRENT_PARAM_VALUES,dummy,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (Final fit)' + dustemwrap_plot_noobj,*(*!dustem_fit).CURRENT_PARAM_VALUES,st=dummy,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (Final fit)' ENDIF ELSE BEGIN - dustemwrap_plot,*(*!dustem_fit).CURRENT_PARAM_VALUES,dummy,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (Final fit)' + dustemwrap_plot,*(*!dustem_fit).CURRENT_PARAM_VALUES,st=dummy,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (Final fit)' ENDELSE + +IF keyword_set(postscript) THEN BEGIN + device,/close + set_plot,mydevice + message,'Wrote '+ps_file,/info +ENDIF + + if keyword_set(wait) then begin message,'Made the plot of the final results',/info wait,wait end -IF keyword_set(fits_save_and_restore) THEN BEGIN - message,'Writing out results structure: '+fits_save_and_restore,/info - dustem_write_fits_table,filename=fits_save_and_restore,help=help +IF keyword_set(fits_save) THEN BEGIN + message,'Writing out results structure: '+fits_save,/info + dustem_write_fits_table,filename=fits_save,help=help ;=== At this point, you could erase all dustem system variables, or exit idl... all the ;=== information needed to recover the results and remake the plots has been saved in the FITS table - ;stop - dustem_read_fits_table,filename=fits_save_and_restore,dustem_st=dustem_spectra_st - ;==== plot result taken from the saved fits table - res=*(*!dustem_fit).CURRENT_PARAM_VALUES - IF !dustem_noobj THEN BEGIN - dustemwrap_plot_noobj,res,dustem_spectra_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' - ENDIF ELSE BEGIN - dustemwrap_plot,res,dustem_spectra_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' - ENDELSE + +;; moved the following to dustem_fitsio_example.pro + ;; dustem_read_fits_table,filename=fits_save,dustem_st=dustem_spectra_st + ;; ;==== plot result taken from the saved fits table + ;; res=*(*!dustem_fit).CURRENT_PARAM_VALUES + ;; IF !dustem_noobj THEN BEGIN + ;; dustemwrap_plot_noobj,res,dustem_spectra_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' + ;; ENDIF ELSE BEGIN + ;; dustemwrap_plot,res,dustem_spectra_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' + ;; ENDELSE IF keyword_set(wait) THEN BEGIN - message,'Saved the results as FITS in the file: '+fits_save_and_restore+', and made a plot using the data in this file',/info + message,'Saved the results as FITS in the file: '+fits_save+', and made a plot using the data in this file',/info wait,wait ENDIF ENDIF -- libgit2 0.21.2