Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delta - pull data for an interesting month with high solar production #297

Open
rachel-labri-tipton opened this issue Nov 10, 2022 · 3 comments

Comments

@rachel-labri-tipton
Copy link
Contributor

rachel-labri-tipton commented Nov 10, 2022

Detailed Description

For the delta view prototype, it would be good to run the delta view on data with lots of sunshine (ie. July in the UK).

@peterdudfield
Copy link
Contributor

Would you prefer raw SQL commands, or python code to do the data fetching?
Perhaps the python way would be better to learn, it looked something like

# import packages
from nowcasting_datamodel.connection import DatabaseConnection
from nowcasting_datamodel.read.read_gsp import get_gsp_yield
from datetime import datetime

# make connection
url='need-to-set)
connection = DatabaseConnection(url=db_url, echo=True)

with connection.get_session() as session:
    # read database
    gsp_yields = get_gsp_yield(session=session, 
                                                    gsp_ids=[0,1,2,3]
                                                    start_datetime_utc=datetime(2022,7,1)
                                                    gsp_ids=datetime(2022,7,2))



# change to json and save

  • i haven't tested this., but this gives you an idea

@rachel-labri-tipton
Copy link
Contributor Author

personally, I'd prefer working with python to do the fetching. but let's see what @braddf feels like.

@peterdudfield
Copy link
Contributor

prep for meeting

# import packages
from nowcasting_datamodel.connection import DatabaseConnection
from nowcasting_datamodel.read.read_gsp import get_gsp_yield
from nowcasting_datamodel.read.read import get_latest_forecast_for_gsps
from nowcasting_datamodel.models.gsp import GSPYield
from nowcasting_datamodel.models.forecast import Forecast
from datetime import datetime

# make connection
url = "need-to-set"
connection = DatabaseConnection(url=url, echo=True)


# get gsp yields
with connection.get_session() as session:
    # read database
    gsp_yields = get_gsp_yield(
        session=session,
        gsp_ids=range(0, 1),  # could be 0 to 318
        start_datetime_utc=datetime(2022, 7, 1),
        end_datetime_utc=datetime(2022, 7, 2),
    )

    # list of pydantic objects
    gsp_yields = [GSPYield.from_orm(gsp_yield) for gsp_yield in gsp_yields]


# get latest foreasts
with connection.get_session() as session:
    forecasts = get_latest_forecast_for_gsps(
        session=session,
        gsp_ids=range(0, 1),
        historic=True,
        start_target_time=datetime(2022, 7, 1),
        end_target_time=datetime(2022, 7, 2),
    )

    forecasts = [Forecast.from_orm_latest(forecast) for forecast in forecasts]


# plot
import plotly.graph_objects as go

x_pv_live = [gsp_yield.datetime_utc for gsp_yield in gsp_yields]
y_pv_live = [gsp_yield.solar_generation_kw / 1000 for gsp_yield in gsp_yields]

x_forecast = [forecast_value.target_time for forecast_value in forecasts[0].forecast_values]
y_forecast = [
    forecast_value.expected_power_generation_megawatts
    for forecast_value in forecasts[0].forecast_values
]

fig = go.Figure(
    data=[
        go.Scatter(x=x_pv_live, y=y_pv_live, name="pvlive"),
        go.Scatter(x=x_forecast, y=y_forecast, name="forecast"),
    ]
)
fig.show(renderer="browser")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: In Progress
Development

No branches or pull requests

2 participants