diff --git a/bifacial_radiance/main.py b/bifacial_radiance/main.py index 304549f2..7e51e26c 100644 --- a/bifacial_radiance/main.py +++ b/bifacial_radiance/main.py @@ -379,7 +379,7 @@ def __init__(self, name=None, path=None, hpc=False): #self.nMods = None # number of modules per row #self.nRows = None # number of rows per scene self.hpc = hpc # HPC simulation is being run. Some read/write functions are modified - self.CompiledResults = None # DataFrame of cumulative results, output from self.calculateResults() + self.CompiledResults = None # DataFrame of cumulative results, output from self.calculateResults1axis() now = datetime.datetime.now() self.nowstr = str(now.date())+'_'+str(now.hour)+str(now.minute)+str(now.second) @@ -2731,7 +2731,7 @@ def analysis1axis(self, trackerdict=None, singleindex=None, accuracy='low', Loop through trackerdict and runs linescans for each scene and scan in there. If multiple scenes exist in the trackerdict, only ONE scene can be analyzed at a time. - Todo: how to run calculateResults with array of multiple results + TODO: how to run calculateResults with array of multiple results Parameters ---------------- @@ -3075,7 +3075,7 @@ def _printRow(analysisobj, key): if module is None: module_local = trackerdict[key]['scenes'][analysis.sceneNum].module else: - module_local = None + module_local = module power_data = analysis.calc_performance(meteo_data=meteo_data, module=module_local, cumulativesky=self.cumulativesky, @@ -3104,7 +3104,7 @@ def _printRow(analysisobj, key): self.CompiledResults = performance.calculateResultsGencumsky1axis(results=self.CompiledResults, bifacialityfactor=1.0, fillcleanedSensors=True, agriPV=False) - + self.CompiledResults.to_csv(os.path.join('results', 'Cumulative_Results.csv')) self.trackerdict = trackerdict @@ -3450,7 +3450,7 @@ def __init__(self, module=None, name=None, hpc=False): self.module = ModuleObj(name=module) - elif type(module) == ModuleObj: # try moduleObj + elif str(type(module)) == "": # try moduleObj self.module = module #self.moduleDict = self.module.getDataDict() @@ -4357,13 +4357,13 @@ def __init__(self, octfile=None, name=None, hpc=False): def getResults(self): """ - go through the AnalysisObj and return a dict of irraidance result keys, - This can be passed into CompileResults + go through the AnalysisObj and return a dict of irradiance result keys. Returns ------- Results : dict. irradiance scan results """ + #TODO (optional?) Merge power_data to returned values?? keylist = ['rowWanted', 'modWanted', 'sceneNum', 'name', 'x', 'y','z', 'Wm2Front', 'Wm2Back', 'Wm2Ground', 'backRatio', 'mattype', 'rearMat' ] resultdict = {k: v for k, v in self.__dict__.items() if k in keylist} @@ -5431,6 +5431,7 @@ def calc_performance(self, meteo_data, cumulativesky, module, from bifacial_radiance import performance from bifacial_radiance import ModuleObj + #TODO: make this operate on the MetObj class, not special dictionary! #TODO: Check that meteo_data only includes correct kwargs # 'dni', 'ghi', 'dhi', 'temp_air', 'wind_speed' diff --git a/bifacial_radiance/module.py b/bifacial_radiance/module.py index b16f8ee5..1af25f30 100644 --- a/bifacial_radiance/module.py +++ b/bifacial_radiance/module.py @@ -98,7 +98,7 @@ def __init__(self, name=None, x=None, y=None, z=None, bifi=1, modulefile=None, omegaParams : dict Dictionary with input parameters for creating a omega or module support structure. Shortcut for ModuleObj.addOmega() - CECMod : Dictionary + CECMod : Dictionary with performance parameters needed for self.calculatePerformance() lpha_sc, a_ref, I_L_ref, I_o_ref, R_sh_ref, R_s, Adjust hpc : bool (default False) Set up module in HPC mode. Namely turn off read/write to module.json @@ -106,25 +106,12 @@ def __init__(self, name=None, x=None, y=None, z=None, bifi=1, modulefile=None, calling e.g. addTorquetube() after this will tend to write to the module.json so pass all geometry parameters at once in to makeModule for best response. - #Efficiency=None, Temp_coeff=None, Peak_Power=None, Module_name=None): - # TODO: REMOVE THESE INPUT PARAMETERS? - Efficiency : float (default None) - Information about module efficiency in percentage. Not currently - used to calculate performance. - Temp_coeff : float (default None) - Information about module temperature coefficient in %. Not - currently used to calculate performance. - Peak_Power : float (default None) - Information about module Peak Power in Watts. Not currently used to - calculate performance. - Module name : string (default None) - Information about module's name. - + '""" self.keys = ['x', 'y', 'z', 'modulematerial', 'scenex','sceney', 'scenez','numpanels','bifi','text','modulefile', 'glass', - 'offsetfromaxis','xgap','ygap','zgap', 'CECMod' ] + 'offsetfromaxis','xgap','ygap','zgap'] #replace whitespace with underlines. what about \n and other weird characters? # TODO: Address above comment? @@ -184,8 +171,7 @@ def __init__(self, name=None, x=None, y=None, z=None, bifi=1, modulefile=None, if cellModule: self.addCellModule(**cellModule, recompile=False) - if CECMod: - self.addCEC(CECMod, glass) + self.addCEC(CECMod, glass, bifi=bifi) if self._manual_text: print('Warning: Module text manually passed and not ' @@ -721,8 +707,8 @@ def addCEC(self, CECMod, glassglass=False, bifi=None): self.CECMod = CECMod self.glassglass = glassglass - if bifi is None: - bifi = self.bifi + 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 906000da..be0a9ee6 100644 --- a/docs/tutorials/21 - Weather to Module Performance.ipynb +++ b/docs/tutorials/21 - Weather to Module Performance.ipynb @@ -11,9 +11,9 @@ "output_type": "stream", "text": [ "Working on a Windows 10\n", - "Python version 3.11.7 | packaged by Anaconda, Inc. | (main, Dec 15 2023, 18:05:47) [MSC v.1916 64 bit (AMD64)]\n", - "Pandas version 2.1.4\n", - "bifacial_radiance version 0+untagged.1554.g980a0b9.dirty\n" + "Python version 3.9.13 (main, Aug 25 2022, 23:51:50) [MSC v.1916 64 bit (AMD64)]\n", + "Pandas version 1.5.3\n", + "bifacial_radiance version 0.4.3.dev341+g93e0ec5.d20240830\n" ] } ], @@ -49,7 +49,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Your simulation will be stored in C:\\Users\\mprillim\\sam_dev\\bifacial_radiance\\bifacial_radiance\\TEMP\\Tutorial_21\n" + "Your simulation will be stored in C:\\Users\\cdeline\\Documents\\Python Scripts\\Bifacial_Radiance\\bifacial_radiance\\TEMP\\Tutorial_21\n" ] } ], @@ -76,7 +76,7 @@ { "data": { "text/plain": [ - "'0+untagged.1554.g980a0b9.dirty'" + "'0.4.3.dev341+g93e0ec5.d20240830'" ] }, "execution_count": 3, @@ -93,9 +93,68 @@ "bifacial_radiance.__version__" ] }, + { + "cell_type": "markdown", + "id": "3f847fea", + "metadata": {}, + "source": [ + "## Geting a CEC Module to pass into demo.makeModule" + ] + }, { "cell_type": "code", "execution_count": 4, + "id": "aa374016", + "metadata": {}, + "outputs": [], + "source": [ + "url = 'https://raw.githubusercontent.com/NREL/SAM/patch/deploy/libraries/CEC%20Modules.csv'\n", + "db = pd.read_csv(url, index_col=0) # Reading this might take 1 min or so, the database is big." + ] + }, + { + "cell_type": "markdown", + "id": "864d0412", + "metadata": {}, + "source": [ + "Find the module that you want. In this case we know it's a SunPower of model SPR-E19-310-COM. \n", + "\n", + "Make sure you select only 1 module from the database -- sometimes there are similar names." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "0ba97ef9", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[False False False ... False False False]\n", + "1 modules selected. Name of 1st entry: SunPower SPR-E19-310-COM\n" + ] + } + ], + "source": [ + "modfilter2 = db.index.str.startswith('SunPower') & db.index.str.endswith('SPR-E19-310-COM')\n", + "print(modfilter2)\n", + "CECMod = db[modfilter2]\n", + "print(len(CECMod), \" modules selected. Name of 1st entry: \", CECMod.index[0])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5ee82ada", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 6, "id": "250eb585", "metadata": {}, "outputs": [ @@ -103,7 +162,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "path = C:\\Users\\mprillim\\sam_dev\\bifacial_radiance\\bifacial_radiance\\TEMP\\Tutorial_21\n", + "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", @@ -112,35 +171,7 @@ "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", - "Creating ~2 skyfiles. \n", - "Created 2 skyfiles in /skies/\n", - "Warning: input `moduletype` is deprecated. Use kwarg `module` instead\n", - "\n", - "Making ~2 .rad files for gendaylit 1-axis workflow (this takes a minute..)\n", - "2 Radfiles created in /objects/\n", - "\n", - "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_Front\n", - "Linescan in process: 1axis_2021-01-13_1100_Back\n", - "Saved: results\\irr_1axis_2021-01-13_1100.csv\n", - "Index: 2021-01-13_1100. Wm2Front: 255.36876666666663. Wm2Back: 45.574796666666664\n", - "Linescan in process: 1axis_2021-01-13_1200_Front\n", - "Linescan in process: 1axis_2021-01-13_1200_Back\n", - "Saved: results\\irr_1axis_2021-01-13_1200.csv\n", - "Index: 2021-01-13_1200. Wm2Front: 254.47736666666665. Wm2Back: 43.65842333333333\n", - "Saving a cumulative-results file in the main simulation folder.This adds up by sensor location the irradiance over all hours or configurations considered.\n", - "Warning: This file saving routine does not clean results, so if your setup has ygaps, or 2+modules or torque tubes, doing a deeper cleaning and working with the individual results files in the results folder is highly suggested.\n", - "\n", - "Saving Cumulative results\n", - "Saved: cumulative_results_.csv\n" + "1 nonzero albedo values.\n" ] } ], @@ -150,65 +181,96 @@ "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", - "demo.setGround(0.2)\n", - "mymodule = demo.makeModule(name='test-module', x=1, y=2, bifi=0.9) \n", - "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(moduletype = mymodule, sceneDict = sceneDict)\n", - "trackerdict = demo.makeOct1axis()\n", - "trackerdict = demo.analysis1axis(sensorsy=3)\n" + "demo.setGround(0.2)" ] }, { "cell_type": "markdown", - "id": "57a30274", + "id": "63433b04", "metadata": {}, "source": [ - "## Geting a CEC Module" + "The CEC data should be passed into the ModuleObj, either at time of creation, or sometime before it is passed into makeScene." ] }, { "cell_type": "code", - "execution_count": 5, - "id": "b0d57ebe", - "metadata": {}, - "outputs": [], + "execution_count": 7, + "id": "3a123afd", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\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": [ - "url = 'https://raw.githubusercontent.com/NREL/SAM/patch/deploy/libraries/CEC%20Modules.csv'\n", - "db = pd.read_csv(url, index_col=0) # Reading this might take 1 min or so, the database is big.\n" + "mymodule = demo.makeModule(name='test-module', x=1, y=2, bifi=0.9, CECMod=CECMod) " ] }, { "cell_type": "markdown", - "id": "686125df", + "id": "6fc18e50", "metadata": {}, "source": [ - "Find the module that you want. In this case we know it's a SunPower of model SPR-E19-310-COM. \n", - "\n", - "Make sure you select only 1 module from the database -- sometimes there are similar names." + "The same data can be passed after the ModuleObj's definition:" ] }, { "cell_type": "code", - "execution_count": 6, - "id": "dcb5646f", + "execution_count": 8, + "id": "6aa21855", + "metadata": {}, + "outputs": [], + "source": [ + "mymodule.addCEC(CECMod)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "3eca187d", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "[False False False ... False False False]\n", - "1 modules selected. Name of 1st entry: SunPower SPR-E19-310-COM\n" + "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", + "\n", + "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" ] } ], "source": [ - "modfilter2 = db.index.str.startswith('SunPower') & db.index.str.endswith('SPR-E19-310-COM')\n", - "print(modfilter2)\n", - "CECMod = db[modfilter2]\n", - "print(len(CECMod), \" modules selected. Name of 1st entry: \", CECMod.index[0])" + "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.makeOct1axis()\n", + "trackerdict = demo.analysis1axis(sensorsy=3)" ] }, { @@ -221,7 +283,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 10, "id": "7bbf6db6", "metadata": {}, "outputs": [ @@ -229,51 +291,25 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'2021-01-13_1100': {'surf_azm': 90.0, 'surf_tilt': 44.14, 'theta': -44.14, 'ghi': 211, 'dhi': 149, 'temp_air': 4.6, 'wind_speed': 3.8, 'skyfile': 'skies\\\\sky2_37.5_-77.33_2021-01-13_1100.rad', 'radfile': 'objects\\\\1axis2021-01-13_1100__C_0.80359_rtr_5.00000_tilt_44.14000_3modsx2rows_origin0,0.rad', 'scene': {'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.80359_rtr_5.00000_tilt_44.14000_3modsx2rows_origin0,0.rad', 'sceneDict': {'tilt': 0, 'pitch': 5, 'clearance_height': 1.5, 'azimuth': 90.0, 'nMods': 3, 'nRows': 2, 'modulez': 0.02, 'axis_tilt': 0, 'originx': 0, 'originy': 0}}, 'octfile': '1axis_2021-01-13_1100.oct', 'AnalysisObj': {'octfile': '1axis_2021-01-13_1100.oct', 'name': '1axis_2021-01-13_1100', 'hpc': False, 'x': [0.3734448, 0.01462469, -0.3441954], 'y': [2.28669e-17, 8.955042e-19, -2.107589e-17], 'z': [1.166863, 1.51507, 1.863277], 'rearZ': [1.151075, 1.499282, 1.847489], 'mattype': ['a1.0.a0.test-module.6457', 'a1.0.a0.test-module.6457', 'a1.0.a0.test-module.6457'], 'rearMat': ['a1.0.a0.test-module.2310', 'a1.0.a0.test-module.2310', 'a1.0.a0.test-module.2310'], 'Wm2Front': [254.9108, 255.7401, 255.45539999999997], 'Wm2Back': [45.16279, 45.26495, 46.29665], 'Back/FrontRatio': [0.17717026045871553, 0.1769952111725491, 0.1812311220231711], 'backRatio': [0.17717026045871553, 0.1769952111725491, 0.1812311220231711], 'rearX': [0.3581237, -0.000696414, -0.3595166], 'rearY': [2.192875e-17, -4.264306e-20, -2.201404e-17]}, 'Wm2Front': [254.9108, 255.7401, 255.45539999999997], 'Wm2Back': [45.16279, 45.26495, 46.29665], 'backRatio': [0.17717026045871553, 0.1769952111725491, 0.1812311220231711]}, '2021-01-13_1200': {'surf_azm': 90.0, 'surf_tilt': 21.2, 'theta': -21.2, 'ghi': 249, 'dhi': 200, 'temp_air': 6.5, 'wind_speed': 3.9, 'skyfile': 'skies\\\\sky2_37.5_-77.33_2021-01-13_1200.rad', 'radfile': 'objects\\\\1axis2021-01-13_1200__C_1.13838_rtr_5.00000_tilt_21.20000_3modsx2rows_origin0,0.rad', 'scene': {'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.13838_rtr_5.00000_tilt_21.20000_3modsx2rows_origin0,0.rad', 'sceneDict': {'tilt': 21.2, 'pitch': 5, 'clearance_height': 1.1383754299179079, 'azimuth': 90.0, 'nMods': 3, 'nRows': 2, 'modulez': 0.02, 'axis_tilt': 0, 'originx': 0, 'originy': 0}}, 'octfile': '1axis_2021-01-13_1200.oct', 'AnalysisObj': {'octfile': '1axis_2021-01-13_1200.oct', 'name': '1axis_2021-01-13_1200', 'hpc': False, 'x': [0.473756, 0.007594116, -0.4585678], 'y': [2.900919e-17, 4.650055e-19, -2.807918e-17], 'z': [1.338767, 1.519579, 1.700391], 'rearZ': [1.318255, 1.499068, 1.67988], 'mattype': ['a1.0.a0.test-module.6457', 'a1.0.a0.test-module.6457', 'a1.0.a0.test-module.6457'], 'rearMat': ['a1.0.a0.test-module.2310', 'a1.0.a0.test-module.2310', 'a1.0.a0.test-module.2310'], 'Wm2Front': [254.43140000000002, 254.5634, 254.43729999999996], 'Wm2Back': [43.32023999999999, 43.42238, 44.23265], 'Back/FrontRatio': [0.17026227791743498, 0.1705752257581971, 0.17384430724462474], 'backRatio': [0.17026227791743498, 0.1705752257581971, 0.17384430724462474], 'rearX': [0.4658003, -0.0003616246, -0.4665235], 'rearY': [2.852204e-17, -2.214312e-20, -2.856633e-17]}, 'Wm2Front': [254.43140000000002, 254.5634, 254.43729999999996], 'Wm2Back': [43.32023999999999, 43.42238, 44.23265], 'backRatio': [0.17026227791743498, 0.1705752257581971, 0.17384430724462474]}}\n" + "{'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" ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "c:\\users\\mprillim\\sam_dev\\bifacial_radiance\\bifacial_radiance\\performance.py:57: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead\n", - " alpha_sc=float(CECMod.alpha_sc),\n", - "c:\\users\\mprillim\\sam_dev\\bifacial_radiance\\bifacial_radiance\\performance.py:58: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead\n", - " a_ref=float(CECMod.a_ref),\n", - "c:\\users\\mprillim\\sam_dev\\bifacial_radiance\\bifacial_radiance\\performance.py:59: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead\n", - " I_L_ref=float(CECMod.I_L_ref),\n", - "c:\\users\\mprillim\\sam_dev\\bifacial_radiance\\bifacial_radiance\\performance.py:60: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead\n", - " I_o_ref=float(CECMod.I_o_ref),\n", - "c:\\users\\mprillim\\sam_dev\\bifacial_radiance\\bifacial_radiance\\performance.py:61: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead\n", - " R_sh_ref=float(CECMod.R_sh_ref),\n", - "c:\\users\\mprillim\\sam_dev\\bifacial_radiance\\bifacial_radiance\\performance.py:62: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead\n", - " R_s=float(CECMod.R_s),\n", - "c:\\users\\mprillim\\sam_dev\\bifacial_radiance\\bifacial_radiance\\performance.py:63: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead\n", - " Adjust=float(CECMod.Adjust)\n" - ] - }, - { - "data": { - "text/plain": [ - "73.50428000429895" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" } ], "source": [ "print(trackerdict)\n", - "tracker_dict_sample = trackerdict['2021-01-13_1100']\n", - "eff_irr = tracker_dict_sample['Wm2Front'] + tracker_dict_sample['Wm2Back']\n", - "bifacial_radiance.performance.calculatePerformance(eff_irr[0],CECMod=CECMod)\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", "#calculatePerformanceModule -> calculcateResults()" ] }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 11, "id": "fe18ea62", "metadata": {}, "outputs": [ @@ -281,7 +317,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "Exporting TrackerDict\n" + "Exporting TrackerDict\n", + "2\n" ] }, { @@ -306,79 +343,107 @@ " \n", " \n", " Unnamed: 0\n", - " dhi\n", - " ghi\n", - " Wm2Back\n", + " timestamp\n", + " rowNum\n", + " modNum\n", + " sceneNum\n", + " name\n", " Wm2Front\n", + " Wm2Back\n", + " DNI\n", + " DHI\n", + " ...\n", " theta\n", " surf_tilt\n", " surf_azm\n", - " clearance_height\n", - " effective_irradiance\n", - " Pout_module\n", - " Wm2BackAvg\n", - " Wm2FrontAvg\n", - " BifiRatio\n", + " POA_eff\n", + " Gfront_mean\n", + " Grear_mean\n", + " Pout_raw\n", + " Mismatch\n", + " Pout\n", + " Pout_Gfront\n", " \n", " \n", " \n", " \n", " 0\n", + " 0\n", " 2021-01-13_1100\n", + " 1\n", + " 2\n", + " 0\n", + " 1axis_2021-01-13_1100_Scene0\n", + " [253.6018 254.6151 254.3044]\n", + " [44.61458 44.93219 45.89365]\n", + " 144\n", " 149\n", - " 211\n", - " [45.16279, 45.26495, 46.29665]\n", - " [254.9108, 255.7401, 255.45539999999997]\n", + " ...\n", " -44.14\n", " 44.14\n", " 90.0\n", - " NaN\n", - " NaN\n", - " NaN\n", - " 45.574797\n", - " 255.368767\n", - " 0.160620\n", + " 294.805893\n", + " 254.173767\n", + " 45.146807\n", + " 93.226676\n", + " 0.011420\n", + " 93.216030\n", + " 80.280919\n", " \n", " \n", " 1\n", + " 1\n", " 2021-01-13_1200\n", + " 1\n", + " 2\n", + " 0\n", + " 1axis_2021-01-13_1200_Scene0\n", + " [252.9921 253.0892 253.1863]\n", + " [43.26411 43.18745 43.85423]\n", + " 97\n", " 200\n", - " 249\n", - " [43.32023999999999, 43.42238, 44.23265]\n", - " [254.43140000000002, 254.5634, 254.43729999999...\n", + " ...\n", " -21.20\n", " 21.20\n", " 90.0\n", - " NaN\n", - " NaN\n", - " NaN\n", - " 43.658423\n", - " 254.477367\n", - " 0.154405\n", + " 292.180937\n", + " 253.089200\n", + " 43.435263\n", + " 91.714260\n", + " 0.005496\n", + " 91.709219\n", + " 79.342954\n", " \n", " \n", "\n", + "

