diff --git a/docker-compose/grafana/Dockerfile b/docker-compose/grafana/Dockerfile index 9f7ab94b12b425be552e96d737d3fb91597e6e1c..b5a8f34b370c83e05ed0f02a032da247c0fe4ccb 100644 --- a/docker-compose/grafana/Dockerfile +++ b/docker-compose/grafana/Dockerfile @@ -5,8 +5,8 @@ RUN grafana-cli plugins install briangann-datatable-panel RUN grafana-cli plugins install ae3e-plotly-panel RUN grafana-cli plugins install yesoreyeram-infinity-datasource RUN grafana-cli plugins install aceiot-svg-panel -RUN grafana-cli plugins install alexanderzobnin-zabbix-app RUN grafana-cli plugins install yesoreyeram-boomtable-panel +RUN grafana-cli plugins install orchestracities-map-panel COPY grafana.ini /etc/grafana/ diff --git a/docker-compose/lofar-device-base/Dockerfile b/docker-compose/lofar-device-base/Dockerfile index 9897528c555aa92edcdf409c1518b53132818cb4..7a4e16b8b4ba855b8a843313ff6258bf2f8c91db 100644 --- a/docker-compose/lofar-device-base/Dockerfile +++ b/docker-compose/lofar-device-base/Dockerfile @@ -1,7 +1,8 @@ ARG SOURCE_IMAGE FROM ${SOURCE_IMAGE} -RUN sudo apt-get update && sudo apt-get install -y git && sudo apt-get clean +RUN sudo apt-get update && sudo apt-get install -y git g++ python3-dev && sudo apt-get clean + COPY docker-compose/lofar-device-base/lofar-requirements.txt /lofar-requirements.txt RUN sudo pip3 install -r /lofar-requirements.txt diff --git a/tangostationcontrol/requirements.txt b/tangostationcontrol/requirements.txt index 6bb820aeaa883e039ee012e46d6025b98f9cbc5c..d1c66a8a28d821d59aac859eb3725d6fbce12243 100644 --- a/tangostationcontrol/requirements.txt +++ b/tangostationcontrol/requirements.txt @@ -16,3 +16,4 @@ etrs-itrs@git+https://github.com/brentjens/etrs-itrs # license pending # numpy must be manually added even though etrs-itrs requires it numpy >= 1.21.0 # BSD lofarantpos >= 0.5.0 # Apache 2 +python-geohash >= 0.8.5 # Apache 2MIT diff --git a/tangostationcontrol/tangostationcontrol/beam/geo.py b/tangostationcontrol/tangostationcontrol/beam/geo.py index 2c8195796811237750becb29f28fcf904f34f03d..0c541ef5c8b6bdd388f81f36bfabc13a9f659a30 100644 --- a/tangostationcontrol/tangostationcontrol/beam/geo.py +++ b/tangostationcontrol/tangostationcontrol/beam/geo.py @@ -2,6 +2,7 @@ import etrsitrs import lofarantpos.geo import numpy import math +import geohash """ LOFAR station positions are measured in ETRS89, which are the coordinates of the position as it would be in 1989. @@ -49,3 +50,11 @@ def ETRS_to_GEO(ETRS_coordinates: numpy.array) -> numpy.array: # Geo coordinates are only used for rough positioning. The difference between ITRF and ETRS matters little here ITRF_to_GEO = ETRS_to_GEO + +def GEO_to_GEOHASH(GEO_coordinates: numpy.array) -> numpy.array: + """ Convert an array of latitude/longitude (degrees) tuples to geohash strings. """ + + def GEO_to_GEOHASH_fn(geo_coords): + return geohash.encode(geo_coords[0], geo_coords[1], precision=32) + + return _apply_fn_on_one_element_or_array(GEO_to_GEOHASH_fn, GEO_coordinates) diff --git a/tangostationcontrol/tangostationcontrol/devices/recv.py b/tangostationcontrol/tangostationcontrol/devices/recv.py index 090d6349c929266bf5a49d65772c36cdc3b820cf..eecbf2b1ef3dea45e6571ab7b1d499269d33c783 100644 --- a/tangostationcontrol/tangostationcontrol/devices/recv.py +++ b/tangostationcontrol/tangostationcontrol/devices/recv.py @@ -22,7 +22,7 @@ from math import pi # Additional import from tangostationcontrol.beam.hba_tile import HBATAntennaOffsets -from tangostationcontrol.beam.geo import ETRS_to_ITRF, ITRF_to_GEO +from tangostationcontrol.beam.geo import ETRS_to_ITRF, ITRF_to_GEO, GEO_to_GEOHASH from tangostationcontrol.common.entrypoint import entry from tangostationcontrol.common.lofar_logging import device_logging_to_python from tangostationcontrol.clients.attribute_wrapper import attribute_wrapper @@ -238,6 +238,10 @@ class RECV(opcua_device): doc='Absolute reference position of antenna field, in latitude/longitude (degrees)', dtype=(numpy.float,), max_dim_x=2) + Antenna_Field_Reference_GEOHASH_R = attribute(access=AttrWriteType.READ, + doc='Absolute reference position of antenna field, as geohash string', + dtype=numpy.str) + HBAT_antenna_ITRF_offsets_R = attribute(access=AttrWriteType.READ, doc='Offsets of the antennas within a tile, in ITRF ("iHBADeltas"). True shape: 96x16x3.', dtype=((numpy.float,),), max_dim_x=48, max_dim_y=96) @@ -250,6 +254,11 @@ class RECV(opcua_device): doc='Absolute reference position of each tile, in latitude/longitude (degrees)', dtype=((numpy.float,),), max_dim_x=2, max_dim_y=96) + HBAT_reference_GEOHASH_R = attribute(access=AttrWriteType.READ, + doc='Absolute reference position of each tile, as geohash strings', + dtype=(numpy.str,), max_dim_x=96,) + + def read_Antenna_Field_Reference_ITRF_R(self): # provide ITRF field coordinates if they were configured if self.Antenna_Field_Reference_ITRF: @@ -261,6 +270,9 @@ class RECV(opcua_device): def read_Antenna_Field_Reference_GEO_R(self): return ITRF_to_GEO(self.read_Antenna_Field_Reference_ITRF_R()) + + def read_Antenna_Field_Reference_GEOHASH_R(self): + return GEO_to_GEOHASH(self.read_Antenna_Field_Reference_GEO_R()) def read_HBAT_antenna_ITRF_offsets_R(self): base_antenna_offsets = numpy.array(self.HBAT_base_antenna_offsets).reshape(16,3) @@ -288,6 +300,9 @@ class RECV(opcua_device): def read_HBAT_reference_GEO_R(self): return ITRF_to_GEO(self.read_HBAT_reference_ITRF_R()) + def read_HBAT_reference_GEOHASH_R(self): + return GEO_to_GEOHASH(self.read_HBAT_reference_GEO_R()) + # ---------- # Summarising Attributes # ---------- diff --git a/tangostationcontrol/tangostationcontrol/test/beam/test_geo.py b/tangostationcontrol/tangostationcontrol/test/beam/test_geo.py index 5694376be684b96e74a6197e5e8c3d13f3df6d39..ecc81b6c45715597f7d6f17debda4b47c15c7343 100644 --- a/tangostationcontrol/tangostationcontrol/test/beam/test_geo.py +++ b/tangostationcontrol/tangostationcontrol/test/beam/test_geo.py @@ -70,3 +70,29 @@ class TestETRS_to_GEO(base.TestCase): LOFAR1_CS001_LBA_GEO = [52.911, 6.868] numpy.testing.assert_almost_equal(CS001_LBA_GEO, LOFAR1_CS001_LBA_GEO, decimal=3) + +class TestGEO_to_GEOHASH(base.TestCase): + def test_convert_single_coordinate(self): + """ Convert a single coordinate. """ + GEO_coords = numpy.array([1.0, 1.0]) + GEOHASH_coords = GEO_to_GEOHASH(GEO_coords) + + self.assertEqual((1,), GEOHASH_coords.shape) + + def test_convert_array(self): + """ Convert an array of coordinates. """ + GEO_coords = numpy.array([ [1.0, 1.0], [2.0, 2.0], [3.0, 3.0] ]) + GEOHASH_coords = GEO_to_GEOHASH(GEO_coords) + + self.assertEqual((3,1), GEOHASH_coords.shape) + + def test_CS001_LBA_regression(self): + """ Verify if the calculated CS001LBA phase center match fixed values, to detect changes in computation. """ + + CS001_LBA_GEO = [52.911, 6.868] + + # Convert to GEO + CS001_LBA_GEOHASH = GEO_to_GEOHASH(numpy.array(CS001_LBA_GEO)) + + # verify against precomputed value + self.assertEqual('u1kvh21hgvrcpm28', CS001_LBA_GEOHASH)