pyhazards.models package

Catalog Summary

This page links the public model catalog, the developer registry workflow, and the package submodules used to implement model builders.

For the curated browsing experience, use Models.

Wildfire

Implemented Models

ASUFM, DNN-LSTM-AutoEncoder, FireCastNet, ForeFire Adapter, Wildfire Forecasting, WildfireSpreadTS, WRF-SFIRE Adapter, CNN-ASPP.

Earthquake

Implemented Models

EQNet, EQTransformer, GPD, PhaseNet, WaveCastNet.

Flood

Implemented Models

EA-LSTM, FloodCast, Google Flood Forecasting, NeuralHydrology LSTM, UrbanFloodCast, HydroGraphNet.

Tropical Cyclone

Implemented Models

Hurricast, SAF-Net, TCIF-fusion, Tropical Cyclone MLP, TropiCycloneNet.

Experimental Adapters

FourCastNet TC Adapter, GraphCast TC Adapter, Pangu TC Adapter.

Developer Registry Workflow

Use this section when you need the package-level builder and registry interface rather than the public catalog presentation.

Build a Registered Model

from pyhazards.models import build_model

model = build_model(
    name="phasenet",
    task="regression",
    in_channels=3,
)

Register a Custom Model

import torch.nn as nn
from pyhazards.models import build_model, register_model

def my_custom_builder(task: str, in_dim: int, out_dim: int, **kwargs) -> nn.Module:
    hidden = kwargs.get("hidden_dim", 128)
    return nn.Sequential(
        nn.Linear(in_dim, hidden),
        nn.ReLU(),
        nn.Linear(hidden, out_dim),
    )

register_model("my_mlp", my_custom_builder, defaults={"hidden_dim": 128})
model = build_model(name="my_mlp", task="regression", in_dim=16, out_dim=1)

Notes

  • Builders receive task plus any kwargs you pass.

  • register_model stores optional defaults so configs can stay small.

  • Use Implementation Guide for the full contributor workflow.

Submodules

pyhazards.models.backbones module

class pyhazards.models.backbones.CNNPatchEncoder(in_channels=3, hidden_dim=64)[source]

Bases: Module

Lightweight CNN encoder for raster patches.

forward(x)[source]
class pyhazards.models.backbones.MLPBackbone(input_dim, hidden_dim=256, depth=2)[source]

Bases: Module

Simple MLP for tabular features.

forward(x)[source]
class pyhazards.models.backbones.TemporalEncoder(input_dim, hidden_dim=128, num_layers=1)[source]

Bases: Module

GRU-based encoder for time-series signals.

forward(x)[source]

pyhazards.models.heads module

class pyhazards.models.heads.ClassificationHead(in_dim, num_classes)[source]

Bases: Module

Simple classification head.

forward(x)[source]
class pyhazards.models.heads.RegressionHead(in_dim, out_dim=1)[source]

Bases: Module

Regression head for scalar or multi-target outputs.

forward(x)[source]
class pyhazards.models.heads.SegmentationHead(in_channels, num_classes)[source]

Bases: Module

Segmentation head for raster masks.

forward(x)[source]

pyhazards.models.builder module

pyhazards.models.builder.build_model(name, task, **kwargs)[source]

Build a model by name and task. This delegates to registry metadata to keep a consistent interface.

Return type:

Module

pyhazards.models.builder.default_builder(name, task, **kwargs)[source]

Generic builder for standard backbones + heads.

Return type:

Module

pyhazards.models.registry module

pyhazards.models.registry.available_models()[source]
pyhazards.models.registry.get_model_config(name)[source]
Return type:

Optional[Dict[str, Any]]

pyhazards.models.registry.register_model(name, builder, defaults=None)[source]
Return type:

None

Module contents

class pyhazards.models.ASUFM(input_dim=7, hidden_dim=64, output_dim=5, lookback=12, dropout=0.1)[source]

Bases: Module

Temporal convolution baseline for wildfire activity forecasting.

forward(x)[source]
Return type:

Tensor

class pyhazards.models.CNNPatchEncoder(in_channels=3, hidden_dim=64)[source]

Bases: Module

Lightweight CNN encoder for raster patches.

forward(x)[source]
class pyhazards.models.ClassificationHead(in_dim, num_classes)[source]

Bases: Module

Simple classification head.

