Skip to content
Merged
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
4 changes: 2 additions & 2 deletions docs/source/referencia/dessem/arquivos/uch.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
.. _uch:

=======================================================
Dados de Unit Commitment Hidráulico (uch.csv)
Dados de Unit Commitment Hidráulico
=======================================================

.. currentmodule:: idessem.dessem.uch

Os dados de unit commitment hidráulico do DESSEM
são armazenados na classe:
localizados no arquivos uch.csv são armazenados na classe:

.. autoclass:: Uch
:members:
2 changes: 1 addition & 1 deletion docs/source/referencia/dessem/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ DESSEM
arquivos/renovaveis
arquivos/respot
arquivos/termdat
arquivos/uch
arquivos/uch
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Dados das Usinas Hidrelétricas
=======================================================

.. currentmodule:: idecomp.libs.usinas_hidreletricas
.. currentmodule:: idessem.libs.usinas_hidreletricas

As informações de usinas hidrelétricas no DESSEM,
localizadas no arquivos das LIBS que são indicados
Expand Down
9 changes: 9 additions & 0 deletions docs/source/referencia/libs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.. _libs:

LIBS
=======

.. toctree::
:maxdepth: 2

arquivos/usinas_hidreletricas
1 change: 1 addition & 0 deletions idessem/dessem/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@
from .renovaveis import Renovaveis # noqa
from .respot import Respot # noqa
from .termdat import Term # noqa
from .uch import Uch # noqa
15 changes: 0 additions & 15 deletions idessem/dessem/avl_altqueda.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
ArquivoCSV,
)

# Para compatibilidade - até versão 1.0.0
from os.path import join
import warnings


class AvlAltQueda(ArquivoCSV):
"""
Expand All @@ -20,17 +16,6 @@ class AvlAltQueda(ArquivoCSV):
BLOCKS = [VersaoModelo, DataEstudo, TabelaAvlAltQueda]
ENCODING = "iso-8859-1"

@classmethod
def le_arquivo(
cls, diretorio: str, nome_arquivo="AVL_ALTQUEDA.DAT"
) -> "AvlAltQueda":
msg = (
"O método le_arquivo(diretorio, nome_arquivo) será descontinuado"
+ " na versão 1.0.0 - use o método read(caminho_arquivo)"
)
warnings.warn(msg, category=FutureWarning)
return cls.read(join(diretorio, nome_arquivo))

@property
def tabela(self):
"""
Expand Down
15 changes: 0 additions & 15 deletions idessem/dessem/avl_desvfpha.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
ArquivoCSV,
)

# Para compatibilidade - até versão 1.0.0
from os.path import join
import warnings


class AvlDesvFpha(ArquivoCSV):
"""
Expand All @@ -27,17 +23,6 @@ class AvlDesvFpha(ArquivoCSV):
}
ENCODING = "iso-8859-1"

@classmethod
def le_arquivo(
cls, diretorio: str, nome_arquivo="AVL_DESVFPHA.DAT"
) -> "AvlDesvFpha":
msg = (
"O método le_arquivo(diretorio, nome_arquivo) será descontinuado"
+ " na versão 1.0.0 - use o método read(caminho_arquivo)"
)
warnings.warn(msg, category=FutureWarning)
return cls.read(join(diretorio, nome_arquivo))

@property
def tabela(self):
"""
Expand Down
49 changes: 7 additions & 42 deletions idessem/dessem/avl_estatfpha.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@
VersaoModelo,
)
from cfinterface.files.blockfile import BlockFile
from typing import Optional, Type, TypeVar
from typing import Optional, TypeVar
from datetime import datetime
import pandas as pd # type: ignore

# Para compatibilidade - até versão 1.0.0
from os.path import join
import warnings


class AvlEstatFpha(BlockFile):
"""
Expand All @@ -30,37 +26,6 @@ class AvlEstatFpha(BlockFile):
ENCODING = "iso-8859-1"
T = TypeVar("T")

@classmethod
def le_arquivo(
cls, diretorio: str, nome_arquivo="AVL_ESTATFPHA.DAT"
) -> "AvlEstatFpha":
msg = (
"O método le_arquivo(diretorio, nome_arquivo) será descontinuado"
+ " na versão 1.0.0 - use o método read(caminho_arquivo)"
)
warnings.warn(msg, category=FutureWarning)
return cls.read(join(diretorio, nome_arquivo))

def _bloco_por_tipo(self, bloco: Type[T], indice: int) -> Optional[T]:
"""
Obtém um gerador de blocos de um tipo, se houver algum no arquivo.

