Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.a-feat-parse-from-zbase' into …
Browse files Browse the repository at this point in the history
…1.a-feat-parse-from-zbase

# Conflicts:
#	docs/tree/figures/settlement_rod.png
#	docs/tree/reference.rst
#	src/baec/measurements/settlement_rod_measurement.py
#	src/baec/measurements/settlement_rod_measurement_series.py
#	tests/measurements/conftest.py
#	tests/measurements/test_settlement_rod_measurement.py
#	tests/measurements/test_settlement_rod_measurement_series.py
  • Loading branch information
RDWimmers committed Jun 10, 2024
2 parents 6dd01ea + e6f6826 commit 15c0511
Show file tree
Hide file tree
Showing 7 changed files with 250 additions and 697 deletions.
Binary file modified docs/tree/figures/settlement_rod.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 3 additions & 14 deletions docs/tree/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Reference
Settlement Rod Measurement
----------------------------

A settlement rod device consists of a rod and a (bottom) settlement plate (see figure below). The measurements are taken at the top of the rod (i.e. `rod_top`)
and at the `ground surface` and since the `rod length` is known, the settlement of at the bottom of the rod (i.e. `rod_bottom`) can be also derived.
A settlement rod device consists of a rod and a (bottom) settlement plate (see figure below). The measurements are taken at the top of the rod (i.e. the `measurement_point`)
and at the `ground surface` and since the `rod length` is known, the settlement of at the bottom of the plate (i.e. `plate_bottom_z`) can be also derived.

.. image:: figures/settlement_rod.png

Expand Down Expand Up @@ -51,7 +51,7 @@ Measurement Device

.. automethod:: __init__

.. _project:
.. _measurementProject:

Project
-------
Expand All @@ -63,14 +63,3 @@ Project

.. automethod:: __init__

CoordinateReferenceSystems
--------------------------

.. _coordinateReferenceSystems:

.. autoclass:: baec.coordinates.CoordinateReferenceSystems
:members:
:inherited-members:
:member-order: bysource

.. automethod:: __init__
163 changes: 64 additions & 99 deletions src/baec/measurements/settlement_rod_measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import datetime
from enum import Enum
from functools import cache

from baec.coordinates import CoordinateReferenceSystems
import pyproj

from baec.measurements.measurement_device import MeasurementDevice
from baec.project import Project

