Blame view

src/idl/dustem_plugin_phangs_class_isrf.pro 4.57 KB
7f205766   Jean-Philippe Bernard   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
FUNCTION dustem_plugin_phangs_class_isrf,key=key $
                                			   ,val=val $
                                			   ,scope=scope $
                                			   ,paramtag=paramtag $
                                			   ,paramdefault=paramdefault $
                                			   ,help=help

;+
; NAME:
;    dustem_plugin_phangs_class_isrf
; PURPOSE:
;    DustEMWrap plugin to get ISRF from a given stellar ISRF phangs class
; CATEGORY:
;    DustEM, Distributed, Mid-Level, Plugin
; CALLING SEQUENCE:
;    ISRF=dustem_plugin_phangs_class_isrf([,key=][,val=][,scope=][,paramtag=][paramdefault=][,/help])
; INPUTS:
;    None
; OPTIONAL INPUT PARAMETERS:
;    key  = input parameter number
;           1: ISRF class to be used (default = 0 = Mathis ISRF)
;					  2: Amplitude factor for the ISRF ("GO")
;           3: E(B-V) for extinction to stars applied to the template, as used in Phangs
ccfa6760   Jean-Philippe Bernard   corrected ISRF cl...
24
;           4: multiplicative factor for photons above 13.6 eV (0 means no ionising photons)
7f205766   Jean-Philippe Bernard   first commit
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
;    val  = corresponding input parameter value
; OUTPUTS:
;    ISRF = stellar ISRF in 4*pi*Inu [ergs/s/cm2/Hz] normalized to Mathis ISRF at 1 mic for the provided G0
; OPTIONAL OUTPUT PARAMETERS:
;    scope = if set, return the scope of the plugin
;    paramdefault = default values of parameters
;    paramtag = if set, return the return plugin parameter names as strings
; ACCEPTED KEY-WORDS:
;    help                  = if set, print this help
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    None
; RESTRICTIONS:
;    The DustEMWrap IDL code must be installed
; PROCEDURE:
;    This is a DustEMWrap plugin for phangs
; EXAMPLES
;    dustem_init
;    vec=dustem_plugin_phangs_class_isrf(scope=scope)
; MODIFICATION HISTORY:
;    Written by JPB June 2023
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
;-

;stop

IF keyword_set(help) THEN BEGIN
  doc_library,'dustem_plugin_phangs_class_isrf'
  ISRF=0.
  goto,the_end
ENDIF

IF keyword_set(scope) THEN BEGIN
    scope='REPLACE_ISRF'
    ;message,'Plugin dustem_plugin_phangs_class_isrf called with scope keyword',/informational
    ;stop
    ISRF=0
    goto, the_end
ENDIF 

;==== define parameter tags
IF keyword_set(paramtag) THEN BEGIN
  paramtag=['class','G0','E(B-V)']
  ;message,'Plugin dustem_plugin_phangs_class_isrf called with paramtag keyword',/informational
  ;stop
  ISRF=0
	GOTO,the_end
ENDIF

;message,'Plugin dustem_plugin_phangs_class_isrf will compute ISRF',/informational
;stop

;default values:
use_class=0L
G0=1.0
EBV=0.
ccfa6760   Jean-Philippe Bernard   corrected ISRF cl...
83
ionis_atenuation_fact=1.
7f205766   Jean-Philippe Bernard   first commit
84
85
86
87
88
89
90
IF keyword_set(key) THEN BEGIN
  ind=where(key EQ 1,count)
  IF count NE 0 THEN use_class=val[ind[0]]
  ind=where(key EQ 2,count)
  IF count NE 0 THEN G0=val[ind[0]]
  ind=where(key EQ 3,count)
  IF count NE 0 THEN EBV=val[ind[0]]
ccfa6760   Jean-Philippe Bernard   corrected ISRF cl...
91
92
  ind=where(key EQ 4,count)
  IF count NE 0 THEN ionis_atenuation_fact=val[ind[0]]
