Blame view

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

9b0b6d7e   Jean-Philippe Bernard   finished implemen...
3
4
;,resolution_filter=resolution_filter

ccbd30b1   Jean-Philippe Bernard   First commit
5
6
7
8
;+
; NAME:
;       make_phangs_ssps_isrf_prediction
; CALLING SEQUENCE:
14ae4f23   Jean-Philippe Bernard   improved
9
;       make_phangs_ssps_isrf_prediction[,source_name=][,/save][,/help]
ccbd30b1   Jean-Philippe Bernard   First commit
10
11
12
13
14
15
16
17
18
19
20
21
22
23
; 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
24
25
26
;       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
27
; SIDE EFFECTS:
14ae4f23   Jean-Philippe Bernard   improved
28
;       produces file _isrf_min_prediction.sav
ccbd30b1   Jean-Philippe Bernard   First commit
29
; EXAMPLE:
14ae4f23   Jean-Philippe Bernard   improved
30
;       make_phangs_ssps_isrf_prediction,source_name='ngc0628',/save
ccbd30b1   Jean-Philippe Bernard   First commit
31
32
33
34
35
36
37
38
39
40
; 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
41
;===== The prediction is scaled to the Muse filter data observations
ccbd30b1   Jean-Philippe Bernard   First commit
42
43
44
45
46

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
47
48
49
50
51
52
53
54
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
55
56
57
use_source_name='ngc0628'
IF keyword_set(source_name) THEN use_source_name=source_name

997cc66d   Jean-Philippe Bernard   improved
58
object_distance=(phangs_get_galaxy_distance(use_source_name)).dist
ccbd30b1   Jean-Philippe Bernard   First commit
59
60
CASE use_source_name OF
	'ngc0628':BEGIN
997cc66d   Jean-Philippe Bernard   improved
61
		;object_distance=9.84  ;MPc
ccbd30b1   Jean-Philippe Bernard   First commit
62
63
		object_thickness=0.1  ;kpc
	END
82beee16   Jean-Philippe Bernard   improved
64
	'ngc3351':BEGIN
997cc66d   Jean-Philippe Bernard   improved
65
		;object_distance=9.96  ;MPc
82beee16   Jean-Philippe Bernard   improved
66
67
		object_thickness=0.1  ;kpc
	END
ccbd30b1   Jean-Philippe Bernard   First commit
68
69
ENDCASE

9b0b6d7e   Jean-Philippe Bernard   finished implemen...
70
71
72
73
74
75
reso_str=''
;stop
;IF keyword_set(resolution_filter) THEN BEGIN
;		reso_str='_'+resolution_filter
;ENDIF

ccbd30b1   Jean-Philippe Bernard   First commit
76
77
78
79
dustem_define_la_common
obp=[1.1,0,1.15,1]

;dustem_init,show_plots=show_plots
9b37a060   Jean-Philippe Bernard   improved for smoo...
80
81
;needed only for NHCO (ie, not used)
;restore,data_dir+use_source_name+'_jwst_images'+reso_str+'.sav',/verb
14ae4f23   Jean-Philippe Bernard   improved
82
83
84
85
;% RESTORE: Restored variable: JWST_IMAGES.
;% RESTORE: Restored variable: FILTERS.
;% RESTORE: Restored variable: HREF.
;% RESTORE: Restored variable: NHCO.
ccbd30b1   Jean-Philippe Bernard   First commit
86
;needed for stellar parameters and voronoi bin info
9b0b6d7e   Jean-Philippe Bernard   finished implemen...
87
restore,data_dir+use_source_name+'_muse_images'+reso_str+'.sav',/verb
14ae4f23   Jean-Philippe Bernard   improved
88
89
90
91
92
93
94
;% 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.
9b37a060   Jean-Philippe Bernard   improved for smoo...
95
;=== needed for muse_filters only (for absolute scaling of ISRF)
9b0b6d7e   Jean-Philippe Bernard   finished implemen...
96
restore,data_dir+use_source_name+'_muse_filters_data'+reso_str+'.sav',/verb
14ae4f23   Jean-Philippe Bernard   improved
97
98
99
;% RESTORE: Restored variable: MUSE_IMAGES.
;% RESTORE: Restored variable: MUSE_FILTERS.
;% RESTORE: Restored variable: HREF.
9b37a060   Jean-Philippe Bernard   improved for smoo...
100
;=== needed for all_seds only (for normalisation to Muse)
9b0b6d7e   Jean-Philippe Bernard   finished implemen...
101
restore,data_dir+use_source_name+'_muse_seds_muse_pixels'+reso_str+'.sav',/verb
14ae4f23   Jean-Philippe Bernard   improved
102
103
;% RESTORE: Restored variable: ALL_SEDS.
;% RESTORE: Restored variable: ALL_SEDS_INDICES.
ccbd30b1   Jean-Philippe Bernard   First commit
104

9b0b6d7e   Jean-Philippe Bernard   finished implemen...
105
106
;stop

ccbd30b1   Jean-Philippe Bernard   First commit
107
108
Nvor=max(voronoi_id)

9b37a060   Jean-Philippe Bernard   improved for smoo...
109
;use_NHmap=NHCO       ;used NH map in 1.e21 (from CO)
ccbd30b1   Jean-Philippe Bernard   First commit
110
111
112
113
114
115
116
117
118
119
120

;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
121
122
123
124
125
126
127
128
129
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
130
131
132
133
134
135
136
137
138
139
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
140
141
142
	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
143
144
145
  Nparams=n_elements(val)
  key=intarr(Nparams)
  FOR i=0L,Nparams-1 DO BEGIN
ccbd30b1   Jean-Philippe Bernard   First commit
146
147
148
	    toto=dustem_parameter_description2type(fpd[i],string_name=string_name,key=one_key)
	    key[i]=one_key
 	ENDFOR
14ae4f23   Jean-Philippe Bernard   improved
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
 	;==== 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
166
167
168
ENDFOR

IF keyword_set(save) THEN BEGIN
14ae4f23   Jean-Philippe Bernard   improved
169
170
171
	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
172
173
ENDIF

14ae4f23   Jean-Philippe Bernard   improved
174
175
176
177
;cgplot,lindgen(Nvor),G0s,/ylog,yrange=[1.e-5,1],xtit='Voronoi ID',ytit='G0'

stop

ccbd30b1   Jean-Philippe Bernard   First commit
178
179
180
the_end:

END