Blame view

LabTools/IRAP/JPB/make_phangs_ssps_isrf_prediction.pro 5.75 KB
ccbd30b1   Jean-Philippe Bernard   First commit
1
2
PRO make_phangs_ssps_isrf_prediction,source_name=source_name,save=save,help=help

ccbd30b1   Jean-Philippe Bernard   First commit
3
4
5
6
;+
; NAME:
;       make_phangs_ssps_isrf_prediction
; CALLING SEQUENCE:
14ae4f23   Jean-Philippe Bernard   improved
7
;       make_phangs_ssps_isrf_prediction[,source_name=][,/save][,/help]
ccbd30b1   Jean-Philippe Bernard   First commit
8
9
10
11
12
13
14
15
16
17
18
19
20
21
; PURPOSE:
;       predicts the minimum ISRF in voronoi bins
; INPUTS:
;       None
; OPTIONAL KEYWORDS:
;       save        = if set, save the classes
;       help        = if set, print this help
; OUTPUTS:
;	    None
; OPTIONAL INPUT:
;       source_name = source name (default='ngc0628')
; OPTIONAL OUTPUT:
;       None
; PROCEDURE AND SUBROUTINE USED
14ae4f23   Jean-Philippe Bernard   improved
22
23
24
;       ISRF saved is the one predicted by dustem_plugin_phangs_stellar_isrf for each Muse Voronoi bin,
;       scaled in amplitude to match the Muse filter data for that Voronoi bin.
;       The G0 value computed is wrt the Mathis field at 1 mic.
ccbd30b1   Jean-Philippe Bernard   First commit
25
; SIDE EFFECTS:
14ae4f23   Jean-Philippe Bernard   improved
26
;       produces file _isrf_min_prediction.sav
ccbd30b1   Jean-Philippe Bernard   First commit
27
; EXAMPLE:
14ae4f23   Jean-Philippe Bernard   improved
28
;       make_phangs_ssps_isrf_prediction,source_name='ngc0628',/save
ccbd30b1   Jean-Philippe Bernard   First commit
29
30
31
32
33
34
35
36
37
38
; MODIFICATION HISTORY:
;       written by Jean-Philippe Bernard
;-

IF keyword_set(help) THEN BEGIN
  doc_library,'make_phangs_ssps_isrf_prediction'
  goto,the_end
ENDIF

;===== predicts the minimum ISRF in voronoi bins
14ae4f23   Jean-Philippe Bernard   improved
39
;===== The prediction is scaled to the Muse filter data observations
ccbd30b1   Jean-Philippe Bernard   First commit
40
41
42
43
44

win=0L
;window,win,xsize=900,ysize=1000 & win=win+1

;=== This is where the data is read from and the ISRFs will be stored
ccbd30b1   Jean-Philippe Bernard   First commit
45
46
47
48
49
50
51
52
data_dir=!phangs_data_dir+'/ISRF/WORK/'

use_model='DBP90'    ;Example with default keywords uses the DBP90 model
use_polarization=0   ; initialize Dustemwrap in no polarization mode 

;== INITIALISE DUSTEM
dustem_init,model=use_model,polarization=use_polarization,show_plots=show_plots

ccbd30b1   Jean-Philippe Bernard   First commit
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use_source_name='ngc0628'
IF keyword_set(source_name) THEN use_source_name=source_name

CASE use_source_name OF
	'ngc0628':BEGIN
		object_distance=9.84  ;MPc
		object_thickness=0.1  ;kpc
	END
ENDCASE

dustem_define_la_common
obp=[1.1,0,1.15,1]

;dustem_init,show_plots=show_plots
;needed only for NHCO
restore,data_dir+use_source_name+'_jwst_images.sav',/verb
14ae4f23   Jean-Philippe Bernard   improved
69
70
71
72
;% RESTORE: Restored variable: JWST_IMAGES.
;% RESTORE: Restored variable: FILTERS.
;% RESTORE: Restored variable: HREF.
;% RESTORE: Restored variable: NHCO.
ccbd30b1   Jean-Philippe Bernard   First commit
73
74
;needed for stellar parameters and voronoi bin info
restore,data_dir+use_source_name+'_muse_images.sav',/verb
14ae4f23   Jean-Philippe Bernard   improved
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
;% RESTORE: Restored variable: ST_TEMPLATES.
;% RESTORE: Restored variable: ST_MUSE_WEIGHTS.
;% RESTORE: Restored variable: VORONOI_ID.
;% RESTORE: Restored variable: AGE_VALUES.
;% RESTORE: Restored variable: METALICITY_VALUES.
;% RESTORE: Restored variable: BINS.
;% RESTORE: Restored variable: HREF.
;=== needed for absolute scaling of ISRF
restore,data_dir+use_source_name+'_muse_filters_data.sav',/verb
;% RESTORE: Restored variable: MUSE_IMAGES.
;% RESTORE: Restored variable: MUSE_FILTERS.
;% RESTORE: Restored variable: HREF.
restore,data_dir+use_source_name+'_muse_seds_muse_pixels.sav',/verb
;% RESTORE: Restored variable: ALL_SEDS.
;% RESTORE: Restored variable: ALL_SEDS_INDICES.
ccbd30b1   Jean-Philippe Bernard   First commit
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104

