-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from rjmalves/implementa-avlcortesfpha
implementa avl_cortesfpha_dec
- Loading branch information
Showing
6 changed files
with
207 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
docs/source/referencia/decomp/arquivos/avl_cortesfpha_dec.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.. _avl_cortesfpha_dec: | ||
|
||
================================================================= | ||
Cortes da Função de Produção Hidráulica (avl_cortesfpha_dec.rvX) | ||
================================================================= | ||
|
||
.. currentmodule:: idecomp.decomp.avl_cortesfpha_dec | ||
|
||
Os cortes para aproximação da função de produção hidráulica são armazenados na classe: | ||
|
||
.. autoclass:: AvlCortesFpha | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from idecomp.decomp.modelos.blocos.versaomodelo import VersaoModelo | ||
from idecomp.decomp.modelos.avl_cortesfpha_dec import TabelaCortesFpha | ||
|
||
from idecomp.decomp.modelos.arquivoscsv.arquivocsv import ArquivoCSV | ||
from typing import Optional | ||
import pandas as pd # type: ignore | ||
|
||
|
||
class AvlCortesFpha(ArquivoCSV): | ||
""" | ||
Arquivo com os cortes da função de produção hidráulica aproximada do DECOMP. | ||
""" | ||
|
||
BLOCKS = [VersaoModelo, TabelaCortesFpha] | ||
|
||
@property | ||
def tabela(self) -> Optional[pd.DataFrame]: | ||
""" | ||
A tabela de dados que está contida no arquivo. | ||
- codigo_usina (`int`) | ||
- periodo (`int`) | ||
- nome_usina (`str`) | ||
- segmento_fpha (`int`) | ||
- fator_correcao (`float`) | ||
- rhs (`float`) | ||
- coeficiente_volume_util (`float`) | ||
- coeficiente_vazao_turbinada (`float`) | ||
- coeficiente_vazao_vertida (`float`) | ||
- coeficiente_vazao_lateral (`float`) | ||
:return: A tabela como um dataframe | ||
:rtype: pd.DataFrame | None | ||
""" | ||
return self._tabela() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Imports de módulos externos | ||
from cfinterface.components.line import Line | ||
from cfinterface.components.integerfield import IntegerField | ||
from cfinterface.components.literalfield import LiteralField | ||
from cfinterface.components.floatfield import FloatField | ||
|
||
|
||
from idecomp.decomp.modelos.blocos.tabelacsv import TabelaCSV | ||
|
||
|
||
class TabelaCortesFpha(TabelaCSV): | ||
""" | ||
Bloco com as informações dos cortes da função de produção hidráulica. | ||
""" | ||
|
||
BEGIN_PATTERN = "-----;-----;--------------;" | ||
LINE_MODEL = Line( | ||
[ | ||
IntegerField(size=5), | ||
IntegerField(size=5), | ||
LiteralField(size=14), | ||
IntegerField(size=7), | ||
FloatField(size=10, decimal_digits=6), | ||
FloatField(size=16, decimal_digits=8), | ||
FloatField(size=16, decimal_digits=8), | ||
FloatField(size=16, decimal_digits=8), | ||
FloatField(size=16, decimal_digits=8), | ||
FloatField(size=16, decimal_digits=8), | ||
], | ||
delimiter=";", | ||
) | ||
COLUMN_NAMES = [ | ||
"codigo_usina", | ||
"periodo", | ||
"nome_usina", | ||
"segmento_fpha", | ||
"fator_correcao", | ||
"rhs", | ||
"coeficiente_volume_util", | ||
"coeficiente_vazao_turbinada", | ||
"coeficiente_vazao_vertida", | ||
"coeficiente_vazao_lateral", | ||
] | ||
END_PATTERN = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from idecomp.decomp.avl_cortesfpha_dec import AvlCortesFpha | ||
|
||
from tests.mocks.mock_open import mock_open | ||
from unittest.mock import MagicMock, patch | ||
|
||
from tests.mocks.arquivos.avl_cortesfpha_dec import MockAvlCortesFpha | ||
|
||
|
||
def test_atributos_encontrados_avl_cortesfpha_dec(): | ||
m: MagicMock = mock_open(read_data="".join(MockAvlCortesFpha)) | ||
with patch("builtins.open", m): | ||
rel = AvlCortesFpha.read( | ||
"./tests/mocks/arquivos/avl_cortesfpha_dec.py" | ||
) | ||
assert rel.versao == "31.23" | ||
|
||
assert rel.tabela.at[0, "codigo_usina"] == 1 | ||
assert rel.tabela.at[0, "periodo"] == 1 | ||
assert rel.tabela.at[0, "nome_usina"] == "CAMARGOS" | ||
assert rel.tabela.at[0, "segmento_fpha"] == 1 | ||
assert rel.tabela.at[0, "fator_correcao"] == 0.991429 | ||
assert rel.tabela.at[0, "rhs"] == -9.42177264 | ||
assert rel.tabela.at[0, "coeficiente_volume_util"] == 0.03350655 | ||
assert rel.tabela.at[0, "coeficiente_vazao_turbinada"] == 0.18047226 | ||
assert rel.tabela.at[0, "coeficiente_vazao_vertida"] == -0.00594416 | ||
assert rel.tabela.at[0, "coeficiente_vazao_lateral"] == 0.00000000 | ||
|
||
|
||
def test_eq_avl_cortesfpha_dec(): | ||
m: MagicMock = mock_open(read_data="".join(MockAvlCortesFpha)) | ||
with patch("builtins.open", m): | ||
rel1 = AvlCortesFpha.read( | ||
"./tests/mocks/arquivos/avl_cortesfpha_dec.py" | ||
) | ||
rel2 = AvlCortesFpha.read( | ||
"./tests/mocks/arquivos/avl_cortesfpha_dec.py" | ||
) | ||
assert rel1 == rel2 | ||
|
||
|
||
def test_neq_avl_cortesfpha_dec(): | ||
m: MagicMock = mock_open(read_data="".join(MockAvlCortesFpha)) | ||
with patch("builtins.open", m): | ||
rel1 = AvlCortesFpha.read( | ||
"./tests/mocks/arquivos/avl_cortesfpha_dec.py" | ||
) | ||
rel2 = AvlCortesFpha.read( | ||
"./tests/mocks/arquivos/avl_cortesfpha_dec.py" | ||
) | ||
rel1.tabela.iloc[0, 0] = -1 | ||
assert rel1 != rel2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
MockAvlCortesFpha = [ | ||
"@Tabela\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"***********************************************************************\n", | ||
"* *\n", | ||
"* CEPEL - CENTRO DE PESQUISAS DE ENERGIA ELETRICA *\n", | ||
"* CEPEL: DECOMP - Versao 31.23 - Jan/2024(L) *\n", | ||
"* *\n", | ||
"***********************************************************************\n", | ||
"\n", | ||
"\n", | ||
" PROGRAMA LICENCIADO PARA OPERADOR NACIONAL DO SISTEMA ELETRICO ONS \n", | ||
"\n", | ||
"\n", | ||
"____________________________________________________________________\n", | ||
"\n", | ||
" PMO - JANEIRO/24 - FEVEREIRO/24 - REV 2 - FCF COM CVAR - 12 REE - VALOR ESPE \n", | ||
"____________________________________________________________________\n", | ||
"\n", | ||
"--------------------------------------------------------------------------------------\n", | ||
"Relatorio dos cortes do modelo para a funcao de producao para as usinas hidroeletricas\n", | ||
"--------------------------------------------------------------------------------------\n", | ||
"--------------------------------------------------------\n", | ||
"USIH; Numero de cadastro da usina hidroeletrica \n", | ||
"IPER; Indice do periodo \n", | ||
"NomeUsih; Nome de cadastro da usina hidroeletrica \n", | ||
"ICORT; Indice do corte \n", | ||
"FCorrec; Fator de correcao \n", | ||
"RHS; Termo independente \n", | ||
"Coef. Vutil; Coeficiente para o volume armazenado (util) \n", | ||
"Coef. Qtur; Coeficiente para a vazao turbinada \n", | ||
"Coef. Qver; Coeficiente para a vazao vertida \n", | ||
"Coef. Qlat; Coeficiente para a vazao lateral a jusante \n", | ||
"--------------------------------------------------------\n", | ||
"\n", | ||
"@Tabela\n", | ||
"-----;-----;--------------;-------;----------;----------------;----------------;----------------;----------------;----------------;\n", | ||
"USIH ;IPER ; NomeUsih ; ICORT ; FCorrec ; RHS ; Coef. Vutil ; Coef. Qtur ; Coef. Qver ; Coef. Qlat ;\n", | ||
" - ; - ; - ; ; ; (MW) ; (MW/hm3) ; (MW/(m3/s)) ; (MW/(m3/s)) ; (MW/(m3/s)) ;\n", | ||
"-----;-----;--------------;-------;----------;----------------;----------------;----------------;----------------;----------------;\n", | ||
" 001 ; 1 ; CAMARGOS ; 1 ; 0.991429 ; -9.42177264 ; 0.03350655 ; 0.18047226 ; -0.00594416 ; 0.00000000 ;\n", | ||
" 001 ; 1 ; CAMARGOS ; 2 ; 0.991429 ; -9.28942843 ; 0.03114815 ; 0.18422951 ; -0.00475755 ; 0.00000000 ;\n", | ||
" 001 ; 1 ; CAMARGOS ; 3 ; 0.991429 ; -9.23272071 ; 0.03175264 ; 0.18269640 ; -0.00594416 ; 0.00000000 ;\n", | ||
" 001 ; 1 ; CAMARGOS ; 4 ; 0.991429 ; -9.14972665 ; 0.03034980 ; 0.18524190 ; -0.00549012 ; 0.00000000 ;\n", | ||
" 001 ; 1 ; CAMARGOS ; 5 ; 0.991429 ; -9.05473727 ; 0.02946855 ; 0.18691818 ; -0.00364501 ; 0.00000000 ;\n", | ||
" 001 ; 1 ; CAMARGOS ; 6 ; 0.991429 ; -8.82947973 ; 0.02853846 ; 0.18809764 ; -0.00226570 ; 0.00000000 ;\n", | ||
" 001 ; 1 ; CAMARGOS ; 7 ; 0.991429 ; -4.40655425 ; 0.01424277 ; 0.20169397 ; -0.00371322 ; 0.00000000 ;\n", | ||
" 001 ; 1 ; CAMARGOS ; 8 ; 0.991429 ; -0.39992744 ; 0.00129264 ; 0.22359016 ; -0.00254243 ; 0.00000000 ;\n", | ||
" 001 ; 1 ; CAMARGOS ; 9 ; 0.991429 ; -0.07193991 ; 0.00023252 ; 0.22627883 ; -0.00143810 ; 0.00000000 ;\n", | ||
" 001 ; 1 ; CAMARGOS ; 10 ; 0.991429 ; 0.00000000 ; 0.00000000 ; 0.22745828 ; -0.00034923 ; 0.00000000 ;\n", | ||
" 001 ; 1 ; CAMARGOS ; 11 ; 0.991429 ; 2.34082529 ; 0.00558994 ; 0.19072127 ; -0.00594416 ; 0.00000000 ;\n", | ||
" 002 ; 1 ; ITUTINGA ; 1 ; 1.000000 ; 0.00000000 ; 0.00000000 ; 0.24752499 ; -0.00127529 ; 0.00000000 ;\n", | ||
" 002 ; 1 ; ITUTINGA ; 2 ; 1.000000 ; 0.54142966 ; 0.00000000 ; 0.23737442 ; -0.00363827 ; 0.00000000 ;\n", | ||
" 002 ; 1 ; ITUTINGA ; 3 ; 1.000000 ; 1.35974034 ; 0.00000000 ; 0.22970369 ; -0.00503435 ; 0.00000000 ;\n", | ||
" 002 ; 1 ; ITUTINGA ; 4 ; 1.000000 ; 1.85067737 ; 0.00000000 ; 0.22663571 ; -0.00611069 ; 0.00000000 ;\n", | ||
" 004 ; 1 ; FUNIL-GRANDE ; 1 ; 1.000000 ; 0.00000000 ; 0.00000000 ; 0.36423193 ; -0.00325837 ; 0.00000000 ;\n", | ||
" 004 ; 1 ; FUNIL-GRANDE ; 2 ; 1.000000 ; 2.63153959 ; 0.00000000 ; 0.34347661 ; -0.00993771 ; 0.00000000 ;\n", | ||
" 004 ; 1 ; FUNIL-GRANDE ; 3 ; 1.000000 ; 6.81302119 ; 0.00000000 ; 0.32698665 ; -0.01501794 ; 0.00000000 ;\n", | ||
" 004 ; 1 ; FUNIL-GRANDE ; 4 ; 1.000000 ; 11.75695089 ; 0.00000000 ; 0.31398883 ; -0.01903542 ; 0.00000000 ;\n", | ||
" 006 ; 1 ; FURNAS ; 1 ; 0.998769 ; -95.88102343 ; 0.01238844 ; 0.77706627 ; -0.00701483 ; 0.00000000 ;\n", | ||
] |