bifacial_radiance icon indicating copy to clipboard operation
bifacial_radiance copied to clipboard

Better exception handling with gencumulativesky and makeModule

Open mikofski opened this issue 5 years ago • 3 comments

I know this issue has been raised before, I am using the latest version in Python-2 on linux. Should I be using Python-3?

tracebback:

In [2]: bifacial_radiance.gui()
Read all values
path = /home/mikm/myfolder
Getting weather file: USA_AZ_Safford.AWOS.722747_TMY3.epw
 ... OK!
Usage: SceneObj(moduletype)
No module type selected. Available module types: [u'Prism Solar Bi60 landscape', u'Prism Solar Bi60', u'test', u'2upTracker', u'cellModule']
Available module names: ['Prism Solar Bi60 landscape', 'Prism Solar Bi60', 'test', '2upTracker', 'cellModule']
('\nModule Name:', 'Prism_Solar_Bi60')
REWRITING pre-existing module file.
Module Prism Solar Bi60 successfully created

Using Pre-determined Module Type: Prism Solar Bi60
sceneDict Warning: Passed 'clearance_height' and 'hub_height' into makeScene. For this fixed tiltroutine, using 'clearance_height' and removing 'hub_height' from sceneDict
message: gencumulativesky: Error - invalid input parameter '-E'

Usage: gencumulativesky [-d] [+s1|+s2] [-a latitude] [-o longitude] [-l] [-m standard meridian] [-h hourshift] [-G|-B] <climate file>
(Note: longitude +ve East of Greenwich)

        -d      Ignore diffuse irradiance
        +s1     Use "smeared sun" approach (default)
        +s2     Use "binned sun" approach
        -l      Output luminance instead of radiance
        -G      File format is col1=global irradiance (W/m2), col2=diffuse irradiance
        -B      File format is col1=direct horizontal irradiance (W/m2), col2=diffuse irradiance
Created Demo1.oct
Linescan in process: Demo1_Front
message: rtrace: skybright`cumulative: undefined variable
Linescan in process: Demo1_Back
message: rtrace: skybright`cumulative: undefined variable
Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1540, in __call__
    return self.func(*args)
  File "/home/mikm/Projects/bifacial_radiance/bifacial_radiance/gui.py", line 412, in runBifacialRadiance
    cellLevelModuleParamsDict=cellLevelModuleParamsDict
  File "/home/mikm/Projects/bifacial_radiance/bifacial_radiance/modelchain.py", line 157, in runModelChain
    (sum(analysis.Wm2Back) / sum(analysis.Wm2Front)))
AttributeError: AnalysisObj instance has no attribute 'Wm2Back'

mikofski avatar Aug 16 '19 09:08 mikofski

I have a strong suspicion I am seeing this error because of #129 and #119 , but I still think it's worth fixing, because if that's the case then I think a more meaningful exception needs to be raised earlier, perhaps by capturing stdout or stderr from the gencumulativesky subprocess and checking to see if it was successful, and raising a meaningful exception if not.

mikofski avatar Aug 16 '19 20:08 mikofski

Hi mikofski,

I got the same error when I misspelled the tube material when creating my module. rad_obj.makeModule(... , material = 'spelled_wrong') I wrote Metalgrey, instead of Metal_Grey

Hope it helps.

costeladebarata avatar Sep 19 '19 04:09 costeladebarata

Correct, this issue arises because your gencumulativesky did not have a -E option. When gencumulativesky returned the error, it printed it, but the python software did not interrupt the operation or raise an exception. This could be solved by better exception handling...

cdeline avatar Oct 10 '19 16:10 cdeline