lofarimaging/collect_from_opcua.py

39 lines
1.4 KiB
Python
Raw Normal View History

2020-03-27 10:16:09 -06:00
#!/usr/bin/env python
2020-05-28 03:31:09 -06:00
import matplotlib
matplotlib.use("Agg")
2020-03-27 10:16:09 -06:00
import time
from lofarimaging.opc_interface import download_xst
from lofarimaging import make_xst_plots
import threading
import sys
2020-04-01 00:45:09 -06:00
import matplotlib.pyplot as plt
2020-04-20 05:12:41 -06:00
import logging
2020-03-27 10:16:09 -06:00
integration_time_s = 5
2020-04-20 05:12:41 -06:00
logger = logging.getLogger(__name__)
2020-03-27 10:16:09 -06:00
def download_and_image(station_name, subband):
port = 50000 + int(station_name[2:])
2020-04-20 05:12:41 -06:00
logger.info("Requesting data for station {} at subband {}".format(station_name, subband))
2020-03-27 10:16:09 -06:00
obstime, visibilities, rcu_mode = download_xst(subband, integration_time_s, port=port)
if rcu_mode in (1, 2, 3, 4):
2020-04-01 00:45:09 -06:00
sky_fig, ground_fig, leaflet_map = make_xst_plots(visibilities, station_name, obstime, subband, rcu_mode, hdf5_filename=f"results/results.h5", extent=[-300, 300, -300, 300], outputpath='/Volumes/home/RFI')
plt.close('all')
2020-03-27 10:16:09 -06:00
else:
2020-04-20 05:12:41 -06:00
logger.warning("Unsupported rcu mode: {}".format(rcu_mode))
2020-03-27 10:16:09 -06:00
if __name__ == "__main__":
2020-04-20 05:12:41 -06:00
logger.setLevel(logging.INFO)
logging.basicConfig(format='%(asctime)s %(message)s')
logger.info("Started collecting from OPCUA")
2020-03-27 10:16:09 -06:00
while True:
2020-04-01 00:45:09 -06:00
for station_name in ("RS210", "RS208", "CS103"):
2020-05-28 03:31:09 -06:00
for subband in (150, 250, 300, 350, 375, 400):
2020-03-27 10:16:09 -06:00
thread = threading.Thread(target=download_and_image, args=(station_name, subband))
thread.start()
2020-04-01 00:45:09 -06:00
time.sleep(30)