; docformat = 'rst' ; ; NAME: ; astElements ; PURPOSE: ; Find an asteroid osculating orbital elements from its name or number. ; ;+ ; :Description: ; Find an asteroid osculating orbital elements from its name or number. ; ; From a local version of the ASTORB file, use the GREP shell ; function to quickly sort ASTORB entries and resolve the ; Name/Number. ; ; :Categories: ; Database, Asteroid, Orbits ; ; :Params: ; design: in, required, type=integer/string ; The asteroid name or designation (string) or the asteroid IAU ; number (integer or string accepted) ; astorb: in, optional, type=integer/string ; The path to a local version of AstOrb (Lowell Obs) ; ; :Returns: A structure with the orbital elements and the absolute ; magnitude. Fields are:: ; .NUM: Asteroid IAU Number ; .NAME: Asteroid Name or Provisional Designation ; .H: Absolute magnitude (Bowell HG System) ; .A: Semi-major axis ; .E: Eccentricity ; .I: Inclination ; .node: Longitude of the node ; .peri: Argument of periapsis ; .n: Mean motion ; ; :Keywords: ; FLAG: out, optional, type=boolean ; Indicates the result of the search ; ; :Examples: ; Find Orbital elements of Ceres, Makemake, Haumea, and Eros:: ; IDL> print, astelements('Ceres') ; IDL> print, astelements('Makemake') ; IDL> print, astelements(136108) ; IDL> print, astelements(433) ; ; :Uses: ; initIDL, astNameFormat ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Written in September 2012, B. Carry (ESA) ; 2013-Aug. - B. Carry (IMCCE) - Result flag added ; 2013-Aug. - B. Carry (IMCCE) - Improved handling of designation (' ','_','') ; 2014-Mar. - B. Carry (IMCCE) - Removed subroutine FILE_EXIST ; 2014-Sep. - B. Carry (IMCCE) - Removed usage of initIDL when possible ; 2018 Oct. - B. Carry (OCA) - idl2, added G slope in output ;- function astElements, design, astorb, flag=flag COMPILE_OPT hidden, idl2 ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--I.1-- Set AstOrb File -------------------------------------------------------------- if keyword_set(astorb) then begin astorb = strtrim(astorb,2) endif else begin confAstroIM= initIDL() confCatalog= initIDL(confAstroIM.soft.catalog, /CATALOG) astorb = confCatalog.astorb endelse ;--I.2-- File Check Out --------------------------------------------------------------- if not file_test(astorb,/READ) then message, /IOERROR, 'AstOrb file not found: '+astorb ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Extract Orbital Elements from AstOrb -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--II.1-- Formated Input and Type --------------------------------------------------- astID = astNameFormat( design, /ASTORB, type=type ) ;--II.2-- Extract the Entire Line from AstOrb --------------------------------------- ;--II.2.1-- Designation is a Number if type eq 1 then begin spawn, ' head -n '+astID+' '+astorb+' | tail -n 1', astOrbLine ;--II.2.2-- Designation is a Name endif else begin spawn, 'grep " '+astID+'" '+astorb, astOrbLine if strCmp(astOrbLine,'') then spawn, 'grep -i " '+astID+'" '+astorb, astOrbLine endelse ;--II.3-- Extract Orbital Elements -------------------------------------------------- ;--II.3.1-- Target Found if keyword_set(astOrbLine) then begin flag=0 num = strMid( astOrbLine[0], 0, 6 ) if num eq ' ' then num=0 else num=round(float(num)) oscEpoch = strMid( astOrbLine[0],106,8 ) oscJD = date_conv( strMid(oscEpoch,0,4)+'-'+$ strMid(oscEpoch,4,2)+'-'+$ strMid(oscEpoch,6,2)+'T00:00:00.000','JULIAN') info ={ num: num, $ name: strtrim( strMid( astOrbLine[0], 7, 18 ),2), $ h: float( strMid( astOrbLine[0], 42, 5 )), $ g: float( strMid( astOrbLine[0], 48, 5 )), $ jd: oscJD, $ a: double(strMid( astOrbLine[0],169,12 )), $ e: float( strMid( astOrbLine[0],158,10 )), $ i: float( strMid( astOrbLine[0],148, 9 )), $ o: float( strMid( astOrbLine[0],136,10 )), $ w: float( strMid( astOrbLine[0],125,10 )), $ n: float( strMid( astOrbLine[0],115,10 )) } ;--II.3.2-- Target Not Found endif else begin flag=1 if type eq 1 then info ={ num: round(float(astID)), name: '', h:-1., jd:-1., a:-1., e:-1., i:-1., w:-1., o:-1., n:-1. } $ else info ={ num:0L, name:astID, h:-1., jd:-1., a:-1., e:-1., i:-1., w:-1., o:-1., n:-1. } endelse return, info end