forward(x)[source]
class pyhazards.models.ConvLEMCell(in_channels, out_channels, kernel_size=3, dt=1.0, activation='tanh', use_reset_gate=False)[source]

Bases: Module

Convolutional Long Expressive Memory (ConvLEM) cell used by WaveCastNet.

forward(x, h, c)[source]
Return type:

tuple[Tensor, Tensor]

reset_parameters()[source]
Return type:

None

class pyhazards.models.EQNet(in_channels=3, hidden_dim=48, num_heads=4, num_layers=2, dropout=0.1)[source]

Bases: Module

Transformer-style earthquake phase-picking baseline.

forward(x)[source]
Return type:

Tensor

class pyhazards.models.EQTransformer(in_channels=3, hidden_dim=48, num_layers=2, dropout=0.1)[source]

Bases: Module

Compact sequence model for joint earthquake phase picking.

forward(x)[source]
Return type:

Tensor

class pyhazards.models.FireCastNet(in_channels=12, hidden_dim=32, out_channels=1, dropout=0.1)[source]

Bases: Module

Compact encoder-decoder wildfire spread network.

forward(x)[source]
Return type:

Tensor

class pyhazards.models.FloodCast(in_channels=3, history=4, hidden_dim=32, out_channels=1, dropout=0.1)[source]

Bases: Module

Compact spatiotemporal inundation baseline.

forward(x)[source]
Return type:

Tensor

class pyhazards.models.ForeFireAdapter(in_channels=12, out_channels=1, diffusion_steps=2)[source]

Bases: Module

Lightweight deterministic spread adapter inspired by simulator-style fronts.

forward(x)[source]
Return type:

Tensor

class pyhazards.models.FourCastNetTC(input_dim=8, history=6, hidden_dim=96, horizon=5, output_dim=3, dropout=0.1)[source]

Bases: Module

Experimental wrapper-style FourCastNet storm adapter.

forward(x)[source]
Return type:

Tensor

class pyhazards.models.GPD(in_channels=3, hidden_dim=32, dropout=0.1)[source]

Bases: Module

Simple CNN baseline for generalized phase detection style picking.

forward(x)[source]
Return type:

Tensor

class pyhazards.models.GoogleFloodForecasting(input_dim=2, hidden_dim=64, out_dim=1, history=4, dropout=0.1)[source]

Bases: Module

Sequence baseline for streamflow-style flood forecasting.

forward(batch)[source]
Return type:

Tensor

class pyhazards.models.GraphCastTC(input_dim=8, hidden_dim=96, horizon=5, output_dim=3, num_layers=2, num_heads=4, dropout=0.1)[source]

Bases: Module

Experimental wrapper-style GraphCast storm adapter.

forward(x)[source]
Return type:

Tensor

class pyhazards.models.Hurricast(input_dim=8, hidden_dim=64, num_layers=2, horizon=5, output_dim=3, dropout=0.1)[source]

Bases: Module

Compact storm-track and intensity baseline for Wave 2 vertical slices.

forward(x)[source]
Return type:

Tensor

class pyhazards.models.HydroGraphNet(node_in_dim, edge_in_dim, out_dim, hidden_dim=64, harmonics=5, num_gn_blocks=5, state_dim=None, rollout_steps=1, enforce_nonnegative=False, dropout=0.0)[source]

Bases: Module

PhysicsNeMo-inspired HydroGraphNet: encoder -> message-passing processor -> residual delta-state decoder.

Supports one-step forward prediction and autoregressive rollout.

_edge_index(adj, batch_size)[source]
Return type:

Tuple[Tensor, Tensor]

_match_edge_dim(edge_feat)[source]
Return type:

Tensor

_one_step(node_x, batch)[source]
Return type:

Tensor

_prepare_edge_inputs(batch, senders, receivers, batch_size, device, dtype)[source]
Return type:

Tensor

forward(batch)[source]
Return type:

Tensor

rollout(batch, predict_steps)[source]
Return type:

Tensor

class pyhazards.models.HydroGraphNetLoss(supervised_weight=1.0, continuity_weight=0.0)[source]

Bases: Module

Supervised regression loss with optional continuity regularization.

forward(preds, targets, prev_state=None, cell_area=None)[source]
Return type:

Tuple[Tensor, Dict[str, float]]

class pyhazards.models.MLPBackbone(input_dim, hidden_dim=256, depth=2)[source]

