diff --git a/docker-compose/lofar-device-base/Dockerfile b/docker-compose/lofar-device-base/Dockerfile index 9897528c555aa92edcdf409c1518b53132818cb4..5decbd092d90f53b2c91b8e2112f045d66e9e862 100644 --- a/docker-compose/lofar-device-base/Dockerfile +++ b/docker-compose/lofar-device-base/Dockerfile @@ -1,7 +1,7 @@ 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..326c31b67e881ee7c65b8ea0c5306bb81818db54 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 @@ -250,6 +250,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: @@ -288,6 +293,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 # ----------