; docformat = 'rst' ; ; NAME: ; GENOIDE_XMLREAD ; PURPOSE: ; Read a Genoid VOTable and store its content in a structure ; ;+ ; :Description: ; Read a Genoid VOTable and store its content in a structure ; ; The suite of small routines GENOIDE_XML... allow to open, complete, close, read ; an XML file in the Genoid standards. ; ; :Categories: ; Disk I/O, Genoide ; ; :Params: ; FILE: in, required, type=string ; The path to the VOTable to be read ; ; :Returns: A structure containing the VOTable. Fields are:: ; .JD: Date in Julian Days ; .ISO: Date in ISO format ; .refName: Name of the ; .refSys: ; .xObs: X Position - Observed ; .yObs: Y Position - Observed ; .xErr: X Position - Uncertainty ; .yErr: Y Position - Uncertainty ; .xCal: X Position - Computed by Genoide ; .yCal: Y Position - Computed by Genoide ; .xOMC: X Position - Observed minus Computed ; .yOMC: Y Position - Observed minus Computed ; .timeScale: Time scale (TT, UTC...) ; .centerFrame: Reference frame center ; .typeFrame: Type of reference frame ; .coordType: Type of coordinates ; .refFrame: ; .obsIAU: IAU code of the observatory ; .bib: Bibliographic note ; ; :Author: ; B.Carry (IMCCE) ; ; :History: ; Change History:: ; Written in July 2013, B. Carry (IMCCE) ; 2013 Sep. - B.Carry (IMCCE) - Cleaned ;- function genoide_xmlRead, file ;--I-- Initialization And Input Verification ;--I.1-- Check Input if ~file_exist(file) then begin message, /info, 'File not found' return, -1 endif ;--I.2-- Number of Entries per Genoid Blocks nbLine=19 ;--II-- Number of Epoch spawn, 'grep obs.dat '+file, result, error split=strsplit( result, '"', /EXTRACT ) nbDate = round(float(split(3))) ;--III-- Create a Structure to Store the Satellite Information sat = replicate( {jd: 0.0d, iso: '', $ refName: '', refsys: '', $ xobs: 0., yobs: 0., $ xerr: 0., yerr: 0., $ xcal: 0., ycal: 0., $ xomc: 0., yomc: 0., $ timescale: '', $ centerFrame: 0., typeFrame: 0., $ coordType: 0., refFrame: 0., $ obsIAU: '', bib: ''}, nbDate ) ;--IV-- Read the VOTable openr, unit, file, /GET_LUN line = ' ' kDate=-1 while ~EOF(unit) do begin ;--IV.1-- Read Current Line readf, unit, line split = strsplit( line, '<>', /EXTRACT, count=nbField ) ;--IV.2-- Starting a New Block if nbField ge 2 then $ if split(1) eq 'vot:TR' or split(1) eq 'TR' then begin kDate++ ;--IV.3-- Store the Block into the Structure for kL=0, nbLine-1 do begin readf, unit, line split = strsplit( line, '<>', /EXTRACT, count=nbSplit ) case kL of ;--IV.3.1-- Time Variables 0: sat(kDate).jd = double( split(2) ) 1: sat(kDate).iso = strTrim( split(2),2 ) ;--IV.3.2-- Dynamic System Reference 2: sat(kDate).refName = strtrim( split(2),2 ) 3: sat(kDate).refsys = strtrim( split(2),2 ) ;--IV.3.3-- Astrometry: Observed, Uncertainty, Computed, O-C 4: sat(kDate).xobs = float( split(2) ) 5: sat(kDate).yobs = float( split(2) ) 6: sat(kDate).xerr = float( split(2) ) 7: sat(kDate).yerr = float( split(2) ) 8: sat(kDate).xcal = float( split(2) ) 9: sat(kDate).ycal = float( split(2) ) 10: sat(kDate).xomc = float( split(2) ) 11: sat(kDate).yomc = float( split(2) ) ;--IV.3.4-- Time and Space Reference Frames 12: sat(kDate).timeScale = strtrim( split(2),2 ) 13: sat(kDate).centerFrame = round(float( split(2) )) 14: sat(kDate).typeFrame = round(float( split(2) )) 15: sat(kDate).coordType = round(float( split(2) )) 16: sat(kDate).refFrame = round(float( split(2) )) ;--IV.3.5-- Observer Location 17: sat(kDate).obsIAU = strtrim( split(2),2 ) ;--IV.3.6-- Bibliographic reference 18: begin if nbSplit gt 2 then sat(kDate).bib = strtrim( split(2),2 ) end endcase endfor endif endwhile ;--IV.4-- Close and Free the File/Unit close, unit free_lun, unit ;--V-- Return Genoide's VOTable as a Structure return, sat end