; docformat = 'rst' ; ; NAME: ; genoidReadObs ; PURPOSE: ; Read a Genoid VOTable and store its content in a structure ; ;+ ; :Description: ; Read a Genoid VOTable and store its content in a structure ; ; :Categories: ; Disk I/O, Genoid ; ; :Params: ; file: in, required, type=string ; The path to the VOTable to be read ; ; :Keywords: ; empty: in, optional, type=integer, default=0 ; If non-zero, skip reading and return an array of "empty" elements. ; ; :Returns: A structure containing the VOTable. Fields are:: ; .JD: Date in Julian Days ; .ISO: Date in ISO format ; .refName: Name of the system ; .X: .Obs: X Position - Observed ; .Err: X Position - Uncertainty ; .Cal: X Position - Computed by Genoide ; .OMC: X Position - Observed minus Computed ; .Y: similar to X structure ; .timeScale: Time scale (TT, UTC...) ; .centerFrame: Reference frame center ; .typeFrame: Type of reference frame ; .coordType: Type of coordinates ; .refFrame: Reference plane (1:equator, 2:ecliptic) ; .obsIAU: IAU code of the observatory ; .method: Photometric method used to obtain x,y measurements ; .Mag: Difference in magnitude between primary and satellite ; .dMag: Standard deviation on mag ; .QC: Quality note of the measure (A|A+|B|C|D) ; .telescope: Telescope used to acquire the measure ; .camera: Camera used to acquire the measure ; .filter: Filter used to acquire the measure ; .author: Name of the person who measured the image ; .when: Epoch at which the image was measured the last time (ISO format) ; .bib: Bibliographic reference ; ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Written in April 2017, B. Carry (OCA) ; 2017 Dec - B. Carry (OCA) - Adapted TD order to new Genoid format ; 2018 Mar - B. Carry (OCA) - Corrected bug on TD order ; 2018 Nov - B. Carry (OCA) - Removed refSys (deprecated) ;- function genoidReadObs, file, empty=empty COMPILE_OPT hidden, idl2 ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--I.1-- Define Empty Elements ---------------------------------------------------------------; xyEmpty={obs:0., err:0., cal:0., omc:0.} satEmpty = {jd: 0.0d, iso: '', $ refName: '', $ x: xyEmpty, y: xyEmpty, $ timeScale: '', centerFrame: 0., typeFrame: 0., $ coordType: 0., refFrame: 0., iau:'', $ method: '', Mag:0., dMag:0., $ QC: '', telescope:'', camera:'', filter:'', author:'', $ when: '', bib: ''} ;--I.2-- Simple Return If Requested ----------------------------------------------------------; if keyword_set(empty) then return, replicate( satEmpty, empty ) ;--I.3-- Syntax Validation -------------------------------------------------------------------; if not keyword_set(file) then begin message, /ioError, 'Syntax: obs = genoidReadObs( file )' return, -1 endif ;--I.4-- File Accessibility ------------------------------------------------------------------; if not file_test(file,/read) then begin message, /Info, 'File cannot be read: '+strTrim(file,2) return, -2 endif ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Number of Date and Output Structure -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--II.1-- Number of Epochs -------------------------------------------------------------------; spawn, 'grep obs.dat '+file, result, error split=strSplit( result, '"', /Extract ) nbEp = round(float(split[3])) ;--II.2-- Output Structure -------------------------------------------------------------------; sat = replicate( satEmpty, nbEp ) ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- III -- Analyze the XML Table -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--III.1-- Blindly Read the XML --------------------------------------------------------------; xml = read_xml( file ) vot = xml.VOT_VOTABLE.VOT_RESOURCE.VOT_TABLE.VOT_DATA.VOT_TABLEDATA.VOT_TR ;--III.2-- Decode XML and Store Fields -------------------------------------------------------; for kEp=0, nbEp-1 do begin loc=vot[kEp] ;--III.2.1-- Time Variables ---------------------------------------------------------------; sat[kEp].jd = double(loc.VOT_TD[0]._TEXT) sat[kEp].iso = strTrim(loc.VOT_TD[1]._TEXT,2) ;--III.2.2-- System Identification --------------------------------------------------------; sat[kEp].refName = strTrim(loc.VOT_TD[2]._TEXT,2) ;--III.2.3-- Satellite Coordinates --------------------------------------------------------; sat[kEp].x.obs = float(loc.VOT_TD[ 3]._TEXT) sat[kEp].y.obs = float(loc.VOT_TD[ 4]._TEXT) sat[kEp].x.err = float(loc.VOT_TD[ 5]._TEXT) sat[kEp].y.err = float(loc.VOT_TD[ 6]._TEXT) sat[kEp].x.cal = float(loc.VOT_TD[ 7]._TEXT) sat[kEp].y.cal = float(loc.VOT_TD[ 8]._TEXT) sat[kEp].x.omc = float(loc.VOT_TD[ 9]._TEXT) sat[kEp].y.omc = float(loc.VOT_TD[10]._TEXT) ;--III.2.4-- Reference Frames -------------------------------------------------------------; sat[kEp].timeScale = strTrim(loc.VOT_TD[11]._TEXT,2) sat[kEp].centerFrame = round(float(loc.VOT_TD[12]._TEXT)) sat[kEp].typeFrame = round(float(loc.VOT_TD[13]._TEXT)) sat[kEp].coordType = round(float(loc.VOT_TD[14]._TEXT)) sat[kEp].refFrame = round(float(loc.VOT_TD[15]._TEXT)) ;--III.2.5-- Telescope Information --------------------------------------------------------; sat[kEp].iau = strTrim(loc.VOT_TD[16]._TEXT,2) sat[kEp].telescope = strTrim(loc.VOT_TD[21]._TEXT,2) sat[kEp].camera = strTrim(loc.VOT_TD[22]._TEXT,2) sat[kEp].filter = strTrim(loc.VOT_TD[23]._TEXT,2) ;--III.2.6-- Photometry -------------------------------------------------------------------; sat[kEp].Mag = float(loc.VOT_TD[18]._TEXT) sat[kEp].dMag = float(loc.VOT_TD[19]._TEXT) sat[kEp].QC = strTrim(loc.VOT_TD[20]._TEXT,2) ;--III.2.7-- Who, When, How? --------------------------------------------------------------; sat[kEp].method = strTrim(loc.VOT_TD[17]._TEXT,2) sat[kEp].author = strTrim(loc.VOT_TD[24]._TEXT,2) sat[kEp].when = strTrim(loc.VOT_TD[25]._TEXT,2) sat[kEp].bib = strTrim(loc.VOT_TD[26]._TEXT,2) ; print, sat[kEp].iso, sat[kEp].Mag, sat[kEp].dMag ; stop endfor return, sat end ; ;--III.2.1-- Time Variables ---------------------------------------------------------------; ; sat[kEp].jd = double(loc.VOT_TD[0]._TEXT) ; sat[kEp].iso = strTrim(loc.VOT_TD[1]._TEXT,2) ; ; ;--III.2.2-- System Identification --------------------------------------------------------; ; sat[kEp].refName = strTrim(loc.VOT_TD[2]._TEXT,2) ; sat[kEp].refSys = strTrim(loc.VOT_TD[3]._TEXT,2) ; ; ;--III.2.3-- Satellite Coordinates --------------------------------------------------------; ; sat[kEp].x.obs = float(loc.VOT_TD[ 4]._TEXT) ; sat[kEp].y.obs = float(loc.VOT_TD[ 5]._TEXT) ; sat[kEp].x.err = float(loc.VOT_TD[ 6]._TEXT) ; sat[kEp].y.err = float(loc.VOT_TD[ 7]._TEXT) ; sat[kEp].x.cal = float(loc.VOT_TD[ 8]._TEXT) ; sat[kEp].y.cal = float(loc.VOT_TD[ 9]._TEXT) ; sat[kEp].x.omc = float(loc.VOT_TD[10]._TEXT) ; sat[kEp].y.omc = float(loc.VOT_TD[11]._TEXT) ; ; ;--III.2.4-- Reference Frames -------------------------------------------------------------; ; sat[kEp].timeScale = strTrim(loc.VOT_TD[12]._TEXT,2) ; sat[kEp].centerFrame = round(float(loc.VOT_TD[13]._TEXT)) ; sat[kEp].typeFrame = round(float(loc.VOT_TD[14]._TEXT)) ; sat[kEp].coordType = round(float(loc.VOT_TD[15]._TEXT)) ; sat[kEp].refFrame = round(float(loc.VOT_TD[16]._TEXT)) ; ; ;--III.2.5-- Telescope Information --------------------------------------------------------; ; sat[kEp].iau = strTrim(loc.VOT_TD[17]._TEXT,2) ; sat[kEp].telescope = strTrim(loc.VOT_TD[22]._TEXT,2) ; sat[kEp].camera = strTrim(loc.VOT_TD[23]._TEXT,2) ; sat[kEp].filter = strTrim(loc.VOT_TD[24]._TEXT,2) ; ; ;--III.2.6-- Photometry -------------------------------------------------------------------; ; sat[kEp].Mag = float(loc.VOT_TD[19]._TEXT) ; sat[kEp].dMag = float(loc.VOT_TD[20]._TEXT) ; sat[kEp].QC = strTrim(loc.VOT_TD[21]._TEXT,2) ; ; ;--III.2.7-- Who, When, How? --------------------------------------------------------------; ; sat[kEp].method = strTrim(loc.VOT_TD[18]._TEXT,2) ; sat[kEp].author = strTrim(loc.VOT_TD[25]._TEXT,2) ; sat[kEp].when = strTrim(loc.VOT_TD[26]._TEXT,2) ; sat[kEp].bib = strTrim(loc.VOT_TD[27]._TEXT,2)