Skip to content
Snippets Groups Projects
Commit ae5458a6 authored by Jan David Mol's avatar Jan David Mol
Browse files

L2SS-785: Added geohashes

parent 9ff5ccb0
No related branches found
No related tags found
1 merge request!331L2SS-785: Add geohash
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
......
......@@ -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
......@@ -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)
......@@ -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
# ----------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment