diff --git a/api/main.py b/api/main.py index ac9791e..8a66ab5 100644 --- a/api/main.py +++ b/api/main.py @@ -26,7 +26,8 @@ associators = [ # todo: ellipse conic int (analytic), SX, arc length localisations = [ {"name": "Ellipse Parametric", "id": "ellipse-parametric"}, - {"name": "Ellipsoid Parametric", "id": "ellipsoid-parametric"} + {"name": "Ellipsoid Parametric", "id": "ellipsoid-parametric"}, + {"name": "Spherical Intersection", "id": "spherical-intersection"} ] adsbs = [ {"name": "adsb.30hours.dev", "url": "adsb.30hours.dev"}, diff --git a/event/algorithm/localisation/EllipseParametric.py b/event/algorithm/localisation/EllipseParametric.py index 0693560..292e07f 100644 --- a/event/algorithm/localisation/EllipseParametric.py +++ b/event/algorithm/localisation/EllipseParametric.py @@ -104,7 +104,7 @@ class EllipseParametric: samples_intersect[i] = Geometry.ecef2lla( samples_intersect[i][0], samples_intersect[i][1], - 0) + samples_intersect[i][2]) output[target]["points"].append([ round(samples_intersect[i][0], 3), round(samples_intersect[i][1], 3), diff --git a/event/algorithm/localisation/SphericalIntersection.py b/event/algorithm/localisation/SphericalIntersection.py index 9b787de..0b2ccd8 100644 --- a/event/algorithm/localisation/SphericalIntersection.py +++ b/event/algorithm/localisation/SphericalIntersection.py @@ -34,4 +34,14 @@ class SphericalIntersection: output = {} + # return if no detections + if not assoc_detections: + return output + + for target in assoc_detections: + + print(assoc_detections) + #nDetections = assoc_detections + #S = np.zeros() + return output \ No newline at end of file diff --git a/event/event.py b/event/event.py index 79e76c7..93af651 100644 --- a/event/event.py +++ b/event/event.py @@ -12,6 +12,7 @@ import time import copy import json import hashlib +import os from algorithm.associator.AdsbAssociator import AdsbAssociator from algorithm.localisation.EllipseParametric import EllipseParametric @@ -19,7 +20,6 @@ from algorithm.localisation.EllipsoidParametric import EllipsoidParametric from algorithm.localisation.SphericalIntersection import SphericalIntersection from algorithm.truth.AdsbTruth import AdsbTruth from common.Message import Message - from data.Ellipsoid import Ellipsoid from algorithm.geometry.Geometry import Geometry @@ -195,6 +195,11 @@ async def main(): await asyncio.sleep(1) def append_api_to_file(api_object, filename=saveFile): + + if not os.path.exists(filename): + with open(filename, 'w') as new_file: + pass + with open(filename, 'a') as json_file: json.dump(api_object, json_file) json_file.write('\n') diff --git a/script/Dockerfile b/script/Dockerfile new file mode 100644 index 0000000..f5b4913 --- /dev/null +++ b/script/Dockerfile @@ -0,0 +1,10 @@ +# use an official Python runtime as a parent image +FROM python:3.9-slim + +# set the working directory to /app +WORKDIR /app + +# install any needed packages specified in requirements.txt +COPY requirements.txt /app +RUN pip install --no-cache-dir -r requirements.txt + diff --git a/script/README.md b/script/README.md index 7647b47..f843783 100644 --- a/script/README.md +++ b/script/README.md @@ -2,4 +2,14 @@ This folder is for post-processing scripts on API data. ## Scripts -- TODO \ No newline at end of file +- **plot_accuracy.py** plots a comparison between ADS-B truth and target localisation data in ENU coordinates. + +## Docker Environment + +To avoid having to install extra libraries on the host machine (e.g. numpy, matplotlib), a Dockerfile is provided to create this environment. + +```bash +sudo docker build -t 3lips-script . +sudo docker run -it -v /opt/3lips/save:/app/save -v /opt/3lips/script:/app/script -v /opt/3lips/event/algorithm/geometry:/app/geometry 3lips-script bash +PYTHONPATH=/app python