dustem_plugin_phangs_class_isrf.pro
4.23 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
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
; 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.
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]]
ENDIF
;==== here we open the ISRF classes but should be done only once, and put into a system varaible
;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.
;==== 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.
;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
IF ptr_valid(class.isrf_template) THEN BEGIN
ISRF=(*class.isrf_template)*G0*fact
ENDIF ELSE BEGIN
message,'Class not found',/continue
stop
ENDELSE
;stop
;un_red
;STILL HAVE TO REDDEN BY E(B-V)
the_end:
RETURN,ISRF
END