7f205766   Jean-Philippe Bernard   first commit
93
94
ENDIF

7f205766   Jean-Philippe Bernard   first commit
95
96
97
98
99
100
101
102
;==== initialize templates if not already present
defsysv,'!dustem_plugin_phangs_class_isrf',exist=exist
IF exist EQ 0 THEN BEGIN
  st={class0:ptr_new(),classes:ptr_new()}
  defsysv,'!dustem_plugin_phangs_class_isrf',st
ENDIF
IF not ptr_valid(!dustem_plugin_phangs_class_isrf.class0) THEN BEGIN
  message,'Initializing Phangs ISRF classes',/info
5b318ce0   Jean-Philippe Bernard   improved pathes
103
104
  ;data_dir='/Volumes/PILOT_FLIGHT1/PHANGS-JWST/DR1/'
  data_dir=!phangs_data_dir+'/ISRF/WORK/'
ccfa6760   Jean-Philippe Bernard   corrected ISRF cl...
105
106
  ;file_save=data_dir+'isrf_classes_one_ratio.sav'
  ;restore,file_save,/verb
7f205766   Jean-Philippe Bernard   first commit
107
108
  ;% RESTORE: Restored variable: CLASSES.
  ;% RESTORE: Restored variable: CLASS0.
ccfa6760   Jean-Philippe Bernard   corrected ISRF cl...
109
110
111
  file_save=data_dir+'isrf_classes_one_ratio_on_ngc0628.fits'
  class0=mrdfits(file_save,1,h1)
  classes=mrdfits(file_save,2,h2)
7f205766   Jean-Philippe Bernard   first commit
112
113
114
115
116
117
118
119
120
121
122
  ;stop
  !dustem_plugin_phangs_class_isrf.class0=ptr_new(class0)
  !dustem_plugin_phangs_class_isrf.classes=ptr_new(classes)
ENDIF

classes=*!dustem_plugin_phangs_class_isrf.classes
class0=*!dustem_plugin_phangs_class_isrf.class0
;IF keyword_set(isrf_class) THEN use_class=isrf_class
IF use_class NE 0 THEN class=classes[use_class] ELSE class=class0
fact=3.941e-17  ;ergs/s/cm2/Hz at 1 micron for Mathis field at G0=1

ccfa6760   Jean-Philippe Bernard   corrected ISRF cl...
123
124
125
126
127
128
129
;stop

ind=where(class.isrf_template NE la_undef(),count)
;IF ptr_valid(class.isrf_template) THEN BEGIN
IF count NE 0 THEN BEGIN
  ;ISRF=(*class.isrf_template)*G0*fact
  ISRF=class.isrf_template*G0*fact
7f205766   Jean-Philippe Bernard   first commit
130
ENDIF ELSE BEGIN
ccfa6760   Jean-Philippe Bernard   corrected ISRF cl...
131
  message,'Class '+use_class+' has no template',/continue
7f205766   Jean-Philippe Bernard   first commit
132
133
134
  stop
ENDELSE

ccfa6760   Jean-Philippe Bernard   corrected ISRF cl...
135
136
137
138
139
140
141
;attenuate ionizing photons if needed
IF ionis_atenuation_fact NE 1. THEN BEGIN
  wav_cut=121.567e-9*1.e6  ;121.567 nm in microns
  ind=where(class.isrf_wavelengths LT wav_cut,count)
  ISRF[ind]=ISRF[ind]*ionis_atenuation_fact
ENDIF

7f205766   Jean-Philippe Bernard   first commit
142
143
;stop
;un_red
cc81fcdc   Jean-Philippe Bernard   improved
144
;STILL HAVE TO REDDEN BY E(B-V)
7f205766   Jean-Philippe Bernard   first commit
145
146
147
148
149

the_end:
RETURN,ISRF
  
END