; docformat = 'rst' ; ; NAME: ; DESIGNATION ; PURPOSE: ; Resolve an Asteroid IAU Number from its Name or reverse ; ;+ ; :Description: ; Resolve an Asteroid IAU Number from its Name or reverse ; ; From a local version of the ASTORB file, use the GREP shell ; function to quickly sort ASTORB entries and resolve the ; Name/Number link. ; ; :Categories: ; Database, Asteroid ; ; :Params: ; DESIGN: in, required, type=integer/string ; Target identifyer (Name, Provisional designation, Number) ; ASTORB: in, optional, type=integer/string ; The path to a local version of AstOrb (Lowell Obs) ; ; :Returns: A string or a long containing the name or IAU number of the asteroid ; ; :Examples: ; IDL> print, designation('Ceres') ; 1 ; IDL> print, designation('Makemake') ; 136472 ; IDL> print, designation(136108) ; Haumea ; IDL> print, designation(433) ; Eros ; ; :Uses: ; INITIDL, ASTNAMEFORMAT ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Written in June 2010, B. Carry (ESA) ; 2012-09-11 - B. Carry (ESA) - Special caracters in names added ; 2013-04-16 - B. Carry (IMCCE) - T1 T2 T2 PL surveys added ; 2013-08-13 - B. Carry (IMCCE) - Improved handling of designation (' ','_','') ; 2013-10-22 - B. Carry (IMCCE) - Added use of initidl ;- function designation, design, astorb COMPILE_OPT hidden ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--I.1-- Set IDL to Local Working Environment ----------------------------------------- confAstroIM= initidl() confCatalog= initidl(confAstroIM.soft.catalog, /CATALOG) ;--I.2-- Set AstOrb File -------------------------------------------------------------- if not keyword_set(astorb) then astorb = confCatalog.astorb $ else astorb = strtrim(astorb,2) ;--I.3-- File Check Out --------------------------------------------------------------- if not file_exist(astorb) then message, /IOERROR, 'AstOrb file not found: '+astorb ;--I.4-- Naming Convention ------------------------------------------------------------ numLength = 6 desLength = 18 ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- 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 endelse ;--II.3-- Extract Orbital Elements -------------------------------------------------- ;--II.3.1-- Target Found if keyword_set(astOrbLine) then begin num = strmid( astOrbLine(0),0,numLength) if valid_num(num) then num=round(float(num)) $ else num=0L des = strtrim(strmid( astOrbLine(0), 7, desLength),2) if type eq 1 then return, des else return, num ;--II.3.2-- Target Not Found endif else begin return, -1 endelse end