Expand Down Expand Up @@ -34,12 +34,12 @@ def __init__(
device: MeasurementDevice,
object_id: str,
date_time: datetime.datetime,
coordinate_reference_systems: CoordinateReferenceSystems,
rod_top_x: float,
rod_top_y: float,
rod_top_z: float,
coordinate_reference_system: pyproj.CRS,
x: float,
y: float,
z: float,
rod_length: float,
rod_bottom_z: float,
plate_bottom_z: float,
ground_surface_z: float,
status: SettlementRodMeasurementStatus,
temperature: float | None = None,
Expand All @@ -61,32 +61,29 @@ def __init__(
The ID of the measured object.
date_time : datetime.datetime
The date and time of the measurement.
coordinate_reference_systems : CoordinateReferenceSystems
The horizontal (X, Y) and vertical (Z) coordinate reference systems (CRS) of the
spatial measurements.
rod_top_x : float
The horizontal X-coordinate of the top of the settlement rod.
Units are according to the `coordinate_reference_systems`.
rod_top_y : float
The horizontal Y-coordinate of the top of the settlement rod.
Units are according to the `coordinate_reference_systems`.
rod_top_z : float
The vertical Z-coordinate of the top of the settlement rod.
coordinate_reference_system : pyproj.CRS
The coordinate reference system of the spatial measurements.
It is a `pyproj.CRS` object (see https://pyproj4.github.io/pyproj/stable/api/crs/crs.html).
x : float
The X-coordinate of the measurement point. Units are according to the `coordinate_reference_system`.
y : float
The Y-coordinate of the measurement point. Units are according to the `coordinate_reference_system`.
z : float
The Z-coordinate of the measurement point.
It is the top of the settlement rod.
Units and datum are according to the `coordinate_reference_systems`.
Units are according to the `coordinate_reference_system`.
rod_length : float
The length of the settlement rod including the thickness of the settlement plate.
It is in principle the vertical distance between the top of the settlement rod and
the bottom of the settlement plate.
Units are according to the `coordinate_reference_systems`.
rod_bottom_z : float
The corrected Z-coordinate at the bottom of the settlement rod (coincides with bottom of settlement plate).
It is in principle the vertical distance between the measurement point and the bottom of the settlement plate.
Units are according to the `coordinate_reference_system`.
plate_bottom_z : float
The corrected Z-coordinate at the bottom of the settlement plate.
Note that the bottom of the plate is in principle the original ground surface.
Units and datum according to the `coordinate_reference_systems`.
Units are according to the `coordinate_reference_system`.
ground_surface_z : float
The Z-coordinate of the ground surface.
It is in principle the top of the fill, if present.
Units and datum according to the `coordinate_reference_systems`.
Units are according to the `coordinate_reference_system`.
status: SettlementRodMeasurementStatus
The status of the measurement.
temperature : float or None, optional
Expand All @@ -110,12 +107,12 @@ def __init__(
self._set_device(device)
self._set_object_id(object_id)
self._set_date_time(date_time)
self._set_coordinate_reference_systems(coordinate_reference_systems)
self._set_rod_top_x(rod_top_x)
self._set_rod_top_y(rod_top_y)
self._set_rod_top_z(rod_top_z)
self._set_coordinate_reference_system(coordinate_reference_system)
self._set_x(x)
self._set_y(y)
self._set_z(z)
self._set_rod_length(rod_length)
self._set_rod_bottom_z(rod_bottom_z)
self._set_plate_bottom_z(plate_bottom_z)
self._set_ground_surface_z(ground_surface_z)
self._set_status(status)
self._set_temperature(temperature)
Expand Down Expand Up @@ -158,46 +155,44 @@ def _set_date_time(self, value: datetime.datetime) -> None:
)
self._date_time = value

def _set_coordinate_reference_systems(
self, value: CoordinateReferenceSystems
) -> None:
def _set_coordinate_reference_system(self, value: pyproj.CRS) -> None:
"""
Private setter for coordinate_reference_systems attribute.
Private setter for coordinate_reference_system attribute.
"""
if not isinstance(value, CoordinateReferenceSystems):
if not isinstance(value, pyproj.CRS):
raise TypeError(
"Expected 'CoordinateReferenceSystems' type for 'coordinate_reference_systems' attribute."
"Expected 'pyproj.CRS' type for 'coordinate_reference_system' attribute."
)
self._coordinate_reference_systems = value
self._coordinate_reference_system = value

def _set_rod_top_x(self, value: float) -> None:
def _set_x(self, value: float) -> None:
"""
Private setter for rod_top_x attribute.
Private setter for x attribute.
"""
if isinstance(value, int):
value = float(value)
if not isinstance(value, float):
raise TypeError("Expected 'float' type for 'rod_top_x' attribute.")
raise TypeError("Expected 'float' type for 'x' attribute.")
self._x = value

def _set_rod_top_y(self, value: float) -> None:
def _set_y(self, value: float) -> None:
"""
Private setter for rod_top_y attribute.
Private setter for y attribute.
"""
if isinstance(value, int):
value = float(value)
if not isinstance(value, float):
raise TypeError("Expected 'float' type 'rod_top_y' attribute.")
raise TypeError("Expected 'float' type 'y' attribute.")
self._y = value

def _set_rod_top_z(self, value: float) -> None:
def _set_z(self, value: float) -> None:
"""
Private setter for rod_top_z attribute.
Private setter for z attribute.
"""
if isinstance(value, int):
value = float(value)
if not isinstance(value, float):
raise TypeError("Expected 'float' type for 'rod_top_z' attribute.")
raise TypeError("Expected 'float' type for 'z' attribute.")
self._z = value

def _set_rod_length(self, value: float) -> None:
Expand All @@ -212,15 +207,15 @@ def _set_rod_length(self, value: float) -> None:
raise ValueError("Negative value not allowed for 'rod_length' attribute.")
self._rod_length = value

def _set_rod_bottom_z(self, value: float) -> None:
def _set_plate_bottom_z(self, value: float) -> None:
"""
Private setter for rod_bottom_z attribute.
Private setter for plate_bottom_z attribute.
"""
if isinstance(value, int):
value = float(value)
if not isinstance(value, float):
raise TypeError("Expected 'float' type for 'rod_bottom_z' attribute.")
self._rod_bottom_z = value
raise TypeError("Expected 'float' type for 'plate_bottom_z' attribute.")
self._plate_bottom_z = value

def _set_ground_surface_z(self, value: float) -> None:
"""
Expand Down Expand Up @@ -305,33 +300,33 @@ def date_time(self) -> datetime.datetime:
return self._date_time

@property
def coordinate_reference_systems(self) -> CoordinateReferenceSystems:
def coordinate_reference_system(self) -> pyproj.CRS:
"""
The horizontal (X, Y) and vertical (Z) coordinate reference systems (CRS) of the
spatial measurements.
The coordinate reference system of the spatial measurements.
It is a `pyproj.CRS` object (see https://pyproj4.github.io/pyproj/stable/api/crs/crs.html).
"""
return self._coordinate_reference_systems
return self._coordinate_reference_system

@property
def rod_top_x(self) -> float:
def x(self) -> float:
"""
The horizontal X-coordinate of the top of the settlement rod.
The X-coordinate of the measurement point.
Units are according to the `coordinate_reference_system`.
"""
return self._x

@property
def rod_top_y(self) -> float:
def y(self) -> float:
"""
The horizontal Y-coordinate of the top of the settlement rod.
The Y-coordinate of the measurement point.
Units are according to the `coordinate_reference_system`.
"""
return self._y

@property
def rod_top_z(self) -> float:
def z(self) -> float:
"""
The vertical Z-coordinate of the top of the settlement rod.
The Z-coordinate of the measurement point.
It is the top of the settlement rod.
Units are according to the `coordinate_reference_system`.
"""
Expand All @@ -341,28 +336,28 @@ def rod_top_z(self) -> float:
def rod_length(self) -> float:
"""
The length of the settlement rod including the thickness of the settlement plate.
It is in principle the vertical distance between the top of the settlement rod and the bottom of the settlement plate.
It is in principle the vertical distance between the measurement point and the bottom of the settlement plate.
Units are according to the `coordinate_reference_system`.
"""
return self._rod_length

@property
def rod_bottom_z(self) -> float:
def plate_bottom_z(self) -> float:
"""
The corrected Z-coordinate at the bottom of the settlement rod (coincides with bottom of settlement plate).
The corrected Z-coordinate at the bottom of the settlement plate.
Note that the bottom of the plate is in principle the original ground surface.
Units are according to the `coordinate_reference_system`.
"""
return self._rod_bottom_z
return self._plate_bottom_z

@property
def rod_bottom_z_uncorrected(self) -> float:
def plate_bottom_z_uncorrected(self) -> float:
"""
The uncorrected Z-coordinate at the bottom of the settlement rod (coincides with bottom of settlement plate).
It is computed as the difference beteen the Z-coordinate of the top of the settlement rod and the rod length.
The uncorrected Z-coordinate at the bottom of the settlement plate.
It is computed as the difference beteen the Z-coordinate of the measurement point and the vertical offset.
Units are according to the `coordinate_reference_system`.
"""
return self.rod_top_z - self.rod_length
return self.z - self.rod_length

@property
def ground_surface_z(self) -> float:
Expand Down Expand Up @@ -399,33 +394,3 @@ def comment(self) -> str:
Additional comment about the measurement.
"""
return self._comment

@cache
def to_dict(self) -> dict:
"""
Convert the measurement to a dictionary.
"""
return {
"project_id": self.project.id,
"project_name": self.project.name,
"device_id": self.device.id,
"device_qr_code": self.device.qr_code,
"object_id": self.object_id,
"coordinate_horizontal_epsg_code": self.coordinate_reference_systems.horizontal.to_epsg(),
"coordinate_vertical_epsg_code": self.coordinate_reference_systems.vertical.to_epsg(),
"coordinate_horizontal_units": self.coordinate_reference_systems.horizontal_units,
"coordinate_vertical_units": self.coordinate_reference_systems.vertical_units,
"coordinate_vertical_datum": self.coordinate_reference_systems.vertical_datum,
"date_time": self.date_time,
"rod_top_x": self.rod_top_x,
"rod_top_y": self.rod_top_y,
"rod_top_z": self.rod_top_z,
"rod_length": self.rod_length,
"rod_bottom_z": self.rod_bottom_z,
"rod_bottom_z_uncorrected": self.rod_bottom_z_uncorrected,
"ground_surface_z": self.ground_surface_z,
"status": self.status.value,
"temperature": self.temperature,
"voltage": self.voltage,
"comment": self.comment,
}
Loading

0 comments on commit 15c0511

Please sign in to comment.