; docformat = 'rst' ; ; NAME: ; READ_EPHEMCC ; PURPOSE: ; Read the ephemeris of position of ephemcc (eproc) into a structure ; ;+ ; :Description: ; Read the ephemeris of position of ephemcc (eproc) into a structure ; ; This function is a simple parser to the outputs of ephemcc, part of the ; Eproc ephemeris generator (IMCCE, Paris Observatory, France). See ; Eproc documentation for more details: ; http://vo.imcce.fr/webservices/miriade/?ephemcc ; ; ; :Categories: ; Ephemeris ; ; :Params: ; SRC: in, required, type=string ; Either the path to a file with the ephemeris or an array ; of strings corresponding to the output of ephemcc ; ; :Returns: A structure containing the ephemeris. The fields follow ; the outputs of eproc ; ; :Keywords: ; MIME: in, optional, type=string, default=ascii ; Indicate the format of the ephemeris (ascii | votable | html), ; TCOOR: in, optional, type=integer, default=1 ; Indicate the type of coordinates (1:spherical, 2:rectangular, 3: Local ; coordinates, 4: Hour angle coordinates, 5: dedicated to ; observation, 6: dedicated to AO observation) ; DATE: in, optional, type=boolean, default='gregorian' ; Indicate the format of dates (gregorian | isodate | julian) ; ; :Examples: ; See call_ephemcc documentation ; ; :Uses: ; TEN, DATE_CONV ; ; :Author: ; B.Carry (IMCCE) ; ; :History: ; Change History:: ; Original Version written in September 2013, B. Carry (IMCCE) ;- function read_ephemcc, src, MIME=MIME, TCOOR=TCOOR, DATE=DATE ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; COMPILE_OPT hidden ;--I.1-- Input Source ------------------------------------------------------------ srcDim = size( src ) ;--I.1.1-- Ephemeris Lines were Provided in Input if srcDim(0) ne 0 then begin ephemcc = strtrim(src,2) nbLine = srcDim(1) ;--I.1.2-- Ephemeris are in the Input File endif else begin openr, unit, src, /GET_LUN ephemcc=' ' line='' nbLine = -1L while ~EOF(unit) do begin readf, unit, line ephemcc=[ephemcc,strtrim(line,2)] nbLine++ endwhile ephemcc=ephemcc(1:nbLine+1) close, unit free_lun, unit endelse ;--I.2-- Options ----------------------------------------------------------------- if not keyword_set(mime) then mime='text' if not keyword_set(tcoor) then tcoor='1' $ else tcoor=strtrim(string(tcoor,format='(I)'),2) if not keyword_set(date) then date='gregorian' case strlowcase(strmid(date,0,1)) of 'g': date='gregorian' 'i': date='isodate' 'j': date='julian' else: date='gregorian' endcase case mime of ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Parse the Ephemeris: ASCII -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; 'text': begin locEp = where( strmid(ephemcc,0,1) ne '#' and $ strmid(ephemcc,0,1) ne 'F' and $ strmid(ephemcc,0,1) ne 'T' and $ strmid(ephemcc,0,1) ne 'R' , nbEp ) case tcoor of ;--II.1-- Sperical Coordinates ----------------------------------------------- '1': begin ;--II.1.1-- Output Structure ephem=replicate( {jd:0.D, iso:'', $ ;-Epoch: JD & ISO ra: {sex:[0,0,0.], dec:0.}, $ ;-RA: Sexagesimal & Decimal dec:{sex:[0,0,0.], dec:0.}, $ ;-DEC: Sexagesimal & Decimal lon:{sex:[0,0,0.], dec:0.}, $ ;-Longitude: Sexagesimal & Decimal [=RA] lat:{sex:[0,0,0.], dec:0.}, $ ;-Latitude: Sexagesimal & Decimal [=DEC] dist:0.D, mag:0., $ ;-Distance, Apparent Mag phase:0., elong:0., $ ;-Solar Phase & Elongation mura:0., mudec:0., $ ;-Coordinates Apparent Rates mudist:0., $ ;-Distance Rate dx:0., dy:0., dz:0.}, nbEp ) ;-Satellite Differential Position ;--II.1.2-- Analyze the Ephemeris for kEp=0, nbEp-1 do begin ;--II.1.2/A-- Split using Spaces split=strsplit(ephemcc(locEP(kEP)), ' ', /EXTRACT, count=nbField ) if nbField ne 0 then begin ;--II.1.2/B-- Gregorian, Julian, ISO Date indDate = 0 case date of 'julian': begin ephem(kEp).jd = double(split(0)) ephem(kEp).iso = date_conv(ephem(kEp).jd,'FITS') end 'isodate': begin ephem(kEp).iso = split(0) ephem(kEp).jd = date_conv(ephem(kEp).iso,'JULIAN') end 'gregorian': begin ephem(kEp).iso = string(split(2),format='(I04)')+'-'+$ string(split(1),format='(I02)')+'-'+$ string(split(0),format='(I02)')+'T'+$ string(split(3),format='(I02)')+':'+$ string(split(4),format='(I02)')+':'+$ string(split(5),format='(F08.5)') ephem(kEp).jd = date_conv(ephem(kEp).iso,'JULIAN') indDate+=5 end endcase ;--II.1.2/C-- Coordinates "RA/DEC" for Equatorial ephem(kEp).ra.sex = [float(split(indDate+1)),float(split(indDate+2)),float(split(indDate+3))] ephem(kEp).dec.sex = [float(split(indDate+4)),float(split(indDate+5)),float(split(indDate+6))] ephem(kEp).ra.dec = ten( ephem(kEp).ra.sex )*15. ephem(kEp).dec.dec = ten( ephem(kEp).dec.sex ) ;--II.1.2/C-- Coordinates "Long/Lat" for Ecliptic = RA/DEC coordEC = frameCoord_EQ2EC( ephem(kEp).ra.dec, ephem(kEp).dec.dec) ephem(kEp).lon.dec = coordEC(0) ephem(kEp).lat.dec = coordEC(1) ephem(kEp).lon.sex = sixty(ephem(kEp).lon.dec) ephem(kEp).lat.sex = sixty(ephem(kEp).lat.dec) ;--II.1.2/D-- Distance, Magnitude, Phase angle, Solar Elongation ephem(kEp).dist = float(split(indDate+ 7)) ephem(kEp).mag = float(split(indDate+ 8)) ephem(kEp).phase = float(split(indDate+ 9)) ephem(kEp).elong = float(split(indDate+10)) ;--II.1.2/E-- Motion Rate ephem(kEp).mura = float(split(indDate+11)) ephem(kEp).mudec = float(split(indDate+12)) ephem(kEp).mudist= float(split(indDate+13)) ;--II.1.2/F-- Satellite Differential Position if nbField eq 17 then begin ephem(kEp).dx = float(split(indDate+14)) ephem(kEp).dy = float(split(indDate+15)) ephem(kEp).dz = float(split(indDate+16)) endif endif endfor end ;--II.2-- Rectangular Coordinates -------------------------------------------- '2': begin ;--II.2.1-- Output Structure ephem=replicate( {jd: 0.D, iso: '', $ x: 0.d, y: 0.d, z: 0.d, $ vx: 0.d, vy: 0.d, vz: 0.d, $ dist: 0.d}, nbEp ) ;--II.2.2-- Analyze the Ephemeris for kEp=0, nbEp-1 do begin ;--II.2.2/A-- Split using Spaces split=strsplit(ephemcc(locEP(kEP)), ' ', /EXTRACT, count=nbField ) if nbField ne 0 then begin ;--II.2.2/B-- Gregorian, Julian, ISO Date indDate = 0 case date of 'julian': begin ephem(kEp).jd = double(split(0)) ephem(kEp).iso = date_conv(ephem(kEp).jd,'FITS') end 'isodate': begin ephem(kEp).iso = split(0) ephem(kEp).jd = date_conv(ephem(kEp).iso,'JULIAN') end 'gregorian': begin ephem(kEp).iso = string(split(2),format='(I04)')+'-'+$ string(split(1),format='(I02)')+'-'+$ string(split(0),format='(I02)')+'T'+$ string(split(3),format='(I02)')+':'+$ string(split(4),format='(I02)')+':'+$ string(split(5),format='(F08.5)') ephem(kEp).jd = date_conv(ephem(kEp).iso,'JULIAN') indDate+=5 end endcase ;--II.2.2/C-- XYZ Coordinates ephem(kEp).x = double(split(indDate+1)) ephem(kEp).y = double(split(indDate+2)) ephem(kEp).z = double(split(indDate+3)) ;--II.2.2/D-- Distance, Magnitude, Phase angle, Solar Elongation ephem(kEp).dist = double(split(indDate+4)) ;--II.2.2/E-- Motion Rate ephem(kEp).vx = double(split(indDate+5)) ephem(kEp).vy = double(split(indDate+6)) ephem(kEp).vz = double(split(indDate+7)) endif endfor end ;--II.3-- Local Coordinates -------------------------------------------------- '3': begin print, 'READ_EPHEMCC - TBD - Code TCOOR=3' end ;--II.4-- Hour Angle Coordinates --------------------------------------------- '4': begin print, 'READ_EPHEMCC - TBD - Code TCOOR=4' end ;--II.5-- Dedicated to Observation ------------------------------------------- '5': begin print, 'READ_EPHEMCC - TBD - Code TCOOR=5' end ;--II.6-- Dedicated to AO Observation ---------------------------------------- '6': begin print, 'READ_EPHEMCC - TBD - Code TCOOR=6' end else: endcase end ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- III -- Parse the Ephemeris: VOTABLE -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; 'votable': begin print, 'READ_EPHEMCC - TBD - Code VOTABLE' end endcase ;-- Return the Structure return, ephem end