Bases: Module

Simple MLP for tabular features.

forward(x)[source]
class pyhazards.models.NeuralHydrologyEALSTM(input_dim=2, hidden_dim=64, num_layers=1, out_dim=1, dropout=0.1)[source]

Bases: Module

Entity-aware LSTM style streamflow baseline.

forward(batch)[source]
Return type:

Tensor

class pyhazards.models.NeuralHydrologyLSTM(input_dim=2, hidden_dim=64, num_layers=2, out_dim=1, dropout=0.1)[source]

Bases: Module

Adapter-style LSTM streamflow baseline.

forward(batch)[source]
Return type:

Tensor

class pyhazards.models.PanguTC(input_dim=8, hidden_dim=96, horizon=5, output_dim=3, dropout=0.1)[source]

Bases: Module

Experimental wrapper-style Pangu-Weather storm adapter.

forward(x)[source]
Return type:

Tensor

class pyhazards.models.PhaseNet(in_channels=3, hidden_dim=32)[source]

Bases: Module

Lightweight phase-picking network for synthetic waveform smoke runs.

forward(x)[source]
Return type:

Tensor

class pyhazards.models.RegressionHead(in_dim, out_dim=1)[source]

Bases: Module

Regression head for scalar or multi-target outputs.

forward(x)[source]
class pyhazards.models.SAFNet(input_dim=8, hidden_dim=64, horizon=5, dropout=0.1)[source]

Bases: Module

Spatiotemporal intensity-focused storm baseline.

forward(x)[source]
Return type:

Tensor

class pyhazards.models.SegmentationHead(in_channels, num_classes)[source]

Bases: Module

Segmentation head for raster masks.

forward(x)[source]
class pyhazards.models.TCIFFusion(input_dim=8, hidden_dim=64, horizon=5, output_dim=3, dropout=0.1)[source]

Bases: Module

Knowledge-guided fusion baseline for tropical cyclone forecasting.

forward(x)[source]
Return type:

Tensor

class pyhazards.models.TemporalEncoder(input_dim, hidden_dim=128, num_layers=1)[source]

Bases: Module

GRU-based encoder for time-series signals.

forward(x)[source]
class pyhazards.models.TropiCycloneNet(input_dim=8, hidden_dim=64, horizon=5, output_dim=3, num_layers=2, dropout=0.1)[source]

Bases: Module

GRU + attention baseline for all-basin tropical cyclone forecasting.

forward(x)[source]
Return type:

Tensor

class pyhazards.models.TropicalCycloneMLP(input_dim=8, history=6, hidden_dim=64, horizon=5, output_dim=3, dropout=0.1)[source]

Bases: Module

Compact MLP baseline for storm track and intensity forecasting.

forward(x)[source]
Return type:

Tensor

class pyhazards.models.TverskyLoss(alpha=0.5, beta=0.5, smooth=1e-06, from_logits=True)[source]

Bases: Module

Tversky loss for binary segmentation.

forward(logits, targets)[source]
Return type:

Tensor

class pyhazards.models.UrbanFloodCast(in_channels=3, history=4, base_channels=32, out_channels=1)[source]

Bases: Module

U-Net style urban inundation baseline.

forward(x)[source]
Return type:

Tensor

class pyhazards.models.WRFSFireAdapter(in_channels=12, out_channels=1, diffusion_steps=3)[source]

Bases: Module

Lightweight raster adapter inspired by WRF-SFIRE style spread diffusion.

forward(x)[source]
Return type:

Tensor

class pyhazards.models.WaveCastNet(in_channels, height, width, temporal_in, temporal_out, hidden_dim=144, num_layers=2, kernel_size=3, dt=1.0, activation='tanh', dropout=0.1)[source]

Bases: Module

Sequence-to-sequence wavefield forecasting model based on ConvLEM cells.

Input shape: (B, C, T_in, H, W) Output shape: (B, C, T_out, H, W)

_init_states(x)[source]
Return type:

tuple[list[Tensor], list[Tensor]]

forward(x)[source]
Return type:

Tensor

class pyhazards.models.WaveCastNetLoss(delta=1.0)[source]

Bases: Module

Huber loss used in the WaveCastNet paper.

forward(pred, target)[source]
Return type:

Tensor

class pyhazards.models.WavefieldMetrics[source]

