; docformat = 'rst' ; ; NAME: ; ssoDiscovery_read ; PURPOSE: ; Read the IMCCE Database of Asteroids Discovery ; ;+ ; :Description: ; Read the IMCCE Database of Asteroids Discovery ; ; :Categories: ; Database, Asteroid ; ; :Returns: ; ; :Keywords: ; ep: in, optional, type=string/double ; An epoch for which the number of discovered object is desired ; ID: in, required, type=integer/string ; Target identifyer ('*', Name, Provisional designation, Number) ; dump: in, optional, type=boolean, default=0 ; Set this keyword to return the whole PDS file ; discovery: in, required, type=string ; The path to the file in which the discovery database will be ; saved ; 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:: ; [Tables from Literature] ; disco.imcce = PATH_TO_YOUR_IMCCE_SSO_DISCOVERY_FILE ; ; :Examples: ; How many asteroids were known at J2000? ; IDL> print, ssodiscovery_read(EP='2000-01-01') ; When was asteroids (8467) Benoitcarry discovered? ; IDL> print, ssodiscovery_read(ID=8467) ; ; :Uses: ; initIDL, astNameFormat, designation, date_conv ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Written in November 2013, B. Carry (IMCCE) ; 2015 Nov. - B. Carry (OCA) - Added compile option idl2 ; 2016 July - B. Carry (OCA) - Changed input format to CSV ;- function ssoDiscovery_Read, ep=ep, ID=ID, who=who, dump=dump, discovery=discovery, config=config COMPILE_OPT hidden, idl2 ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--I.1-- Set IDL to Local Working Environment ----------------------------------------- ;--I.1.1-- Global Catalog Configuration if not keyword_set(config) then config = initIDL(/CATALOG) $ else config = initIDL(config, /CATALOG) ;--I.1.2-- Custom Discovery Database if not keyword_set(discovery) then discovery = config.disco.imcce ;--I.2-- IMCCE Discovery Database Format ---------------------------------------------- empty = {num:0L, des:'', orbit:{main:'', sub:''}, $ when: {jd:0., iso:''}, where:'', who:'', $ h:0., g:0., a:0., e:0., i:0. } ; discoFormat='(I6,A-20,A-9,A-20,A-10,D9.1,F5.2,F5.2,F8.4,F6.4,F6.2,A-24,A-40)' ; discoFormat='(I,A,A,A,A,D,F,F,F,F,F,A,A)' ; discoFormat='(I6,A-20,A-9,A-20,A-10,D9.1,F5.2,F5.2,F8.4,F6.4,F6.2,A-24,A-40)' discoFormat ='(I,A,A,A,A,D,F,F,F,F,F,A,A)' ;--I.3-- What to Do? ------------------------------------------------------------------ if not keyword_set(EP) and not keyword_set(id) and not keyword_set(who) then dump=1 ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Single Asteroid Requested -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; if keyword_set(ID) then begin ;--II.1-- Identify Input Type --------------------------------------------------- trash = astNameFormat(ID, TYPE=idType ) ;--II.2-- Set Asteroid IAU Number ----------------------------------------------- if idType eq 1 then begin num = ID des = designation(ID) endif else begin num = designation(ID) des = strtrim(ID,2) endelse ;--II.3-- Object Identifier in the Database ------------------------------------- if num ne 0 then testString=string(num,format='(I6)')+',' $ else testString=string(des,format='(A-20)')+',' ;--II.4-- Extract Database Line ------------------------------------------------- spawn, 'grep "'+testString+'" '+discovery, result, count=nbLine ;--II.5-- Parse Database Line --------------------------------------------------- if nbLine eq 1 then begin iso='' wher='' who='' split = strSplit( result[0], ',',/Extract) disco = {num: round(float(split[0])), $ des:strtrim(spli[1],2), $ orbit: {main: strtrim(split[2],2), sub: strtrim(split[3],2)}, $ when: {jd:double(split[5]), iso:strTrim(split[4],2)}, $ where:strTrim(split[10],2), who:strtrim(split[11],2), $ h:float(split[6]), a:float(split[7]), e:float(split[8]), i:float(split[9]) } ; reads, result[0], num, des, dynClass, dynSub, iso, jd, h, a, e, i, wher, who, format=discoFormat ; disco = {num:num, des:strtrim(des,2), $ ; orbit: {main: strtrim(dynClass,2), sub: strtrim(dynSub,2)}, $ ; when: {jd:jd, iso:iso}, $ ; where:strtrim(wher,2), who:strtrim(who,2), h:h, a:a, e:e, i:i } return, disco ;--II.6-- Exception: Target not found ------------------------------------------- endif else begin message, 'Target not Found: '+strtrim(ID,2) return, empty endelse endif ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- III -- Single Observer Requested -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; if keyword_set(WHO) then begin print, 'ssoDiscovery_read: code reading by observer' endif ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- IV -- Read the Discovery Database -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--IV.1-- Read Discovery Database ------------------------------------------------------ ; readfmt, discovery, discoFormat, num, des, dynClass, dynSub, iso, jd, h, g, a, e, i, wher, who, /SILENT readcol, discovery, delimiter=',', skipLine=1, format=discoFormat, $ num, des, dynClass, dynSub, iso, jd, h, g, a, e, i, wher, who, /Silent nbAst = n_elements(des) ;--IV.2-- Output Database Structure ---------------------------------------------------- disco = replicate(empty,nbAst) ;--IV.3-- Fill the Structure ----------------------------------------------------------- disco.num = num disco.des = strtrim(des,2) disco.orbit.main= strTrim(dynClass,2) disco.orbit.sub = strTrim(dynSub,2) disco.h = h disco.g = g disco.a = a disco.e = e disco.i = i disco.when.iso = strTrim(iso,2) disco.when.jd = jd disco.where = strtrim(wher,2) disco.who = strtrim(who,2) ;--IV.4-- Entire Dump Requested ------------------------------------------------------ if keyword_set(DUMP) then return, disco ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- V -- Epoch Statistics Requested -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; if keyword_set(EP) then begin ;--V.1-- Single or Multiple Epochs? ------------------------------------------------- nbEp = n_elements(EP) stat=lonarr(3,nbEp) for kEp=0, nbEp-1 do begin ;--V.2-- Convert Input Epoch in JD -------------------------------------------------- JD = date_conv(EP[kEp],'JULIAN') ;--V.3-- Select Discoveries up to Epoch --------------------------------------------- sel = where( disco.when.jd le JD and disco.when.jd ne 0, nbDisco ) ;--V.4-- Numbered and Unumbered Statistics ------------------------------------------ trash = where( disco[sel].num eq 0, nbDes, ncomp=nbNum ) stat[*,kEp] = [nbDisco, nbNum, nbDes] endfor ;--V.6-- Return Values --------------------------------------------------------------- return, stat endif end