ERAD#
ERAD is a free, open-source Python toolkit for computing energy resilience measures in the face of hazards like earthquakes and flooding. It uses a graph database to store data and perform analysis at the household level for a variety of critical services that are connected by the power distribution network. It uses asset fragility curves, which are functions that relate hazard severity to survival probability for power system assets including cables, transformers, substations, roof-mounted solar panels, etc. Programs like undergrounding, microgrid, and electricity backup units for critical infrastructures may all be evaluated using metrics and compared across different neighborhoods to assess their effects on energy resilience.
pip install git+https://github.com/NREL/erad.git@al/erad_v1
Collecting git+https://github.com/NREL/erad.git@al/erad_v1
Cloning https://github.com/NREL/erad.git (to revision al/erad_v1) to /private/var/folders/_7/k4nd0c9s5z914hjjvkpygcg80000gr/T/pip-req-build-awylc815
Running command git clone --filter=blob:none --quiet https://github.com/NREL/erad.git /private/var/folders/_7/k4nd0c9s5z914hjjvkpygcg80000gr/T/pip-req-build-awylc815
Running command git checkout -b al/erad_v1 --track origin/al/erad_v1
Switched to a new branch 'al/erad_v1'
branch 'al/erad_v1' set up to track 'origin/al/erad_v1'.
Resolved https://github.com/NREL/erad.git to commit 33a35d5ec03e8b702d67ed7e7bd5b6d37edefd3b
Installing build dependencies ... ?25l-
\
|
/
-
\
|
/
done
?25h Getting requirements to build wheel ... ?25l- done
?25h Preparing metadata (pyproject.toml) ... ?25l- done
?25hRequirement already satisfied: grid-data-models in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from NREL-erad==0.0.1) (2.0.1)
Requirement already satisfied: geopandas in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from NREL-erad==0.0.1) (1.0.1)
Requirement already satisfied: requests in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from NREL-erad==0.0.1) (2.32.3)
Requirement already satisfied: shapely in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from NREL-erad==0.0.1) (2.1.0)
Requirement already satisfied: pandas in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from NREL-erad==0.0.1) (2.2.3)
Requirement already satisfied: pyhigh in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from NREL-erad==0.0.1) (0.0.6)
Requirement already satisfied: geopy in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from NREL-erad==0.0.1) (2.4.1)
Requirement already satisfied: scipy in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from NREL-erad==0.0.1) (1.15.2)
Requirement already satisfied: numpy>=1.22 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from geopandas->NREL-erad==0.0.1) (2.2.5)
Requirement already satisfied: pyogrio>=0.7.2 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from geopandas->NREL-erad==0.0.1) (0.10.0)
Requirement already satisfied: packaging in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from geopandas->NREL-erad==0.0.1) (25.0)
Requirement already satisfied: pyproj>=3.3.0 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from geopandas->NREL-erad==0.0.1) (3.7.1)
Requirement already satisfied: python-dateutil>=2.8.2 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from pandas->NREL-erad==0.0.1) (2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from pandas->NREL-erad==0.0.1) (2025.2)
Requirement already satisfied: tzdata>=2022.7 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from pandas->NREL-erad==0.0.1) (2025.2)
Requirement already satisfied: geographiclib<3,>=1.52 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from geopy->NREL-erad==0.0.1) (2.0)
Requirement already satisfied: click~=8.1.7 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from grid-data-models->NREL-erad==0.0.1) (8.1.8)
Requirement already satisfied: importlib-metadata in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from grid-data-models->NREL-erad==0.0.1) (8.6.1)
Requirement already satisfied: infrasys~=0.4.0 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from grid-data-models->NREL-erad==0.0.1) (0.4.0)
Requirement already satisfied: networkx in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from grid-data-models->NREL-erad==0.0.1) (3.4.2)
Requirement already satisfied: plotly in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from grid-data-models->NREL-erad==0.0.1) (6.0.1)
Requirement already satisfied: pydantic~=2.10.6 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from grid-data-models->NREL-erad==0.0.1) (2.10.6)
Requirement already satisfied: charset-normalizer<4,>=2 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from requests->NREL-erad==0.0.1) (3.4.1)
Requirement already satisfied: idna<4,>=2.5 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from requests->NREL-erad==0.0.1) (3.10)
Requirement already satisfied: urllib3<3,>=1.21.1 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from requests->NREL-erad==0.0.1) (2.4.0)
Requirement already satisfied: certifi>=2017.4.17 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from requests->NREL-erad==0.0.1) (2025.4.26)
Requirement already satisfied: loguru~=0.7.2 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from infrasys~=0.4.0->grid-data-models->NREL-erad==0.0.1) (0.7.3)
Requirement already satisfied: pint~=0.23 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from infrasys~=0.4.0->grid-data-models->NREL-erad==0.0.1) (0.24.4)
Requirement already satisfied: pyarrow~=19.0 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from infrasys~=0.4.0->grid-data-models->NREL-erad==0.0.1) (19.0.1)
Requirement already satisfied: rich~=13.7.1 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from infrasys~=0.4.0->grid-data-models->NREL-erad==0.0.1) (13.7.1)
Requirement already satisfied: annotated-types>=0.6.0 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from pydantic~=2.10.6->grid-data-models->NREL-erad==0.0.1) (0.7.0)
Requirement already satisfied: pydantic-core==2.27.2 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from pydantic~=2.10.6->grid-data-models->NREL-erad==0.0.1) (2.27.2)
Requirement already satisfied: typing-extensions>=4.12.2 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from pydantic~=2.10.6->grid-data-models->NREL-erad==0.0.1) (4.13.2)
Requirement already satisfied: six>=1.5 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from python-dateutil>=2.8.2->pandas->NREL-erad==0.0.1) (1.17.0)
Requirement already satisfied: zipp>=3.20 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from importlib-metadata->grid-data-models->NREL-erad==0.0.1) (3.21.0)
Requirement already satisfied: narwhals>=1.15.1 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from plotly->grid-data-models->NREL-erad==0.0.1) (1.36.0)
Requirement already satisfied: platformdirs>=2.1.0 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from pint~=0.23->infrasys~=0.4.0->grid-data-models->NREL-erad==0.0.1) (4.3.7)
Requirement already satisfied: flexcache>=0.3 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from pint~=0.23->infrasys~=0.4.0->grid-data-models->NREL-erad==0.0.1) (0.3)
Requirement already satisfied: flexparser>=0.4 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from pint~=0.23->infrasys~=0.4.0->grid-data-models->NREL-erad==0.0.1) (0.4)
Requirement already satisfied: markdown-it-py>=2.2.0 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from rich~=13.7.1->infrasys~=0.4.0->grid-data-models->NREL-erad==0.0.1) (3.0.0)
Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from rich~=13.7.1->infrasys~=0.4.0->grid-data-models->NREL-erad==0.0.1) (2.19.1)
Requirement already satisfied: mdurl~=0.1 in /opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages (from markdown-it-py>=2.2.0->rich~=13.7.1->infrasys~=0.4.0->grid-data-models->NREL-erad==0.0.1) (0.1.2)
Note: you may need to restart the kernel to use updated packages.
We start by loading a sample GDM system using the gdmloader.
from gdm.distribution import DistributionSystem
from gdmloader.constants import GCS_CASE_SOURCE
from gdmloader.source import SystemLoader
gdm_loader = SystemLoader()
gdm_loader.add_source(GCS_CASE_SOURCE)
distribution_system: DistributionSystem = gdm_loader.load_dataset(
source_name=GCS_CASE_SOURCE.name,
system_type=DistributionSystem,
dataset_name="p5r",
)
distribution_system.name = "p5r"
/opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py:502: UserWarning: Ellipsis is not a Python type (it may be an instance of an object), Pydantic will allow any object with no validation since we cannot even enforce that the input is an instance of the given type. To get rid of this error wrap the type with `pydantic.SkipValidation`.
warn(
ERAD Asset and Hazard systems are also infrasys systems. This means these class also have all the functionality to serialize and deserialize, add components and perform model validation. An AssetSystem can be built directly from a given GDM system using the from_gdm method. Once built, an instance of HarzardSimulator can be created by passing the asset system. Finally, the simualation can be run by calling the run method and passing an instance of HazardSystem. This system may have definitions of multiple hazards.
from erad.models.asset import Asset
from erad.runner import HarzardSimulator
from erad.systems.asset_system import AssetSystem
from erad.systems.hazard_system import HazardSystem
asset_system = AssetSystem.from_gdm(distribution_system)
hazard_scenario = HarzardSimulator(asset_system=asset_system)
hazard_scenario.run(hazard_system=HazardSystem.earthquake_example())
for component in asset_system.iter_all_components():
component.pprint()
break
2025-05-18 09:15:21.584 | WARNING | erad.runner:run:37 - No HazardFragilityCurves definations found in the passed HazardSystem using default curve definations
Asset( name='source', distribution_asset=UUID('9e94878c-d664-46aa-bd96-f3127c5ffcd2'), asset_type=<AssetTypes.substation: 0>, height=<Quantity(3, 'meter')>, latitude=36.60102672210813, longitude=-120.91292875147646, asset_state=[ AssetState( name='', timestamp=datetime.datetime(2025, 5, 18, 9, 15, 21, 584216), wind_speed=None, flood_velocity=None, flood_depth=None, fire_boundary_dist=None, peak_ground_velocity=SpeedProbability( name='', survival_probability=0.5300401162709448, speed=<Quantity(43.7665689, 'centimeter / second')> ), peak_ground_acceleration=AccelerationProbability( name='', survival_probability=0.5027933876698256, acceleration=<Quantity(1.52785696, 'meter / second ** 2')> ), survival_probability=0.2665006656607766 ) ] )