; docformat = 'rst' ; ; NAME: ; readBusDeMeo ; PURPOSE: ; Read average or individual spectra of Bus-DeMeo taxonomy. ; ;+ ; :Description: ; Read average or individual spectra of Bus-DeMeo taxonomy. ; ; :Categories: ; Database, Asteroid, Colors ; ; :Params: ; path: in, optional, type=string ; Path to the directory of the Bus-DeMeo taxonomy. ; ; :Keywords: ; template: in, optional, type=boolean, default=1 ; Only read average template spectra ; objects: in, optional, type=boolean, default=0 ; Read individual object spectra (has the effect to set template=0) ; config: in, optional, type=string, default='~/.idl/catalogs.ini' ; Path to the configuration file for catalogs, at the ; minimum this file should contain the 2 following lines to be used ; by current routine:: ; [Small bodies surface properties] ; bus-demeo = /home/bcarry/data/mining/sdss/Bus-DeMeo/ ; design: in, optional, type=string, default='design.csv' ; Path to a file describing the colors, linestyle, symbols of each class ; ; :Returns: A structure with the average spectrum of each class in Bus-DeMeo taxonomy.Fields are:: ; N: the number of classes ; wave: a vector of reference wavelength for each spectral bin (micron) ; class: an array of structure, with name, spec, and dev fields ; for each class ; ; :Examples: ; Read the taxonomy and plot A-type spectrum. ; IDL> taxo=readBusDeMeo() ; IDL> cgPlot, taxo.wave, taxo.class[0].spec,title=taxo.class[0].name+'-type' ; ; :Uses: ; initIDL, readcol ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Written in November 2015, B. Carry (OCA) ; 2016 Feb. - B. Carry (OCA) - Can now read templates or individual objects ; 2016 Dec. - B. Carry (OCA) - Added reading of colors/symbol if available ; 2017 Mar. - B. Carry (OCA) - Added Eigenvector if available ;- function readBusDeMeo, path,template=template,objects=objects,PCs=PCs,config=config,design=design ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--I.1-- Set IDL Compilation Options --------------------------------------------------------- COMPILE_OPT hidden, idl2 ;--I.2-- Set Taxonomy File ------------------------------------------------------------------- ;--I.2.1-- From default configuration if not keyword_set(path) then begin if keyword_set(config) then confCatalog= initIDL(config, /CATALOG) $ else begin confAstroIM= initIDL() confCatalog= initIDL(confAstroIM.soft.catalog, /CATALOG) endelse path = confCatalog.surface.taxo ;--I.2.2-- From command-line input endif else path = strtrim(path,2) if not keyword_set(design) then design='design.csv' ;--I.2.3-- Filenames fileTemplate=path+'meanspectra.csv' fileList =path+'listspectra.csv' filePCs =path+'PCs.csv' fileDesign =path+design ;--I.3-- Individual or Template Spectra ------------------------------------------------------ if not keyword_set(objects) and not keyword_set(pcs) then template=1 else begin if keyword_set(objects) then pcs=0 if keyword_set(pcs) then objects=0 endelse ;--I.4-- Check Presence of Files ------------------------------------------------------------ if keyword_set(template) and not file_test(fileTemplate,/read) then begin message, /ioError, 'Bus-DeMeo template spectra file not found: '+fileTemplate return, -1 endif if keyword_set(objects) and not file_test(fileList,/read) then begin message, /ioError, 'Bus-DeMeo list of spectra file not found: '+fileList return, -1 endif if keyword_set(PCs) and not file_test(filePCs,/read) then begin message, /ioError, 'Bus-DeMeo eigenvector file not found: '+filePCs return, -1 endif ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Read Bus-DeMeo Taxonomy File -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; if keyword_set(template) then begin ;--II.1-- Blind Read of Bus-DeMeo Taxonomy ------------------------------------------------- readcol, fileTemplate, wave, $ avgA, errA, avgB, errB, $ avgC, errC, avgCb, errCb, avgCg, errCg, avgCgh, errCgh, avgCh, errCh, $ avgD, errD, avgK, errK, avgL, errL, $ avgO, errO, avgQ, errQ, avgR, errR, $ avgS, errS, avgSa, errSa, avgSq, errSq, avgSr, errSr, avgSv, errSv, $ avgT, errT, avgV, errV, $ avgX, errX, avgXc, errXc, avgXe, errXe, avgXk, errXk, $ delimiter=',', skipline=2, $ format='(F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F)', /silent nbClass=24 nbWave = n_elements(wave) ;--II.2-- Set Missing Deviation to 0.05 ---------------------------------------------------- errCg *=0. & errCg += 0.05 errO *=0. & errO += 0.05 errR *=0. & errR += 0.05 ;--II.3-- Define Class Names -------------------------------------------------------------- classN = ['A','B','C','Cb','Cg','Cgh','Ch','D','K','L','O','Q','R','S','Sa','Sq','Sr','Sv','T','V','X','Xc','Xe','Xk'] ;--II.4-- Set OutPut Structure ------------------------------------------------------------- taxo={ N:nbClass, wave: wave, $ class: replicate( {name:'', spec:fltarr(nbWave), dev:fltarr(nbWave), WavelengthUnit:'micron', $ color:'Black', sym:'Filled circle', size:1.0, style:0, thick:1.0}, nbClass ) } ;--II.5-- For each Class, add Name, Spec, and Deviation ------------------------------------ taxo.class.name = classN taxo.class.spec = [ [avgA], [avgB], [avgC], [avgCb], [avgCg], [avgCgh], [avgCh], $ [avgD], [avgK], [avgL], [avgO], [avgQ], [avgR], [avgS], $ [avgSa], [avgSq], [avgSr], [avgSv], [avgT], [avgV], $ [avgX], [avgXc], [avgXe], [avgXk] ] taxo.class.dev = [ [errA], [errB], [errC], [errCb], [errCg], [errCgh], [errCh], $ [errD], [errK], [errL], [errO], [errQ], [errR], [errS], $ [errSa], [errSq], [errSr], [errSv], [errT], [errV], $ [errX], [errXc], [errXe], [errXk] ] ;--II.6-- Add Design Information if Present ------------------------------------------------ if file_test(fileDesign,/read) then begin ;--II.6.1-- Read Design File readcol, fileDesign, dLab, dCol, dSiz, dSym, dSty, dThk, format='(A,A,F,A,A,F)', delimiter=',', /Silent dLab=strTrim(dLab,2) dCol=strTrim(dCol,2) dSym=strTrim(dSym,2) ;--II.6.2-- For Each Class for kC=0, nbClass-1 do begin pD=where( strCmp(taxo.class[kC].name, dLab) ) taxo.class[kC].color= dCol[pD] taxo.class[kC].sym = dSym[pD] taxo.class[kC].size = dSiz[pD] taxo.class[kC].style= lineStyleID(dSty[pD]) taxo.class[kC].thick= dThk[pD] endfor endif return, taxo endif ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- III -- Read Individual Spectra -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; if keyword_set(objects) then begin ;--III.1-- Read the List of Spectra -------------------------------------------------------- readcol, fileList, fileName, ssoNum, ssoName, ssoClass, delimiter=',', format='(A,L,A,A)', /Silent nbSSO=n_elements(fileName) fileName = strtrim(fileName,2) ssoName = strtrim(ssoName,2) ssoClass = strtrim(ssoClass,2) ;--III.2-- Set OutPut Structure ------------------------------------------------------------ taxo=replicate({num:0L, name:'', class:'', wave:ptr_new(), spec:ptr_new(), unc:ptr_new()},nbSSO) ;--III.3-- Fill Basic Information ---------------------------------------------------------- taxo.num = ssoNum taxo.name = ssoName taxo.class= ssoClass ;--III.4-- Read and Store Each Object ------------------------------------------------------ for kSSO=0, nbSSO-1 do begin ;--III.4.1-- Check for File if not file_test(path+fileName[kSSO],/read) then begin message, /ioError, 'Bus-DeMeo individual spectrum file not found: '+fileName[kSSO] return, -1 endif ;--III.4.2-- Read File readcol, path+fileName[kSSO], wave, refl, unc, format='(F,F,F)', /Silent ;--III.4.3-- Update Pointers taxo[kSSO].wave = ptr_new(/Allocate_heap) taxo[kSSO].spec = ptr_new(/Allocate_heap) taxo[kSSO].unc = ptr_new(/Allocate_heap) ;--III.4.4-- Store Spectra in Structure *taxo[kSSO].wave = wave *taxo[kSSO].spec = refl *taxo[kSSO].unc = unc endfor return, taxo endif ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- IV -- Read PC Eigenvectors -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; if keyword_set(PCs) then begin ;--IV.1-- Read the EigenVectors ------------------------------------------------------------ readcol, filePCs, delimiter=',', /Silent, pcWave, $ PC1 , PC2 , PC3 , PC4 , PC5 , PC6 , PC7 , PC8 , PC9 , PC10, $ PC11, PC12, PC13, PC14, PC15, PC16, PC17, PC18, PC19, PC20, $ PC21, PC22, PC23, PC24, PC25, PC26, PC27, PC28, PC29, PC30, $ PC31, PC32, PC33, PC34, PC35, PC36, PC37, PC38, PC39, PC40 nbChannel=n_elements(PC1) ;--IV.2-- Set OutPut Structure ------------------------------------------------------------- taxo={wave:pcWave, $ PC1 :PC1 , PC2 :PC2 , PC3 :PC3 , PC4 :PC4 , PC5 :PC5 , PC6 :PC6 , PC7 :PC7 , PC8 :PC8 , PC9 :PC9 , PC10:PC10, $ PC11:PC11, PC12:PC12, PC13:PC13, PC14:PC14, PC15:PC15, PC16:PC16, PC17:PC17, PC18:PC18, PC19:PC19, PC20:PC20, $ PC21:PC21, PC22:PC22, PC23:PC23, PC24:PC24, PC25:PC25, PC26:PC26, PC27:PC27, PC28:PC28, PC29:PC29, PC30:PC30, $ PC31:PC31, PC32:PC32, PC33:PC33, PC34:PC34, PC35:PC35, PC36:PC36, PC37:PC37, PC38:PC38, PC39:PC39, PC40:PC40} return, taxo endif end