Skip to content

Commit

Permalink
Journal cleanup
Browse files Browse the repository at this point in the history
development journals cleanup
  • Loading branch information
shirubana committed Feb 14, 2020
1 parent 5ddba0a commit 9a55a25
Show file tree
Hide file tree
Showing 12 changed files with 3,272 additions and 3,966 deletions.
607 changes: 607 additions & 0 deletions docs/tutorials/(development) Glass Test.ipynb

Large diffs are not rendered by default.

125 changes: 125 additions & 0 deletions docs/tutorials/(development) Glass Test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#!/usr/bin/env python
# coding: utf-8

# In[1]:


import os
from pathlib import Path

testfolder = Path().resolve().parent.parent / 'bifacial_radiance' / 'TEMP'

# Another option using relative address; for some operative systems you might need '/' instead of '\'
# testfolder = os.path.abspath(r'..\..\bifacial_radiance\TEMP')
print ("Your simulation will be stored in %s" % testfolder)


# In[2]:


from bifacial_radiance import *
demo = RadianceObj('bifacial_example',str(testfolder))
demo.setGround(0.30) # This prints available materials.
epwfile = demo.getEPW(lat = 37.5, lon = -77.6) # This location corresponds to Richmond, VA.
metdata = demo.readWeatherFile(epwfile)
demo.gendaylit(metdata,8) # Noon, June 17th (timepoint # 4020)\


# In[16]:





# In[12]:


module_type = 'Bi60'

numcellsx = 6
numcellsy = 12
xcell = 0.156
ycell = 0.156
xcellgap = 0.02
ycellgap = 0.02

torquetube = True
diameter = 0.15
tubetype = 'round'
material = 'Metal_Grey'
xgap = 0.1
ygap = 0
zgap = 0.05
numpanels = 1
axisofrotationTorqueTube = False
glass = True

cellLevelModuleParams = {'numcellsx': numcellsx, 'numcellsy':numcellsy,
'xcell': xcell, 'ycell': ycell, 'xcellgap': xcellgap, 'ycellgap': ycellgap}

mymodule = demo.makeModule(name=module_type, torquetube=torquetube, diameter=diameter, tubetype=tubetype, material=material,
xgap=xgap, ygap=ygap, zgap=zgap, numpanels=numpanels,
cellLevelModuleParams=cellLevelModuleParams,
axisofrotationTorqueTube=axisofrotationTorqueTube, glass=glass, z=0.0002)

sceneDict = {'tilt':25,'pitch':5.5,'hub_height':1.0,'azimuth':90, 'nMods': 20, 'nRows': 1, originx=0, originy=0}
scene = demo.makeScene(module_type,sceneDict)
octfile = demo.makeOct(demo.getfilelist())


# In[15]:


sceneDict = {'tilt':25,'pitch':5.5,'hub_height':1.0,'azimuth':90, 'nMods': 20, 'nRows': 10, 'originx':0, 'originy':0}
scene = demo.makeScene(module_type,sceneDict)
octfile = demo.makeOct(demo.getfilelist())

Advanced Rendering:

My workflow for going from oct file to png is:
rvu -> rpict -> pcond -> pfilt -> ra_tiff -> convert
In detail:
1. Use rvu to view the oct file
rvu 1axis_07_01_08.oct
use aim and origin to move around, zoom in/out, etc
save a view file with view render.vf
2. Run rpict to render the image to hdr. This is the time consuming step. It takes between 1 and 3 hours depending on how complex the geometry is.
rpict -x 4800 -y 4800 -i -ps 1 -dp 530 -ar 964 -ds 0.016 -dj 1 -dt 0.03 -dc 0.9 -dr 5 -st 0.12 -ab 5 -aa 0.11 -ad 5800 -as 5800 -av 25 25 25 -lr 14 -lw 0.0002 -vf render.vf bifacial_example.oct > render.hdr
3. Run pcond to mimic human visual response:
pcond -h render.hdr > render.pcond.hdr
4. Resize and adjust exposure with pfilt
pfilt -e +0.2 -x /4 -y /4 render.pcond.hdr > render.pcond.pfilt.hdr
5. Convert hdr to tif
ra_tiff render.pcond.pfilt.hdr render.tif
6. Convert tif to png with imagemagick convert utility
convert render.tif render.png
7. Annotate the image with convert
convert render.png -fill black -gravity South -annotate +0+5 'Created with NREL bifacial_radiance https://github.com/NREL/bifacial_radiance' render_annotated.png

