Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up RTS-GMLC parser code #309

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 64 additions & 64 deletions egret/parsers/rts_gmlc/_reserves.py
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
# ___________________________________________________________________________
#
# EGRET: Electrical Grid Research and Engineering Tools
# Copyright 2019 National Technology & Engineering Solutions of Sandia, LLC
# (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S.
# Government retains certain rights in this software.
# This software is distributed under the Revised BSD License.
# ___________________________________________________________________________
from __future__ import annotations
from typing import NamedTuple, Optional, Sequence
reserve_name_map = {
'Spin_Up': 'spinning_reserve_requirement',
'Reg_Up': 'regulation_up_requirement',
'Reg_Down': 'regulation_down_requirement',
'Flex_Up': 'flexible_ramp_up_requirement',
'Flex_Down': 'flexible_ramp_down_requirement'
}
def is_valid_reserve_name(name:str, model_dict:dict=None):
if name in reserve_name_map:
return True
if name.find('_R') < 0:
return False
res, area = name.split('_R', 1)
return (res in reserve_name_map) and \
((model_dict is None) or (area in model_dict['elements']['area']))
class ScalarReserveValue(NamedTuple):
''' A reserve type, scope, and scalar value.
If area_name is None, this is a global reserve value.
'''
reserve_type: str
area_name: Optional[str]
value: float
class ScalarReserveData():
''' Scalar reserve values that should only be applied to one type of model.
'''
def __init__(self,
da_scalars: Sequence[ScalarReserveValue],
rt_scalars: Sequence[ScalarReserveValue]):
self._da_scalars = da_scalars
self._rt_scalars = rt_scalars
@property
def da_scalars(self) -> Sequence[ScalarReserveValue]:
''' Scalar reserve values that only apply to DAY_AHEAD models
'''
return self._da_scalars
@property
def rt_scalars(self) -> Sequence[ScalarReserveValue]:
''' Scalar reserve values that only apply to REAL_TIME models
'''
return self._rt_scalars
def get_simulation_reserves(self, simulation_type:str) -> Sequence[ScalarReserveValue]:
''' Get scalar reserve values that only apply the requested simulation type
'''
return self._rt_scalars if simulation_type == 'REAL_TIME' else self._da_scalars
# ___________________________________________________________________________
#
# EGRET: Electrical Grid Research and Engineering Tools
# Copyright 2019 National Technology & Engineering Solutions of Sandia, LLC
# (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S.
# Government retains certain rights in this software.
# This software is distributed under the Revised BSD License.
# ___________________________________________________________________________

from __future__ import annotations

from typing import NamedTuple, Optional, Sequence

reserve_name_map = {
'Spin_Up': 'spinning_reserve_requirement',
'Reg_Up': 'regulation_up_requirement',
'Reg_Down': 'regulation_down_requirement',
'Flex_Up': 'flexible_ramp_up_requirement',
'Flex_Down': 'flexible_ramp_down_requirement'
}

def is_valid_reserve_name(name:str, model_dict:dict=None):
if name in reserve_name_map:
return True
if name.find('_R') < 0:
return False
res, area = name.split('_R', 1)
return (res in reserve_name_map) and \
((model_dict is None) or (area in model_dict['elements']['area']))

class ScalarReserveValue(NamedTuple):
''' A reserve type, scope, and scalar value.

If area_name is None, this is a global reserve value.
'''
reserve_type: str
area_name: Optional[str]
value: float

class ScalarReserveData():
''' Scalar reserve values that should only be applied to one type of model.
'''
def __init__(self,
da_scalars: Sequence[ScalarReserveValue],
rt_scalars: Sequence[ScalarReserveValue]):
self._da_scalars = da_scalars
self._rt_scalars = rt_scalars

@property
def da_scalars(self) -> Sequence[ScalarReserveValue]:
''' Scalar reserve values that only apply to DAY_AHEAD models
'''
return self._da_scalars

@property
def rt_scalars(self) -> Sequence[ScalarReserveValue]:
''' Scalar reserve values that only apply to REAL_TIME models
'''
return self._rt_scalars

def get_simulation_reserves(self, simulation_type:str) -> Sequence[ScalarReserveValue]:
''' Get scalar reserve values that only apply the requested simulation type
'''
return self._rt_scalars if simulation_type == 'REAL_TIME' else self._da_scalars
Loading
Loading