#!/usr/bin/env python # -*- coding: utf-8 -*- from astropy.io.votable import parse_single_table from astropy.time import Time from astropy.coordinates import SkyCoord from mapper import Mapper from iterator import Iterator import matplotlib.pyplot as plt import numpy as np import sys , pprint def main(): """ VOTable processing """ # Read the annotations file_to_process = "../../data/BetaLyr_Vizier.xml" mapper = Mapper("BETALYR", file_to_process, "ndgnsolidgdea") mapper.read_annotation() print("read " + mapper.__repr__()) # Read data and initiate an iterator iterator = Iterator(file_to_process, mapper) pp = pprint.PrettyPrinter(indent=4) x1 = [] y1 = [] x2 = [] y2 = [] x3 = [] y3 = [] x4 = [] y4 = [] x5 = [] y5 = [] header = {} while iterator.hasNext() : #pp.pprint( iterator.next_object()) response = iterator.next_object() #pp.pprint(response) print(iterator.get_listed_columns()) for k,v in response.items() : if not k.startswith("#"): header[k] = v print(response.keys()) data = response["#timeseries:TimeSerie.points#timeseries:data.Point"] for point in data: x1.append(point['Point.timeseries.data.Point.timestamp']) y1.append(point['Point.timeseries.data.Point.observable']) x2.append(point['Point1.timeseries.data.Point.timestamp']) y2.append(point['Point1.timeseries.data.Point.observable']) x3.append(point['Point2.timeseries.data.Point.timestamp']) y3.append(point['Point2.timeseries.data.Point.observable']) x4.append(point['Point3.timeseries.data.Point.timestamp']) y4.append(point['Point3.timeseries.data.Point.observable']) x5.append(point['Point4.timeseries.data.Point.timestamp']) y5.append(point['Point4.timeseries.data.Point.observable']) # Let's assume we have only one TS in this file """ Plotting section """ fig, ax1 = plt.subplots() plt.plot(x1, y1, "bo", markersize=1) plt.plot(x2, y2, "ro", markersize=1) plt.plot(x3, y3, "yo", markersize=1) plt.plot(x4, y4, "go", markersize=1) plt.plot(x5, y5, "go", markersize=1) plt.xlabel('Time') plt.ylabel('Mag') ax1.text(x1[0], min(y2), pp.pformat(header), fontsize=8) plt.show() if __name__ == "__main__": main()