2 rows × 23 columns

\n", "" ], "text/plain": [ - " Unnamed: 0 dhi ghi Wm2Back \\\n", - "0 2021-01-13_1100 149 211 [45.16279, 45.26495, 46.29665] \n", - "1 2021-01-13_1200 200 249 [43.32023999999999, 43.42238, 44.23265] \n", + " 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", + "\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", + "\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", "\n", - " Wm2Front theta surf_tilt \\\n", - "0 [254.9108, 255.7401, 255.45539999999997] -44.14 44.14 \n", - "1 [254.43140000000002, 254.5634, 254.43729999999... -21.20 21.20 \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", "\n", - " surf_azm clearance_height effective_irradiance Pout_module Wm2BackAvg \\\n", - "0 90.0 NaN NaN NaN 45.574797 \n", - "1 90.0 NaN NaN NaN 43.658423 \n", + " Pout_Gfront \n", + "0 80.280919 \n", + "1 79.342954 \n", "\n", - " Wm2FrontAvg BifiRatio \n", - "0 255.368767 0.160620 \n", - "1 254.477367 0.154405 " + "[2 rows x 23 columns]" ] }, - "execution_count": 17, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -405,7 +470,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.7" + "version": "3.9.13" } }, "nbformat": 4, diff --git a/docs/tutorials/21 - Weather to Module Performance.py b/docs/tutorials/21 - Weather to Module Performance.py index 0ae93bfc..031ea381 100644 --- a/docs/tutorials/21 - Weather to Module Performance.py +++ b/docs/tutorials/21 - Weather to Module Performance.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # coding: utf-8 -# In[2]: +# In[1]: # This information helps with debugging and getting support :) @@ -20,7 +20,7 @@ # This tutorial shows how to use the new function on bifacial_radiance calculatePerformanceModule performance, as well as how to find CEC Module parameters. # -# In[3]: +# In[2]: import os @@ -36,7 +36,7 @@ print ("Your simulation will be stored in %s" % testfolder) -# In[4]: +# In[3]: import bifacial_radiance @@ -47,58 +47,87 @@ bifacial_radiance.__version__ +# ## Geting a CEC Module to pass into demo.makeModule + +# In[4]: + + +url = 'https://raw.githubusercontent.com/NREL/SAM/patch/deploy/libraries/CEC%20Modules.csv' +db = pd.read_csv(url, index_col=0) # Reading this might take 1 min or so, the database is big. + + +# Find the module that you want. In this case we know it's a SunPower of model SPR-E19-310-COM. +# +# Make sure you select only 1 module from the database -- sometimes there are similar names. + # In[5]: +modfilter2 = db.index.str.startswith('SunPower') & db.index.str.endswith('SPR-E19-310-COM') +print(modfilter2) +CECMod = db[modfilter2] +print(len(CECMod), " modules selected. Name of 1st entry: ", CECMod.index[0]) + + +# In[ ]: + + + + + +# In[6]: + + # Selecting only two times as examples starttime = '01_13_11'; endtime = '01_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) demo.setGround(0.2) -mymodule = demo.makeModule(name='test-module', x=1, y=2, bifi=0.9) -sceneDict = {'tilt': 10, 'azimuth': 180, 'pitch': 5,'hub_height':1.5, 'nMods':3, 'nRows': 2} -trackerdict = demo.set1axis(metdata = metdata, cumulativesky = False) -trackerdict = demo.gendaylit1axis() -trackerdict = demo.makeScene1axis(moduletype = mymodule, sceneDict = sceneDict) -trackerdict = demo.makeOct1axis() -trackerdict = demo.analysis1axis(sensorsy=3) -# ## Geting a CEC Module +# The CEC data should be passed into the ModuleObj, either at time of creation, or sometime before it is passed into makeScene. -# In[ ]: +# In[7]: -url = 'https://raw.githubusercontent.com/NREL/SAM/patch/deploy/libraries/CEC%20Modules.csv' -db = pd.read_csv(url, index_col=0) # Reading this might take 1 min or so, the database is big. +mymodule = demo.makeModule(name='test-module', x=1, y=2, bifi=0.9, CECMod=CECMod) -# Find the module that you want. In this case we know it's a SunPower of model SPR-E19-310-COM. -# -# Make sure you select only 1 module from the database -- sometimes there are similar names. +# The same data can be passed after the ModuleObj's definition: -# In[ ]: +# In[8]: -modfilter2 = db.index.str.startswith('SunPower') & db.index.str.endswith('SPR-E19-310-COM') -print(modfilter2) -CECMod = db[modfilter2] -print(len(CECMod), " modules selected. Name of 1st entry: ", CECMod.index[0]) +mymodule.addCEC(CECMod) + + +# In[9]: + + +sceneDict = {'tilt': 10, 'azimuth': 180, 'pitch': 5,'hub_height':1.5, 'nMods':3, 'nRows': 2} +trackerdict = demo.set1axis(metdata = metdata, cumulativesky = False) +trackerdict = demo.gendaylit1axis() +trackerdict = demo.makeScene1axis(trackerdict, module = mymodule, sceneDict = sceneDict) +trackerdict = demo.makeOct1axis() +trackerdict = demo.analysis1axis(sensorsy=3) # ## Calculating the Performance and Exporting the Results to a CSV -# In[ ]: +# In[10]: -demo.calculateResults(CECMod=CECMod) +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() #calculatePerformanceModule -> calculcateResults() -# In[ ]: +# In[11]: -#demo.exportTrackerDict(savefile=os.path.join('results','Final_Results.csv'),reindex=False) -#pd.read_csv(os.path.join('results','Final_Results.csv')) +demo.exportTrackerDict(savefile=os.path.join('results','Final_Results.csv'),reindex=False) +pd.read_csv(os.path.join('results','Final_Results.csv')) diff --git a/tests/test_performance.py b/tests/test_performance.py index 0b6e1077..68ce71dc 100644 --- a/tests/test_performance.py +++ b/tests/test_performance.py @@ -29,6 +29,9 @@ # TODO: write test sequence for AnalysisObj.calc_performance # TODO: write test sequence using default Prism Solar module. +# TODO: write test sequence for RadianceObj.calculateResults1axis +# TODO: write test sequence for performance.calculateResults +# TODO: write test sequence for performance.calculateResultsGencumsky1axis def test_calculatePerformance(): @@ -45,7 +48,7 @@ def test_calculatePerformance(): #CECMod = CECMODS['Canadian_Solar_Inc__CS5P_220M'] CECMod = pd.read_csv(os.path.join(TESTDIR, 'Canadian_Solar_Inc__CS5P_220M.csv'), index_col=0).iloc[:,0] - module = bifacial_radiance.ModuleObj('test') + module = bifacial_radiance.ModuleObj('test-module') module.addCEC(CECMod = CECMod) p_mp_celltemp = module.calculatePerformance(s1, temp_cell=s2)