Skip to content

Commit

Permalink
Critical Hours (#3849)
Browse files Browse the repository at this point in the history
Co-authored-by: Conor Brady <[email protected]>
- Critical hours are calculated for each station within a fire zone unit. A representative start and end time is then selected for the fire zone unit.
- Critical hours are saved in a new critical_hours table.
- This is a temporary implementation that will be replaced once we are able to perform critical hours calculations spatially. As this is temporary there are no tests.
- A lot of functionality is borrowed/copied from FireBat.
  • Loading branch information
dgboss authored Sep 5, 2024
1 parent 30f0c07 commit 3d1486a
Show file tree
Hide file tree
Showing 14 changed files with 1,270 additions and 10 deletions.
9 changes: 8 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,19 @@
"console": "integratedTerminal",
},
{
"name": "app.jobs.rdps_sfms ",
"name": "app.jobs.rdps_sfms",
"type": "python",
"request": "launch",
"module": "app.jobs.rdps_sfms",
"console": "integratedTerminal"
},
{
"name": "local critical hours",
"type": "python",
"request": "launch",
"module": "app.auto_spatial_advisory.critical_hours",
"console": "integratedTerminal"
},
{
"name": "Chrome",
"type": "pwa-chrome",
Expand Down
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"excinfo",
"fastapi",
"FBAN",
"ffmc",
"fireweather",
"firezone",
"GDPS",
Expand Down Expand Up @@ -110,6 +111,7 @@
"reproject",
"rocketchat",
"rollup",
"rtol",
"sessionmaker",
"sfms",
"sqlalchemy",
Expand Down
56 changes: 56 additions & 0 deletions api/alembic/versions/c9e46d098c73_critical_hours.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""Critical hours
Revision ID: c9e46d098c73
Revises: 6910d017b626
Create Date: 2024-08-12 16:24:00.489375
"""

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "c9e46d098c73"
down_revision = "6910d017b626"
branch_labels = None
depends_on = None


def upgrade():
op.create_table(
"critical_hours",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("advisory_shape_id", sa.Integer(), nullable=False),
sa.Column("threshold", sa.Enum("advisory", "warning", name="hficlassificationthresholdenum"), nullable=False),
sa.Column("run_parameters", sa.Integer(), nullable=False),
sa.Column("fuel_type", sa.Integer(), nullable=False),
sa.Column("start_hour", sa.Integer(), nullable=False),
sa.Column("end_hour", sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(
["advisory_shape_id"],
["advisory_shapes.id"],
),
sa.ForeignKeyConstraint(
["fuel_type"],
["sfms_fuel_types.id"],
),
sa.ForeignKeyConstraint(
["run_parameters"],
["run_parameters.id"],
),
sa.PrimaryKeyConstraint("id"),
comment="Critical hours by firezone unit, fuel type and sfms run parameters.",
)
op.create_index(op.f("ix_critical_hours_advisory_shape_id"), "critical_hours", ["advisory_shape_id"], unique=False)
op.create_index(op.f("ix_critical_hours_fuel_type"), "critical_hours", ["fuel_type"], unique=False)
op.create_index(op.f("ix_critical_hours_id"), "critical_hours", ["id"], unique=False)
op.create_index(op.f("ix_critical_hours_run_parameters"), "critical_hours", ["run_parameters"], unique=False)


def downgrade():
op.drop_index(op.f("ix_critical_hours_run_parameters"), table_name="critical_hours")
op.drop_index(op.f("ix_critical_hours_id"), table_name="critical_hours")
op.drop_index(op.f("ix_critical_hours_fuel_type"), table_name="critical_hours")
op.drop_index(op.f("ix_critical_hours_advisory_shape_id"), table_name="critical_hours")
op.drop_table("critical_hours")
Loading

0 comments on commit 3d1486a

Please sign in to comment.