Commit 188f0db1 authored by Joseph Siddons's avatar Joseph Siddons
Browse files

docs: update readme

parent 91bccabb
...@@ -101,15 +101,22 @@ QuadTree( ...@@ -101,15 +101,22 @@ QuadTree(
max_depth: int, max_depth: int,
depth: int = 0 # Internal parameter depth: int = 0 # Internal parameter
) )
```
The boundary is defined by a `Rectangle` class, which is defined by the bounding box.
```python
Rectangle( Rectangle(
lon: float, # Centre longitude west: float, # Western edge
lat: float, # Centre latitude east: float, # Eastern edge
lon_range: float, # Full width of rectangle (degrees) south: float, # Southern edge
lat_range: float, # Full height of rectangle (degrees) north: float, # Northern edge
) )
``` ```
The `Rectangle` class will raise an error if the northern or southern boundary go beyond the north
or south pole.
```python ```python
from GeoSpatialTools import QuadTree, Record, Rectangle from GeoSpatialTools import QuadTree, Record, Rectangle
from random import choice from random import choice
...@@ -119,7 +126,7 @@ lat_range = list(range(-90, 90)) ...@@ -119,7 +126,7 @@ lat_range = list(range(-90, 90))
N_samples = 1000 N_samples = 1000
# Construct Tree # Construct Tree
boundary = Rectangle(0, 0, 360, 180) # Full domain boundary = Rectangle(-180, 180, -90, 90) # Full domain
qt = QuadTree(boundary) qt = QuadTree(boundary)
records: list[Record] = [Record(choice(lon_range), choice(lat_range)) for _ in range(N_samples)] records: list[Record] = [Record(choice(lon_range), choice(lat_range)) for _ in range(N_samples)]
...@@ -134,7 +141,10 @@ neighbours: list[Record] = qt.nearby_points(test_value, dist) ...@@ -134,7 +141,10 @@ neighbours: list[Record] = qt.nearby_points(test_value, dist)
#### OctTree - 3d QuadTree #### OctTree - 3d QuadTree
Adds `SpaceTimeRecord`, `SpaceTimeRectangle` and `OctTree` classes. Adds `SpaceTimeRecord`, `SpaceTimeRectangle` and `OctTree` classes. This allows for querying in a
third dimension, specifically this adds a time dimension. Typically the time dimension is assumed
to be of `datetime.datetime` type, however this is expected to work with numeric values, for example
pentad, day of year. However, this non-datetime behaviour is not intended.
```python ```python
SpaceTimeRecord( SpaceTimeRecord(
...@@ -144,14 +154,19 @@ SpaceTimeRecord( ...@@ -144,14 +154,19 @@ SpaceTimeRecord(
uid: str | None, uid: str | None,
**data **data
) )
```
As with the `Rectangle` class for the `QuadTree`, the `SpaceTimeRectangle` defines the boundary of
an `OctTree` class, and is defined by the space-time bounding box.
```python
SpaceTimeRectangle( SpaceTimeRectangle(
lon: float, # Centre longitude west: float, # Western edge
lat: float, # Centre latitude east: float, # Eastern edge
datetime: datetime, # Central datetime south: float, # Southern edge
w: float, # Full width of rectangle (degrees) north: float, # Northern edge
h: float, # Full height of rectangle (degrees) start: datetime.datetime, # Start datetime
dt: timedelta, # Time extent of rectangle end: datetime.datetime, # End datetime
) )
``` ```
...@@ -175,7 +190,7 @@ dates = date_range( ...@@ -175,7 +190,7 @@ dates = date_range(
N_samples = 1000 N_samples = 1000
# Construct Tree # Construct Tree
boundary = SpaceTimeRectangle(0, 0, datetime(2009, 1, 15, 12), 360, 180, timedelta(days=31)) # Full domain boundary = SpaceTimeRectangle(-180, 180, -90, 90, datetime(2009, 1, 1, 0), datetime(2009, 1, 2, 23)) # Full domain
ot = OctTree(boundary) ot = OctTree(boundary)
records: list[SpaceTimeRecord] = [ records: list[SpaceTimeRecord] = [
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment