; docformat = 'rst' ; ; NAME: ; ssoddGetDB ; PURPOSE: ; Return the content of the main table of the Solar System Objects ; Density Database for a specific target or simply dump the database. ; ;+ ; :Description: ; Return the content of the main table of the Solar System Objects ; Density Database for a specific target or simply dump the database. ; ; :Categories: ; Database, SSODD ; ; :Params: ; ID: in, required, type=integer/string ; Target identifyer ('*', Name, Provisional designation, Number) ; ; :Returns: A structure with the mass, diameter, density, porosity, ; macroporosity estimates, or code for success (-1: target not found, -2: SSODD file ; not found, -3: No target specified). Structure fields are:: ; .NUM: Target Number ; .NAME: Target Name ; .TYPE: Target dynamical class (aster|comet|KBO) ; .CLASS: Target dynamical class (MB/Trojan...) ; .TAXO: Target taxonomic class ; .MET: Target analog meteorite ; .NAME: Target Name ; .MASS: Mass estimate:: ; .val: Value in kg ; .dev: Standard deviation in kg ; .DIAM: Diameter estimate:: ; .val: Value in km ; .dev: Standard deviation in km ; .DENS: Density estimate:: ; .val: Value in g/cc ; .dev: Standard deviation in g/cc ; .POROSITY: Porosity estimate:: ; .val: Value in percent ; .unc: Standard deviation in percent ; .MACROPOROSITY: Porosity estimate:: ; .val: Value in percent ; .unc: Standard deviation in percent ; ; :Keywords: ; SSODD: in, optional, type=string ; Path to the SSODD main table ; 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] ; DB = PATH_TO_YOUR_SSODD_DB_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, ssoddGetDB(1) ; IDL> print, ssoddGetDB('Pallas') ; ; :Uses: ; initIDL, readfmt, astNameFormat, designation, meanWithUnc ; ; :Author: ; B.Carry (IMCCE) ; ; :History: ; Change History:: ; Written in June 2014, B. Carry (IMCCE) ; 2018 June - B. Carry (OCA) - Allows csv format ;- function ssoddGetDB, id, SSODD=SSODD, config=config, dump=dump, verbose=verbose COMPILE_OPT hidden, idl2 ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- 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.DB endif ;--I.2-- Output Structure Definition -------------------------------------------- valUnc={val:0., unc:0.} empty={num:0L, name:'', type:'', $ class:'', taxo:'', met:'', $ mass:valUnc, diam:valUnc, dens:valUnc, $ porosity:valUnc, macroporosity:valUnc} ;--I.3-- Dump mode Exception ---------------------------------------------------- if keyword_set(Dump) then ID='*' if strcmp(ID,'*') then DUMP=1 ;--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: info=ssoddGetDB([ID,/DUMP,...])' return, -3 endif ;--I.4.2-- SSODD DB File Not Found if ~file_test(ssodd,/read) then begin if keyword_set(VERBOSE) then message, /IOERROR, 'SSODD File Not Found: '+strtrim(ssodd,2) return, -2 endif ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Read the Whole SSODD file -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ; print, ssodd readcol, ssodd, delimiter=',', $ ssoddNum, ssoddName, ssoddType, ssoddClass, ssoddTaxo, ssoddMet, $ massVal, massUnc, diamVal, diamUnc, densVal, densUnc, $ poroVal, poroUnc, macroVal, macroUnc, /Silent, $ format='(L6,A15,'+$ 'A6,A3,'+$ 'A3,A3,'+$ 'F8.2,F8.2,F7.2,F7.2,F6.2,F6.2,'+$ 'F8.1,F8.1,F8.1,F8.1)' nbSSODD = n_elements(ssoddNum) ssoddName = strtrim(ssoddName ,2) ssoddType = strtrim(ssoddType ,2) ssoddClass= strtrim(ssoddClass,2) ssoddTaxo = strtrim(ssoddTaxo ,2) ssoddMet = strtrim(ssoddMet ,2) ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- III -- DB Selection from Input ID -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; if not keyword_set(dump) then begin print, 'TO BE CODED!!!!' ;- ;- ;--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 ;- sel=where( num eq ssoddNum or strcmp(des, ssoddName,/FOLD) , nbSel ) ;- ;- 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 ;- endif else begin nbSel = nbSSODD sel = indgen(nbSel) endelse ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- IV -- Result Concatenation and Averaging -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--IV.1-- Create the Output Structure -------------------------------------------- if nbSel gt 1 then result = replicate(empty,nbSel) $ else result = empty ;--IV.2-- Fill the Structure ----------------------------------------------------- for kSel=0, nbSel-1 do begin result[kSel].num = ssoddNum[sel[kSel]] result[kSel].name = ssoddName[sel[kSel]] result[kSel].type = ssoddType[sel[kSel]] result[kSel].class = ssoddClass[sel[kSel]] result[kSel].taxo = ssoddTaxo[sel[kSel]] result[kSel].met = ssoddMet[sel[kSel]] result[kSel].mass.val = massVal[sel[kSel]] result[kSel].mass.unc = massUnc[sel[kSel]] result[kSel].diam.val = diamVal[sel[kSel]] result[kSel].diam.unc = diamUnc[sel[kSel]] result[kSel].dens.val = densVal[sel[kSel]] result[kSel].dens.unc = densUnc[sel[kSel]] result[kSel].porosity.val = poroVal[sel[kSel]] result[kSel].porosity.unc = poroUnc[sel[kSel]] result[kSel].macroporosity.val = macroVal[sel[kSel]] result[kSel].macroporosity.unc = macroUnc[sel[kSel]] endfor ;--IV.3-- Return Individual Estimates and Averages ------------------------------- return, result end