extract_all_muse_phangs_seds.pro
3.16 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
FUNCTION extract_all_muse_phangs_seds,source_name, $
voronoi_id, $
images, $
filters, $
indices=indices, $
counts=counts, $
use_these_indices=use_these_indices, $
help=help
;+
; NAME:
; extract_all_muse_phangs_seds
; PURPOSE:
; extract SEDs in Muse Voronoi bins
; CATEGORY:
; PHANGS ISRF
; CALLING SEQUENCE:
; all_seds=extract_all_muse_phangs_seds(source_name,voronoi_id,images,filters[,indices=][,counts=][,use_these_indices=])
; INPUTS:
; source_name = source name
; voronoi_id = voronoi id map
; images = images cube from which SEDs must be extracted
; filters = filters name list corresponing to images
; OPTIONAL INPUT PARAMETERS:
; use_these_indices = if set SED extraction will use these indices instead of recomputing them from voronoi_id map
; OUTPUTS:
; None
; OPTIONAL OUTPUT PARAMETERS:
; indices = list of indices
; counts = list of pixel numbers for each voronoi bin
; ACCEPTED KEY-WORDS:
; help = If set, print this help
; COMMON BLOCKS:
; None
; SIDE EFFECTS:
; The following files are written :
; /tmp/seds_muse_pixels.sav (by default, or filename if set) containing variable all_seds and all_seds_indices
; RESTRICTIONS:
; None
; PROCEDURE:
; uses dustem_sed_extractor
; EXAMPLES
;
; 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,'extract_all_muse_phangs_seds'
all_seds=-1
goto,the_end
ENDIF
;Nvor=max(voronoi_id)
Nvor=max(voronoi_id)+1 ;+1 is because voronoi IDs start at 0
dustem_init
;file='/tmp/seds_muse_pixels.sav'
;IF keyword_set(filename) THEN file=filename
;message,'upon completion, extracted seds will be stored in '+file,/continue
;stop
all_seds=ptrarr(Nvor)
all_seds_indices=ptrarr(Nvor)
counts=lonarr(Nvor)
IF NOT keyword_set(use_these_indices) THEN BEGIN
FOR vid=0LL,Nvor-1 DO BEGIN
IF vid mod 10 EQ 0 THEN BEGIN
message,'Extracting sed '+strtrim(vid,2)+' '+strtrim(1.*vid/Nvor*100.,2)+' %',/continue
ENDIF
index=where(voronoi_id EQ vid,count)
IF count NE 0 THEN BEGIN
sed=dustem_sed_extractor(images,index,filters,/total_intensity_only)
all_seds[vid]=ptr_new(sed)
all_seds_indices[vid]=ptr_new(index)
counts[vid]=count
ENDIF
ENDFOR
ENDIF ELSE BEGIN
FOR vid=0LL,Nvor-1 DO BEGIN
IF vid mod 10 EQ 0 THEN BEGIN
message,'Extracting sed '+strtrim(vid,2)+' '+strtrim(1.*vid/Nvor*100.,2)+' %',/continue
ENDIF
index=*use_these_indices[vid]
sed=dustem_sed_extractor(images,index,filters,/total_intensity_only)
all_seds[vid]=ptr_new(sed)
all_seds_indices[vid]=ptr_new(index)
counts[vid]=n_elements(index)
ENDFOR
ENDELSE
indices=all_seds_indices ;to be retruned as keyword
;save,all_seds,all_seds_indices,file=file
;message,'Saved '+file,/info
the_end:
RETURN,all_seds
END