:param bloco: Um tipo de bloco para ser lido
:type bloco: T
:param indice: O índice do bloco a ser acessado, dentre os do tipo
:type indice: int
:return: O gerador de blocos, se houver
:rtype: Optional[Generator[T], None, None]
"""
try:
return next(
b
for i, b in enumerate(self.data.of_type(bloco))
if i == indice
)
except StopIteration:
return None

@property
def versao(self) -> Optional[str]:
"""
Expand All @@ -69,8 +34,8 @@ def versao(self) -> Optional[str]:
:return: A versão do modelo
:rtype: str | None
"""
b = self._bloco_por_tipo(VersaoModelo, 0)
if b is not None:
b = self.data.get_blocks_of_type(VersaoModelo)
if isinstance(b, VersaoModelo):
return b.data
return None

Expand All @@ -82,8 +47,8 @@ def data_estudo(self) -> Optional[datetime]:
:return: A data como objeto
:rtype: datetime | None
"""
b = self._bloco_por_tipo(DataEstudo, 0)
if b is not None:
b = self.data.get_blocks_of_type(DataEstudo)
if isinstance(b, DataEstudo):
return b.data
return None

Expand All @@ -99,7 +64,7 @@ def estatisticas_desvios(self) -> pd.DataFrame:
:return: As variáveis como um dataframe
:rtype: pd.DataFrame | None
"""
b = self._bloco_por_tipo(BlocoDesvios, 0)
if b is not None:
b = self.data.get_blocks_of_type(BlocoDesvios)
if isinstance(b, BlocoDesvios):
return b.data
return None
15 changes: 0 additions & 15 deletions idessem/dessem/avl_fpha1.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
ArquivoCSV,
)

# Para compatibilidade - até versão 1.0.0
from os.path import join
import warnings


class AvlFpha1(ArquivoCSV):
"""
Expand All @@ -27,17 +23,6 @@ class AvlFpha1(ArquivoCSV):
}
ENCODING = "iso-8859-1"

@classmethod
def le_arquivo(
cls, diretorio: str, nome_arquivo="AVL_FPHA1.DAT"
) -> "AvlFpha1":
msg = (
"O método le_arquivo(diretorio, nome_arquivo) será descontinuado"
+ " na versão 1.0.0 - use o método read(caminho_arquivo)"
)
warnings.warn(msg, category=FutureWarning)
return cls.read(join(diretorio, nome_arquivo))

@property
def tabela(self):
"""
Expand Down
23 changes: 7 additions & 16 deletions idessem/dessem/avl_fpha2.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
import pandas as pd # type: ignore
from datetime import datetime

# Para compatibilidade - até versão 1.0.0
from os.path import join
import warnings


class AvlFpha2(BlockFile):
"""
Expand All @@ -30,17 +26,6 @@ def __init__(self, data=...) -> None:
super().__init__(data)
self.__df_completo: Optional[pd.DataFrame] = None

@classmethod
def le_arquivo(
cls, diretorio: str, nome_arquivo="AVL_FPHA2.DAT"
) -> "AvlFpha2":
msg = (
"O método le_arquivo(diretorio, nome_arquivo) será descontinuado"
+ " na versão 1.0.0 - use o método read(caminho_arquivo)"
)
warnings.warn(msg, category=FutureWarning)
return cls.read(join(diretorio, nome_arquivo))

@property
def tabela(self):
"""
Expand All @@ -60,8 +45,14 @@ def tabela(self):
if self.__df_completo is None:
tabelas = self.data.of_type(TabelaAvlFpha2)
tabelas_validas = [t.data for t in tabelas if t is not None]
tabelas_validas = [
t for t in tabelas_validas if isinstance(t, pd.DataFrame)
]
tabelas_validas = [
t.dropna(axis=1, how="all") for t in tabelas_validas
]
self.__df_completo = pd.concat(
[t for t in tabelas_validas if isinstance(t, pd.DataFrame)],
tabelas_validas,
ignore_index=True,
)
return self.__df_completo
Expand Down
21 changes: 6 additions & 15 deletions idessem/dessem/avl_fpha3.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
import pandas as pd # type: ignore
from datetime import datetime

# Para compatibilidade - até versão 1.0.0
from os.path import join
import warnings


class AvlFpha3(BlockFile):
"""
Expand All @@ -30,17 +26,6 @@ def __init__(self, data=...) -> None:
super().__init__(data)
self.__df_completo: Optional[pd.DataFrame] = None

@classmethod
def le_arquivo(
cls, diretorio: str, nome_arquivo="AVL_FPHA3.DAT"
) -> "AvlFpha3":
msg = (
"O método le_arquivo(diretorio, nome_arquivo) será descontinuado"
+ " na versão 1.0.0 - use o método read(caminho_arquivo)"
)
warnings.warn(msg, category=FutureWarning)
return cls.read(join(diretorio, nome_arquivo))

@property
def tabela(self):
"""
Expand All @@ -61,6 +46,12 @@ def tabela(self):
if self.__df_completo is None:
tabelas = self.data.of_type(TabelaAvlFpha3)
tabelas_validas = [t.data for t in tabelas if t is not None]
tabelas_validas = [
t for t in tabelas_validas if isinstance(t, pd.DataFrame)
]
tabelas_validas = [
t.dropna(axis=1, how="all") for t in tabelas_validas
]
self.__df_completo = pd.concat(
[t for t in tabelas_validas if isinstance(t, pd.DataFrame)],
ignore_index=True,
Expand Down
Loading