; docformat = 'rst' ; ; NAME: ; ASTPROPERELEMENTS ; PURPOSE: ; Find an asteroid proper elements from its name or number ; ;+ ; :Description: ; Find an asteroid proper elements from its name or number ; ; From a local version of the ASTDYS file, use the GREP shell ; function to quickly sort ASTDYS entries and resolve the ; Name/Number. ; ; :Categories: ; Database, Asteroid, Orbits ; ; :Params: ; DESIGN: in, required, type=integer/string ; Target identifyer (Name, Provisional designation, Number) ; ASTDYS: in, optional, type=string ; The path to the directory containing proper elements ; from ASTDYS, numbered and multi-opposition asteroids files: ; http://hamilton.dm.unipi.it/astdys2/index.php?pc=5 ; ; :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 ; ; :Keywords: ; FLAG: out, optional, type=boolean ; Indicates the result of the search ; ; :Examples: ; Find proper elements of Ceres, Makemake, Haumea, and Eros ; IDL> print, astproperelements('Ceres') ; IDL> print, astproperelements('Makemake') ; IDL> print, astproperelements(136108) ; IDL> print, astproperelements(433) ; ; :Uses: ; initidl, file_exist, astnameformat ; ; :Author: ; B.Carry (IMCCE) ; ; :History: ; Change History:: ; Written in July 2013, B. Carry (IMCCE) ;- function AstProperElements, DESIGN, ASTDYS, FLAG=FLAG ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; COMPILE_OPT hidden ;--I.1-- Set IDL to Local Working Environment ----------------------------------------- confAstroIM= initidl() confCatalog= initidl(confAstroIM.soft.catalog, /CATALOG) ;--I.2-- Set Astdys Directory --------------------------------------------------------- ;--I.2.1-- Set Directory if not keyword_set(astdys) then astdys = confCatalog.astdys $ else astdys = strtrim(astdys,2) ;--I.2.2-- Set File Names astDysNum = astdys+'allnum.pro' astDysDes = astdys+'ufitobs.pro' ;--I.3-- File Check Out --------------------------------------------------------------- ;--I.3.1-- AstDys Directory if not dir_exist(astdys) then message, /IOERROR, 'AstDyS directory not found: '+astdys ;--I.3.2-- Numbered Asteroids File if not file_exist(astDysNum) then message, /IOERROR, 'AstDyS numbered asteroids file not found: '+astDysNum ;--I.3.1-- Multiple Opposition Asteroids File if not file_exist(astDysDes) then message, /IOERROR, 'AstDyS multi-opposition asteroids file not found: '+astDysDes ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Extract Orbital Elements from Astdys -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--II.1-- Formated Input and Type --------------------------------------------------- astID = astnameformat( design, /ASTDYS, type=type ) ;--II.2-- Extract the Entire Line from Astdys --------------------------------------- ;--II.2.1-- Designation is a Number if type eq 1 then begin num = round(float(astID)) des = designation(num) spawn, 'grep "'+astID+'" '+astDysNum, astdysLine ;--II.2.2-- Designation is a Name endif else begin num = designation(astID) des = astID spawn, 'grep "'+astID+'" '+astDysDes, astdysLine endelse ;--II.3-- Extract Orbital Elements -------------------------------------------------- ;--II.3.1-- Target Found if keyword_set(astdysLine) then begin flag=0 num = strmid( astdysLine(0), 0, 6 ) if num eq ' ' then num=0 else num=round(float(num)) info ={ num: num, $ name: des, $ h: float( strmid( astdysLine(0), 60, 5 )), $ a: double(strmid( astdysLine(0), 10, 7 )), $ e: float( strmid( astdysLine(0), 18, 5 )), $ i: asin(float( strmid( astdysLine(0), 24, 5 )))/!DTOR } ;--II.3.2-- Target Not Found endif else begin flag=1 if type eq 1 then info ={ num: round(float(astID)), name: '', h: -1.0, a: -1.0, e: -1.0, i: -1.0 } $ else info ={ num: 0, name: astID, h: -1.0, a: -1.0, e: -1.0, i: -1.0 } endelse return, info end