Blame view

LabTools/IRAP/JPB/read_muse_templates_info.pro 5.18 KB
d6343d56   Jean-Philippe Bernard   First commit
1
2
FUNCTION read_muse_templates_info,age_values=age_values,metalicity_values=metalicity_values,young=young,object=object,Nbins=Nbins,Nage=Nage,NZ=NZ,bins=bins

0ed148cc   Jean-Philippe Bernard   improved
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
47
48
49
;+
; NAME:
;    read_muse_templates_info
; PURPOSE:
;    Reads the Muse template info structure
; CATEGORY:
;    DustEM
; CALLING SEQUENCE:
;    st_templates=read_muse_templates_info([age_values=][,metalicity_values=][,young=][,object=][,Nbins=][,Nage=][,NZ=][,bins=])
; INPUTS:
;    None
; OPTIONAL INPUT PARAMETERS:
;    object  = object name (default='NGC0628')
; OUTPUTS:
;    weights = weights array (dim [Nage,NZ])
; OPTIONAL OUTPUT PARAMETERS:
;    age_values = 
;    metalicity_values =
;    Nbins =
;    Nage=
;    NZ=
;    bins=
; ACCEPTED KEY-WORDS:
;    young  = 
;    help                  = if set, print this help
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    None
; RESTRICTIONS:
;    The DustEMWrap IDL code must be installed
; PROCEDURE:
;    
; EXAMPLES
;    
; MODIFICATION HISTORY:
;    Written by JPB Jan 2024
;    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_templates_info'
  st_templates=0.
  goto,the_end
ENDIF

d6343d56   Jean-Philippe Bernard   First commit
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
dustem_define_la_common

use_object='NGC0628'
IF keyword_set(object) THEN use_object=object

;stop

IF keyword_set(young) THEN BEGIN
    dir='/Volumes/PILOT_FLIGHT1/PHANGS_MUSE/DR2p2/coopt/MUSEDAP/young'
	file=dir+'/'+use_object+'-0.92asec_templates_SFH_info.fits'
ENDIF ELSE BEGIN
	dir='/Volumes/PILOT_FLIGHT1/PHANGS_MUSE/DR2p2/coopt/MUSEDAP/fiducial'
	file=dir+'/'+use_object+'-0.92asec_templates_SFH_info.fits'
ENDELSE

st_templates=mrdfits(file,1,h)
help,st_templates,/str
	;** Structure <cd20ff78>, 5 tags, length=40, data length=40, refs=1:
	;   ID              LONG64                         0
	;   AGE             DOUBLE           1.9953000
	;   Z               DOUBLE         -0.40000000
	;   M_              DOUBLE          0.63730000
	;   M__LV           DOUBLE          0.75800000
	;print,minmax(st_templates.id)
	;                     0                    67
	;print,minmax(st_templates.age)
	;0.0063000000       15.848900
	;print,minmax(st_templates.Z)
	;     -0.72000000      0.41000000

order=sort(st_templates.age)
ages=st_templates[order].age
un=uniq(ages)
age_values=ages[un]
Nage=n_elements(age_values)

order=sort(st_templates.Z)
metalicity=st_templates[order].Z
un=uniq(metalicity)
metalicity_values=metalicity[un]
NZ=n_elements(metalicity_values)

Nbins=Nage*NZ

print,age_values
print,metalicity_values
	;stop
bins=lonarr(Nage,NZ)
bins[*]=la_undef(2)
FOR i=0L,Nage-1 DO BEGIN
	FOR j=0L,NZ-1 DO BEGIN
    	ind=where(st_templates.age EQ age_values[i] AND st_templates.Z EQ metalicity_values[j],count)
    	IF count NE 0 THEN BEGIN
    		bins[i,j]=st_templates[ind].id
    	ENDIF ELSE BEGIN
    		message,'Did not find age='+strtrim(age_values[i],2)+' Z='+strtrim(metalicity_values[j],2),/info
    		;stop
    	ENDELSE
    ENDFOR
ENDFOR

;   round metalicity values to match ssps file names
try=round(metalicity_values*100)/100.
metalicity_values=try

print,age_values
print,metalicity_values

;stop

;	age_values=[0.03, 0.05, 0.08, 0.15, 0.25, 0.40, 0.60, 1.0, 1.75, 3.0, 5.0, 8.5, 13.5]
;	metalicity_values=[-1.49, -0.96, -0.35, +0.06, +0.26, +0.4]

0ed148cc   Jean-Philippe Bernard   improved
123
124
the_end:

d6343d56   Jean-Philippe Bernard   First commit
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
RETURN,st_templates




; ENDIF ELSE BEGIN
; 	dir='/Volumes/PILOT_FLIGHT1/PHANGS_MUSE/DR2p2/coopt/MUSEDAP/fiducial'
; 	;NGC0628-0.92asec_templates_SFH_info.fits
; 	file=dir+'/'+use_object+'-0.92asec_templates_SFH_info.fits'
; 	st_templates=mrdfits(file,1,h)
; 	help,st_templates,/str
; ;** Structure <a93050c8>, 5 tags, length=40, data length=40, refs=1:
; ;   ID              LONG64                         0
; ;   AGE             DOUBLE          0.15000000
; ;   Z               DOUBLE          0.25590000
; ;   M_              DOUBLE          0.75750000
; ;   M__LV           DOUBLE          0.16300000


; 	print,age_values
; ;	     0.030000000     0.050000000     0.080000000      0.15000000      0.25000000      0.40000000      0.60000000       1.0000000       1.7500000       3.0000000       5.0000000       8.5000000       13.500000
; 	print,metalicity_values
; ;      -1.4863000     -0.96140000     -0.35120000     0.060000000      0.25590000      0.39710000

; 	order=sort(st_templates.age)
; 	ages=st_templates[order].age
; 	un=uniq(ages)
; 	age_values=ages[un]
;     Nage=n_elements(age_values)

; 	order=sort(st_templates.Z)
; 	metalicity=st_templates[order].Z
; 	un=uniq(metalicity)
; 	metalicity_values=metalicity[un]
;     NZ=n_elements(metalicity_values)

;     Nbins=Nage*NZ

; stop
; 	age_values=[0.03, 0.05, 0.08, 0.15, 0.25, 0.40, 0.60, 1.0, 1.75, 3.0, 5.0, 8.5, 13.5]
; 	metalicity_values=[-1.49, -0.96, -0.35, +0.06, +0.26, +0.4]
; 	Nage=n_elements(age_values)
; 	NZ=n_elements(metalicity_values)
;     Nbins=Nage*NZ
;     one_st={ID:0LL,AGE:la_undef(5),Z:la_undef(5),M_:la_undef(5),M__LV:la_undef(5)}
;     st_templates=replicate(one_st,Nbins)
;     bins=lonarr(Nage,NZ)
;     bins[*]=la_undef(2)    
;     ;stop
;     FOR i=0L,Nbins-1 DO BEGIN
;     	bins[i]=i
;     	st_templates[i].ID=i
;     	ij=index2ij([i],[NAGE,NZ])
;     	st_templates[i].AGE=age_values[ij[0,0]]
;         st_templates[i].Z=metalicity_values[ij[0,1]]
;     ENDFOR
; ENDELSE

; RETURN,st_templates
END