dustem_plot_nuinu_em.pro 3.67 KB
PRO dustem_plot_nuinu_em,st,_extra=_extra,help=help

;+
; NAME:
;     dustem_plot_nuinu_em
; PURPOSE:
;    Plots a Dustem spectrum
; CATEGORY:
;    Dustem
; CALLING SEQUENCE:
;    dustem_plot_fit_sed,st[,/help][,_extra=]
; INPUTS:
;    st        = Dustem model output structure
; OPTIONAL INPUT PARAMETERS:
;    _extra    = extra parameters for the plot routine
; OUTPUTS:
;    None
; OPTIONAL OUTPUT PARAMETERS:
;    None
; ACCEPTED KEY-WORDS:
;    help      = If set, print this help
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    model is plotted
; RESTRICTIONS:
;    The dustem idl wrapper must be installed
; PROCEDURE:
;    None
; EXAMPLES
;    dustem_init,/wrap
;    dir=getenv('DUSTEM_RES')
;    st=dustem_read_all_res(dir)
;    dustem_plot_nuinu_em,st,yr=[1e-28,1.e-22],/ysty,xr=[1,5e3],/xsty
; MODIFICATION HISTORY:
;    Written by J.-Ph. Bernard
;    see evolution details on the dustem cvs maintained at CESR
;    Contact J.-Ph. Bernard (Jean-Philippe.Bernard@cesr.fr) in case of problems.
;-

IF keyword_set(help) THEN BEGIN
  doc_library,'dustem_plot_nuinu_em'
  goto,the_end
ENDIF

Ngrains=n_tags(st.sed)-2
colors=dustem_grains_colors(Ngrains,/cgplot)

;This is to go to units of W/m^2/sr for N_H=1.e20 H/cm^2
fact=1./4./!pi*1.e4/1.e7*1.e20


i=1L
;plot_oo,st.sed.wav,st.sed.(i)*fact,/nodata,_Extra=extra,xtit=xtit,ytit=ytit,tit=tit
;cgplot,st.sed.wav,st.sed.(i)*fact,/nodata,_Extra=extra,xtit=xtit,ytit=ytit,tit=tit,/xlog,/ylog
cgplot,st.sed.wav,st.sed.(i)*fact,/nodata,_extra=_extra
FOR i=1L,Ngrains DO BEGIN
  ;oplot,st.sed.wav,st.sed.(i)*fact,color=colors(i-1),psym=psym
  cgoplot,st.sed.wav,st.sed.(i)*fact,color=colors[i-1],psym=psym
  ;stop
ENDFOR
;oplot,st.sed.wav,st.sed.(i)*fact,color=255,psym=psym
cgoplot,st.sed.wav,st.sed.(i)*fact,color='black',psym=psym

;stop

;Remarks: not sure that the plot of the sed below actually works. See dustem_sed_plot.pro

defsysv,'!dustem_data',exists=exists
IF exists THEN BEGIN
   IF ptr_valid(!dustem_data.sed) THEN BEGIN
     ind_filt=where((*!dustem_data.sed).filt_names NE 'SPECTRUM',count_filt)
     ind_spec=where((*!dustem_data.sed).filt_names EQ 'SPECTRUM',count_spec)

     ;=== Plot the data
     ;use_col_data_spec=255
     ;use_col_data_filt=100
     use_col_data_spec='blue'
     use_col_data_filt='red'
     IF count_spec NE 0 THEN BEGIN
       ;plotsym,0,/fill
       ;oplot,((*!dustem_data.sed).wav)(ind_spec),((*!dustem_data.sed).values)(ind_spec)*(3.e8/1.e-6/(*!dustem_data.sed).wav(ind_spec))/1.d20,psym=8,_extra=extra,color=use_col_data_spec,syms=0.5
       cgoplot,((*!dustem_data.sed).wav)[ind_spec],((*!dustem_data.sed).values)[ind_spec]*(3.e8/1.e-6/(*!dustem_data.sed).wav[ind_spec])/1.d20,psym='Filled Circle',_extra=extra,color=use_col_data_spec
       err_bar,((*!dustem_data.sed).wav)(ind_spec),((*!dustem_data.sed).values)(ind_spec)*(3.e8/1.e-6/(*!dustem_data.sed).wav(ind_spec))/1.d20,yrms=3.*((*!dustem_data.sed).sigma)(ind_spec)/2.*(3.e8/1.e-6/(*!dustem_data.sed).wav(ind_spec))/1.d20,color=use_col_data_spec
     ENDIF
     IF count_filt NE 0 THEN BEGIN
       plotsym,0,/fill
       ;oplot,((*!dustem_data.sed).wav)(ind_filt),((*!dustem_data.sed).values)(ind_filt)*(3.e8/1.e-6/(*!dustem_data.sed).wav(ind_filt))/1.d20,psym=8,_extra=extra,color=use_col_data_filt
       cgoplot,((*!dustem_data.sed).wav)(ind_filt),((*!dustem_data.sed).values)(ind_filt)*(3.e8/1.e-6/(*!dustem_data.sed).wav(ind_filt))/1.d20,psym=8,_extra=extra,color=use_col_data_filt
       err_bar,((*!dustem_data.sed).wav)(ind_filt),((*!dustem_data.sed).values)(ind_filt)*(3.e8/1.e-6/(*!dustem_data.sed).wav(ind_filt))/1.d20,yrms=3.*((*!dustem_data.sed).sigma)(ind_filt)/2*(3.e8/1.e-6/(*!dustem_data.sed).wav(ind_filt))/1.d20,color=use_col_data_filt
     ENDIF
   ENDIF
ENDIF

the_end:

END