; docformat = 'rst' ; ; NAME: ; ssoddGetAnalog ; PURPOSE: ; Return the spectral classification and analog meteorite from the Solar ; System Objects Density Database for a specific target or ; simply dump the database ; ;+ ; :Description: ; Return the spectral classification and analog meteorite from the Solar ; System Objects Density Database for a specific target or ; simply dump the database ; ; :Categories: ; Database, SSODD, Asteroid ; ; :Params: ; ID: in, required, type=integer/string ; Target identifyer ('*', Name, Provisional designation, Number) ; ; :Returns: A structure with the spectral information and meteorite ; analog, or code for success (-1: target not found, -2: SSODD file ; not found, -3: No target specified). Structure fields are:: ; .N: Number of entries in the SSODD Analog table ; .TAXO: Taxonomy Information:: ; .sel: Use entry? (boolean) ; .scheme: Taxonomic scheme (Tholen|Bus|DeMeo|...) ; .class: Taxonomic class ; .who: Bibliographic reference ; .MET: Analog Meteorite Information:: ; .sel: Use entry? (boolean) ; .class: Meteorite class (same as in ssoddGetMet) ; .who: Bibliographic reference ; .IND: An array of N structures for each published analog::; ; .TAXO: (see above) ; .MET: (see above) ; ; :Keywords: ; SSODD: in, optional, type=string ; Path to the SSODD analog file ; CONFIG: in, optional, type=string ; Path to the configuration file for catalogs, at the ; minimum this file should contain the 2 following lines to be used ; by current routine:: ; [Solar System Objects Density Database] ; analog = PATH_TO_YOUR_SSODD_ANALOG_FILE ; DUMP: in, optional, type=boolean, default=0 ; Set this keyword to return the whole SSODD file ; VERBOSE: in, optional, type=boolean, default=0 ; Trigger dialog with user ; ; :Examples: ; Search SSODD for Ceres and Pallas:: ; IDL> print, ssoddGetAnalog(1) ; IDL> print, ssoddGetAnalog('Pallas') ; ; :Uses: ; initIDL, readfmt, astNameFormat, designation, meanWithUnc ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Written in August 2014, B. Carry (IMCCE) ; 2017 Dec - B. Carry (OCA) - Changed input file to CSV ; 2018 Feb - B. Carry (OCA) - Added target identification in output structure ;- function ssoddGetAnalog, id, SSODD=SSODD, config=config, dump=dump, verbose=verbose COMPILE_OPT hidden ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--I.1-- Set IDL to Local Working Environment ----------------------------------- if not keyword_set(SSODD) then begin if not keyword_set(CONFIG) then begin config = initidl(/CATALOG) endif SSODD = config.ssodd.analog endif ;--I.2-- Output Structure Definition -------------------------------------------- emptyId ={num:0L, name:''} emptyTax={sel:0, scheme:'', class:'', src:''} emptyMet={sel:0, class:'', src:''} empty={id:emptyId, taxo:emptyTax, met:emptyMet} ;--I.3-- Dump mode Exception ---------------------------------------------------- if keyword_set(DUMP) then ID='*' ;--I.4-- Exceptions ------------------------------------------------------------ ;--I.4.1-- Neither ID nor DUMP Specified if not keyword_set(ID) then begin if keyword_set(VERBOSE) then message, /IOERROR, 'No target identifier specified: analog=ssoddGetAnalog([ID,/DUMP,...])' return, -3 endif ;--I.4.2-- SSODD Analog File Not Found if not file_test (ssodd,/read) then begin if keyword_set(VERBOSE) then message, /INFO, 'SSODD File Not Found: '+strtrim(ssodd,2) return, -2 endif ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Read the Whole SSODD file -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; readcol, ssodd, delimiter=',', /Silent, format='(L,A,I,A,A,A,I,A,A)', $ ssoddNum, ssoddName, tSel, tScheme, tClass, tSrc, mSel, mClass, mSrc nbSSODD = n_elements(ssoddNum) ssoddName= strtrim(ssoddName,2) tSrc = strtrim(tSrc,2) mSrc = strtrim(mSrc,2) tScheme= strtrim(tScheme,2) tClass= strtrim(tClass,2) mClass= strtrim(mClass,2) ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- III -- Asteroid Designation Interpretation -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--III.1-- Identify Input Type --------------------------------------------------- trash = astNameFormat(ID, TYPE=idType ) ;--III.2-- Set Asteroid IAU Number ----------------------------------------------- if idType eq 1 then begin num = round(float(ID)) des = designation(ID) endif else begin num = designation(ID) des = strtrim(ID,2) endelse ;--III.3-- Line Selection -------------------------------------------------------- ;--III.3.1-- Complete Dump of the SSODD catalog if keyword_set(dump) or strcmp(ID,'*',1) then begin sel=indgen(nbSSODD) nbSel=nbSSODD ;--III.3.2-- Only a Specified Target endif else begin ;--III.3.2/A-- Search Single Line if num ne 0 then begin selT=where( (num eq ssoddNum or strcmp(des, ssoddName,/FOLD)) and tSel eq 1 ) selM=where( (num eq ssoddNum or strcmp(des, ssoddName,/FOLD)) and mSel eq 1 ) endif else begin selT=where( strcmp(des, ssoddName,/FOLD) and tSel eq 1 ) selM=where( strcmp(des, ssoddName,/FOLD) and mSel eq 1 ) endelse nbSel=1 selT=selT[0] selM=selM[0] ;--III.3.2/B-- Exception: No information available if selT eq -1 then begin if num ne 0 then selT=where( (num eq ssoddNum or strcmp(des, ssoddName,/FOLD)) ) $ else selT=where( strcmp(des, ssoddName,/FOLD) ) endif if selM eq -1 then begin if num ne 0 then selM=where( (num eq ssoddNum or strcmp(des, ssoddName,/FOLD)) ) $ else selM=where( strcmp(des, ssoddName,/FOLD) ) endif endelse ;--III.4-- Target not Found Exception ------------------------------------------- if nbSel eq 0 then begin if keyword_set(VERBOSE) then message, /INFO, 'Target not found: '+strtrim(string(ID,format='(A)'),2) return, -1 endif ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- IV -- Result Concatenation and Averaging -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--IV.1-- Single Object Requested ------------------------------------------------ if nbSel eq 1 then begin result = empty result.id.num = ssoddNum[selT] result.id.name = ssoddName[selT] result.taxo.sel = tSel[selT] result.taxo.scheme = tScheme[selT] result.taxo.class = tClass[selT] result.taxo.src = tSrc[selT] result.met.sel = mSel[selM] result.met.class = mClass[selM] result.met.src = mSrc[selM] ;--IV.2-- Database Dump ---------------------------------------------------------- endif else begin result = replicate(empty,nbSel) for kSel=0, nbSel-1 do begin result[kSel].id.num = ssoddNum[sel[kSel]] result[kSel].id.name = ssoddName[sel[kSel]] result[kSel].taxo.sel = tSel[sel[kSel]] result[kSel].taxo.scheme = tScheme[sel[kSel]] result[kSel].taxo.class = tClass[sel[kSel]] result[kSel].taxo.src = tSrc[sel[kSel]] result[kSel].met.sel = mSel[sel[kSel]] result[kSel].met.class = mClass[sel[kSel]] result[kSel].met.src = mSrc[sel[kSel]] endfor endelse ;--IV.3-- Return Results --------------------------------------------------------- return, result end