Blame view

LabTools/IRAP/JPB/read_muse_phangs_voronoi_bins.pro 3.28 KB
0ed148cc   Jean-Philippe Bernard   improved
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
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
d6343d56   Jean-Philippe Bernard   First commit
47
48
49
50

;stop

;==== maps of MUSE parameters
9c5f0ed1   Jean-Philippe Bernard   improved
51
;dir=!phangs_data_dir+'/phangs_drive/PHANGS_MUSE/DR2p2/coopt/MUSEDAP/fiducial/'
3e3d714b   Jean-Philippe Bernard   removed hardcoded...
52
;dir='/Volumes/PILOT_FLIGHT1/PHANGS_MUSE/DR2p2/coopt/MUSEDAP/fiducial/'
d451cb3c   Jean-Philippe Bernard   improved
53
;dir=!phangs_data_dir+'/phangs_drive/Archive/PHANGS_MUSE/DR2.2/copt/MUSEDAP/fiducial/'
99ec1937   Jean-Philippe Bernard   improved
54
55
56
57
;dir=!phangs_data_dir+'/phangs_drive/Archive/PHANGS_MUSE/DR2.2/copt/MUSEDAP/fiducial/intermediate/DR2.2v1_copt_SFHs/'
dir=!phangs_data_dir+'/phangs_drive/Archive/PHANGS_MUSE/DR2.2/copt/MUSEDAP/fiducial/'
;file=dir+object+'-0.92asec_MAPS-001.fits'
file=dir+object+'-0.92asec_MAPS.fits'
9c5f0ed1   Jean-Philippe Bernard   improved
58
59
60
61
62
st_info=file_info(file)
IF st_info.exists NE 1 THEN BEGIN
	message,'Could not find '+file,/continue
	stop
ENDIF
d6343d56   Jean-Philippe Bernard   First commit
63
64
65
66
67
68
69
70
71
72
73
74
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
0ed148cc   Jean-Philippe Bernard   improved
75
snr_bin=mrdfits(file,4,h) ;This is the SNR map
d6343d56   Jean-Philippe Bernard   First commit
76
77
print,sxpar(h,'EXTNAME')
;SNRBIN
0ed148cc   Jean-Philippe Bernard   improved
78
bin_id=mrdfits(file,5,h) ;This is the bin ID map
d6343d56   Jean-Philippe Bernard   First commit
79
80
81
82
83
84
85
86
87
88
89
90
91
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

9b37a060   Jean-Philippe Bernard   improved for smoo...
92
93
;stop

d6343d56   Jean-Philippe Bernard   First commit
94
ind=where(finite(bin_id) NE 1,count)
0ed148cc   Jean-Philippe Bernard   improved
95
96
97
98
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()

d6343d56   Jean-Philippe Bernard   First commit
99
100
101
102
print,sxpar(h,'EXTNAME')
h=cd2astro_header(h)
sxaddpar,h,'EQUINOX',2000.

9b37a060   Jean-Philippe Bernard   improved for smoo...
103
;=== reproject voronoi ids on provided header
d6343d56   Jean-Philippe Bernard   First commit
104
IF keyword_set(header_in) THEN BEGIN
9b37a060   Jean-Philippe Bernard   improved for smoo...
105
106
	;stop
	voronoi_id=long(project2(h,bin_id,header_in,/silent,/round))
d6343d56   Jean-Philippe Bernard   First commit
107
108
	header_out=header_in
ENDIF ELSE BEGIN
9b37a060   Jean-Philippe Bernard   improved for smoo...
109
	voronoi_id=long(bin_id)
d6343d56   Jean-Philippe Bernard   First commit
110
111
112
	header_out=h
ENDELSE

0ed148cc   Jean-Philippe Bernard   improved
113
114
the_end:

d6343d56   Jean-Philippe Bernard   First commit
115
116
117
RETURN,voronoi_id

END