-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
466 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,3 +130,4 @@ climate_health/web_interface/yarn-error.log* | |
|
||
climate_health/web_interface/node_modules/ | ||
|
||
/scripts/runs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import ee | ||
import xarray | ||
from matplotlib import pyplot as plt | ||
from matplotlib.colors import Normalize | ||
|
||
from ..google_earth_engine.gee_raw import load_credentials | ||
import geopandas as gpd | ||
|
||
# Load the GeoJSON file using GeoPandas | ||
def get_gridded_data(polygons_filename): | ||
gdf = gpd.read_file(polygons_filename) | ||
# Get the bounding box of all polygons in the GeoJSON | ||
lon1, lat1, lon2, lat2 = gdf.total_bounds | ||
print(lon1, lat1, lon2, lat2) | ||
credentials = load_credentials() | ||
ee.Initialize(ee.ServiceAccountCredentials(credentials.account, key_data=credentials.private_key)) | ||
collection = ee.ImageCollection('ECMWF/ERA5_LAND/DAILY_AGGR').filterDate('2024-08-01', '2024-8-03').select('temperature_2m') | ||
# lon1 = 28.8 | ||
# lon2 = 30.9 | ||
# lat1 = -2.9 | ||
# lat2 = -1.0 | ||
country_bounds = ee.Geometry.Rectangle(*gdf.total_bounds)#lon1, lat1, lon2, lat2) | ||
projection = collection.first().select(0).projection() # EPSG:4326 | ||
dataset = xarray.open_dataset( | ||
collection, | ||
engine='ee', | ||
projection=projection, | ||
geometry=country_bounds | ||
) | ||
ds = dataset | ||
first_image = dataset.isel(time=0) | ||
temp_d = first_image['temperature_2m'] | ||
temp_d.plot() | ||
temp = temp_d.values | ||
#plt.imshow(temp, extent=[ds.lon.min(), ds.lon.max(), ds.lat.min(), ds.lat.max()], origin='lower', cmap='viridis', | ||
# norm=Normalize()) | ||
#plt.imshow(temp, cmap='viridis') | ||
gdf.boundary.plot(ax=plt.gca(), edgecolor='red', linewidth=1) | ||
plt.show() | ||
return temp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import warnings | ||
import dataclasses | ||
from pathlib import Path | ||
from typing import Iterable, TypeVar | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from typing import List | ||
|
||
from pydantic import BaseModel | ||
|
||
|
||
class PredictionBase(BaseModel): | ||
orgUnit: str | ||
dataElement: str | ||
period: str | ||
|
||
|
||
class PredictionResponse(PredictionBase): | ||
value: float | ||
|
||
|
||
class PredictionSamplResponse(PredictionBase): | ||
values: list[float] | ||
|
||
|
||
class FullPredictionResponse(BaseModel): | ||
diseaseId: str | ||
dataValues: List[PredictionResponse] | ||
|
||
|
||
class FullPredictionSampleResponse(BaseModel): | ||
diseaseId: str | ||
dataValues: List[PredictionSamplResponse] |
Oops, something went wrong.