Skip to content

Conversation

@gellwood
Copy link
Collaborator

@gellwood gellwood commented Nov 26, 2025

Please check if the PR fulfills these requirements

  • CHANGELOG.md is updated
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Any new Django model inputs have also been added to job/test/posts/all_inputs_test.json

What kind of change does this PR introduce?

This pull request introduces a new, extensible system for configuring and generating custom timeseries tables for Excel export, along with utility helpers to safely extract and format timeseries data. It also adds a new API endpoint for retrieving these tables and updates the database schema to allow for larger monthly energy totals. The changes are grouped below by theme.

Custom Timeseries Table System:

  • Adds custom_timeseries_table_config.py, which defines a flexible configuration structure for timeseries Excel tables, including column definitions, formatting options, and example configurations for energy/demand, emissions, and load profiles. This enables easier customization and extension of exported timeseries data.
  • Adds custom_timeseries_table_helpers.py, providing utility functions (safe_get_list, safe_get_value, safe_get, generate_datetime_column, etc.) for robust extraction and formatting of nested timeseries data, including special handling for datetime columns and monthly peaks.

API and Routing:

  • Adds a new API endpoint /job/get_timeseries_table/ to urls.py to serve the generated timeseries tables.

Database and Validation:

  • Updates the monthly_totals_kwh field in the ElectricLoadInputs model to allow values up to 1,000,000,000 (1e9) kWh, both in the Django model and via a new migration, to support larger energy datasets. [1] [2]

Miscellaneous:

  • Adds a missing import for datetime in views.py to support new datetime handling in the timeseries helpers.builds off the get_timeseries_table and add functionality by making it more generalized using custom_timeseries_table_config to allow the user to specify which table they want to use.

What is the current behavior?

The user can specify the timeseries table endpoint and specify which timeseries configuration they want to be used. Each timeseries table configuration has its own formatting options so they can be easily changed.

Base columns set to TRUE don't change across scenarios (or run_uuids). Base columns set to FALSE change for each new rate scenario.

If the user inputs a year, that sets the first timestep in the table. If year is a leap year, the last day is removed.

What is the new behavior (if this is a feature change)?

N/A

Does this PR introduce a breaking change?

Hopefully, no changes will need to be made. This is a new endpoint and doesn't change the previous logic and code used to create other tables.

Other information:

Date Timestep column format has been set to be a date time in excel so that plotting is much simpler.

Introduces a new endpoint `/job/hourly_rate_table` that generates an Excel file with hourly rate data for one or more scenarios. Adds `hourly_rate_helpers.py` with utility functions for datetime generation and safe dictionary access, and implements the `hourly_rate_table` view to assemble and return the Excel file based on scenario data.
Enhanced the Excel export in hourly_rate_table by adding specific formats for datetime, integers, and energy rates. Rate headers now use the rate name from urdb_metadata for clarity. Data columns for load and peak load use integer formatting, and datetime strings are written as Excel datetimes for better compatibility.
Renamed hourly_rate_helpers.py to timeseries_table_helpers.py and updated all references accordingly. Added (but not currently used) custom_timeseries_table_config.py to define flexible timeseries table configurations. Refactored the hourly_rate_table view and URL to get_timeseries_table, enhanced Excel formatting with colored headers, and improved code organization for future extensibility.
…ures easily

Moved and expanded timeseries table configuration to support column formatting, worksheet naming, and Excel output customization. Renamed and enhanced helper functions for safer data extraction. Updated the view to dynamically use the new configuration structure, allowing selection of table layouts and improved formatting for Excel exports.
@gellwood gellwood requested a review from Bill-Becker November 26, 2025 20:16
Copy link
Collaborator

@Bill-Becker Bill-Becker left a comment

Choose a reason for hiding this comment

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

Looks good!

Bill-Becker and others added 3 commits December 1, 2025 16:45
Documented new /job/get_timeseries_table endpoint, custom_timeseries_energy_demand table option, and increased monthly_totals_kwh max value. Prepares changelog for v3.17.1 minor updates.
@gellwood gellwood merged commit 01c4083 into develop Dec 2, 2025
1 check passed
@gellwood gellwood deleted the get-timeseries-table-generalize branch December 2, 2025 16:28
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.

3 participants