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 ;+ ; 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 dustem_define_la_common use_object='NGC0628' IF keyword_set(object) THEN use_object=object ;stop IF keyword_set(young) THEN BEGIN ;dir=!phangs_data_dir+'/phangs_drive/PHANGS_MUSE/DR2p2/coopt/MUSEDAP/young/' dir=!phangs_data_dir+'/phangs_drive/Archive/PHANGS_MUSE/DR2.2/copt/MUSEDAP/young/' ;dir='/Volumes/PILOT_FLIGHT1/PHANGS_MUSE/DR2p2/coopt/MUSEDAP/young' file=dir+'/'+use_object+'-0.92asec_templates_SFH_info.fits' ENDIF ELSE BEGIN ;dir=!phangs_data_dir+'/phangs_drive/PHANGS_MUSE/DR2p2/coopt/MUSEDAP/fiducial/' dir=!phangs_data_dir+'/phangs_drive/Archive/PHANGS_MUSE/DR2.2/copt/MUSEDAP/fiducial/intermediate/DR2.2v1_copt_SFHs/' ;dir='/Volumes/PILOT_FLIGHT1/PHANGS_MUSE/DR2p2/coopt/MUSEDAP/fiducial' file=dir+'/'+use_object+'-0.92asec_templates_SFH_info.fits' ENDELSE st_info=file_info(file) IF st_info.exists NE 1 THEN BEGIN message,'Could not find '+file,/continue stop ENDIF st_templates=mrdfits(file,1,h) help,st_templates,/str ;** Structure , 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] the_end: 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 , 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