Blame view

LabTools/IRAP/JPB/phangs_extract_seds.pro 4.7 KB
6fd06be5   Jean-Philippe Bernard   improved
1
PRO phangs_extract_seds,source_name=source_name,save=save,help=help
d8b7c983   Jean-Philippe Bernard   First commit
2

6fd06be5   Jean-Philippe Bernard   improved
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
;+
; NAME:
;    phangs_extract_seds
; PURPOSE:
;    extract SEDs in Muse Voronoi bins
; CATEGORY:
;    PHANGS ISRF
; CALLING SEQUENCE:
;    phangs_extract_seds[,source_name=][,/save]
; INPUTS:
;    None
; OPTIONAL INPUT PARAMETERS:
;    source_name            : source name (default = 'ngc0628')
; OUTPUTS:
;    None
; OPTIONAL OUTPUT PARAMETERS:
;    None
; ACCEPTED KEY-WORDS:
;    help      = If set, print this help
;    save      = If set, save result
;	 nostop    = if set, does not stop
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    The following files are written, if they do not already exist:
;    _jwst_seds_muse_pixels.sav
;    _muse_seds_muse_pixels.sav
;    _astrosat_seds_muse_pixels.sav
;    _herschel_seds_muse_pixels.sav
;    _all_seds_muse_pixels.sav
; RESTRICTIONS:
;    None
; PROCEDURE:
;    
; EXAMPLES
;	phangs_extract_seds,source_name='ngc0628'
; MODIFICATION HISTORY:
;    Written by J.-Ph. Bernard (2023)
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
;-

IF keyword_set(help) THEN BEGIN
  doc_library,'phangs_extract_seds'
  goto,the_end
ENDIF
d8b7c983   Jean-Philippe Bernard   First commit
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

use_source_name='ngc0628'
IF keyword_set(source_name) THEN use_source_name=source_name

data_dir=!phangs_data_dir+'/ISRF/WORK/'

extract_seds:

restore,data_dir+use_source_name+'_jwst_images.sav',/verb
;% RESTORE: Restored variable: JWST_IMAGES.
;% RESTORE: Restored variable: FILTERS.
;% RESTORE: Restored variable: HREF.
;% RESTORE: Restored variable: NHCO.
restore,data_dir+use_source_name+'_muse_images.sav',/verb
;% 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.
restore,data_dir+use_source_name+'_astrosat_data.sav',/verb
;% RESTORE: Restored variable: ASTROSAT_IMAGES.
;% RESTORE: Restored variable: ASTROSAT_FILTERS.
;% RESTORE: Restored variable: HREF.
restore,data_dir+use_source_name+'_muse_filters_data.sav',/verb
6fd06be5   Jean-Philippe Bernard   improved
75
76
77
78
79
80
81
;% RESTORE: Restored variable: MUSE_IMAGES.
;% RESTORE: Restored variable: MUSE_FILTERS.
;% RESTORE: Restored variable: HREF.
restore,data_dir+use_source_name+'_herschel_images.sav',/verb
;% RESTORE: Restored variable: HERSCHEL_IMAGES.
;% RESTORE: Restored variable: HERSCHEL_FILTERS.
;% RESTORE: Restored variable: HREF.
d8b7c983   Jean-Philippe Bernard   First commit
82
83
84
85
86

;stop

;=== extract and save observed seds in Muse Voronoi bins
file_save=data_dir+use_source_name+'_jwst_seds_muse_pixels.sav'
6fd06be5   Jean-Philippe Bernard   improved
87
88
89
90
91
92
res=file_info(file_save)
IF not res.exists THEN BEGIN
	extract_all_muse_phangs_seds,use_source_name,voronoi_id,jwst_images,filters,indices=all_seds_indices,file=file_save,counts=counts
ENDIF
restore,data_dir+use_source_name+'_jwst_seds_muse_pixels.sav',/verb  ;just to get the all_seds_indices variable

d8b7c983   Jean-Philippe Bernard   First commit
93
file_save=data_dir+use_source_name+'_muse_seds_muse_pixels.sav'
6fd06be5   Jean-Philippe Bernard   improved
94
95
96
97
98
res=file_info(file_save)
IF not res.exists THEN BEGIN
	extract_all_muse_phangs_seds,use_source_name,voronoi_id,muse_images,muse_filters,use_these_indices=all_seds_indices,file=file_save,counts=counts
ENDIF

d8b7c983   Jean-Philippe Bernard   First commit
99
file_save=data_dir+use_source_name+'_astrosat_seds_muse_pixels.sav'
6fd06be5   Jean-Philippe Bernard   improved
100
101
102
103
104
105
106
107
108
109
res=file_info(file_save)
IF not res.exists THEN BEGIN
	extract_all_muse_phangs_seds,source_name,voronoi_id,astrosat_images,astrosat_filters,use_these_indices=all_seds_indices,file=file_save,counts=counts
ENDIF

file_save=data_dir+use_source_name+'_herschel_seds_muse_pixels.sav'
res=file_info(file_save)
IF not res.exists THEN BEGIN
	extract_all_muse_phangs_seds,source_name,voronoi_id,herschel_images,herschel_filters,use_these_indices=all_seds_indices,file=file_save,counts=counts
ENDIF
d8b7c983   Jean-Philippe Bernard   First commit
110
111
112

;==== The following is not really useful, can be done through SED aggregation later
;==== However, not equivalent to the above, because of undefined pixels in some of the images, and the way this is handled by sed extractor
6fd06be5   Jean-Philippe Bernard   improved
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
;stop

file_save=data_dir+use_source_name+'_all_seds_muse_pixels.sav'
res=file_info(file_save)
IF not res.exists THEN BEGIN
	use_filters=[astrosat_filters,muse_filters,filters,herschel_filters]
	use_Nfilters=n_elements(use_filters)
	use_images=fltarr([sxpar(href,'NAXIS1'),sxpar(href,'NAXIS2'),2,use_Nfilters])
	from=0L & to=from+n_elements(filters)-1
	use_images[*,*,*,from:to]=jwst_images
	from=to+1 & to=from+n_elements(muse_filters)-1
	use_images[*,*,*,from:to]=muse_images
	from=to+1 & to=from+n_elements(astrosat_filters)-1
	use_images[*,*,*,from:to]=astrosat_images
	from=to+1 & to=from+n_elements(herschel_filters)-1
	use_images[*,*,*,from:to]=herschel_images
	extract_all_muse_phangs_seds,use_source_name,voronoi_id,use_images,use_filters,indices=all_seds_indices,file=file_save,counts=counts
ENDIF

the_end:
d8b7c983   Jean-Philippe Bernard   First commit
133
134

END