From 2caeb8aa1ec17acb347395ddb05fa006ebc4b191 Mon Sep 17 00:00:00 2001 From: cdeline Date: Tue, 3 Sep 2024 16:18:16 -0600 Subject: [PATCH] get bifacialityfactor from scene in call to calculateResultsGencumsky1axis reduce CompiledResults savefile to 3 digits --- bifacial_radiance/main.py | 19 +- bifacial_radiance/module.py | 6 +- .../21 - Weather to Module Performance.ipynb | 587 ++++++++++++++++-- .../21 - Weather to Module Performance.py | 74 ++- 4 files changed, 602 insertions(+), 84 deletions(-) diff --git a/bifacial_radiance/main.py b/bifacial_radiance/main.py index 7e51e26c..85a1e625 100644 --- a/bifacial_radiance/main.py +++ b/bifacial_radiance/main.py @@ -2529,7 +2529,8 @@ def makeScene1axis(self, trackerdict=None, module=None, sceneDict=None, module : str or ModuleObj Name or ModuleObj created with makeModule() sceneDict : - Dictionary with keys:`tilt`, `hub_height`, `pitch`, `azimuth` + Dictionary with keys:`tilt`, `hub_height`, `pitch` (or GCR), `azimuth`, + optional: 'originx', 'originy' cumulativesky : bool Defines if sky will be generated with cumulativesky or gendaylit. customtext : str @@ -3065,8 +3066,6 @@ def _printRow(analysisobj, key): meteo_data = _trackerMeteo(trackerdict[key]) - - try: for analysis in trackerdict[key]['AnalysisObj']: # loop over multiple row & module in trackerDict['AnalysisObj'] @@ -3100,12 +3099,16 @@ def _printRow(analysisobj, key): except KeyError: pass - + if module is None: + module_local = trackerdict[keys_all[0]]['scenes'][analysis.sceneNum].module + else: + module_local = module self.CompiledResults = performance.calculateResultsGencumsky1axis(results=self.CompiledResults, - bifacialityfactor=1.0, + bifacialityfactor=module_local.bifi, fillcleanedSensors=True, agriPV=False) - self.CompiledResults.to_csv(os.path.join('results', 'Cumulative_Results.csv')) + self.CompiledResults.to_csv(os.path.join('results', 'Cumulative_Results.csv'), + float_format='%0.3f') self.trackerdict = trackerdict return self.CompiledResults @@ -5263,7 +5266,7 @@ def _checkPath(rowpath): # create the file structure if it doesn't exist savefile = 'compiledRow_{}.csv'.format(rowWanted) df_row.to_csv(os.path.join(rowpath, savefile), sep = ',', - index = False) + index=False, float_format='%0.3f') return df_row @@ -5321,7 +5324,7 @@ def analyzeField(self, octfile, scene, name=None, savefile = 'compiledField_{}.csv'.format(name) result.to_csv(os.path.join(fieldpath, savefile), sep = ',', - index = False) + index=False, float_format='%0.3f') return result diff --git a/bifacial_radiance/module.py b/bifacial_radiance/module.py index 6c514f2c..07e38c69 100644 --- a/bifacial_radiance/module.py +++ b/bifacial_radiance/module.py @@ -694,7 +694,7 @@ def _makeModuleFromDict(self, x=None, y=None, z=None, xgap=None, ygap=None, return text #End of makeModuleFromDict() - def addCEC(self, CECMod, glassglass=False, bifi=None): + def addCEC(self, CECMod, glassglass=None, bifi=None): """ @@ -708,8 +708,8 @@ def addCEC(self, CECMod, glassglass=False, bifi=None): """ keys = ['alpha_sc', 'a_ref', 'I_L_ref', 'I_o_ref', 'R_sh_ref', 'R_s', 'Adjust'] - - self.glassglass = glassglass + if glassglass is not None: + self.glassglass = glassglass if bifi: self.bifi = bifi diff --git a/docs/tutorials/21 - Weather to Module Performance.ipynb b/docs/tutorials/21 - Weather to Module Performance.ipynb index be0a9ee6..77801e42 100644 --- a/docs/tutorials/21 - Weather to Module Performance.ipynb +++ b/docs/tutorials/21 - Weather to Module Performance.ipynb @@ -95,7 +95,7 @@ }, { "cell_type": "markdown", - "id": "3f847fea", + "id": "2469642f", "metadata": {}, "source": [ "## Geting a CEC Module to pass into demo.makeModule" @@ -104,7 +104,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "aa374016", + "id": "1423a9f2", "metadata": {}, "outputs": [], "source": [ @@ -114,7 +114,7 @@ }, { "cell_type": "markdown", - "id": "864d0412", + "id": "d1715477", "metadata": {}, "source": [ "Find the module that you want. In this case we know it's a SunPower of model SPR-E19-310-COM. \n", @@ -125,7 +125,7 @@ { "cell_type": "code", "execution_count": 5, - "id": "0ba97ef9", + "id": "fd6a686c", "metadata": {}, "outputs": [ { @@ -147,7 +147,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5ee82ada", + "id": "d2db8630", "metadata": {}, "outputs": [], "source": [] @@ -186,7 +186,7 @@ }, { "cell_type": "markdown", - "id": "63433b04", + "id": "84a1a789", "metadata": {}, "source": [ "The CEC data should be passed into the ModuleObj, either at time of creation, or sometime before it is passed into makeScene." @@ -195,7 +195,7 @@ { "cell_type": "code", "execution_count": 7, - "id": "3a123afd", + "id": "9370c9c2", "metadata": { "scrolled": true }, @@ -218,16 +218,16 @@ }, { "cell_type": "markdown", - "id": "6fc18e50", + "id": "27d8bd56", "metadata": {}, "source": [ - "The same data can be passed after the ModuleObj's definition:" + "The same data could instead be passed after the ModuleObj's definition, or at time of performance analysis:" ] }, { "cell_type": "code", "execution_count": 8, - "id": "6aa21855", + "id": "111bdbd2", "metadata": {}, "outputs": [], "source": [ @@ -237,7 +237,36 @@ { "cell_type": "code", "execution_count": 9, - "id": "3eca187d", + "id": "1f2e3cd4", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Module Name: test\n", + "Module test updated in module.json\n" + ] + } + ], + "source": [ + "# Let's make a second module, and set it to the default Prism Solar module type\n", + "mymodule2 = demo.makeModule(name='test', x=1, y=2, bifi=0.8, CECMod=None) " + ] + }, + { + "cell_type": "markdown", + "id": "3ba61504", + "metadata": {}, + "source": [ + "We're going to set up two scenes, each with a different module type!" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "10e35e7c", "metadata": {}, "outputs": [ { @@ -246,6 +275,38 @@ "text": [ "Creating ~2 skyfiles. \n", "Created 2 skyfiles in /skies/\n", + "\n", + "Making ~2 .rad files for gendaylit 1-axis workflow (this takes a minute..)\n", + "2 Radfiles created in /objects/\n" + ] + } + ], + "source": [ + "sceneDict = {'tilt': 0, 'azimuth': 180, 'pitch': 5,'hub_height':1.5, 'nMods':5, 'nRows': 2}\n", + "sceneDict2 = {'tilt': 0, 'azimuth': 180, 'pitch': 5,'hub_height':2.5, 'nMods':2, 'nRows': 1, 'originx': -15}\n", + "trackerdict = demo.set1axis(metdata = metdata, cumulativesky = False)\n", + "trackerdict = demo.gendaylit1axis()\n", + "trackerdict = demo.makeScene1axis(trackerdict, module = mymodule, sceneDict = sceneDict)" + ] + }, + { + "cell_type": "markdown", + "id": "211eddf7", + "metadata": {}, + "source": [ + "Make a second scene with the other module type" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "29c4a111", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ "\n", "Making ~2 .rad files for gendaylit 1-axis workflow (this takes a minute..)\n", "2 Radfiles created in /objects/\n", @@ -253,24 +314,30 @@ "Making 2 octfiles in root directory.\n", "Created 1axis_2021-01-13_1100.oct\n", "Created 1axis_2021-01-13_1200.oct\n", - "Linescan in process: 1axis_2021-01-13_1100_Scene0_Row1_Module2_Front\n", - "Linescan in process: 1axis_2021-01-13_1100_Scene0_Row1_Module2_Back\n", - "Saved: results\\irr_1axis_2021-01-13_1100_Scene0_Row1_Module2.csv\n", - "Index: 2021-01-13_1100. Wm2Front: 254.17376666666667. Wm2Back: 45.14680666666666\n", - "Linescan in process: 1axis_2021-01-13_1200_Scene0_Row1_Module2_Front\n", - "Linescan in process: 1axis_2021-01-13_1200_Scene0_Row1_Module2_Back\n", - "Saved: results\\irr_1axis_2021-01-13_1200_Scene0_Row1_Module2.csv\n", - "Index: 2021-01-13_1200. Wm2Front: 253.0892. Wm2Back: 43.43526333333333\n" + "Linescan in process: 1axis_2021-01-13_1100_Scene0_Row1_Module3_Front\n", + "Linescan in process: 1axis_2021-01-13_1100_Scene0_Row1_Module3_Back\n", + "Saved: results\\irr_1axis_2021-01-13_1100_Scene0_Row1_Module3.csv\n", + "Index: 2021-01-13_1100. Wm2Front: 254.2473666666667. Wm2Back: 39.878330000000005\n", + "Linescan in process: 1axis_2021-01-13_1200_Scene0_Row1_Module3_Front\n", + "Linescan in process: 1axis_2021-01-13_1200_Scene0_Row1_Module3_Back\n", + "Saved: results\\irr_1axis_2021-01-13_1200_Scene0_Row1_Module3.csv\n", + "Index: 2021-01-13_1200. Wm2Front: 253.52549999999997. Wm2Back: 38.10270333333333\n", + "Linescan in process: 1axis_2021-01-13_1100_Scene1_Row1_Module1_Front\n", + "Linescan in process: 1axis_2021-01-13_1100_Scene1_Row1_Module1_Back\n", + "Saved: results\\irr_1axis_2021-01-13_1100_Scene1_Row1_Module1.csv\n", + "Index: 2021-01-13_1100. Wm2Front: 253.4396. Wm2Back: 52.886446666666664\n", + "Linescan in process: 1axis_2021-01-13_1200_Scene1_Row1_Module1_Front\n", + "Linescan in process: 1axis_2021-01-13_1200_Scene1_Row1_Module1_Back\n", + "Saved: results\\irr_1axis_2021-01-13_1200_Scene1_Row1_Module1.csv\n", + "Index: 2021-01-13_1200. Wm2Front: 252.89083333333335. Wm2Back: 50.851236666666665\n" ] } ], "source": [ - "sceneDict = {'tilt': 10, 'azimuth': 180, 'pitch': 5,'hub_height':1.5, 'nMods':3, 'nRows': 2}\n", - "trackerdict = demo.set1axis(metdata = metdata, cumulativesky = False)\n", - "trackerdict = demo.gendaylit1axis()\n", - "trackerdict = demo.makeScene1axis(trackerdict, module = mymodule, sceneDict = sceneDict)\n", + "trackerdict = demo.makeScene1axis(trackerdict, module = mymodule2, sceneDict=sceneDict2, append=True)\n", "trackerdict = demo.makeOct1axis()\n", - "trackerdict = demo.analysis1axis(sensorsy=3)" + "trackerdict = demo.analysis1axis(sensorsy=3)\n", + "trackerdict = demo.analysis1axis(sensorsy=3, sceneNum=1)" ] }, { @@ -283,7 +350,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 14, "id": "7bbf6db6", "metadata": {}, "outputs": [ @@ -291,34 +358,85 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'2021-01-13_1100': {'surf_azm': 90.0, 'surf_tilt': 44.14, 'theta': -44.14, 'dni': 144, 'ghi': 211, 'dhi': 149, 'temp_air': 4.6, 'wind_speed': 3.8, 'skyfile': 'skies\\\\sky2_37.5_-77.33_2021-01-13_1100.rad', 'scenes': [{'module': {'x': 1, 'y': 2, 'z': 0.02, 'modulematerial': 'black', 'scenex': 1.01, 'sceney': 2.0, 'scenez': 0.1, 'numpanels': 1, 'bifi': 0.9, 'text': '! genbox black test-module 1 2 0.02 | xform -t -0.5 -1.0 0 -a 1 -t 0 2.0 0', 'modulefile': 'objects\\\\test-module.rad', 'glass': False, 'offsetfromaxis': 0, 'xgap': 0.01, 'ygap': 0.0, 'zgap': 0.1}, 'modulefile': 'objects\\\\test-module.rad', 'hpc': False, 'name': 'Scene0', 'gcr': 0.4, 'text': '!xform -rx 44.14 -t 0 0 1.5 -a 3 -t 1.01 0 0 -a 2 -t 0 5 0 -i 1 -t -1.01 -0.0 0 -rz 90.0 -t 0 0 0 \"objects\\\\test-module.rad\"', 'radfiles': 'objects\\\\1axis2021-01-13_1100__C_0.80_rtr_5.00_tilt_44_3modsx2rows_origin0,0.rad', 'sceneDict': {'tilt': 44.14, 'azimuth': 90.0, 'pitch': 5, 'nMods': 3, 'nRows': 2, 'modulez': 0.02, 'axis_tilt': 0, 'originx': 0, 'originy': 0, 'hub_height': 1.5}}], 'octfile': '1axis_2021-01-13_1100.oct', 'AnalysisObj': [{'octfile': '1axis_2021-01-13_1100.oct', 'name': '1axis_2021-01-13_1100_Scene0', 'hpc': False, 'modWanted': 2, 'rowWanted': 1, 'sceneNum': 0, 'power_data': None, 'columns': ['hpc', 'modWanted', 'name', 'octfile', 'power_data', 'rowWanted', 'sceneNum'], 'methods': ['analysis', 'analyzeField', 'analyzeRow', 'calc_performance', 'getResults', 'groundAnalysis', 'makeFalseColor', 'makeImage', 'moduleAnalysis'], 'x': array([ 0.3734448 , 0.01462469, -0.3441954 ]), 'y': array([ 2.286690e-17, 8.955042e-19, -2.107589e-17]), 'z': array([1.166863, 1.51507 , 1.863277]), 'rearZ': array([1.151075, 1.499282, 1.847489]), 'mattype': array(['a1.0.a0.test-module.6457', 'a1.0.a0.test-module.6457',\n", - " 'a1.0.a0.test-module.6457'], dtype=object), 'rearMat': array(['a1.0.a0.test-module.2310', 'a1.0.a0.test-module.2310',\n", - " 'a1.0.a0.test-module.2310'], dtype=object), 'Wm2Front': array([253.6018, 254.6151, 254.3044]), 'Wm2Back': array([44.61458, 44.93219, 45.89365]), 'Back/FrontRatio': array([0.17592306, 0.17647034, 0.18046668]), 'backRatio': array([0.17592306, 0.17647034, 0.18046668]), 'rearX': array([ 0.3581237 , -0.00069641, -0.3595166 ]), 'rearY': array([ 2.192875e-17, -4.264306e-20, -2.201404e-17])}]}, '2021-01-13_1200': {'surf_azm': 90.0, 'surf_tilt': 21.2, 'theta': -21.2, 'dni': 97, 'ghi': 249, 'dhi': 200, 'temp_air': 6.5, 'wind_speed': 3.9, 'skyfile': 'skies\\\\sky2_37.5_-77.33_2021-01-13_1200.rad', 'scenes': [{'module': {'x': 1, 'y': 2, 'z': 0.02, 'modulematerial': 'black', 'scenex': 1.01, 'sceney': 2.0, 'scenez': 0.1, 'numpanels': 1, 'bifi': 0.9, 'text': '! genbox black test-module 1 2 0.02 | xform -t -0.5 -1.0 0 -a 1 -t 0 2.0 0', 'modulefile': 'objects\\\\test-module.rad', 'glass': False, 'offsetfromaxis': 0, 'xgap': 0.01, 'ygap': 0.0, 'zgap': 0.1}, 'modulefile': 'objects\\\\test-module.rad', 'hpc': False, 'name': 'Scene0', 'gcr': 0.4, 'text': '!xform -rx 21.2 -t 0 0 1.5 -a 3 -t 1.01 0 0 -a 2 -t 0 5 0 -i 1 -t -1.01 -0.0 0 -rz 90.0 -t 0 0 0 \"objects\\\\test-module.rad\"', 'radfiles': 'objects\\\\1axis2021-01-13_1200__C_1.14_rtr_5.00_tilt_21_3modsx2rows_origin0,0.rad', 'sceneDict': {'tilt': 21.2, 'azimuth': 90.0, 'pitch': 5, 'nMods': 3, 'nRows': 2, 'modulez': 0.02, 'axis_tilt': 0, 'originx': 0, 'originy': 0, 'hub_height': 1.5}}], 'octfile': '1axis_2021-01-13_1200.oct', 'AnalysisObj': [{'octfile': '1axis_2021-01-13_1200.oct', 'name': '1axis_2021-01-13_1200_Scene0', 'hpc': False, 'modWanted': 2, 'rowWanted': 1, 'sceneNum': 0, 'power_data': None, 'columns': ['hpc', 'modWanted', 'name', 'octfile', 'power_data', 'rowWanted', 'sceneNum'], 'methods': ['analysis', 'analyzeField', 'analyzeRow', 'calc_performance', 'getResults', 'groundAnalysis', 'makeFalseColor', 'makeImage', 'moduleAnalysis'], 'x': array([ 0.473756 , 0.00759412, -0.4585678 ]), 'y': array([ 2.900919e-17, 4.650055e-19, -2.807918e-17]), 'z': array([1.338767, 1.519579, 1.700391]), 'rearZ': array([1.318255, 1.499068, 1.67988 ]), 'mattype': array(['a1.0.a0.test-module.6457', 'a1.0.a0.test-module.6457',\n", - " 'a1.0.a0.test-module.6457'], dtype=object), 'rearMat': array(['a1.0.a0.test-module.2310', 'a1.0.a0.test-module.2310',\n", - " 'a1.0.a0.test-module.2310'], dtype=object), 'Wm2Front': array([252.9921, 253.0892, 253.1863]), 'Wm2Back': array([43.26411, 43.18745, 43.85423]), 'Back/FrontRatio': array([0.17100905, 0.17064055, 0.17320865]), 'backRatio': array([0.17100905, 0.17064055, 0.17320865]), 'rearX': array([ 4.658003e-01, -3.616246e-04, -4.665235e-01]), 'rearY': array([ 2.852204e-17, -2.214312e-20, -2.856633e-17])}]}}\n" + "No CECModule data passed; using default for Prism Solar BHC72-400\n", + " timestamp name modNum rowNum sceneNum \\\n", + "0 2021-01-13_1100 1axis_2021-01-13_1100_Scene0 3 1 0 \n", + "1 2021-01-13_1100 1axis_2021-01-13_1100_Scene1 1 1 1 \n", + "2 2021-01-13_1200 1axis_2021-01-13_1200_Scene0 3 1 0 \n", + "3 2021-01-13_1200 1axis_2021-01-13_1200_Scene1 1 1 1 \n", + "\n", + " x \\\n", + "0 [0.3734448, 0.01462469, -0.3441954] \n", + "1 [-14.62656, -14.98538, -15.3442] \n", + "2 [0.473756, 0.007594116, -0.4585678] \n", + "3 [-14.52624, -14.99241, -15.45857] \n", + "\n", + " y \\\n", + "0 [2.28669e-17, 8.955042e-19, -2.107589e-17] \n", + "1 [2.28669e-17, 8.955042e-19, -2.107589e-17] \n", + "2 [2.900919e-17, 4.650055e-19, -2.807918e-17] \n", + "3 [2.900919e-17, 4.650055e-19, -2.807918e-17] \n", + "\n", + " z \\\n", + "0 [1.166863, 1.51507, 1.863277] \n", + "1 [2.166863, 2.51507, 2.863277] \n", + "2 [1.338767, 1.519579, 1.700391] \n", + "3 [2.338767, 2.519579, 2.700391] \n", + "\n", + " mattype \\\n", + "0 [a2.0.a0.test-module.6457, a2.0.a0.test-module... \n", + "1 [a0.0.a0.test.6457, a0.0.a0.test.6457, a0.0.a0... \n", + "2 [a2.0.a0.test-module.6457, a2.0.a0.test-module... \n", + "3 [a0.0.a0.test.6457, a0.0.a0.test.6457, a0.0.a0... \n", + "\n", + " rearMat ... Pout_raw \\\n", + "0 [a2.0.a0.test-module.2310, a2.0.a0.test-module... ... 91.741892 \n", + "1 [a0.0.a0.test.2310, a0.0.a0.test.2310, a0.0.a0... ... 123.689074 \n", + "2 [a2.0.a0.test-module.2310, a2.0.a0.test-module... ... 90.335684 \n", + "3 [a0.0.a0.test.2310, a0.0.a0.test.2310, a0.0.a0... ... 121.962507 \n", + "\n", + " Pout_Gfront BGG BGE Mismatch Pout Wind Speed DNI \\\n", + "0 80.304410 14.116369 14.242658 0.017150 91.726159 3.8 144 \n", + "1 106.026011 16.693980 16.659179 0.003706 123.684491 3.8 144 \n", + "2 79.481255 13.526226 13.656590 0.007205 90.329175 3.9 97 \n", + "3 105.082904 16.086384 16.063129 0.002439 121.959532 3.9 97 \n", + "\n", + " DHI GHI \n", + "0 149 211 \n", + "1 149 211 \n", + "2 200 249 \n", + "3 200 249 \n", + "\n", + "[4 rows x 29 columns]\n" ] } ], "source": [ - "print(trackerdict)\n", + "#print(trackerdict)\n", "#tracker_dict_sample = {'2021-01-13_1100':trackerdict['2021-01-13_1100']}\n", "#eff_irr = tracker_dict_sample['Wm2Front'] + tracker_dict_sample['Wm2Back']\n", "Compiled_Results = demo.calculateResults1axis()\n", + "print(Compiled_Results)\n", "#calculatePerformanceModule -> calculcateResults()" ] }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 15, "id": "fe18ea62", - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Exporting TrackerDict\n", - "2\n" + "3\n", + "3\n", + "1\n", + "1\n" ] }, { @@ -371,79 +489,137 @@ " 0\n", " 2021-01-13_1100\n", " 1\n", - " 2\n", + " 3\n", " 0\n", " 1axis_2021-01-13_1100_Scene0\n", - " [253.6018 254.6151 254.3044]\n", - " [44.61458 44.93219 45.89365]\n", + " [253.6687 254.6041 254.4693]\n", + " [39.11227 39.6468 40.87592]\n", " 144\n", " 149\n", " ...\n", " -44.14\n", " 44.14\n", " 90.0\n", - " 294.805893\n", - " 254.173767\n", - " 45.146807\n", - " 93.226676\n", - " 0.011420\n", - " 93.216030\n", - " 80.280919\n", + " 290.137864\n", + " 254.247367\n", + " 39.878330\n", + " 91.741892\n", + " 0.017150\n", + " 91.726159\n", + " 80.304410\n", " \n", " \n", " 1\n", " 1\n", - " 2021-01-13_1200\n", + " 2021-01-13_1100\n", + " 1\n", " 1\n", + " 1\n", + " 1axis_2021-01-13_1100_Scene1\n", + " [252.9754 253.764 253.5794]\n", + " [52.61953 53.14808 52.89173]\n", + " 144\n", + " 149\n", + " ...\n", + " -44.14\n", + " 44.14\n", + " 90.0\n", + " 295.748757\n", + " 253.439600\n", + " 52.886447\n", + " 123.689074\n", + " 0.003706\n", + " 123.684491\n", + " 106.026011\n", + " \n", + " \n", + " 2\n", " 2\n", + " 2021-01-13_1200\n", + " 1\n", + " 3\n", " 0\n", " 1axis_2021-01-13_1200_Scene0\n", - " [252.9921 253.0892 253.1863]\n", - " [43.26411 43.18745 43.85423]\n", + " [253.6684 253.7525 253.1556]\n", + " [38.08933 37.6907 38.52808]\n", + " 97\n", + " 200\n", + " ...\n", + " -21.20\n", + " 21.20\n", + " 90.0\n", + " 287.817933\n", + " 253.525500\n", + " 38.102703\n", + " 90.335684\n", + " 0.007205\n", + " 90.329175\n", + " 79.481255\n", + " \n", + " \n", + " 3\n", + " 3\n", + " 2021-01-13_1200\n", + " 1\n", + " 1\n", + " 1\n", + " 1axis_2021-01-13_1200_Scene1\n", + " [252.7885 252.8908 252.9932]\n", + " [50.66072 51.01453 50.87846]\n", " 97\n", " 200\n", " ...\n", " -21.20\n", " 21.20\n", " 90.0\n", - " 292.180937\n", - " 253.089200\n", - " 43.435263\n", - " 91.714260\n", - " 0.005496\n", - " 91.709219\n", - " 79.342954\n", + " 293.571823\n", + " 252.890833\n", + " 50.851237\n", + " 121.962507\n", + " 0.002439\n", + " 121.959532\n", + " 105.082904\n", " \n", " \n", "\n", - "

2 rows × 23 columns

\n", + "

4 rows × 23 columns

\n", "" ], "text/plain": [ " Unnamed: 0 timestamp rowNum modNum sceneNum \\\n", - "0 0 2021-01-13_1100 1 2 0 \n", - "1 1 2021-01-13_1200 1 2 0 \n", + "0 0 2021-01-13_1100 1 3 0 \n", + "1 1 2021-01-13_1100 1 1 1 \n", + "2 2 2021-01-13_1200 1 3 0 \n", + "3 3 2021-01-13_1200 1 1 1 \n", "\n", " name Wm2Front \\\n", - "0 1axis_2021-01-13_1100_Scene0 [253.6018 254.6151 254.3044] \n", - "1 1axis_2021-01-13_1200_Scene0 [252.9921 253.0892 253.1863] \n", + "0 1axis_2021-01-13_1100_Scene0 [253.6687 254.6041 254.4693] \n", + "1 1axis_2021-01-13_1100_Scene1 [252.9754 253.764 253.5794] \n", + "2 1axis_2021-01-13_1200_Scene0 [253.6684 253.7525 253.1556] \n", + "3 1axis_2021-01-13_1200_Scene1 [252.7885 252.8908 252.9932] \n", "\n", " Wm2Back DNI DHI ... theta surf_tilt surf_azm \\\n", - "0 [44.61458 44.93219 45.89365] 144 149 ... -44.14 44.14 90.0 \n", - "1 [43.26411 43.18745 43.85423] 97 200 ... -21.20 21.20 90.0 \n", + "0 [39.11227 39.6468 40.87592] 144 149 ... -44.14 44.14 90.0 \n", + "1 [52.61953 53.14808 52.89173] 144 149 ... -44.14 44.14 90.0 \n", + "2 [38.08933 37.6907 38.52808] 97 200 ... -21.20 21.20 90.0 \n", + "3 [50.66072 51.01453 50.87846] 97 200 ... -21.20 21.20 90.0 \n", "\n", - " POA_eff Gfront_mean Grear_mean Pout_raw Mismatch Pout \\\n", - "0 294.805893 254.173767 45.146807 93.226676 0.011420 93.216030 \n", - "1 292.180937 253.089200 43.435263 91.714260 0.005496 91.709219 \n", + " POA_eff Gfront_mean Grear_mean Pout_raw Mismatch Pout \\\n", + "0 290.137864 254.247367 39.878330 91.741892 0.017150 91.726159 \n", + "1 295.748757 253.439600 52.886447 123.689074 0.003706 123.684491 \n", + "2 287.817933 253.525500 38.102703 90.335684 0.007205 90.329175 \n", + "3 293.571823 252.890833 50.851237 121.962507 0.002439 121.959532 \n", "\n", " Pout_Gfront \n", - "0 80.280919 \n", - "1 79.342954 \n", + "0 80.304410 \n", + "1 106.026011 \n", + "2 79.481255 \n", + "3 105.082904 \n", "\n", - "[2 rows x 23 columns]" + "[4 rows x 23 columns]" ] }, - "execution_count": 11, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -452,6 +628,281 @@ "demo.exportTrackerDict(savefile=os.path.join('results','Final_Results.csv'),reindex=False)\n", "pd.read_csv(os.path.join('results','Final_Results.csv'))" ] + }, + { + "cell_type": "markdown", + "id": "eb2202f4", + "metadata": {}, + "source": [ + "## Now look at gencumulativesky tracking workflow" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "7cd42dfc", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "path = C:\\Users\\cdeline\\Documents\\Python Scripts\\Bifacial_Radiance\\bifacial_radiance\\TEMP\\Tutorial_21\n", + "Getting weather file: USA_VA_Richmond.724010_TMY2.epw\n", + " ... OK!\n", + "8760 line in WeatherFile. Assuming this is a standard hourly WeatherFile for the year for purposes of saving Gencumulativesky temporary weather files in EPW folder.\n", + "Coercing year to 2021\n", + "Filtering dates\n", + "Saving file EPWs\\metdata_temp.csv, # points: 8760\n", + "Calculating Sun position for Metdata that is right-labeled with a delta of -30 mins. i.e. 12 is 11:30 sunpos\n", + "Loading albedo, 1 value(s), 0.200 avg\n", + "1 nonzero albedo values.\n", + "\n", + "Module Name: test-module\n", + "Module test-module updated in module.json\n", + "Pre-existing .rad file objects\\test-module.rad will be overwritten\n", + "\n" + ] + } + ], + "source": [ + "starttime = '01_13_11'; endtime = '12_13_12'\n", + "demo = bifacial_radiance.RadianceObj('tutorial_21', path = testfolder) # Create a RadianceObj 'object'\n", + "weatherfile = demo.getEPW(lat = 37.5, lon = -77.6) # This location corresponds to Richmond, VA.\n", + "metdata = demo.readWeatherFile(weatherFile=weatherfile, starttime=starttime, endtime=endtime)\n", + "#metdata = demo.readWeatherFile(weatherFile=weatherfile)\n", + "demo.setGround(0.2)\n", + "mymodule = demo.makeModule(name='test-module', x=1, y=2, bifi=0.9, CECMod=CECMod) " + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "893d060e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Saving file EPWs\\1axis_-15.0.csv, # points: 1875\n", + "Saving file EPWs\\1axis_-10.0.csv, # points: 241\n", + "Saving file EPWs\\1axis_0.0.csv, # points: 2\n", + "Saving file EPWs\\1axis_5.0.csv, # points: 242\n", + "Saving file EPWs\\1axis_10.0.csv, # points: 33\n", + "Saving file EPWs\\1axis_15.0.csv, # points: 1683\n", + "message: There were 1833 sun up hours in this climate file\n", + "Total Ibh/Lbh: 0.000000\n", + "Created skyfile skies\\1axis_-15.0.rad\n", + "message: There were 238 sun up hours in this climate file\n", + "Total Ibh/Lbh: 0.000000\n", + "Created skyfile skies\\1axis_-10.0.rad\n", + "message: There were 2 sun up hours in this climate file\n", + "Total Ibh/Lbh: 0.000000\n", + "Created skyfile skies\\1axis_0.0.rad\n", + "message: There were 239 sun up hours in this climate file\n", + "Total Ibh/Lbh: 0.000000\n", + "Created skyfile skies\\1axis_5.0.rad\n", + "message: There were 33 sun up hours in this climate file\n", + "Total Ibh/Lbh: 0.000000\n", + "Created skyfile skies\\1axis_10.0.rad\n", + "message: There were 1661 sun up hours in this climate file\n", + "Total Ibh/Lbh: 0.000000\n", + "Created skyfile skies\\1axis_15.0.rad\n", + "\n", + "Making .rad files for cumulativesky 1-axis workflow\n", + "6 Radfiles created in /objects/\n", + "\n", + "Making 6 octfiles in root directory.\n", + "Created 1axis_-15.0.oct\n", + "Created 1axis_-10.0.oct\n", + "Created 1axis_0.0.oct\n", + "Created 1axis_5.0.oct\n", + "Created 1axis_10.0.oct\n", + "Created 1axis_15.0.oct\n", + "Linescan in process: 1axis_-15.0_Scene0_Row1_Module2_Front\n", + "Linescan in process: 1axis_-15.0_Scene0_Row1_Module2_Back\n", + "Saved: results\\irr_1axis_-15.0_Scene0_Row1_Module2.csv\n", + "Index: -15.0. Wm2Front: 628970.8666666666. Wm2Back: 80627.91333333333\n", + "Linescan in process: 1axis_-15.0_Scene0_Row1_Module4_Front\n", + "Linescan in process: 1axis_-15.0_Scene0_Row1_Module4_Back\n", + "Saved: results\\irr_1axis_-15.0_Scene0_Row1_Module4.csv\n", + "Index: -15.0. Wm2Front: 629100.6333333333. Wm2Back: 74004.94666666667\n", + "Linescan in process: 1axis_-10.0_Scene0_Row1_Module2_Front\n", + "Linescan in process: 1axis_-10.0_Scene0_Row1_Module2_Back\n", + "Saved: results\\irr_1axis_-10.0_Scene0_Row1_Module2.csv\n", + "Index: -10.0. Wm2Front: 147707.96666666665. Wm2Back: 19605.173333333336\n", + "Linescan in process: 1axis_-10.0_Scene0_Row1_Module4_Front\n", + "Linescan in process: 1axis_-10.0_Scene0_Row1_Module4_Back\n", + "Saved: results\\irr_1axis_-10.0_Scene0_Row1_Module4.csv\n", + "Index: -10.0. Wm2Front: 148857.30000000002. Wm2Back: 17508.036666666667\n", + "Linescan in process: 1axis_0.0_Scene0_Row1_Module2_Front\n", + "Linescan in process: 1axis_0.0_Scene0_Row1_Module2_Back\n", + "Saved: results\\irr_1axis_0.0_Scene0_Row1_Module2.csv\n", + "Index: 0.0. Wm2Front: 1020.194. Wm2Back: 151.87096666666665\n", + "Linescan in process: 1axis_0.0_Scene0_Row1_Module4_Front\n", + "Linescan in process: 1axis_0.0_Scene0_Row1_Module4_Back\n", + "Saved: results\\irr_1axis_0.0_Scene0_Row1_Module4.csv\n", + "Index: 0.0. Wm2Front: 999.1938. Wm2Back: 118.14943333333333\n", + "Linescan in process: 1axis_5.0_Scene0_Row1_Module2_Front\n", + "Linescan in process: 1axis_5.0_Scene0_Row1_Module2_Back\n", + "Saved: results\\irr_1axis_5.0_Scene0_Row1_Module2.csv\n", + "Index: 5.0. Wm2Front: 149755.56666666665. Wm2Back: 19677.773333333334\n", + "Linescan in process: 1axis_5.0_Scene0_Row1_Module4_Front\n", + "Linescan in process: 1axis_5.0_Scene0_Row1_Module4_Back\n", + "Saved: results\\irr_1axis_5.0_Scene0_Row1_Module4.csv\n", + "Index: 5.0. Wm2Front: 143861.16666666666. Wm2Back: 17468.406666666666\n", + "Linescan in process: 1axis_10.0_Scene0_Row1_Module2_Front\n", + "Linescan in process: 1axis_10.0_Scene0_Row1_Module2_Back\n", + "Saved: results\\irr_1axis_10.0_Scene0_Row1_Module2.csv\n", + "Index: 10.0. Wm2Front: 17115.093333333334. Wm2Back: 2382.903333333333\n", + "Linescan in process: 1axis_10.0_Scene0_Row1_Module4_Front\n", + "Linescan in process: 1axis_10.0_Scene0_Row1_Module4_Back\n", + "Saved: results\\irr_1axis_10.0_Scene0_Row1_Module4.csv\n", + "Index: 10.0. Wm2Front: 17351.12. Wm2Back: 2037.3946666666668\n", + "Linescan in process: 1axis_15.0_Scene0_Row1_Module2_Front\n", + "Linescan in process: 1axis_15.0_Scene0_Row1_Module2_Back\n", + "Saved: results\\irr_1axis_15.0_Scene0_Row1_Module2.csv\n", + "Index: 15.0. Wm2Front: 716495.6999999998. Wm2Back: 86140.92666666665\n", + "Linescan in process: 1axis_15.0_Scene0_Row1_Module4_Front\n", + "Linescan in process: 1axis_15.0_Scene0_Row1_Module4_Back\n", + "Saved: results\\irr_1axis_15.0_Scene0_Row1_Module4.csv\n", + "Index: 15.0. Wm2Front: 718218.0333333333. Wm2Back: 79305.50333333334\n" + ] + } + ], + "source": [ + "sceneDict = {'tilt': 0, 'azimuth': 180, 'pitch': 5,'hub_height':1.5, 'nMods':5, 'nRows': 2}\n", + "trackerdict = demo.set1axis(metdata=metdata, cumulativesky=True, limit_angle=15, backtrack=False)\n", + "trackerdict = demo.genCumSky1axis()\n", + "trackerdict = demo.makeScene1axis(trackerdict, module = mymodule, sceneDict = sceneDict)\n", + "trackerdict = demo.makeOct1axis()\n", + "trackerdict = demo.analysis1axis(modWanted = [2,4], sensorsy=3)" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "d6340420", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " row module BGG Gfront_mean Grear_mean \\\n", + "0 1 2 12.557396 1.661065e+06 208586.560967 \n", + "1 1 4 11.483591 1.658387e+06 190442.437433 \n", + "\n", + " POA_eff \\\n", + "0 [1871869.4886333328, 1867017.283133333, 187006... \n", + "1 [1852009.9815333332, 1844897.6626333334, 18495... \n", + "\n", + " Wm2Back \n", + "0 [210804.10129999998, 205951.89580000003, 20900... \n", + "1 [193622.5344, 186510.2155, 191194.56240000002] \n" + ] + } + ], + "source": [ + "demo.calculateResults1axis() # saves to demo.CompiledResults and results/Cumulative_Results.csv\n", + "print(demo.CompiledResults)" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "5d891480", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Unnamed: 0rowmoduleBGGGfront_meanGrear_meanPOA_effWm2Back
001212.5573961.661065e+06208586.560967[1871869.4886333328, 1867017.283133333, 187006...[210804.10129999998, 205951.89580000003, 20900...
111411.4835911.658387e+06190442.437433[1852009.9815333332, 1844897.6626333334, 18495...[193622.5344, 186510.2155, 191194.56240000002]
\n", + "
" + ], + "text/plain": [ + " Unnamed: 0 row module BGG Gfront_mean Grear_mean \\\n", + "0 0 1 2 12.557396 1.661065e+06 208586.560967 \n", + "1 1 1 4 11.483591 1.658387e+06 190442.437433 \n", + "\n", + " POA_eff \\\n", + "0 [1871869.4886333328, 1867017.283133333, 187006... \n", + "1 [1852009.9815333332, 1844897.6626333334, 18495... \n", + "\n", + " Wm2Back \n", + "0 [210804.10129999998, 205951.89580000003, 20900... \n", + "1 [193622.5344, 186510.2155, 191194.56240000002] " + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pd.read_csv(os.path.join('results','Cumulative_Results.csv'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e46594de", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { diff --git a/docs/tutorials/21 - Weather to Module Performance.py b/docs/tutorials/21 - Weather to Module Performance.py index 031ea381..1f603eb3 100644 --- a/docs/tutorials/21 - Weather to Module Performance.py +++ b/docs/tutorials/21 - Weather to Module Performance.py @@ -94,7 +94,7 @@ mymodule = demo.makeModule(name='test-module', x=1, y=2, bifi=0.9, CECMod=CECMod) -# The same data can be passed after the ModuleObj's definition: +# The same data could instead be passed after the ModuleObj's definition, or at time of performance analysis: # In[8]: @@ -105,29 +105,93 @@ # In[9]: -sceneDict = {'tilt': 10, 'azimuth': 180, 'pitch': 5,'hub_height':1.5, 'nMods':3, 'nRows': 2} +# Let's make a second module, and set it to the default Prism Solar module type +mymodule2 = demo.makeModule(name='test', x=1, y=2, bifi=0.8, CECMod=None) + + +# We're going to set up two scenes, each with a different module type! + +# In[12]: + + +sceneDict = {'tilt': 0, 'azimuth': 180, 'pitch': 5,'hub_height':1.5, 'nMods':5, 'nRows': 2} +sceneDict2 = {'tilt': 0, 'azimuth': 180, 'pitch': 5,'hub_height':2.5, 'nMods':2, 'nRows': 1, 'originx': -15} trackerdict = demo.set1axis(metdata = metdata, cumulativesky = False) trackerdict = demo.gendaylit1axis() trackerdict = demo.makeScene1axis(trackerdict, module = mymodule, sceneDict = sceneDict) + + +# Make a second scene with the other module type + +# In[13]: + + +trackerdict = demo.makeScene1axis(trackerdict, module = mymodule2, sceneDict=sceneDict2, append=True) trackerdict = demo.makeOct1axis() trackerdict = demo.analysis1axis(sensorsy=3) +trackerdict = demo.analysis1axis(sensorsy=3, sceneNum=1) # ## Calculating the Performance and Exporting the Results to a CSV -# In[10]: +# In[14]: -print(trackerdict) +#print(trackerdict) #tracker_dict_sample = {'2021-01-13_1100':trackerdict['2021-01-13_1100']} #eff_irr = tracker_dict_sample['Wm2Front'] + tracker_dict_sample['Wm2Back'] Compiled_Results = demo.calculateResults1axis() +print(Compiled_Results) #calculatePerformanceModule -> calculcateResults() -# In[11]: +# In[15]: demo.exportTrackerDict(savefile=os.path.join('results','Final_Results.csv'),reindex=False) pd.read_csv(os.path.join('results','Final_Results.csv')) + +# ## Now look at gencumulativesky tracking workflow + +# In[16]: + + +starttime = '01_13_11'; endtime = '12_13_12' +demo = bifacial_radiance.RadianceObj('tutorial_21', path = testfolder) # Create a RadianceObj 'object' +weatherfile = demo.getEPW(lat = 37.5, lon = -77.6) # This location corresponds to Richmond, VA. +metdata = demo.readWeatherFile(weatherFile=weatherfile, starttime=starttime, endtime=endtime) +#metdata = demo.readWeatherFile(weatherFile=weatherfile) +demo.setGround(0.2) +mymodule = demo.makeModule(name='test-module', x=1, y=2, bifi=0.9, CECMod=CECMod) + + +# In[17]: + + +sceneDict = {'tilt': 0, 'azimuth': 180, 'pitch': 5,'hub_height':1.5, 'nMods':5, 'nRows': 2} +trackerdict = demo.set1axis(metdata=metdata, cumulativesky=True, limit_angle=15, backtrack=False) +trackerdict = demo.genCumSky1axis() +trackerdict = demo.makeScene1axis(trackerdict, module = mymodule, sceneDict = sceneDict) +trackerdict = demo.makeOct1axis() +trackerdict = demo.analysis1axis(modWanted = [2,4], sensorsy=3) + + +# In[18]: + + +demo.calculateResults1axis() # saves to demo.CompiledResults and results/Cumulative_Results.csv +print(demo.CompiledResults) + + +# In[19]: + + +pd.read_csv(os.path.join('results','Cumulative_Results.csv')) + + +# In[ ]: + + + +