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