read_muse_phangs_voronoi_bins.pro 2.7 KB
FUNCTION read_muse_phangs_voronoi_bins,object,header_in=header_in,header_out=header_out,snr_bin=snr_bin,flux=flux,snr_flux=snr_flux,help=help

;+
; NAME:
;    read_muse_phangs_voronoi_bins
; PURPOSE:
;    read muse voronoi data
; CATEGORY:
;    DustEM, Distributed, Mid-Level, Plugin
; CALLING SEQUENCE:
;    voronoi_id=read_muse_phangs_voronoi_bins(object[,header_in=][,header_out=][,snr_bin=][,flux=][,snr_flux=])
; INPUTS:
;    object   = object name
; OPTIONAL INPUT PARAMETERS:
;    header_in = if set, project on this header
; OUTPUTS:
;    voronoi_id = voronoi id map
; OPTIONAL OUTPUT PARAMETERS:
;    header_out = output map header
;    snr_bin = S/N ration map
;    flux = Flux map
;    snr_flux = flux S/N map
; ACCEPTED KEY-WORDS:
;    help                  = if set, print this help
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    None
; RESTRICTIONS:
;    
; PROCEDURE:
;    
; EXAMPLES
;    voronoi_id=read_muse_phangs_voronoi_bins('NGC0628',header_out=h,snr_bin=snr,flux=flux,snr_flux=snr_flux)
;    image_cont20,flux,h,/square,/silent,imrange=[0,100]
; MODIFICATION HISTORY:
;    Written by JPB June 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,'read_muse_phangs_voronoi_bins'
  voronoi_id=0.
  goto,the_end
ENDIF

;stop

;==== maps of MUSE parameters
dir='/Volumes/PILOT_FLIGHT1/PHANGS_MUSE/DR2p2/coopt/MUSEDAP/fiducial/'
file=dir+object+'-0.92asec_MAPS-001.fits'
toto=mrdfits(file,0,h) ;This is ?
print,sxpar(h,'EXTNAME')
;stop
;toto=mrdfits(file,1,h) ;This looks like a map pixel ID
;print,sxpar(h,'EXTNAME')
;ID
flux=mrdfits(file,2,h) ;This looks like a map of fluxes (usable in Dustem ?)
print,sxpar(h,'EXTNAME')
;FLUX
snr_flux=mrdfits(file,3,h) ;This looks like a map of SNR (of flux ?)
;print,sxpar(h,'EXTNAME')
;SNR
snr_bin=mrdfits(file,4,h) ;This is the SNR map
print,sxpar(h,'EXTNAME')
;SNRBIN
bin_id=mrdfits(file,5,h) ;This is the bin ID map
print,sxpar(h,'EXTNAME')
;BIN_ID
;toto=mrdfits(file,6,h) ;This is the bin ID
;print,sxpar(h,'EXTNAME')
;V_STARS
;toto=mrdfits(file,7,h) ;This is the bin ID
;print,sxpar(h,'EXTNAME')
;FORM_ERR_V_STARS
;etc ...
;stop
hh=cd2astro_header(h)
;image_cont20,snrbin,h,/square,image_color='jpbloadct',imrange=[50,200],/silent,off_bar=obp

ind=where(finite(bin_id) NE 1,count)
IF count NE 0 THEN bin_id[ind]=la_undef()
ind=where(finite(bin_id) EQ -1,count)
IF count NE 0 THEN bin_id[ind]=la_undef()

print,sxpar(h,'EXTNAME')
h=cd2astro_header(h)
sxaddpar,h,'EQUINOX',2000.

IF keyword_set(header_in) THEN BEGIN
	voronoi_id=project2(h,bin_id,header_in,/silent,/round)
	header_out=header_in
ENDIF ELSE BEGIN
	voronoi_id=bin_id
	header_out=h
ENDELSE

the_end:

RETURN,voronoi_id

END