Updating the d00_pickle_prep.py script - #3
Open
prateek-joshi-31 wants to merge 1 commit into
Open
Conversation
…iable is not hard-coded but rather dynamically set based on the scenario
There was a problem hiding this comment.
Pull request overview
This PR updates the Augur pickle-prep script to remove the hard-coded weather_year and instead infer it dynamically from the scenario/case name, enabling parallel runs across different weather years.
Changes:
- Derives
weather_yearby parsing a 4-digit suffix from the scenario string and validates it is within 2014–2024. - Switches RECF input loading to use
India_8760_recf_{weather_year}.pklrather than a single fixed file. - Adds an existence check with a clearer error if the weather-year-specific RECF pickle is missing.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+38
to
55
| # -------- Determine the weather_year from the scenario name -------- | ||
| # Every scenario name ends with its 4-digit weather year (e.g. BaseCase2015), | ||
| # matching the 'WeatherYear' switch in cases.csv. This allows multiple | ||
| # weather-year scenarios to run in parallel without a hard-coded year. | ||
| weather_year_match = re.search(r'(\d{4})$', scenario) | ||
| if weather_year_match is None: | ||
| raise ValueError( | ||
| "Could not determine the weather year from scenario '{}'. " | ||
| "Scenario names must end with a 4-digit weather year " | ||
| "(e.g. 'BaseCase2015').".format(scenario)) | ||
| weather_year = int(weather_year_match.group(1)) | ||
| if not 2014 <= weather_year <= 2024: | ||
| raise ValueError( | ||
| "Weather year {} parsed from scenario '{}' is outside the " | ||
| "supported range (2014 - 2024).".format(weather_year, scenario)) | ||
|
|
||
| # -------- Define the file paths -------- | ||
| user, runname = scenario.split('_')[0], scenario.split('_')[0] + '_' + scenario.split('_')[1] |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A slight change to the d00_pickle_prep.py script was made. Previously, the variable "weather_year" was hard-coded in the script. This feature did not allow for parallel model runs using different values for "weather_year". Now, the script dynamically sets the "weather_year" variable based on the particular scenario name and details, allowing for parallel model runs using different values for "weather_year".
Technical Details
Implementation notes
Additional changes (if any)
Switches added/removed/changed (if any)
Issues resolved (if any)
Known incompatibilities (if any)
Relevant sources or documentation (if any)
Is the model cleaner/better/faster/smaller than before? If so, how?
Validation / Comparison Report
Link to report and/or example plots
(if pertinent) How big is the default run folder before and after the change?
(if pertinent) What is the run time for a basic run (5 years) on the same machine before and after the change?
Review
Was anything relevant to the ReEDS-to-PCM conversion changed?
No.