Commit 154b93fd authored by Bognár, Á.'s avatar Bognár, Á.
Browse files

Added tutorial to visualize simulated irradaince

Also made postprocess.view_idf_and_ill() able to return ax instead of plt.show() to use for animated plots.
parent 3722440c
...@@ -6,3 +6,6 @@ __pycache__/ ...@@ -6,3 +6,6 @@ __pycache__/
# docs # docs
.ipynb_checkpoints .ipynb_checkpoints
# test
tests/
...@@ -65,7 +65,7 @@ def view_idf_to_ax(fname=None, idf_txt=None, test=False): ...@@ -65,7 +65,7 @@ def view_idf_to_ax(fname=None, idf_txt=None, test=False):
ax.set_zlim(limits["z"]) ax.set_zlim(limits["z"])
return ax return ax
def view_idf_and_ill(p_name, idf_name, sps, ill, save_fig): def view_idf_and_ill(p_name, idf_name, sps, ill, save_fig, return_ax=False):
from geomeppy.geom.polygons import Polygon3D from geomeppy.geom.polygons import Polygon3D
"To view the e+ IDF and the DS sensorpoints together. Ill should be a pd.series with time in index" "To view the e+ IDF and the DS sensorpoints together. Ill should be a pd.series with time in index"
# TODO implement auto save fig: Save_fig False: no saving, True: save it to /geo # TODO implement auto save fig: Save_fig False: no saving, True: save it to /geo
...@@ -86,4 +86,7 @@ def view_idf_and_ill(p_name, idf_name, sps, ill, save_fig): ...@@ -86,4 +86,7 @@ def view_idf_and_ill(p_name, idf_name, sps, ill, save_fig):
except: except:
plt.savefig('{}.png'.format(p_name)) plt.savefig('{}.png'.format(p_name))
else: else:
plt.show(block=False) if return_ax:
return ax2
else:
plt.show(block=False)
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
import json
import os
import sys
sys.path.append(r'c:\TUe\SEAC\Git\daypym_gl2\daypym\daypym')
from postprocess import *
from daypym import *
## This tutorial shows how to visualize irradiance results with Daypym
# navigate to the project folder and run:
for f in os.listdir():
if f.endswith('.hea'):
project_name = f[:-4]
source_idf_name = r'{}.idf'.format(project_name)
# load teh previously calculated irradiance
ill = ill_to_df(p_name=project_name)
# read sensor point metadata json
with open('pts/{}.json'.format(project_name), 'r') as fp:
sps = json.load(fp)
# plot the sensor-point irradiance at a given timestep
t = pd.Timestamp('2001-06-06 15:10:00')
view_idf_and_ill(p_name=project_name, idf_name=source_idf_name, sps=sps,
ill=ill.loc[t, : ], save_fig=False)
# animated visualization of the results:
starttime = pd.Timestamp('2001-06-06 07:30:00')
endtime = pd.Timestamp('2001-06-06 19:50:00')
ill_t = ill.loc[starttime:endtime]
with open('pts/{}.json'.format(project_name), 'r') as fp:
sps2 = json.load(fp)
for t in ill_t.index:
ax = view_idf_and_ill(p_name=project_name, idf_name=source_idf_name,
sps=sps2, ill=ill.loc[t], save_fig=False,
return_ax=True)
min_irrad = ill.loc[t].min()
max_irrad = ill.loc[t].max()
mean_irrad = np.round(ill.loc[t].mean())
ax.set_title(str(t) + '\n'
+ 'G_min={}\n G_mean={}\n G_max={}'.format(min_irrad, mean_irrad, max_irrad))
plt.draw()
plt.pause(0.02)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment