; docformat = 'rst' ; ; NAME: ; ssoddGetLink ; PURPOSE: ; Return the asteroid-meteorite link data table from the Solar ; System Objects Density Database for a specific link or ; simply dump the database ; ;+ ; :Description: ; Return the asteroid-meteorite link data talbe from the Solar ; System Objects Density Database for a specific link or ; simply dump the database ; ; :Categories: ; Database, SSODD, Asteroid, Meteorite ; ; :Params: ; ID: in, required, type=integer/string ; Taxonomic class or population identifyer (*, comet|aster, Cb, V) ; ; :Returns: A structure with the asteroid-meteorite links, or code for ; success (-1: selection, -2: SSODD file not found). Structure fields are:: ; .pop: Population. ; .scheme: Taxonomic scheme. ; .class: Taxonomic class. ; .met: Analog meteorite ID. ; ; :Keywords: ; SSODD: in, optional, type=string ; Path to the SSODD asteroid-meteorite links 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] ; link = PATH_TO_YOUR_SSODD_LINK_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: ; Read all asteroid-meteorite links in SSODD:: ; IDL> links= ssoddGetLink() ; IDL> forprint, links.class, links.met, textout=2 ; ; :Uses: ; initIDL, readfmt ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Written in September 2014, B. Carry (IMCCE) ; 2017 Dec - B. Carry (OCA) - Changed input format to CSV ;- function ssoddGetLink, 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.link endif ;--I.2-- Output Structure Definition -------------------------------------------- empty={pop:'', scheme:'', class:'', met:''} ;--I.3-- Dump mode Exception ---------------------------------------------------- if keyword_set(DUMP) then ID='*' if not keyword_set(ID) then ID='*' ;--I.4-- Exceptions ------------------------------------------------------------ ;--I.4.1-- SSODD Link 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='(A,A,A,A,A)', $ ssoddPop, ssoddScheme, ssoddClass, ssoddMet ; readfmt, ssodd, '(2x,A11,4x,A6,4x,A4,4x,A4)', $ ; ssoddPop, ssoddScheme, ssoddClass, ssoddMet, /SILENT nbSSODD = n_elements(ssoddPop) ssoddPop = strtrim(ssoddPop,2) ssoddScheme= strtrim(ssoddScheme,2) ssoddClass = strtrim(ssoddClass,2) ssoddMet = strtrim(ssoddMet,2) ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- III -- Population/Class Interpretation -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--III.1-- Global Dump ----------------------------------------------------------- if keyword_set(dump) or strcmp(ID,'*',1) then begin sel=indgen(nbSSODD) nbSel=nbSSODD ;--III.2-- Specific Population or Class ------------------------------------------ endif else begin sel=where(strcmp(ID,ssoddPop,/FOLD) or strcmp(ID,ssoddClass,/FOLD), nbSel ) endelse ;--III.3-- 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 -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--IV.1-- Single Object Requested ------------------------------------------------ if nbSel eq 1 then begin result = empty result.pop = ssoddPop(sel) result.scheme = ssoddScheme(sel) result.class = ssoddClass(sel) result.met = ssoddMet(sel) ;--IV.2-- Database Dump ---------------------------------------------------------- endif else begin result = replicate(empty,nbSel) for kSel=0, nbSel-1 do begin result(kSel).pop = ssoddPop(sel(kSel)) result(kSel).scheme = ssoddScheme(sel(kSel)) result(kSel).class = ssoddClass(sel(kSel)) result(kSel).met = ssoddMet(sel(kSel)) endfor endelse ;--IV.3-- Return Results --------------------------------------------------------- return, result end