Blame view

LabTools/IRAP/JPB/extract_all_muse_phangs_seds.pro 3.16 KB
9b0b6d7e   Jean-Philippe Bernard   finished implemen...
1
2
3
4
5
6
7
8
FUNCTION extract_all_muse_phangs_seds,source_name, $
                                 voronoi_id, $
                                 images, $
                                 filters, $
                                 indices=indices, $
                                 counts=counts, $
                                 use_these_indices=use_these_indices, $
                                 help=help
d6343d56   Jean-Philippe Bernard   First commit
9

9b0b6d7e   Jean-Philippe Bernard   finished implemen...
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:
;    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.  
;-
d6343d56   Jean-Philippe Bernard   First commit
49

9b0b6d7e   Jean-Philippe Bernard   finished implemen...
50
51
52
53
54
55
56
57
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
d6343d56   Jean-Philippe Bernard   First commit
58
59
dustem_init

9b0b6d7e   Jean-Philippe Bernard   finished implemen...
60
61
;file='/tmp/seds_muse_pixels.sav'
;IF keyword_set(filename) THEN file=filename
d6343d56   Jean-Philippe Bernard   First commit
62

9b0b6d7e   Jean-Philippe Bernard   finished implemen...
63
;message,'upon completion, extracted seds will be stored in '+file,/continue
6fd06be5   Jean-Philippe Bernard   improved
64
;stop
d6343d56   Jean-Philippe Bernard   First commit
65
66
67
68
69
70
71
72
73
74
75

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)
9b0b6d7e   Jean-Philippe Bernard   finished implemen...
76
77
78
79
80
81
      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
d6343d56   Jean-Philippe Bernard   First commit
82
83
84
85
86
87
88
   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]
9b0b6d7e   Jean-Philippe Bernard   finished implemen...
89
      sed=dustem_sed_extractor(images,index,filters,/total_intensity_only)
d6343d56   Jean-Philippe Bernard   First commit
90
91
92
93
94
95
      all_seds[vid]=ptr_new(sed)
      all_seds_indices[vid]=ptr_new(index)
      counts[vid]=n_elements(index)
   ENDFOR   
ENDELSE

9b0b6d7e   Jean-Philippe Bernard   finished implemen...
96
97
98
99
100
101
102
103
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
d6343d56   Jean-Philippe Bernard   First commit
104
105

END