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

Added script to generate and run multiple forecasts #82

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

liamjdavis
Copy link

@liamjdavis liamjdavis commented Mar 12, 2024

Pull Request

Description

  • wrote script scripts/generate_multiple_forecasts.py that generates multiple forecasts given several pv ids
  • saves forecasts to a new csv for each site

Fixes #77

How Has This Been Tested?

The script's testing script is tests/test_generate_multiple_forecasts.py, which runs the program with dummy sites.

Example CSV created while testing

  • Yes

If your changes affect data processing, have you plotted any changes? i.e. have you done a quick sanity check?

  • Yes

Checklist:

  • My code follows OCF's coding style guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked my code and corrected any misspellings

Copy link

codecov bot commented Mar 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.94%. Comparing base (05e6f20) to head (5baf435).
Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #82      +/-   ##
==========================================
+ Coverage   79.82%   79.94%   +0.11%     
==========================================
  Files          12       12              
  Lines         352      354       +2     
==========================================
+ Hits          281      283       +2     
  Misses         71       71              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

forecasts.csv Outdated
@@ -0,0 +1,193 @@
power_wh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be best not upload the output from the forecasts. Also their appears to be only the "power_wh" column?

"latitude",
"longitude",
"capacity_kwp",
"date",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure that the init_time is saved i.e: the time at which the forecast was made. And also the time in which the forecast represents


def test_generate_forecasts():
# Generate 100 random PV IDs between 1 and 50000
pv_ids = [random.randint(1, 50000) for _ in range(100)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are you passing in the metadata such as latitude, longitude to be used in the function? I would create 2/3 dummy sites to use instead.

), "forecast.csv doesn't exist"

# Load the output file
df = pd.read_csv("quartz_solar_forecast/dataset/forecasts.csv")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some screen shots to the PR of this test passing? The current forecasts.csv doesn't exist in this location.

@liamjdavis
Copy link
Author

I revised the scripts. Now, a new csv is generated for each individual forecast, screenshot in the PR. Let me know if this is what you wanted.

@zakwatts
Copy link
Contributor

zakwatts commented Mar 22, 2024

Hi @liamjdavis, I tested out the script and have attached images of the results. It looks like you are saving multiple copies of the same thing. A couple of changes to avoid this!
Screenshot 2024-03-22 at 10 56 14
Screenshot 2024-03-22 at 10 56 25

@zakwatts
Copy link
Contributor

Notice, the pv_id in all of the saved csvs is the same.

Copy link
Contributor

@zakwatts zakwatts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of changes then it should be good to go! Thanks for you hard work on this!



# write to a new csv
csv_df.to_csv(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe take this csv saving outside of the for loop as its saving multiple copies of the same thing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and call it something like, "forecast_multiple_sites_{INSERT FORECAST CREATION TIME}.csv

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please include the forecast creation time in the csv name

@liamjdavis
Copy link
Author

Fixed! Screenshots below.
Screenshot 2024-03-23 095712
Screenshot 2024-03-23 095719
Screenshot 2024-03-23 095726

Copy link
Contributor

@zakwatts zakwatts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of changes. Some updates should be made to the documentation. When I pulled the code and ran it locally, it could not find the dataset folder when following the instructions in the readme


3. Run
```bash
python generate_multiple_forecasts.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This currently wont run, it needs to be python scripts/generate_multiple_forecasts.py otherwise it can't find the dataset folder its trying to save the csvs into.



# write to a new csv
csv_df.to_csv(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please include the forecast creation time in the csv name

@zakwatts
Copy link
Contributor

Hi @liamjdavis, do you plan on making these changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pass a dictionary of sites to generate forecasts for and save together
2 participants