Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
phumthep committed Sep 29, 2024
1 parent 264029d commit d9a2166
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 70 deletions.
5 changes: 5 additions & 0 deletions docs/source/api_pages/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

API Reference
===================================
.. toctree::
modules
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pownet.data\_processor module
-----------------------------

.. automodule:: pownet.data_processor
:imported-members:
:members:
:undoc-members:
:show-inheritance:
Expand All @@ -25,6 +26,7 @@ pownet.data\_utils module
-------------------------

.. automodule:: pownet.data_utils
:imported-members:
:members:
:undoc-members:
:show-inheritance:
Expand Down
16 changes: 15 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import sys
import os
import re

sys.path.insert(0, os.path.abspath("../../src/"))

# Import mock modules for readthedocs
autodoc_mock_imports = [
"datetime",
"pandas",
"gurobipy",
"highspy",
"networkx",
"numpy",
"matplotlib.pyplot",
"math",
"__future__",
"re",
]

# -- Project information

project = "PowNet"
Expand Down
6 changes: 1 addition & 5 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,4 @@ Content
pages/license
pages/acknowledgement
pages/publications
pages/api
api_pages/modules
api_pages/core
api_pages/modeling
api_pages/pownet
api_pages/api
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ dependencies = [
"matplotlib >= 3.7.1",
"numpy >= 1.24.3",
"pandas >= 1.5.3",
"mplcursors >= 0.5.1",
"pyomo >= 6.5.0",
"gurobipy >= 10.0.3",
"networkx >= 3.1.0",
"highspy >= 1.6.0"
Expand Down
1 change: 1 addition & 0 deletions src/pownet/core/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def __init__(
fuelmap: dict,
demand: pd.DataFrame,
) -> None:
"""Initialize the OutputProcessor object."""
self.year: int = year
self.fuelmap: dict = fuelmap
self.demand: pd.DataFrame = demand
Expand Down
4 changes: 2 additions & 2 deletions src/pownet/data_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import numpy as np
import pandas as pd

from pownet.folder_utils import get_model_dir, get_database_dir
from pownet.data_utils import get_dates
from .folder_utils import get_model_dir, get_database_dir
from .data_utils import get_dates


class DataProcessor:
Expand Down
108 changes: 53 additions & 55 deletions src/pownet/data_utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"""data_utils.py: functions for processing user inputs"""

import re
import datetime
import os

import numpy as np
import pandas as pd
from pownet.folder_utils import get_database_dir, get_output_dir

# from .folder_utils import get_database_dir, get_output_dir


def get_dates(year):
Expand Down Expand Up @@ -140,31 +138,31 @@ def get_current_time() -> str:
return datetime.datetime.now().strftime("%Y%m%d_%H%M")


def write_df_to_output_dir(
df: pd.DataFrame,
output_name: str,
model_id: str,
) -> None:
"""Write a dataframe to the output folder.
Args:
df: The dataframe to write.
output_name: The name of the output file.
model_id: The model ID.
Returns:
None
"""
# First check that the output directory exists. If not, create it.
if not os.path.exists(get_output_dir()):
os.makedirs(get_output_dir())
df.to_csv(
os.path.join(
get_output_dir(),
f"{model_id}_{output_name}.csv",
),
index=False,
)
# def write_df_to_output_dir(
# df: pd.DataFrame,
# output_name: str,
# model_id: str,
# ) -> None:
# """Write a dataframe to the output folder.

# Args:
# df: The dataframe to write.
# output_name: The name of the output file.
# model_id: The model ID.

# Returns:
# None
# """
# # First check that the output directory exists. If not, create it.
# if not os.path.exists(get_output_dir()):
# os.makedirs(get_output_dir())
# df.to_csv(
# os.path.join(
# get_output_dir(),
# f"{model_id}_{output_name}.csv",
# ),
# index=False,
# )


def calc_remaining_duration(
Expand Down Expand Up @@ -322,29 +320,29 @@ def parse_lmp(lmp: dict[str, float], sim_horizon: int, step_k: int) -> pd.DataFr
return lmp_df


def get_fuel_mix_order() -> list[str]:
"""Return the order of fuel mix for plotting.
We use this list to order the node variables dataframe.
Returns
list[str]: The order of fuel mix.
-------
"""
return pd.read_csv(
os.path.join(get_database_dir(), "fuels.csv"),
header=0,
)["name"].tolist()


def get_fuel_color_map() -> dict:
"""Return a map of fuel type to its color. This is defined in the database folder."""
fuel_color_map = (
pd.read_csv(
os.path.join(get_database_dir(), "fuels.csv"),
header=0,
usecols=["name", "color"],
)
.set_index("name")
.to_dict()["color"]
)
return fuel_color_map
# def get_fuel_mix_order() -> list[str]:
# """Return the order of fuel mix for plotting.
# We use this list to order the node variables dataframe.

# Returns
# list[str]: The order of fuel mix.
# -------
# """
# return pd.read_csv(
# os.path.join(get_database_dir(), "fuels.csv"),
# header=0,
# )["name"].tolist()


# def get_fuel_color_map() -> dict:
# """Return a map of fuel type to its color. This is defined in the database folder."""
# fuel_color_map = (
# pd.read_csv(
# os.path.join(get_database_dir(), "fuels.csv"),
# header=0,
# usecols=["name", "color"],
# )
# .set_index("name")
# .to_dict()["color"]
# )
# return fuel_color_map
5 changes: 0 additions & 5 deletions src/pownet/modeling/objfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

from __future__ import annotations

import gurobipy as gp
import gurobipy as GRB
import pandas as pd


""" Functions for the objective function
"""

Expand Down

0 comments on commit d9a2166

Please sign in to comment.