Nvor=max(voronoi_id)

use_NHmap=NHCO       ;used NH map in 1.e21 (from CO)

;stop
!quiet=1

t1=systime(0,/sec)
first_vid=0L
lambir=dustem_get_wavelengths(isrf_wavelengths=isrf_wavelengths)
;show_each=10
show_each=100
Nlamb=n_elements(isrf_wavelengths)

14ae4f23   Jean-Philippe Bernard   improved
105
106
107
108
109
110
111
112
113
ISRFS=dblarr(Nlamb,Nvor)
G0s=dblarr(Nvor)

;==== get Mathis field for G0 calculations
file=!dustem_soft_dir+'/data/ISRF_MATHIS.DAT'
readcol,file,Mathis_wavs,Mathis_ISRF
Mathis_ISRF=interpol(Mathis_ISRF,Mathis_wavs,isrf_wavelengths)
Mathis_1mic=interpol(Mathis_ISRF,isrf_wavelengths,1.0)

ccbd30b1   Jean-Philippe Bernard   First commit
114
115
116
117
118
119
120
121
122
123
FOR vid=first_vid,Nvor-1 DO BEGIN
	IF vid mod show_each EQ 0 THEN BEGIN
		t2=systime(0,/sec)
		delta_t_hr=(t2-t1)/60.^2 ;elapsed time [hr]
		frac_perc=vid/Nvor*100
		delta_t_remain=delta_t_hr/frac_perc*100.-delta_t_hr  ;remaining time [hr]
		message,'done '+strtrim(frac_perc)+' % in '+strtrim(delta_t_hr,2)+' hr remaining '+strtrim(delta_t_remain,2)+' hr',/continue
	ENDIF
	;===== get the SSP weights for the given voronoi bins
	weights=phangs_binid2weights(st_muse_weights,vid,st_templates,age_values,metalicity_values,reddening=reddening)
14ae4f23   Jean-Philippe Bernard   improved
124
125
126
	amplitude=1.         ;amplitude is set to 1, and will be corrected by G0 below
	use_reddening=0.     ;This sets Muse reddening to 0. Will be contsrained later
	fpd=phangs_stellar_continuum_plugin_weight2params(weights,parameter_values=val,redenning=use_reddening,/force_include_reddening,amplitude=amplitude,/force_include_amplitude)
8bc14240   Jean-Philippe Bernard   improved
127
128
129
  Nparams=n_elements(val)
  key=intarr(Nparams)
  FOR i=0L,Nparams-1 DO BEGIN
ccbd30b1   Jean-Philippe Bernard   First commit
130
131
132
	    toto=dustem_parameter_description2type(fpd[i],string_name=string_name,key=one_key)
	    key[i]=one_key
 	ENDFOR
14ae4f23   Jean-Philippe Bernard   improved
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
 	;==== compute the prediction stellar continuum for comparison to the Muse filter data.
 	;==== Here we use the reddening from MUSE
 	val_sed=val
 	val_sed[1]=reddening   ;for the SED, we use E(B-V)
 	spectrum=dustem_plugin_phangs_stellar_continuum(key=key,val=val_sed)
 	sed=interpol(spectrum[*,0],lambir,dustem_filter2wav(muse_filters[0:2]))
 	muse_sed=(*all_seds[vid]).stokesI
 	facts=muse_sed/sed
 	muse_factor=la_mean(facts)     ;This takes the average value over the MUSE bands
 	;print,G0,reddening
 	;stop
 	val_isrf=val ;for the ISRF, we use E(B-V)=0
 	ISRFS[*,vid]=dustem_plugin_phangs_stellar_isrf(key=key,val=val_isrf,object_distance=object_distance,object_thickness=object_thickness)
 	ISRFS[*,vid]=ISRFS[*,vid]*muse_factor ;=== scale the amplitude of ISRFs to the muse data
 	;=== compute corresponding G0
 	G0=interpol(ISRFS[*,vid],isrf_wavelengths,1.)/Mathis_1mic
 	G0s[vid]=G0
ccbd30b1   Jean-Philippe Bernard   First commit
150
151
152
ENDFOR

IF keyword_set(save) THEN BEGIN
14ae4f23   Jean-Philippe Bernard   improved
153
154
155
	file_save=data_dir+use_source_name+'_isrf_min_prediction.sav'
	save,ISRFS,G0s,object_distance,object_thickness,use_source_name,file=file_save,/verb
	phangs_make_isrf_product,use_source_name,voronoi_id,ISRFS,G0s,object_distance,object_thickness
ccbd30b1   Jean-Philippe Bernard   First commit
156
157
ENDIF

14ae4f23   Jean-Philippe Bernard   improved
158
159
160
161
;cgplot,lindgen(Nvor),G0s,/ylog,yrange=[1.e-5,1],xtit='Voronoi ID',ytit='G0'

stop

ccbd30b1   Jean-Philippe Bernard   First commit
162
163
164
the_end:

END