Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes on generic_metric and mode_specific_metrics in relation to Mo… (
#91) * Changes on generic_metric and mode_specific_metrics in relation to Mode_confirm mapping with dynamic labels. * Address Review comments. * Update generate_plots.py & scaffolding.py * Fix merge conflict. * Fix scaffolding, updated mode_specific_metrics.ipynb. * Revert version changes to 3.7.12. * Update initialization of dynamic_labels from { } to json object referenced from example-study-label-options.json * Default initialize dynamic_labels to { }. * Add an environment variable in Docker Compose to pass dynamic config. * Chang in docker-compose for STUDY_CONFIG to dev-emulator-study. Reverted changes for DYNAMIC_CONFIG back to STUDY_CONFIG from generate_plots.py * Change back docker-compose.dev.yml: STUDY_CONFIG to stage-program. * Replace Mode_confirm with Replaced_mode for barplot_mode() in mode_specific_metrics.ipynb * 1. Remove extraneous whitespace from generate_plots.py. 2. Revert refactoring colour -> color in plots.py * Remove extraneous whitespace from line 96 in generate_plots.py * Introduce defaultdic for dic_translations with Other in analogy to dic_re in scaffolding.py. * Handle initialization of mode_count_interest. Introduce try-except block to handle raise RuntimeError error. * Move quality_text code into the if block in the above cell. * Update log messages for dynamic_labels_url and label_options unavailable cases. * Update scaffolding to introduce compute_CO2_impact_kg() computation when dynamic label is available. * 1. Change the plots.py X-axis to showcase CO2 Impact in kg. 2. In scaffolding.py update conversion from lb to kg for final return of CO2_Impact(kg). 3. Update energy_calculations to call new function compute_CO2_impact_kg when dynamic label is available for direct kgCO2 computation. * Move the compute_CO2_impact_kg() call to scaffolding, such that energy_impact is computed regardless. * Changes to understand difference between default mapping and dynamic label computation for CO2 Emissions. * Update scaffolding to create different dictionary mappings for MODE, REPLACED, and PURPOSE on the basis of the dynamic labels. * Update Trip_purpose to To Work instead of Work whenever dynamic label is available. * Update scaffolding.py CO2_footprint_lb() to utilize the distance while computing for different fuel types so that Mode_confirm_lb_CO2 and Replaced_mode_lb_CO2 is properly computed. The overall CO2_Impact(lb) computation remains the same. The representation in Energy Emission notebook is same. * Update changes for generic_timeseries. 1. Inside scaffolding.py introduce new func compute_CO2_footprint_kg() to compute Mode_confirm_kg_CO2 metric only. Update distance computation to be reflected for expanded_ct['Mode_confirm_kg_CO2']. Updated generic_timeseries to showcase metrics in kg and lb for all cases- default mapping and dynamic labels. Added dynamic_labels in call to add_energy_labels. * Create new metrics_study and metrics_program options html files without energy metrics options. * Update index.html to use different metrics_ options html when dynamic label is available. * Remove redundant check for dynamic_labels_urls. Update the message to show the STUDY_CONFIG associated with the success/failure message. * Remove print statements used to evaluate the difference in energy calculations while using dynamic labels and default mapping (from auxillary_files/energy_intensity). * Update the mode mapping in accordance to MODE for Daily Mode Share in generic_timeseries.ipynb. * Refactor the code to load the config and corresponding metrics.html page., * Reinstate the comment for energy_calculations.ipynb. Removed extranneous space for generic_timeseries.ipynb. Removed extranneous space for scaffolding.py. Reverted the bumped round off value to 3. This had been bumped up to 5, to make a better comparative study between the CO2 emission computation from energy_intensity.csv and label_options. Since, the comparative changes have been reverted. This has been reverted to pre-existing round-off of 3 places. * Update data.label_options to dynamic_labels to make it coherent across different notebook and generate_plots.py. * Created a new function inside scaffolding.py, mapping_labels(dynamic_labels, label_type). This replaces the same/similar logic written across different notebooks. Notably called from generic_metrics notebook - load_viz_notebook_data(), and other calls from generic_timeseries. Updated generic_timeseries.ipynb to call the scaffolding.mapping_labels(dynamic_labels, label_type) to remove redundancy of same code. * Moving the mapping_labels() call inside the conditional check for each label_type. This way, we would not be looking for REPLACED_MODE for study in label_options. * Update the purpose mapping for Work to select from scaffolding.mapping_labels() instead of hardcoding it with translation from work to To Work. * Update the Timeseries of emissions per miles TO Timeseries of emissions per kilometer. We are computing in kg and kilometer for generic_timeseries and energy_calculations. * Update plots.py CO2_impact to take x and y Labels from the notebook. Update energy_calculations notebook to display Imperic way for non dynamic config, and Metric way for dynamic config. Update scaffolding to compute the CO2 emissions as lbs/mile and kg/km. Both computatoin of default mapping and dynamic config mapping will have lbs/mile and kg/km CO2 emissions. * Update generic_timeseries to show the CO2 emissions in Imperial system for default mapping, and in Metric system for dynamic config. * Added print statements to understand the difference in CO2 emissions for default mapping and one with dynamic config. * Renamed 1. compute_CO2_impact_kg to compute_CO2_impact_dynamic 2. compute_CO2_footprint_kg to compute_footprint_dynamic 3. compute_CO2_impact_lb to compute_CO2_impact_default 4. compute_CO2_footprint_lb to compute_CO2_footprint_default. * Removed the unnecessary file unde frontend/Dockerfile.dev. * Showing Timeseries of emissions per mile for default mapping. * Remove extranneous whitespaces from energy_calculations and generic_timeseries notebook. * Remove whitespace from generic_timeseries.ipynb * Fixing the scaffolding calculation for computation of conversion to kg_CO2 from lb_CO2 and vice-versa in both dynamic config and default mapping case. * Add new function in scaffolding.py to print the computation of CO2 emissions. This will be called from energy_calculations notebook. * Added is_debug_mode flag, which by default is set to False. When it is set to True, then the print statements associated with the CO2 emissions computation will be called from scaffolding.py print_CO2_emission_calculations(). Removed the duplicate code about print statements, and moved into scaffolding.py. * Removed energy_impact computation for Dynamic config case. * Update distace_miles column in the selected_columns in scaffolding.py for print_CO2_emission_calculations() function. * Setting the default is_debug_mode flag to False. This will disable call to print the CO2 emission calculation. * Removed redundant if/else case for different label_type inside mapping_labels() function. Refactored compute_CO2_impact_dynamic() and compute_CO2_footprint_dynamic() to compute the CO2 emission in compute_CO2_footprint_dynamic() function and differentiate between Mode_confirm and Replaced_mode CO2 emission in compute_CO2_impact_dynamic(). * Energy_calculations.ipynb added justification for computation of total_lb_CO2 emission in Dynamic Label case, and total_kg_CO2_emission in default config case. * Refactor both energy_calculations and generic_timeseries notebook to avoid code duplication for dynamic labels and default mapping cases. * Stored the returned expanded_ct from compute_CO2_footprint_dynamic(). * Fixed try-catch block to handle case where emissions is not defined. Re-added the removed comments. * Fixed issue with default mapping - calling the right function. Updated prefix to the new functions to reflect its functionality. * Remove conversion_kilometer_to_mile and vice versa in scaffolding.py CO2_footprint_default() and compute_CO2_footprint_dynamic(). * Removed f{'distance_unit'} with distance_unit for compute_daily_metrics() in generic_timeseries notebook. * Update sense keyword in the phrase for dropdown menu for Trip miles by mode (sensed). * Updated the comment to explain this is specically used to test with example-program-label-options for print_CO2_emission_calculations().
- Loading branch information