From 40d7809d5d5134f3dfd596bfa36baf47de1e938c Mon Sep 17 00:00:00 2001 From: EdFage <87755165+EdFage@users.noreply.github.com> Date: Thu, 7 Dec 2023 11:21:12 +0000 Subject: [PATCH 1/5] add tilt and orientation to PVSite --- quartz_solar_forecast/pydantic_models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/quartz_solar_forecast/pydantic_models.py b/quartz_solar_forecast/pydantic_models.py index 83e5d76a..757afdda 100644 --- a/quartz_solar_forecast/pydantic_models.py +++ b/quartz_solar_forecast/pydantic_models.py @@ -6,3 +6,7 @@ class PVSite(BaseModel): latitude: float = Field(..., description="the latitude of the site", ge=-90, le=90) longitude: float = Field(..., description="the longitude of the site", ge=-180, le=180) capacity_kwp: float = Field(..., description="the capacity [kwp] of the site", ge=0) + tilt: float = Field(..., description="the tilt of the site [degrees], the panels' angle relative to horizontal ground", ge=0, le=90) + orientation: float = Field(..., description="the orientation of the site [degrees], the angle between north and the direction the panels face, measured on the horizontal plane." + , ge=0, le=360) + From f1079af827a0423bdb5021aa1d3e61e502f6fcc2 Mon Sep 17 00:00:00 2001 From: EdFage <87755165+EdFage@users.noreply.github.com> Date: Thu, 7 Dec 2023 11:24:49 +0000 Subject: [PATCH 2/5] have make_pv_data() use orientation and tilt from PVSite --- quartz_solar_forecast/data.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/quartz_solar_forecast/data.py b/quartz_solar_forecast/data.py index 86919b64..4a368a3c 100644 --- a/quartz_solar_forecast/data.py +++ b/quartz_solar_forecast/data.py @@ -125,7 +125,6 @@ def make_pv_data(site: PVSite, ts) -> xr.Dataset: timestamp = [ts] pv_id = [1] - # would be nice to not use ss_id, should be pv_id da = xr.DataArray( data=generation_wh, dims=["pv_id", "timestamp"], @@ -135,8 +134,8 @@ def make_pv_data(site: PVSite, ts) -> xr.Dataset: timestamp=timestamp, pv_id=pv_id, kwp=(["pv_id"], [site.capacity_kwp]), - tilt=(["pv_id"], [0]), - orientation=(["pv_id"], [0]), + tilt=(["pv_id"], [site.tilt]), + orientation=(["pv_id"], [site.orientation]), ), ) da = da.to_dataset(name="generation_wh") From 6242caf51c195164a5134aa74a1db279f61000a3 Mon Sep 17 00:00:00 2001 From: EdFage <87755165+EdFage@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:23:52 +0000 Subject: [PATCH 3/5] Add default value --- quartz_solar_forecast/pydantic_models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quartz_solar_forecast/pydantic_models.py b/quartz_solar_forecast/pydantic_models.py index 757afdda..919f90eb 100644 --- a/quartz_solar_forecast/pydantic_models.py +++ b/quartz_solar_forecast/pydantic_models.py @@ -6,7 +6,7 @@ class PVSite(BaseModel): latitude: float = Field(..., description="the latitude of the site", ge=-90, le=90) longitude: float = Field(..., description="the longitude of the site", ge=-180, le=180) capacity_kwp: float = Field(..., description="the capacity [kwp] of the site", ge=0) - tilt: float = Field(..., description="the tilt of the site [degrees], the panels' angle relative to horizontal ground", ge=0, le=90) - orientation: float = Field(..., description="the orientation of the site [degrees], the angle between north and the direction the panels face, measured on the horizontal plane." + tilt: float = Field(default=35, description="the tilt of the site [degrees], the panels' angle relative to horizontal ground", ge=0, le=90) + orientation: float = Field(default=180, description="the orientation of the site [degrees], the angle between north and the direction the panels face, measured on the horizontal plane." , ge=0, le=360) From e89d2b92ce459e7c1f8fa1e115809d4f5473475d Mon Sep 17 00:00:00 2001 From: EdFage <87755165+EdFage@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:24:05 +0000 Subject: [PATCH 4/5] Fix typo --- examples/example.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/example.py b/examples/example.py index ab0687cf..9a2a23ff 100644 --- a/examples/example.py +++ b/examples/example.py @@ -8,10 +8,10 @@ def main(): site = PVSite(latitude=51.75, longitude=-1.25, capacity_kwp=1.25) # run model - predications_df = run_forecast(site=site, ts='2023-10-30') + predictions_df = run_forecast(site=site, ts='2023-10-30') - print(predications_df) - print(f"Max: {predications_df['power_wh'].max()}") + print(predictions_df) + print(f"Max: {predictions_df['power_wh'].max()}") if __name__ == "__main__": From e10643b1098437cf50fdb2a2144cf473d258ffc4 Mon Sep 17 00:00:00 2001 From: EdFage <87755165+EdFage@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:27:28 +0000 Subject: [PATCH 5/5] format with black --- examples/example.py | 2 +- quartz_solar_forecast/pydantic_models.py | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/examples/example.py b/examples/example.py index 9a2a23ff..d52fe0fb 100644 --- a/examples/example.py +++ b/examples/example.py @@ -8,7 +8,7 @@ def main(): site = PVSite(latitude=51.75, longitude=-1.25, capacity_kwp=1.25) # run model - predictions_df = run_forecast(site=site, ts='2023-10-30') + predictions_df = run_forecast(site=site, ts="2023-10-30") print(predictions_df) print(f"Max: {predictions_df['power_wh'].max()}") diff --git a/quartz_solar_forecast/pydantic_models.py b/quartz_solar_forecast/pydantic_models.py index 919f90eb..4e626bfb 100644 --- a/quartz_solar_forecast/pydantic_models.py +++ b/quartz_solar_forecast/pydantic_models.py @@ -2,11 +2,18 @@ class PVSite(BaseModel): - latitude: float = Field(..., description="the latitude of the site", ge=-90, le=90) longitude: float = Field(..., description="the longitude of the site", ge=-180, le=180) capacity_kwp: float = Field(..., description="the capacity [kwp] of the site", ge=0) - tilt: float = Field(default=35, description="the tilt of the site [degrees], the panels' angle relative to horizontal ground", ge=0, le=90) - orientation: float = Field(default=180, description="the orientation of the site [degrees], the angle between north and the direction the panels face, measured on the horizontal plane." - , ge=0, le=360) - + tilt: float = Field( + default=35, + description="the tilt of the site [degrees], the panels' angle relative to horizontal ground", + ge=0, + le=90, + ) + orientation: float = Field( + default=180, + description="the orientation of the site [degrees], the angle between north and the direction the panels face, measured on the horizontal plane.", + ge=0, + le=360, + )