; docformat = 'rst' ; ; NAME: ; ssoDiscovery_build ; PURPOSE: ; Build the IMCCE Database of Asteroids Discovery ; ;+ ; :Description: ; Build the IMCCE Database of Asteroids Discovery ; ; Discovery date of asteroids is reported by the Minor Planet Center (MPC) upon ; numeration. Present code can parse both AstOrb (Lowell Obs.) and MPC ; discovery files to create a custom database of asteroids discoveries, ; dated on half-months. ; ; :Categories: ; Database, Asteroid ; ; :Params: ; BUILD: in, required, type=string ; The path to the file in which the discovery database will be ; saved ; ; :Keywords: ; ASTORB: in, optional, type=string ; The path to a local version of AstOrb (Lowell Obs) ; MPC: in, optional, type=string ; The path to a local version of MPC Discovery Information for ; Numbered asteroids ; 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:: ; [Asteroid Orbits] ; astorb = PATH_TO_YOUR_ASTORB_FILE ; disco.mpc = PATH_TO_YOUR_MPC_FILE ; verbose: in, optional, type=boolean, default=0 ; Trigger the display of information on the stdout ; ; :Examples: ; Create the master IMCCE Discovery Database: ; IDL> ssoDiscovery_build, 'local.csv' ; ; :Uses: ; initIDL, readASTORB, date_conv, astClass ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Written in November 2013, B. Carry (IMCCE) ; 2014 Sep. - B. Carry (IMCCE): Dynamical class added ; 2015 Nov. - B. Carry (OCA) - Added compile option idl2 ; 2016 July - B. Carry (OCA) - Changed output format to CSV ; 2016 Oct. - B. Carry (OCA) - Changed comma to semi-colon in output ; 2016 Nov. - B. Carry (OCA) - Back to comma, added translation for discoverers ;- pro ssoDiscovery_Build, build, ASTORB=ASTORB, MPC=MPC, config=config, verbose=verbose 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-- MPC Discovery Information if not keyword_set(MPC) then MPC = config.disco.mpc ;--I.1.3-- AstOrb Database if not keyword_set(ASTORB) then ASTORB = config.astorb ;--I.1.4-- Output Catalog if not keyword_set(build) then build = config.disco.imcce ;--I.2-- IMCCE Discovery Database Format ---------------------------------------------- discoFormat='(I6,", ",A-20,", ",A-9,", ",A-20,", ",A-10,", ",D9.1,", ",F5.2,", ",F5.2,", ",F9.4,", ",F6.4,", ",F6.2,", ",A-24,", ",A-40)' ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Build Discovery Database -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; if keyword_set(verbose) then print, ' Building the IMCCE Asteroid Discovery Database' ;--II.1-- Read Different Databases ----------------------------------------------------- ;--II.1.1-- Read AstOrb aoData = readastorb(astorb) nbAst = n_elements( aoData.name ) ;--II.1.2-- Read MPC Discovery Information readfmt, MPC, 'A8,1x,A19,1x,A10,2x,I4,1x,I2,1x,I2,2x,A24,1x,A40', $ preNum, name, design, year, month, day, place, who, /SILENT nbNum = n_elements( name ) isoDate = string(year,format='(I04)')+'-'+string(month,format='(I02)')+'-'+string(day,format='(I02)') mpcData = {num: lindgen(nbNum)+1, name:strtrim(name,2), des:strtrim(design,2), $ iso: isoDate, where:strtrim(place,2), who:strtrim(who,2)} ;--II.2-- Output Database Structure ---------------------------------------------------- empty = {num:0L, des:'', orbit:{main:'', sub:''}, $ when: {jd:0., iso:''}, where:'', who:'', $ h:0., g: 0., a:0., e:0., i:0. } disco = replicate(empty,nbAst) ;--II.3-- Asteroid Name, Orbital Elements... ------------------------------------------- disco.num = aoData.num disco.des = aoData.name disco.h = aoData.h disco.g = aoData.g disco.a = aoData.a disco.e = aoData.e disco.i = aoData.i aoData = 0 ;-free memory ;--II.3-- Numbered Asteroids ----------------------------------------------------------- for kNum=0L, nbNum-1 do begin disco[kNum].when.iso= mpcData.iso[kNum] disco[kNum].when.jd = date_conv(mpcData.iso[kNum],'JULIAN') disco[kNum].where = mpcData.where[kNum] disco[kNum].who = mpcData.who[kNum] dynClass = astClass(disco[kNum].num, disco[kNum].a, disco[kNum].e) disco[kNum].orbit.main = dynClass.type disco[kNum].orbit.sub = dynClass.subtype endfor if keyword_set(verbose) then print, ' ... Numbered done' ;--II.4-- Unnumbered Asteroids --------------------------------------------------------- ;--II.4.1-- Asteroid and Trojan Surveys surveysID = ['P-L', 'T-1', 'T-2', 'T-3'] surveysISO= ['1960-06-01', '1971-06-01', '1973-06-01', '1977-06-01'] surveysJD = [2437086.5D, 2441103.5, 2441834.5, 2443295.5] nbSurvey= n_elements(surveysID) for kSurv=0, nbSurvey-1 do begin cur = where( strmid(disco.des,5,3) eq surveysID[kSurv] and disco.num eq 0, nbCur ) for kCur=0L, nbCur-1 do begin disco[cur[kCur]].when.iso= surveysISO[kSurv] disco[cur[kCur]].when.jd = surveysJD[kSurv] disco[cur[kCur]].where = 'TBD' disco[cur[kCur]].who = 'TBD' dynClass = astClass(disco[cur[kCur]].des, disco[cur[kCur]].a, disco[cur[kCur]].e) disco[cur[kCur]].orbit.main = dynClass.type disco[cur[kCur]].orbit.sub = dynClass.subtype endfor endfor if keyword_set(verbose) then print, ' ... Surveys done' ;--II.4.2-- Provisional Designation prov = where( disco.num eq 0 and not $ (strmid(disco.des,5,3) eq surveysID[0] or $ strmid(disco.des,5,3) eq surveysID[1] or $ strmid(disco.des,5,3) eq surveysID[2] or $ strmid(disco.des,5,3) eq surveysID[3] ), nbDes) letter = ['A','B','C','D','E','F','G','H','J','K','L','M',$ 'N','O','P','Q','R','S','T','U','V','W','X','Y'] nbLet = n_elements( letter ) for kD=0, nbDes-1 do begin ;--II.4.2.1-- Current Year Initial JD year = round(float(strmid( disco[prov[kD]].des,0,4))) jdY = date_conv( string(year,format='(I04)')+'-01-07', 'JULIAN' ) ;--II.4.2.2-- Half-Month Values month = where( strmid( disco[prov[kD]].des,5,1) eq letter ) disco[prov[kD]].when.JD = jDY + month[0]*15.D disco[prov[kD]].when.ISO= date_conv(jDY + month[0]*15.D,'FITS') disco[prov[kD]].where = 'n.a.' disco[prov[kD]].who = 'n.a.' dynClass = astClass(disco[prov[kD]].des, disco[prov[kD]].a, disco[prov[kD]].e) disco[prov[kD]].orbit.main = dynClass.type disco[prov[kD]].orbit.sub = dynClass.subtype endfor if keyword_set(verbose) then print, ' ... Provisional designation done' ;--II.5-- Export Result to Disk --------------------------------------------------------- now = date_conv(systime(/UTC,/JULIAN),'FITS') discoComment='Num, Designation, Main Dynamical Class, Sub Dynamical Class, ISO, JD, H, G, a, e, i, Place, Who' forprint, disco.num, disco.des, $ disco.orbit.main, disco.orbit.sub, $ strmid(disco.when.iso,0,10), disco.when.jd, $ disco.h, disco.g, disco.a, disco.e, disco.i, $ disco.where, disco.who, $ format=discoFormat, comment=discoComment, textout=build, /SILENT end