Bases: object

ACC and RFNE metrics reported in the WaveCastNet paper.

static accuracy(pred, target)[source]
Return type:

float

static compute_all(pred, target)[source]
Return type:

dict[str, float]

static rfne(pred, target)[source]
Return type:

float

class pyhazards.models.WildfireASPP(in_channels=12, base_channels=32, aspp_channels=32, dilations=(1, 3, 6, 12), dropout=0.0)[source]

Bases: WildfireCNNASPP

Backward-compatible name for the CNN + ASPP wildfire model.

class pyhazards.models.WildfireCNNASPP(in_channels=12, base_channels=32, aspp_channels=32, dilations=(1, 3, 6, 12), dropout=0.0)[source]

Bases: Module

CNN + ASPP wildfire segmentation model.

Input:

x : (B, C, H, W) float tensor

Output:

logits : (B, 1, H, W) float tensor (sigmoid applied externally)

forward(x)[source]
Return type:

Tensor

class pyhazards.models.WildfireFPA(stage, component)[source]

Bases: Module

Paper-facing wrapper for the two-stage FPA-FOD wildfire framework.

forward(x)[source]
Return type:

Tensor

forward_with_reconstruction(x)[source]
Return type:

tuple[Tensor, Tensor]

class pyhazards.models.WildfireForecasting(input_dim=7, hidden_dim=64, output_dim=5, lookback=12, num_layers=2, dropout=0.1)[source]

Bases: Module

Sequence forecaster for weekly wildfire size-group activity.

forward(x)[source]
Return type:

Tensor

class pyhazards.models.WildfireMamba(in_dim, num_counties, past_days, hidden_dim=128, gcn_hidden=64, mamba_layers=2, state_dim=64, conv_kernel=5, dropout=0.1, adjacency=None, with_count_head=False)[source]

Bases: Module

Mamba-based spatio-temporal wildfire model for county-day ERA5 features.

Input shape: (batch, past_days, num_counties, num_features) Output: logits per county for the next day (use sigmoid for probabilities)

_get_adjacency(batch_size)[source]
Return type:

Tensor

static _temporal_delta(x)[source]
Return type:

Tensor

forward(x, adjacency=None)[source]
Parameters:
  • x (Tensor) – Tensor shaped (batch, past_days, num_counties, in_dim)

  • adjacency (Optional[Tensor]) – Optional (N, N) or (B, N, N) adjacency override.

Returns:

(batch, num_counties) - optional counts: (batch, num_counties) if with_count_head is enabled.

Return type:

  • logits

set_adjacency(adj)[source]

Set/override the spatial adjacency.

Return type:

None

class pyhazards.models.WildfireSpreadTS(history=4, in_channels=6, hidden_dim=32, out_channels=1, dropout=0.1)[source]

Bases: Module

Temporal convolution baseline for wildfire spread masks.

forward(x)[source]
Return type:

Tensor

pyhazards.models.asufm_builder(task, input_dim=7, hidden_dim=64, output_dim=5, lookback=12, dropout=0.1, **kwargs)[source]
Return type:

Module

pyhazards.models.available_models()[source]
pyhazards.models.build_model(name, task, **kwargs)[source]

Build a model by name and task. This delegates to registry metadata to keep a consistent interface.

Return type:

Module

pyhazards.models.cnn_aspp_builder(task, in_channels=12, base_channels=32, aspp_channels=32, dilations=(1, 3, 6, 12), dropout=0.0, **kwargs)[source]

PyHazards-style model builder.

Return type:

Module

pyhazards.models.eqnet_builder(task, in_channels=3, hidden_dim=48, num_heads=4, num_layers=2, dropout=0.1, **kwargs)[source]
Return type:

Module

pyhazards.models.eqtransformer_builder(task, in_channels=3, hidden_dim=48, num_layers=2, dropout=0.1, **kwargs)[source]
Return type:

Module

pyhazards.models.firecastnet_builder(task, in_channels=12, hidden_dim=32, out_channels=1, dropout=0.1, **kwargs)[source]
Return type:

Module

pyhazards.models.floodcast_builder(task, in_channels=3, history=4, hidden_dim=32, out_channels=1, dropout=0.1, **kwargs)[source]
Return type:

Module

pyhazards.models.forefire_builder(task, in_channels=12, out_channels=1, diffusion_steps=2, **kwargs)[source]
Return type:

