Skip to content

Commit

Permalink
raise in case of bad cloud cover percentage
Browse files Browse the repository at this point in the history
  • Loading branch information
nonnontrivial committed Jun 15, 2024
1 parent 379a625 commit 2a0162f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 6 additions & 2 deletions api/api/prediction/meteo/open_meteo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ async def get_values_at_site(self) -> t.Tuple[int, float]:
return cloud_cover, elevation

def get_hourly_index_of_site_time(self) -> int:
"""pull out the relevant slice in the meteo data"""
"""pull out the relevant index in the meteo data"""
return get_astro_time_hour(self.site.utc_time)

def get_cloud_cover_as_oktas(self, cloud_cover_percentage: int):
"""convert percentage to integer oktas value (eights of sky covered)"""
"""convert cloud cover percentage to oktas (eights of sky covered)"""
import numpy as np
import math

if cloud_cover_percentage is None or math.isnan(cloud_cover_percentage):
raise ValueError("cloud cover percentage is not a number. is open meteo volume up to date?")

percentage_as_oktas = int(np.interp(cloud_cover_percentage, (0, 100), (0, MAX_OKTAS)))
return percentage_as_oktas
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ services:
depends_on:
- openmeteo

# sr:
# build: ./sr
# environment:
# OPEN_METEO_HOST: "openmeteo"
# restart: on-failure
# depends_on:
# - openmeteo


# pp:
# build: ./pp
# environment:
Expand Down

0 comments on commit 2a0162f

Please sign in to comment.