-
Notifications
You must be signed in to change notification settings - Fork 9
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
Rhorsey/sampling v2 plotting patch #217
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6f68102
Updating plotting scripts to sampling V2. AMI todo and EIA needs a qu…
rHorsey 79d6ec1
Adding license to apportionment.
rHorsey d35ae57
Updating downloading of comstock data from s3.
rHorsey f7faead
Addressing Chriss comments - many thanks!
rHorsey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,63 +1,73 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
import logging | ||
|
||
import comstockpostproc as cspp | ||
|
||
|
||
logging.basicConfig(level='INFO') # Use DEBUG, INFO, or WARNING | ||
logger = logging.getLogger(__name__) | ||
|
||
def main(): | ||
# ComStock run | ||
comstock = cspp.ComStock( | ||
s3_base_dir='eulp/euss_com', # If run not on S3, download results_up**.parquet manually | ||
comstock_run_name='hprtu_stdperf_fan_test_10k', # Name of the run on S3 | ||
comstock_run_version='hprtu_stdperf_fan_test_10k', # Use whatever you want to see in plot and folder names | ||
comstock_year=2018, # Typically don't change this | ||
athena_table_name=None, # Typically don't change this | ||
truth_data_version='v01', # Typically don't change this | ||
buildstock_csv_name='buildstock.csv', # Download buildstock.csv manually | ||
acceptable_failure_percentage=0.025, # Can increase this when testing and high failure are OK | ||
drop_failed_runs=True, # False if you want to evaluate which runs failed in raw output data | ||
color_hex='#0072B2', # Color used to represent this run in plots | ||
skip_missing_columns=True, # False if you want to ensure you have all data specified for export | ||
reload_from_csv=False, # True if CSV already made and want faster reload times | ||
include_upgrades=True, # False if not looking at upgrades | ||
upgrade_ids_to_skip=[], # Use [1, 3] etc. to exclude certain upgrades | ||
make_timeseries_plots=True, | ||
states={ | ||
#'MN': 'Minnesota', # specify state to use for timeseries plots in dictionary format. State ID must correspond correctly. | ||
'MA':'Massachusetts', | ||
'OR': 'Oregon', | ||
'LA': 'Louisiana', | ||
#'AZ': 'Arizona', | ||
#'TN': 'Tennessee' | ||
}, | ||
upgrade_ids_for_comparison={} # Use {'<Name you want for comparison run folder>':[0,1,2]}; add as many upgrade IDs as needed, but plots look strange over 5 | ||
) | ||
|
||
# CBECS | ||
cbecs = cspp.CBECS( | ||
cbecs_year=2018, # 2012 and 2018 currently available | ||
truth_data_version='v01', # Typically don't change this | ||
color_hex='#009E73', # Color used to represent CBECS in plots | ||
reload_from_csv=False # True if CSV already made and want faster reload times | ||
) | ||
|
||
# Scale ComStock run to CBECS 2018 AND remove non-ComStock buildings from CBECS | ||
# This is how weights in the models are set to represent national energy consumption | ||
comstock.add_national_scaling_weights(cbecs, remove_non_comstock_bldg_types_from_cbecs=True) | ||
|
||
# Export CBECS and ComStock data to wide and long formats for Tableau and to skip processing later | ||
cbecs.export_to_csv_wide() # May comment this out after run once | ||
comstock.export_to_csv_wide() # May comment this out after run once | ||
# comstock.export_to_csv_long() # Long format useful for stacking end uses and fuels | ||
|
||
# Create measure run comparisons; only use if run has measures | ||
comparison = cspp.ComStockMeasureComparison(comstock, states=comstock.states, make_comparison_plots = comstock.make_comparison_plots, make_timeseries_plots = comstock.make_timeseries_plots) | ||
|
||
# Code to execute the script | ||
if __name__=="__main__": | ||
main() | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
import logging | ||
|
||
import comstockpostproc as cspp | ||
|
||
|
||
logging.basicConfig(level='INFO') # Use DEBUG, INFO, or WARNING | ||
logger = logging.getLogger(__name__) | ||
|
||
def main(): | ||
# ComStock run | ||
comstock = cspp.ComStock( | ||
s3_base_dir='eulp/euss_com', # If run not on S3, download results_up**.parquet manually | ||
comstock_run_name='sampling_lighting_11079_1', # Name of the run on S3 | ||
comstock_run_version='sampling_lighting_11079_1', # Use whatever you want to see in plot and folder names | ||
comstock_year=2018, # Typically don't change this | ||
athena_table_name=None, # Typically don't change this | ||
truth_data_version='v01', # Typically don't change this | ||
buildstock_csv_name='buildstock.csv', # Download buildstock.csv manually | ||
acceptable_failure_percentage=0.25, # Can increase this when testing and high failure are OK | ||
drop_failed_runs=True, # False if you want to evaluate which runs failed in raw output data | ||
color_hex='#0072B2', # Color used to represent this run in plots | ||
skip_missing_columns=True, # False if you want to ensure you have all data specified for export | ||
reload_from_csv=False, # True if CSV already made and want faster reload times | ||
include_upgrades=True, # False if not looking at upgrades | ||
upgrade_ids_to_skip=[], # Use [1, 3] etc. to exclude certain upgrades | ||
make_timeseries_plots=False, | ||
states={ | ||
#'MN': 'Minnesota', # specify state to use for timeseries plots in dictionary format. State ID must correspond correctly. | ||
'MA':'Massachusetts', | ||
#'OR': 'Oregon', | ||
#'LA': 'Louisiana', | ||
#'AZ': 'Arizona', | ||
#'TN': 'Tennessee' | ||
}, | ||
upgrade_ids_for_comparison={} # Use {'<Name you want for comparison run folder>':[0,1,2]}; add as many upgrade IDs as needed, but plots look strange over 5 | ||
) | ||
|
||
# Stock Estimation for Apportionment: | ||
stock_estimate = cspp.Apportion( | ||
stock_estimation_version='2024R2', # Only updated when a new stock estimate is published | ||
truth_data_version='v01' # Typically don't change this | ||
) | ||
|
||
# CBECS | ||
cbecs = cspp.CBECS( | ||
cbecs_year=2018, # 2012 and 2018 currently available | ||
truth_data_version='v01', # Typically don't change this | ||
color_hex='#009E73', # Color used to represent CBECS in plots | ||
reload_from_csv=False # True if CSV already made and want faster reload times | ||
) | ||
|
||
# Scale ComStock runs to the 'truth data' from StockE V3 estimates using bucket-based apportionment | ||
comstock.add_weights_aportioned_by_stock_estimate(apportionment=stock_estimate) | ||
# Scale ComStock run to CBECS 2018 AND remove non-ComStock buildings from CBECS | ||
comstock.add_national_scaling_weights(cbecs, remove_non_comstock_bldg_types_from_cbecs=True) | ||
|
||
# Export CBECS and ComStock data to wide and long formats for Tableau and to skip processing later | ||
# cbecs.export_to_csv_wide() # May comment this out after run once | ||
# comstock.create_national_aggregation() | ||
# comstock.create_geospatially_resolved_aggregations(comstock.STATE_ID, pretty_geo_col_name='state_id') | ||
# comstock.create_geospatially_resolved_aggregations(comstock.COUNTY_ID, pretty_geo_col_name='county_id') | ||
# TODO Long is def not working as expected anymore... | ||
# comstock.export_to_csv_long() # Long format useful for stacking end uses and fuels | ||
|
||
# Create measure run comparisons; only use if run has measures | ||
comparison = cspp.ComStockMeasureComparison(comstock, states=comstock.states, make_comparison_plots = comstock.make_comparison_plots, make_timeseries_plots = comstock.make_timeseries_plots) | ||
|
||
# Code to execute the script | ||
if __name__=="__main__": | ||
main() |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is ComStock wide export?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the create_national_aggregations method now - same code under the hood but redone to get correctly weighted national level results!