NREL / bifacial_radiance

Toolkit for working with RADIANCE for the ray-trace modeling of Bifacial Photovoltaics
https://bifacial-radiance.readthedocs.io
BSD 3-Clause "New" or "Revised" License
91 stars 48 forks source link

How do I use my own weather files? #492

Closed AugustVan closed 3 months ago

AugustVan commented 1 year ago

What do I have to change in this piece of code to be able to use my own epw weather files? image

shirubana commented 1 year ago

in theory noting, if your EPW is in the right format for EPWs. IF it is giving an error that means some of the columns or formating is not the standard, check the documentation for EPW on the EnergyPlus webiste.

The function expects an EPW with extension EPW.

if you want to specify other formats, we currently support on hte main branch: source : str To help identify different types of .csv files. If None, it assumes it is a TMY3-style formated data. Current options: 'TMY3', 'solargis', 'EPW'

And the development branch has 'sam' (psm3 format) and NSRDB data input as well.

S.

AugustVan commented 11 months ago

I don't think i'm using the wrong file because it's an epw file, I just think it's my lack of programming skills. Would it be possible to show the lines of code it takes to use my own epw files?

shirubana commented 11 months ago

sure, you can either share it here, or to my email silvana.ovaitt@nrel.gov, or we can have a short meeting to iron it out (couple 30 mins spot open today and tomorrow but more on wednesday)

AugustVan commented 11 months ago

This is the code I have at the moment.

import os from pathlib import Path from bifacial_radiance import * import numpy as np import pandas as pd

testfolder = str(Path().resolve().parent.parent / 'bifacial_radiance' / 'TEMP' / 'August') if not os.path.exists(testfolder): os.makedirs(testfolder)

testopstelling = RadianceObj('x',str(testfolder))

testopstelling.setGround() albedo = 0.7 testopstelling.setGround(albedo)

GETTING WHEATER FILE

epwfile = testopstelling.getEPW(lat = 37.5, lon = -77.6) metdata = testopstelling.readWeatherFile(epwfile, coerce_year=2001) fullYear = True if fullYear: testopstelling.genCumSky() # entire year. else: timeindex = metdata.datetime.index(pd.to_datetime('2001-06-17 12:0:0 -7')) testopstelling.gendaylit(timeindex) # Noon, June 17th (timepoint # 4020)

CREATING A MODULE

moduletype = 'test-module'

num_panels = 1 x = 0 y = 0 x_gap = 0.20 y_gap = 0.10 z_gap = 0

num_cells_x = 12 num_cells_y = 24 x_cell = 0.17283 y_cell = 0.08692 x_cell_gap = 0.002 y_cell_gap = 0.002

cellLevelModuleParams = {'numcellsx': num_cells_y, 'numcellsy': num_cells_x, 'xcell': y_cell, 'ycell': x_cell, 'xcellgap': y_cell_gap, 'ycellgap': x_cell_gap}

module = testopstelling.makeModule(name=moduletype, x=x, y=y, numpanels=num_panels, xgap=x_gap, ygap=y_gap, cellModule=cellLevelModuleParams)

Making the scene

pitch = 9 # m albedo = 0.22 # 'grass' # ground albedo hub_height = 1.9 # m nMods = 6 # six modules per row. nRows = 3 # 3 row azimuth_ang = 270 # Facing west tilt = 90 # tilt.

sceneDict = {'tilt': tilt, 'pitch': pitch, 'hub_height': hub_height, 'azimuth': azimuth_ang, 'nMods': nMods, 'nRows': nRows}

scene = testopstelling.makeScene(module=moduletype, sceneDict=sceneDict)

CREATING FRAME

torquetubelength = 14.036 postheight = 0.05 postwidth = 0.03

post_x = -2.285 z_step = 1.148 y_step = 9

y = 9.127

for i in range(3): post_z = 2.9 for j in range(3): name = 'Post{}{}'.format(i, j) text = '! genbox Metal_Aluminum_Anodized torquetube_row2 {} {} {} | xform -t {} -0.2 0.15 | xform -t {} {} {} ' \ '| ' \ 'xform -rz 90'.format( torquetubelength, postheight, postwidth, (-torquetubelength + module.sceney) / 2.0, post_x, y, post_z) customObject = testopstelling.makeCustomObject(name, text) testopstelling.appendtoScene(radfile=scene.radfiles, customObject=customObject, text="!xform -rz 0") post_z -= z_step

y -= y_step

pileheight = 3.05 pilewidth = 0.05 piledepth = 0.05

x_offset = - 0.1 y_step = 2.15

x_value = -9 for i in range(3): y_value = -8.23 for j in range(7): name_string = 'pile{}{}'.format(i, j) text = ('! genbox Metal_Grey pile{}row{} '.format(i, j) + '{} {} {} '.format(pilewidth, piledepth, pileheight)

testopstelling.scene.showScene()

ANALYSIS

octfile = testopstelling.makeOct(testopstelling.getfilelist())

analysis = AnalysisObj(octfile, testopstelling.basename)

frontscan, backscan = analysis.moduleAnalysis(scene)

results = analysis.analysis(octfile, testopstelling.basename, frontscan, backscan)

load.read1Result('results\irr_x.csv')

bifacialityfactor = 0.9 print('Annual bifacial ratio: %0.2f ' %( np.mean(analysis.Wm2Back) * bifacialityfactor / np.mean(analysis.Wm2Front)) )

scene.saveImage() analysis.makeImage('side.vp') analysis.makeFalseColor('side.vp')

shirubana commented 11 months ago

Hi AugustVan

So, if you have an epw file you have to pass the file name/direction here:

epwfile= r'C:/Users/AugustVan/Documents/LocationEPWfile.epw
metdata = testopstelling.readWeatherFile(epwfile)

Let me know if this doesnt work

AugustVan commented 11 months ago

Hh I forgot the r' ', thanks alot!

shirubana commented 11 months ago

yeah python has weird things like that. lmk other questions through here or email

S.

cdeline commented 3 months ago

Closing this as solved.