-
Notifications
You must be signed in to change notification settings - Fork 6
Refactor Database Model to support timerange and potentially geospatial queries #14
Copy link
Copy link
Open
Labels
Description
Refactor Model Definition for Spray indicator and UAV.
This will also support the current api calls for forecast5, current weather and THI
Models
CurrentWeather Model
class CurrentWeather(Document):
id: UUID
location: dict # GeoJSON Point for location
timestamp: datetime # Timestamp of the weather data
temperature: float # Temperature in Celsius
humidity: float # Relative humidity in percentage
thi: Optional[float] # Temperature Humidity Index
wet_bulb_temp: Optional[float] # Wet bulb temperature
class Settings:
name = "current_weather"
indexes = [
[("location", "2dsphere")], # Geospatial index for location
]Forecast5 Model
class Forecast5(Document):
id: UUID
location: dict # GeoJSON Point for location
location_id: str # Unique location identifier
timestamp: datetime # Timestamp for the forecast data
temperature: float # Temperature in Celsius
humidity: float # Relative humidity in percentage
wet_bulb_temp: Optional[float] # Wet bulb temperature
class Settings:
name = "forecast5"
indexes = [
[("location", "2dsphere")], # Geospatial index for location
[("location_id", 1), ("timestamp", 1)], # Compound index for time range queries
]SprayLabels Model
class SprayLabels(Document):
id: UUID
foreacast_id: uuid
location: dict # GeoJSON Point for location
location_id: str # Unique location identifier
label: str # Spray suitability label: optimal/marginal/unsuitable
timestamp: datetime # Timestamp for label assignment
class Settings:
name = "spray_labels"
indexes = [
[("location", "2dsphere")], # Geospatial index for location
[("location_id", 1), ("timestamp", 1)], # Compound index for time range queries
]Queries supported.
Weather
- Find weather data for specific location or within a 10 km radius of a location.
- Retrieve all current weather data for a specific location.
Forecast data
- Retrieve forecast for next 5 days for a location, or within 10km radius.
- Retrieve forecast data for location, for a specific (future) time range
- Find weather (forecast) conditions (e.g., temperature, humidity) for a specific location at a particular timestamp.
- Search for weather (forecast) data that meets certain conditions, like "temperature greater than 20°C".
(- Get historical weather forecasts for a location within a given time range.)
THI
- Calculate current THI for a specific location.
Spray data
- Get spray labels for a specific location (location_id) between specific dates.
- Retrieve all spray suitability labels for a location during the past three months.
At that time do not define an TTL and save all documents
Reactions are currently unavailable