Skip to content

Commit

Permalink
updated bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanlassere committed May 4, 2024
1 parent e3cb3b7 commit 70083f1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 81 deletions.
3 changes: 1 addition & 2 deletions afc/ctrlWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,9 @@ def make_inputs(parameter, df, ext_df=pd.DataFrame(), return_json=True):
return inputs

if __name__ == '__main__':
import datetime as dtm

root = os.getcwd()

from afc.utility.weather import read_tmy3
from afc.utility.weather import example_weather_forecast
# from afc.radiance.configs import get_config
from afc.defaultConfig import default_parameter
Expand Down Expand Up @@ -488,3 +486,4 @@ def make_inputs(parameter, df, ext_df=pd.DataFrame(), return_json=True):
plot_standard1(pd.concat([wf, df], axis=1).ffill().iloc[:-1])
except:
pass

8 changes: 4 additions & 4 deletions afc/utility/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,19 @@ def get_forecast(st=dt.datetime.now(), tz=-8,


def example_weather_forecast(date=None, horizon=24):
"""Reads weather forecast CSV"""
if not date:
# select today's date
start_time = dt.datetime.now().date()
else:
start_time = pd.to_datetime(date)

# read weather (forecast) data
weather_path = os.path.join(os.path.dirname(root), 'resources', 'weather',
'USA_CA_San.Francisco.Intl.AP.724940_TMY3.csv')
weather, info = read_tmy3(weather_path, coerce_year=start_time.year)
weather = read_tmy3(weather_path, coerce_year=start_time.year) [0]
weather = weather.resample('5min').interpolate()

# output data
wf = weather.loc[start_time:start_time+pd.DateOffset(hours=horizon),]
wf = wf[['temp_air','dni','dhi','wind_speed']+['ghi']].copy()
return wf
return wf

78 changes: 5 additions & 73 deletions dev/Development-ControllerWrapper.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,76 +13,10 @@
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Found existing installation: afc 1.2.0\n",
"Uninstalling afc-1.2.0:\n",
" Successfully uninstalled afc-1.2.0\n",
"\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n",
"\u001b[0mProcessing /home/user/Desktop/AFC\n",
" Preparing metadata (setup.py) ... \u001b[?25ldone\n",
"\u001b[?25hCollecting doper@ git+https://github.com/LBNL-ETA/DOPER (from afc==1.2.0)\n",
" Cloning https://github.com/LBNL-ETA/DOPER to /tmp/pip-install-fknv4zme/doper_4ec90b40aecc435ebf8a623ab59a2061\n",
" Running command git clone --filter=blob:none --quiet https://github.com/LBNL-ETA/DOPER /tmp/pip-install-fknv4zme/doper_4ec90b40aecc435ebf8a623ab59a2061\n",
" Resolved https://github.com/LBNL-ETA/DOPER to commit 139ddd78c856b12385fb9d9b72f533b348006984\n",
" Preparing metadata (setup.py) ... \u001b[?25ldone\n",
"\u001b[?25hRequirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from afc==1.2.0) (2.1.4)\n",
"Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from afc==1.2.0) (1.26.3)\n",
"Requirement already satisfied: pvlib in /usr/local/lib/python3.10/dist-packages (from afc==1.2.0) (0.10.3)\n",
"Requirement already satisfied: fmlc in /usr/local/lib/python3.10/dist-packages (from afc==1.2.0) (1.2.2)\n",
"Requirement already satisfied: frads>=1.2.3 in /usr/local/lib/python3.10/dist-packages (from afc==1.2.0) (1.2.5)\n",
"Requirement already satisfied: epmodel>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from frads>=1.2.3->afc==1.2.0) (0.6.0)\n",
"Requirement already satisfied: pyradiance>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from frads>=1.2.3->afc==1.2.0) (0.3.1)\n",
"Requirement already satisfied: pywincalc>=3.1.0 in /usr/local/lib/python3.10/dist-packages (from frads>=1.2.3->afc==1.2.0) (3.3.1)\n",
"Requirement already satisfied: pyenergyplus-lbnl>=23.2.0 in /usr/local/lib/python3.10/dist-packages (from frads>=1.2.3->afc==1.2.0) (23.2.0)\n",
"Requirement already satisfied: scipy>=1.10.1 in /usr/local/lib/python3.10/dist-packages (from frads>=1.2.3->afc==1.2.0) (1.11.4)\n",
"Requirement already satisfied: pyomo>6.0 in /usr/local/lib/python3.10/dist-packages (from doper@ git+https://github.com/LBNL-ETA/DOPER->afc==1.2.0) (6.7.0)\n",
"Requirement already satisfied: matplotlib in /usr/local/lib/python3.10/dist-packages (from doper@ git+https://github.com/LBNL-ETA/DOPER->afc==1.2.0) (3.8.2)\n",
"Requirement already satisfied: pyutilib in /usr/local/lib/python3.10/dist-packages (from doper@ git+https://github.com/LBNL-ETA/DOPER->afc==1.2.0) (6.0.0)\n",
"Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from fmlc->afc==1.2.0) (2.31.0)\n",
"Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.10/dist-packages (from pandas->afc==1.2.0) (2.8.2)\n",
"Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->afc==1.2.0) (2023.3.post1)\n",
"Requirement already satisfied: tzdata>=2022.1 in /usr/local/lib/python3.10/dist-packages (from pandas->afc==1.2.0) (2023.4)\n",
"Requirement already satisfied: h5py in /usr/local/lib/python3.10/dist-packages (from pvlib->afc==1.2.0) (3.10.0)\n",
"Requirement already satisfied: pydantic>=2.3.0 in /usr/local/lib/python3.10/dist-packages (from epmodel>=0.6.0->frads>=1.2.3->afc==1.2.0) (2.7.1)\n",
"Requirement already satisfied: ply in /usr/local/lib/python3.10/dist-packages (from pyomo>6.0->doper@ git+https://github.com/LBNL-ETA/DOPER->afc==1.2.0) (3.11)\n",
"Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.8.2->pandas->afc==1.2.0) (1.16.0)\n",
"Requirement already satisfied: deprecation in /usr/local/lib/python3.10/dist-packages (from pywincalc>=3.1.0->frads>=1.2.3->afc==1.2.0) (2.1.0)\n",
"Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->doper@ git+https://github.com/LBNL-ETA/DOPER->afc==1.2.0) (1.2.0)\n",
"Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib->doper@ git+https://github.com/LBNL-ETA/DOPER->afc==1.2.0) (0.12.1)\n",
"Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib->doper@ git+https://github.com/LBNL-ETA/DOPER->afc==1.2.0) (4.47.0)\n",
"Requirement already satisfied: kiwisolver>=1.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->doper@ git+https://github.com/LBNL-ETA/DOPER->afc==1.2.0) (1.4.5)\n",
"Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib->doper@ git+https://github.com/LBNL-ETA/DOPER->afc==1.2.0) (23.2)\n",
"Requirement already satisfied: pillow>=8 in /usr/local/lib/python3.10/dist-packages (from matplotlib->doper@ git+https://github.com/LBNL-ETA/DOPER->afc==1.2.0) (10.2.0)\n",
"Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->doper@ git+https://github.com/LBNL-ETA/DOPER->afc==1.2.0) (3.1.1)\n",
"Requirement already satisfied: nose in /usr/local/lib/python3.10/dist-packages (from pyutilib->doper@ git+https://github.com/LBNL-ETA/DOPER->afc==1.2.0) (1.3.7)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->fmlc->afc==1.2.0) (3.3.2)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->fmlc->afc==1.2.0) (3.6)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->fmlc->afc==1.2.0) (2.1.0)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->fmlc->afc==1.2.0) (2023.11.17)\n",
"Requirement already satisfied: annotated-types>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.3.0->epmodel>=0.6.0->frads>=1.2.3->afc==1.2.0) (0.6.0)\n",
"Requirement already satisfied: pydantic-core==2.18.2 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.3.0->epmodel>=0.6.0->frads>=1.2.3->afc==1.2.0) (2.18.2)\n",
"Requirement already satisfied: typing-extensions>=4.6.1 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.3.0->epmodel>=0.6.0->frads>=1.2.3->afc==1.2.0) (4.11.0)\n",
"Building wheels for collected packages: afc\n",
" Building wheel for afc (setup.py) ... \u001b[?25ldone\n",
"\u001b[?25h Created wheel for afc: filename=afc-1.2.0-py3-none-any.whl size=7140498 sha256=2615987406bf8d600e7b786096a5f60bebd8d1b78035dc12ff45bd4d9aea6b2d\n",
" Stored in directory: /tmp/pip-ephem-wheel-cache-m9to4vo4/wheels/47/18/fc/44e5e4fb6854bba4c476cfaacb67ae1821009f082ffb9c5a30\n",
"Successfully built afc\n",
"Installing collected packages: afc\n",
"Successfully installed afc-1.2.0\n",
"\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n",
"\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.0\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython3 -m pip install --upgrade pip\u001b[0m\n"
]
}
],
"outputs": [],
"source": [
" !pip uninstall -y afc\n",
" !pip install .."
"#!pip uninstall -y afc\n",
"#!pip install .."
]
},
{
Expand Down Expand Up @@ -132,9 +66,9 @@
"CO2 Emissions [kg]\t\t0.0\n",
"\n",
"Duration:\n",
" {'duration': {'radiance': 27.029191255569458, 'glare': 2.0114641189575195, 'varts': 0.14593076705932617, 'optall': 0.29031968116760254, 'outputs': 0.0016021728515625, 'all': 33.03873920440674}}\n",
" {'duration': {'radiance': 27.060535430908203, 'glare': 1.9472463130950928, 'varts': 0.13808465003967285, 'optall': 0.28128671646118164, 'outputs': 0.001566171646118164, 'all': 32.997591495513916}}\n",
"Optimization:\n",
" {'opt-stats': {'duration': 0.19099187850952148, 'termination': 'optimal', 'objective': 21.11283136}}\n"
" {'opt-stats': {'duration': 0.19169211387634277, 'termination': 'optimal', 'objective': 21.11283136}}\n"
]
},
{
Expand Down Expand Up @@ -607,11 +541,9 @@
" return inputs\n",
"\n",
"if __name__ == '__main__':\n",
" import datetime as dtm\n",
"\n",
" root = os.getcwd()\n",
"\n",
" from afc.utility.weather import read_tmy3\n",
" from afc.utility.weather import example_weather_forecast\n",
" # from afc.radiance.configs import get_config\n",
" from afc.defaultConfig import default_parameter\n",
Expand Down
3 changes: 2 additions & 1 deletion examples/example_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ def example1():
# read weather (forecast) data
# this would normally come from a weather forecast module
wf = example_weather_forecast(date='2023-07-01')
df = wf[wf.index.date == wf.index[0].date()]

# Initialize controller
ctrl = Controller()

# Make inputs
parameter = default_parameter()
inputs = make_inputs(parameter, wf)
inputs = make_inputs(parameter, df)

# Query controller
log = ctrl.do_step(inputs=inputs) # run controller
Expand Down
3 changes: 2 additions & 1 deletion test/test_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ def test1():

# read weather (forecast) data
wf = example_weather_forecast(date='2023-07-01')
df = wf[wf.index.date == wf.index[0].date()]

# Initialize controller
ctrl = Controller()

# Make inputs
parameter = default_parameter()
inputs = make_inputs(parameter, wf)
inputs = make_inputs(parameter, df)

# Query controller
ctrl.do_step(inputs=inputs)
Expand Down

0 comments on commit 70083f1

Please sign in to comment.