extract_all_muse_phangs_seds.pro 1.42 KB
PRO extract_all_muse_phangs_seds,source_name,voronoi_id,jwst_images,filters,filename=filename,indices=indices,counts=counts,use_these_indices=use_these_indices

data_dir='/Volumes/PILOT_FLIGHT1/PHANGS-JWST/DR1/'

Nvor=max(voronoi_id)
dustem_init

file='/tmp/jwst_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)
      sed=dustem_sed_extractor(jwst_images,index,filters,/total_intensity_only)
      all_seds[vid]=ptr_new(sed)
      all_seds_indices[vid]=ptr_new(index)
      counts[vid]=count
   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(jwst_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

save,all_seds,all_seds_indices,file=file
message,'Saved '+file,/info

END