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