; docformat = 'rst' ; ; NAME: ; CALL_EPHEMCC ; PURPOSE: ; Generate ephemeris of position by calling ephemcc (eproc) in a child process in BASH ; ;+ ; :Description: ; Generate ephemeris of position by calling ephemcc (eproc) in a child process in BASH ; ; This function is a simple interface to the ephemcc utility of the ; Eproc ephemeris generator (IMCCE, Paris Observatory, France). See ; Eproc documentation for more details: ; http://vo.imcce.fr/webservices/miriade/?ephemcc ; If Eproc is installed locally, CALL_EPHEMCC uses it, otherwise a ; request to Eproc webservice Miriade is performed. ; ; :Categories: ; Ephemeris ; ; :Params: ; ID: in, required, type=integer/string ; Target identifyer ('*', Name, Provisional designation, Number) ; EP: in, required, type=double/string ; The epoch at which the ephemeris should be computed ; ; :Returns: A structure containing the ephemeris ; ; :Keywords: ; TYPE: in, optional, type=string, default='aster' ; Type of target (aster | planet | satel | comet), can be set ; alternatively with the optional keywords ASTEROID, PLANET, ; SATELLITE, COMET ; ASTEROID: in, optional, type=boolean, default=1 ; Set the target type to asteroid (equiv. to type='aster') ; PLANET: in, optional, type=boolean, default=0 ; Set the target type to planet (equiv. to type='planet') ; SATELLITE: in, optional, type=boolean, default=0 ; Set the target type to satellite (equiv. to type='satel') ; COMET: in, optional, type=boolean, default=0 ; Set the target type to comet (equiv. to type='comet') ; ; NBD: in, optional, type=integer, default=1 ; Number of dates of ephemeris to compute ; STEP: in, optional, type=string, default='1d' ; Step of increment followed by one of (d)ays or (h)ours or ; (m)inutes or (s)econds, e.g, '1.5h' ; SCALE: in, optional, type=string, default='UTC' ; Timescale to use (TT or UTC) ; DATELIST: in, optional, type=boolean, default=0 ; If set, interprets the input epoch as a file containing a ; list of JD ; ; OBSERVER: in, optional, type=string, default='500' ; The IAU Code or geographic coordinates of the ; observer's location ; GEOCENTRIC: in, optional, type=boolean, default=1 ; Compute ephemeris from the geocentre ; HELIOCENTRIC: in, optional, type=boolean, default=0 ; Compute ephemeris from the heliocentre ; ; TEPH: in, optional, type=integer, default=1 ; Type of ephemeris (1:astrometric J2000, 2:apparent of the ; date, 3: mean of the date, 4: mean J2000) ; TCOOR: in, optional, type=integer, default=1 ; Type of coordinates (1:spherical, 2:rectangular, 3: Local ; coordinates, 4: Hour angle coordinates, 5: dedicated to ; observation, 6: dedicated to AO observation) ; RPLANE: in, optional, type=integer, default=1 ; Reference plane (1:equator, 2: ecliptic) ; ; GREGORIAN: in, optional, type=boolean, default=1 ; Set the output dates to Gregorian Calendar ; ISO: in, optional, type=boolean, default=0 ; Set the output dates to ISO format 'YYYY-MM-DDTHH:MM:SS.SSSS' ; JULIAN: in, optional, type=boolean, default=0 ; Set the output dates to Julian Days (double) ; ; WEB: in, optional, type=boolean, default=0 ; Force the use of Miriade upon a local installation of Eproc ; DUMP: in, optional, type=string ; A path to a file to export the ephemeris in [string] ; MIME: in, optional, type=string, default=ascii ; Format of the ephemeris (ascii | votable | html), ; FROM: in, optional, type=string ; Who is requesting the ephemeris (only used in Miriade for traceability and statistics ; ; :Examples: ; Compute the astrometric J2000 position of Ceres as seen from ; Paris, for each day in January 2000.:: ; IDL> ephem=call_ephemcc(1, '2000-01-01T12:00:00', obs='007', nbd=31, step='1d') ; IDL> help, ephem, /STRUCTURE ; ; :Uses: ; DATE_CONV, ASTNAMEFORMAT, ISNUMERIC, READ_EPHEMCC, ; ; :Author: ; B.Carry (IMCCE) ; ; :History: ; Change History:: ; Original Version written in August 2007, B. Carry (ESO/LESIA) ; 2008 Feb. - B.Carry (ESO) - Added observer location choice ; 2013 Sep. - B.Carry (IMCCE) - Converted to function ; 2013 Sep. - B.Carry (IMCCE) - I/O homogeneous with Miriade (http://vo.imcce.fr/webservices/miriade/?ephemcc) ;- function call_ephemcc, ID, EP, $ type=type, planet=planet, asteroid=asteroid, satellite=satellite, comet=comet, $ NBD=NBD, step=step, scale=scale, dateList=dateList, $ observer=observer, geocentric=geocentric, heliocentric=heliocentric, $ tEph=tEph, tCoor=tCoor, rPlane=rPlane, $ ISO=ISO, julian=julian, gregorian=gregorian, $ WEB=WEB, DUMP=DUMP, mime=mime, from=from ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; COMPILE_OPT hidden ;--I.1-- Input Epoch ------------------------------------------------------------- ; epDim = size( ep ) if keyword_set(DATELIST) then epoch=ep else $ epoch = strtrim(string( epRead(ep,/JD), format='(D16.8)'), 2) ; if epDim(1) eq 7 then begin ; if strcmp(ep,'now') then ep = systime(/UTC,/JULIAN) ; epoch = strtrim(string(date_conv(ep,'JULIAN'), format='(D16.8)'), 2) ; endif else begin ; epoch = strtrim(string( ep, format='(D16.8)'), 2) ; endelse ;--I.2-- Input Target ------------------------------------------------------------ ;--I.2.1-- Type of Target if keyword_set(TYPE) then begin tType = strtrim(type,2) endif else begin ;--I.2.1/A-- If Nothing Specified -> Target is an asteroid if not keyword_set(PLANET) AND $ not keyword_set(SATELLITE) AND $ not keyword_set(COMET) AND $ not keyword_set(ASTEROID) then asteroid=1 ;--I.2.1/B-- Choose from User-supplied Keywords if keyword_set(PLANET) then tType = 'planet' if keyword_set(SATELLITE) then tType = 'satel' if keyword_set(COMET) then tType = 'comet' if keyword_set(ASTEROID) then tType = 'aster' endelse ;--I.2.2-- Name format if valid_num( ID ) then begin tName = strtrim(string(ID,format='(A)'),2) tId = '-n' endif else begin slash=strpos(ID,'/') if strcmp(tType,'aster') and slash eq -1 then begin tName = '"'+strtrim(astNameFormat(ID,/ASTORB),2)+'"' tId = '-nom' endif else begin tName = '"'+strtrim(ID,2)+'"' tId = '-nom' endelse endelse ;--I.3-- Observer's location ------------------------------------------------------ obsID = ' -uai' obsName= '500' if keyword_set(observer) then begin split = strsplit(observer,' ', /EXTRACT, count=N) if N gt 1 then begin obsID = ' -g' obsName = strtrim(observer,2) endif else begin obsID = ' -uai' obsName = strtrim(string(observer,format='(A3)'),2) endelse endif ;--I.4-- Input Time Variables ---------------------------------------------------- if not keyword_set( NBD ) then nbd='1' $ else nbd=strtrim(string(nbd,format='(I)'),2) if not keyword_set( STEP ) then step = '1d' if not keyword_set( SCALE ) then scale ='UTC' ;--I.5-- Type of Ephemeris, Coordinates, and Reference Plane---------------------- if not keyword_set( TEPH ) then tEph ='1' $ else tEph =strtrim(string(tEph,format='(I)'),2) if not keyword_set( TCOOR ) then tCoor ='1' $ else tCoor =strtrim(string(tCoor,format='(I)'),2) if not keyword_set( RPLANE ) then rPlane='1' $ else rPlane=strtrim(string(rPlane,format='(I)'),2) ;--I.6-- User-preferences -------------------------------------------------------- ;--I.6.1--I/O for Miriade (vo.imcce.fr) if not keyword_set( MIME ) then mime = 'text' if not keyword_set( FROM ) then from = 'IDL' ;--I.6.2--I/O for Eproc (local) epFormat='gregorian' if keyword_set( ISO ) then epFormat='isodate' if keyword_set(JULIAN) then epFormat='julian' ;--I.6.3--Output Ephemeris to File if keyword_set( DUMP ) then sDump=' > '+strtrim(dump,2) $ else sDump='' ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Ephemeris Generation from Local Eproc -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; if not keyword_set( WEB ) and $ keyword_set( file_which(getenv('PATH'), 'ephemcc') ) then begin ;--II.1-- Generate the Command line ----------------------------------------------- ;--II.1.1-- Target sTarget = tType+' '+tId+' '+tName ;--II.1.2-- Epochs if keyword_set(DATELIST) then begin sTime = ' -j '+epoch+' 1 ' endif else begin sTime = ' -j '+epoch+' -d '+nbd+' -p '+step endelse sScale = ' -e '+scale ;--II.1.3-- Reference plane and Type of Ephemeris sEphem = ' -tp '+rPlane+$ ' -te '+tEph+$ ' -tc '+tCoor ;--II.1.4-- Observer if keyword_set(heliocentric) then begin sObs = ' -c 1' endif else begin sObs = obsId+' '+obsName endelse ;--II.1.5-- Options sOption = ' -print --'+epFormat ;--II.2-- Call Eproc -------------------------------------------------------------- spawn, 'ephemcc '+sTarget+sScale+sTime+sEphem+sObs+sOption+sDump, ephO, ephE ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- III -- Ephemeris Generation using Miriade (vo.imcce.fr) -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; endif else begin ;--III.1-- Generate the URL line --------------------------------------------------- ;--III.1.1-- Target sTarget = '-type='+tType+'&-name='+tName ;--III.1.2-- Epochs sTime = '&-ep='+epoch+'&-nbd='+nbd+'&-step='+step sScale= '&-tscale='+scale epFormat='isodate' ;--III.1.3-- Reference plane and Type of Ephemeris sEphem = '&-rplane='+rPlane+$ '&-teph=' +tEph+$ '&-tcoor=' +tCoor ;--III.1.4-- Observer if keyword_set(heliocentric) then begin sObs = '&-obs=@sun' endif else begin sObs = '&-obs='+obsName endelse ;--III.1.5-- Options sOption = '&-mime='+mime+$ '&-from='+from ;--III.2-- Call Miriade ------------------------------------------------------------ miriade = 'http://vo.imcce.fr/webservices/miriade/ephemcc_query.php?' if keyword_set(DATELIST) then begin spawn, 'curl -F "epochs=@'+epoch+'" "'+miriade+sTarget+sScale+sEphem+sObs+sOption+'"'+sDump, ephO, ephE endif else begin spawn, 'curl "'+miriade+sTarget+sScale+sTime+sEphem+sObs+sOption+'"'+sDump, ephO, ephE endelse endelse ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- IV -- Organize Ephemeris into a Structure -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--IV.1-- Analyse the Ephemeris if keyword_set(dump) then ephem = read_ephemcc( dump, mime=mime, tcoor=tCoor, date=epFormat ) $ else ephem = read_ephemcc( ephO, mime=mime, tcoor=tCoor, date=epFormat ) ;--IV.2-- Return the Structure return, ephem end