# In[8]:


analysis = AnalysisObj(octfile, demo.basename)


# In[9]:


frontscan, backscan = analysis.moduleAnalysis(scene)
results = analysis.analysis(octfile, demo.basename, frontscan, backscan)
load.read1Result('results\irr_bifacial_example.csv')


# In[10]:


frontscan, backscan = analysis.moduleAnalysis(scene, frontsurfaceoffset=0.02, backsurfaceoffset = 0.02)
results = analysis.analysis(octfile, demo.basename, frontscan, backscan)
load.read1Result('results\irr_bifacial_example.csv')


# In[ ]:




Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down
245 changes: 245 additions & 0 deletions docs/tutorials/(development) Sensor Position Sanity Check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
#!/usr/bin/env python
# coding: utf-8

# ## Sensor Position Sanity Check
#
# Extreme case test: 90 degree.

# <a id='step1'></a>

# In[1]:


import bifacial_radiance
import numpy as np
import os # this operative system to do teh relative-path testfolder for this example.
import pprint # We will be pretty-printing the trackerdictionary throughout to show its structure.


# In[2]:


testfolder = os.path.abspath(r'..\..\bifacial_radiance\TEMP')
albedo = "litesoil" # this is one of the options on ground.rad
lat = 37.5
lon = -77.6

# Scene variables
nMods = 1
nRows = 1
hub_height = 2.3 # meters
gcr = 0.35

moduletype = 'SimpleModule'
x=1
y=2
sensorsy = 4 # to make it fast

timeindex = 4020


# <a id='step3'></a>

# In[3]:


simulationName = 'Vertical-SouthFacing'
demo = bifacial_radiance.RadianceObj(simulationName, path = testfolder)
demo.setGround(albedo)
epwfile = demo.getEPW(lat = lat, lon = lon)
metdata = demo.readWeatherFile(weatherFile = epwfile)
demo.gendaylit(metdata,timeindex)
mymodule = demo.makeModule(name=moduletype, x=x, y=y)
sceneDict = {'gcr': gcr,'hub_height':hub_height, 'tilt': 90, 'azimuth': 180, 'nMods':nMods, 'nRows': nRows}
scene = demo.makeScene(moduletype,sceneDict)
octfile = demo.makeOct(demo.getfilelist())
analysis = bifacial_radiance.AnalysisObj(octfile, demo.basename)
frontscan, backscan = analysis.moduleAnalysis(scene, sensorsy = sensorsy)
results = analysis.analysis(octfile, demo.basename, frontscan, backscan)
bifacial_radiance.load.read1Result('results\irr_Vertical-SouthFacing.csv')


# In[4]:


pprint.pprint(frontscan)
pprint.pprint(backscan)


# In[5]:


frontscan['ystart'] = -0.5


# In[6]:


results = analysis.analysis(octfile, demo.basename+'_hack_ystart', frontscan, backscan)
bifacial_radiance.load.read1Result('results\irr_Vertical-SouthFacing_hack_ystart.csv')


# In[7]:


pprint.pprint(frontscan)
pprint.pprint(backscan)


# In[8]:


frontscan['orient'] = '-0.000 1.000 -0.000'


# In[9]:


results = analysis.analysis(octfile, demo.basename+'_hack_ystart_orient', frontscan, backscan)


# In[11]:


bifacial_radiance.load.read1Result('results\irr_Vertical-SouthFacing_hack_ystart_orient.csv')


# SUCCESS! Hitting the right Side now (front scan only)!
#
# ## Vertical East Facing

# In[12]:


