dustem_habing_field.pro 1.99 KB
FUNCTION DUSTEM_HABING_FIELD, x, unit=unit

;+
; NAME:
;   dustem_habing_field
;  
; PURPOSE:
;   Returns the Habing interstellar radiation field SED (ISRF)
;   in W/m2 (4*!pi*nu*I_nu)
;   (from Draine & Bertoldi 1996)
;
; CATEGORY:
;    DustEMWrap, Distributed, LowLevel, Helper
;  
; CALLING SEQUENCE:
;   habing = DUSTEM_HABING_FIELD(x,unit=unit)
;
; INPUTS:
;    x : wavelength grid for the ISRF (1D array)
;
; OPTIONAL INPUT PARAMETERS:
;    UNIT: unit of the ISRF. Choices are 
;	     'W': wave in um [Default]
;	     'F': frequency in cm-1
;	     'E': energy in eV
;
; OUTPUTS:
;    ISRF : the Habing isrf as 1d vector in requested units
;
; OPTIONAL OUTPUT PARAMETERS:
;
; ACCEPTED KEY-WORDS:
;    help = print this help
;
; COMMON BLOCKS:
;    None
;
; SIDE EFFECTS:
;
; RESTRICTIONS:
;
; PROCEDURES AND SUBROUTINES USED:
;   
; EXAMPLES
;      wavs=3.+findgen(3000) ; wavelenghts 3 to 3003um
;      isrf = DUSTEM_HABING_FIELD(wavs,unit='W')
;
; MODIFICATION HISTORY:
;    Written by LV 2009
;    Initially distributed with the Fortran, incorporated into DustEMWrap 2022
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
;-

  IF keyword_set(help) THEN BEGIN
     doc_library,'dustem_habing_field'
     field=0
     goto,the_end
  ENDIF



; computes the Habing interstellar radiation field SED (ISRF)
; in W/m2 (4*!pi*nu*I_nu)
; (from Draine & Bertoldi 1996)
; X	(I): X-grid for the ISRF
; UNIT	(I): unit of the ISRF. Choices are 
;	     'W': wave in um [Default]
;	     'F': frequency in cm-1
;	     'E': energy in eV 

 if n_elements( UNIT ) EQ 0 then unit = 'W' $
 else unit = strupcase( strcompress( unit,/rem) )

 x = double( x )

 CASE unit of 

   'W': x3 = 1.d1 * x 

   'F': x3 = 1.d5 / x

   'E': x3 = 12.4 / x

 ENDCASE

 field = - x3^3*4.1667 + x3^2*12.5 - x3*4.3333 
 field = 1.d-1 * 3.d8 * 1.d-14 * field 

 i_neg = where( field LT 0.d0, c_neg )
 field( i_neg ) = 0.d0

 the_end:
 RETURN, field
END                             ;FUNCTION DUSTEM_HABING_FIELD