ERP results from API #173
-
|
Hi, community, I am using the API but cannot find a way to get the ERP results I can run on the web tool. Thank you in advance for your help |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
I've never used it in the API but it looks like it's there:
This returns the structure of the input file for ERP analysis: |
Beta Was this translation helpful? Give feedback.
-
Here's an example of how to use it: Basic Setupimport requests
import time
API_KEY = 'YOUR_API_KEY_HERE' # Get from developer.nrel.gov
base_url = "https://developer.nrel.gov/api/reopt/stable"Step 1: Run REopt Optimization# Basic REopt inputs
reopt_inputs = {
"Site": {"latitude": 37.77, "longitude": -122.42},
"ElectricLoad": {
"doe_reference_name": "LargeOffice",
"annual_kwh": 6000000,
"critical_load_percent": 0.5
},
"ElectricTariff": {"urdb_label": "YOUR_UTILITY_RATE"},
"ElectricUtility": {
"outage_start_time_steps": [1000, 3000, 5000],
"outage_durations": 24
},
"PV": {"max_kw": 10000},
"ElectricStorage": {"max_kw": 5000, "max_kwh": 20000}
}
# Submit and get results
resp = requests.post(f"{base_url}/job/?api_key={API_KEY}", json=reopt_inputs)
run_uuid = resp.json()['run_uuid']
# Wait for results
while True:
resp = requests.get(f"{base_url}/job/{run_uuid}/results/?api_key={API_KEY}")
if resp.json().get('status') != 'Optimizing...':
break
time.sleep(10)Step 2: Run ERP Analysis# ERP inputs - requires REopt run_uuid
erp_inputs = {
"reopt_run_uuid": run_uuid
}
# Submit ERP job
resp = requests.post(f"{base_url}/erp/?api_key={API_KEY}", json=erp_inputs)
erp_uuid = resp.json()['run_uuid']
# Wait for ERP results
while True:
resp = requests.get(f"{base_url}/erp/{erp_uuid}/results/?api_key={API_KEY}")
if resp.json().get('status') != 'Optimizing...':
erp_results = resp.json()
break
time.sleep(10)Step 3: Get ERP Results# Key ERP outputs
survival_curve = erp_results["outputs"]["mean_cumulative_survival_by_duration"]
print(f"Survival probabilities: {survival_curve}")Key Differences from Web Tool
|
Beta Was this translation helpful? Give feedback.


Here's an example of how to use it:
Basic Setup
Step 1: Run REopt Optimization