dustem_plugin_phangs_class_isrf.pro
4.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
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
; 4: multiplicative factor for photons above 13.6 eV (0 means no ionising photons)
; 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.
ionis_atenuation_fact=1.
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]]
ind=where(key EQ 4,count)
IF count NE 0 THEN ionis_atenuation_fact=val[ind[0]]
ENDIF
;==== 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
;data_dir='/Volumes/PILOT_FLIGHT1/PHANGS-JWST/DR1/'
data_dir=!phangs_data_dir+'/ISRF/WORK/'
;file_save=data_dir+'isrf_classes_one_ratio.sav'
;restore,file_save,/verb
;% RESTORE: Restored variable: CLASSES.
;% RESTORE: Restored variable: CLASS0.
file_save=data_dir+'isrf_classes_one_ratio_on_ngc0628.fits'
class0=mrdfits(file_save,1,h1)
classes=mrdfits(file_save,2,h2)
;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
;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
ENDIF ELSE BEGIN
message,'Class '+use_class+' has no template',/continue
stop
ENDELSE
;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
;stop
;un_red
;STILL HAVE TO REDDEN BY E(B-V)
the_end:
RETURN,ISRF
END