simulationName = 'Vertical-EastFacing'
demo = bifacial_radiance.RadianceObj(simulationName, path = testfolder)
demo.setGround(albedo)
epwfile = demo.getEPW(lat = lat, lon = lon)
metdata = demo.readWeatherFile(weatherFile = epwfile)
demo.gendaylit(metdata,timeindex)
mymodule = demo.makeModule(name=moduletype, x=x, y=y)
sceneDict = {'gcr': gcr,'hub_height':hub_height, 'tilt': 90, 'azimuth': 90, 'nMods':nMods, 'nRows': nRows}
scene = demo.makeScene(moduletype,sceneDict)
octfile = demo.makeOct(demo.getfilelist())
analysis = bifacial_radiance.AnalysisObj(octfile, demo.basename)
frontscan, backscan = analysis.moduleAnalysis(scene, sensorsy = sensorsy)
results = analysis.analysis(octfile, demo.basename, frontscan, backscan)
bifacial_radiance.load.read1Result('results\irr_Vertical-EastFacing.csv')


# In[13]:


pprint.pprint(frontscan)
pprint.pprint(backscan)


# In[14]:


frontscan['xstart'] = 0.5


# In[15]:


results = analysis.analysis(octfile, demo.basename+'_hack_xstart', frontscan, backscan)
bifacial_radiance.load.read1Result('results\irr_Vertical-EastFacing_hack_xstart.csv')


# In[16]:


pprint.pprint(frontscan)
pprint.pprint(backscan)


# In[17]:


frontscan['orient'] = '-1.000 0.000 -0.000'


# In[18]:


results = analysis.analysis(octfile, demo.basename+'_hack_xstart_orient', frontscan, backscan)
bifacial_radiance.load.read1Result('results\irr_Vertical-EastFacing_hack_xstart_orient.csv')


# # Success! :D
#
# # 75 ?

# In[21]:


simulationName = 'Vertical-EastFacing-75'
demo = bifacial_radiance.RadianceObj(simulationName, path = testfolder)
demo.setGround(albedo)
epwfile = demo.getEPW(lat = lat, lon = lon)
metdata = demo.readWeatherFile(weatherFile = epwfile)
demo.gendaylit(metdata,timeindex)
mymodule = demo.makeModule(name=moduletype, x=x, y=y)
sceneDict = {'gcr': gcr,'hub_height':hub_height, 'tilt': 75, 'azimuth': 90, 'nMods':nMods, 'nRows': nRows}
scene = demo.makeScene(moduletype,sceneDict)
octfile = demo.makeOct(demo.getfilelist())
analysis = bifacial_radiance.AnalysisObj(octfile, demo.basename)
frontscan, backscan = analysis.moduleAnalysis(scene, sensorsy = sensorsy)
results = analysis.analysis(octfile, demo.basename, frontscan, backscan)
bifacial_radiance.load.read1Result('results\irr_Vertical-EastFacing.csv')


# ## =(

# In[30]:


simulationName = 'Flat-135'
demo = bifacial_radiance.RadianceObj(simulationName, path = testfolder)
demo.setGround(albedo)
epwfile = demo.getEPW(lat = lat, lon = lon)
metdata = demo.readWeatherFile(weatherFile = epwfile)
demo.gendaylit(metdata,timeindex)
mymodule = demo.makeModule(name=moduletype, x=0.001, y=y)
sceneDict = {'gcr': gcr,'hub_height':hub_height, 'tilt': 45, 'azimuth': 135, 'nMods':nMods, 'nRows': nRows}
scene = demo.makeScene(moduletype,sceneDict)
octfile = demo.makeOct(demo.getfilelist())
analysis = bifacial_radiance.AnalysisObj(octfile, demo.basename)
frontscan, backscan = analysis.moduleAnalysis(scene, sensorsy = sensorsy)
results = analysis.analysis(octfile, demo.basename, frontscan, backscan)
bifacial_radiance.load.read1Result('results\irr_Flat-135.csv')


# In[31]:


pprint.pprint(frontscan)
pprint.pprint(backscan)


# In[37]:


pprint.pprint(backscan)


# In[38]:


frontscan['orient']='-0.500 0.500 -0.707'
backscan['orient'] = '0.500 -0.500 0.707'


# In[39]:


results = analysis.analysis(octfile, demo.basename+'_hack_orient', frontscan, backscan)
bifacial_radiance.load.read1Result('results\irr_Flat-135_hack_orient.csv')


# In[ ]:




0 comments on commit 9a55a25

Please sign in to comment.