Module

pyhazards.models.fourcastnet_tc_builder(task, input_dim=8, history=6, hidden_dim=96, horizon=5, output_dim=3, dropout=0.1, **kwargs)[source]
Return type:

Module

pyhazards.models.google_flood_forecasting_builder(task, input_dim=2, hidden_dim=64, out_dim=1, history=4, dropout=0.1, **kwargs)[source]
Return type:

Module

pyhazards.models.gpd_builder(task, in_channels=3, hidden_dim=32, dropout=0.1, **kwargs)[source]
Return type:

Module

pyhazards.models.graphcast_tc_builder(task, input_dim=8, hidden_dim=96, horizon=5, output_dim=3, num_layers=2, num_heads=4, dropout=0.1, **kwargs)[source]
Return type:

Module

pyhazards.models.hurricast_builder(task, input_dim=8, hidden_dim=64, num_layers=2, horizon=5, output_dim=3, dropout=0.1, **kwargs)[source]
Return type:

Module

pyhazards.models.hydrographnet_builder(task, node_in_dim, edge_in_dim, out_dim, **kwargs)[source]
Return type:

HydroGraphNet

pyhazards.models.neuralhydrology_ealstm_builder(task, input_dim=2, hidden_dim=64, num_layers=1, out_dim=1, dropout=0.1, **kwargs)[source]
Return type:

Module

pyhazards.models.neuralhydrology_lstm_builder(task, input_dim=2, hidden_dim=64, num_layers=2, out_dim=1, dropout=0.1, **kwargs)[source]
Return type:

Module

pyhazards.models.pangu_tc_builder(task, input_dim=8, hidden_dim=96, horizon=5, output_dim=3, dropout=0.1, **kwargs)[source]
Return type:

Module

pyhazards.models.phasenet_builder(task, in_channels=3, hidden_dim=32, **kwargs)[source]
Return type:

Module

pyhazards.models.register_model(name, builder, defaults=None)[source]
Return type:

None

pyhazards.models.saf_net_builder(task, input_dim=8, hidden_dim=64, horizon=5, dropout=0.1, **kwargs)[source]
Return type:

Module

pyhazards.models.tcif_fusion_builder(task, input_dim=8, hidden_dim=64, horizon=5, output_dim=3, dropout=0.1, **kwargs)[source]
Return type:

Module

pyhazards.models.tropicalcyclone_mlp_builder(task, input_dim=8, history=6, hidden_dim=64, horizon=5, output_dim=3, dropout=0.1, **kwargs)[source]
Return type:

Module

pyhazards.models.tropicyclonenet_builder(task, input_dim=8, hidden_dim=64, horizon=5, output_dim=3, num_layers=2, dropout=0.1, **kwargs)[source]
Return type:

Module

pyhazards.models.urbanfloodcast_builder(task, in_channels=3, history=4, base_channels=32, out_channels=1, **kwargs)[source]
Return type:

Module

pyhazards.models.wavecastnet_builder(task, in_channels, height, width, temporal_in, temporal_out, **kwargs)[source]
Return type:

WaveCastNet

pyhazards.models.wildfire_aspp_builder(task, **kwargs)[source]
Return type:

Module

pyhazards.models.wildfire_forecasting_builder(task, input_dim=7, hidden_dim=64, output_dim=5, lookback=12, num_layers=2, dropout=0.1, **kwargs)[source]
Return type:

Module

pyhazards.models.wildfire_fpa_builder(task, in_dim=None, input_dim=None, out_dim=None, output_dim=None, depth=2, hidden_dim=64, activation='relu', dropout=None, latent_dim=32, num_layers=1, ae_hidden_dim=None, ae_num_layers=None, lookback=50, **kwargs)[source]
Return type:

Module

pyhazards.models.wildfire_mamba_builder(task, in_dim, num_counties, past_days, **kwargs)[source]

Builder used by the model registry.

Return type:

WildfireMamba

pyhazards.models.wildfirespreadts_builder(task, history=4, in_channels=6, hidden_dim=32, out_channels=1, dropout=0.1, **kwargs)[source]
Return type:

Module

pyhazards.models.wrf_sfire_builder(task, in_channels=12, out_channels=1, diffusion_steps=3, **kwargs)[source]
Return type:

Module