Skip to content

Commit

Permalink
Fixes #445, fixes #509.
Browse files Browse the repository at this point in the history
Change load.deepcleanResult to key off any module name, ending in .6457 or .2310 in automatic mode.
Should fix Tutorial #8 - mismatch.
  • Loading branch information
cdeline committed Sep 10, 2024
1 parent c932849 commit f150969
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 42 deletions.
6 changes: 3 additions & 3 deletions bifacial_radiance/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,11 @@ def filter_sub(resultsDict, sensorsy, frontmask, backmask=None):
# by default, these are the material values attached to bifacial_radiance
# modules
if 'mattype' in resultsDict:
frontmask = ['PVmodule.6457']
else: frontmask = ['PVmodule.2310'] # result only has _Back file passed
frontmask = ['.6457']
else: frontmask = ['.2310'] # result only has _Back file passed

if 'rearMat' in resultsDict:
backmask = ['PVmodule.2310']
backmask = ['.2310']
else: backmask = None

else:
Expand Down
57 changes: 21 additions & 36 deletions docs/tutorials/8 - Electrical Mismatch Method.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,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.1553.g23d2640.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"
]
}
],
Expand Down Expand Up @@ -75,20 +75,14 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"path = C:\\Users\\mprillim\\sam_dev\\bifacial_radiance\\bifacial_radiance\\TEMP\\Tutorial_08\n",
"Making path: images\n",
"Making path: objects\n",
"Making path: results\n",
"Making path: skies\n",
"Making path: EPWs\n",
"Making path: materials\n",
"path = C:\\Users\\cdeline\\Documents\\Python Scripts\\Bifacial_Radiance\\bifacial_radiance\\TEMP\\Tutorial_08\n",
"Loading albedo, 1 value(s), 0.250 avg\n",
"1 nonzero albedo values.\n",
"Getting weather file: USA_VA_Richmond.724010_TMY2.epw\n",
Expand All @@ -99,8 +93,8 @@
"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",
"\n",
"Module Name: test-module\n",
"Module test-module updated in module.json\n",
"Module Name: PVmodule\n",
"Module PVmodule updated in module.json\n",
"Creating ~3 skyfiles. \n",
"Created 3 skyfiles in /skies/\n",
"\n",
Expand All @@ -111,20 +105,24 @@
"Created 1axis_2021-11-06_0800.oct\n",
"Created 1axis_2021-11-06_0900.oct\n",
"Created 1axis_2021-11-06_1000.oct\n",
"sceneDict Warning: 'hub_height' and 'clearance_height' are being passed. Using hub_height and removing clearance_height\n",
"Linescan in process: 1axis_2021-11-06_0800_Front\n",
"Linescan in process: 1axis_2021-11-06_0800_Back\n",
"Saved: results\\irr_1axis_2021-11-06_0800.csv\n",
"Index: 2021-11-06_0800. Wm2Front: 217.21925833333333. Wm2Back: 6.115893083333334\n",
"Index: 2021-11-06_0800. Wm2Front: 216.76329999999996. Wm2Back: 6.098131166666666\n",
"sceneDict Warning: 'hub_height' and 'clearance_height' are being passed. Using hub_height and removing clearance_height\n",
"Linescan in process: 1axis_2021-11-06_0900_Front\n",
"Linescan in process: 1axis_2021-11-06_0900_Back\n",
"Saved: results\\irr_1axis_2021-11-06_0900.csv\n",
"Index: 2021-11-06_0900. Wm2Front: 373.20349166666665. Wm2Back: 34.79393916666667\n",
"Index: 2021-11-06_0900. Wm2Front: 372.0182416666666. Wm2Back: 34.83552916666667\n",
"sceneDict Warning: 'hub_height' and 'clearance_height' are being passed. Using hub_height and removing clearance_height\n",
"Linescan in process: 1axis_2021-11-06_1000_Front\n",
"Linescan in process: 1axis_2021-11-06_1000_Back\n",
"Saved: results\\irr_1axis_2021-11-06_1000.csv\n",
"Index: 2021-11-06_1000. Wm2Front: 337.41221666666667. Wm2Back: 40.40333416666667\n",
"Index: 2021-11-06_1000. Wm2Front: 335.4062166666667. Wm2Back: 40.55148166666667\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",
"sceneDict Warning: 'hub_height' and 'clearance_height' are being passed. Using hub_height and removing clearance_height\n",
"\n",
"Saving Cumulative results\n",
"Saved: cumulative_results_.csv\n"
Expand All @@ -141,7 +139,7 @@
" os.makedirs(testfolder)\n",
"\n",
"simulationName = 'tutorial_8'\n",
"moduletype = \"test-module\"\n",
"moduletype = \"PVModule\"\n",
"albedo = 0.25 \n",
"lat = 37.5 \n",
"lon = -77.6\n",
Expand Down Expand Up @@ -224,30 +222,17 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3 files in the directory\n"
]
},
{
"ename": "ValueError",
"evalue": "array of sample points is empty",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[2], line 8\u001b[0m\n\u001b[0;32m 6\u001b[0m numcells\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m72\u001b[39m\u001b[38;5;66;03m# Options are 72 or 96 at the moment.\u001b[39;00m\n\u001b[0;32m 7\u001b[0m downsamplingmethod \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mbyCenter\u001b[39m\u001b[38;5;124m'\u001b[39m \u001b[38;5;66;03m# Options are 'byCenter' or 'byAverage'.\u001b[39;00m\n\u001b[1;32m----> 8\u001b[0m bifacial_radiance\u001b[38;5;241m.\u001b[39mmismatch\u001b[38;5;241m.\u001b[39manalysisIrradianceandPowerMismatch(testfolder\u001b[38;5;241m=\u001b[39mresultfolder, writefiletitle\u001b[38;5;241m=\u001b[39mwritefiletitle, portraitorlandscape\u001b[38;5;241m=\u001b[39mportraitorlandscape, \n\u001b[0;32m 9\u001b[0m bififactor\u001b[38;5;241m=\u001b[39mbififactor, numcells\u001b[38;5;241m=\u001b[39mnumcells)\n\u001b[0;32m 11\u001b[0m \u001b[38;5;28mprint\u001b[39m (\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mYour hourly mismatch values are now saved in the file above! :D\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
"File \u001b[1;32mc:\\users\\mprillim\\sam_dev\\bifacial_radiance\\bifacial_radiance\\mismatch.py:318\u001b[0m, in \u001b[0;36manalysisIrradianceandPowerMismatch\u001b[1;34m(testfolder, writefiletitle, portraitorlandscape, bififactor, numcells, downsamplingmethod)\u001b[0m\n\u001b[0;32m 316\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m z \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;241m0\u001b[39m, filelist\u001b[38;5;241m.\u001b[39m\u001b[38;5;21m__len__\u001b[39m()):\n\u001b[0;32m 317\u001b[0m data\u001b[38;5;241m=\u001b[39mload\u001b[38;5;241m.\u001b[39mread1Result(os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mjoin(testfolder,filelist[z]))\n\u001b[1;32m--> 318\u001b[0m [frontres, backres] \u001b[38;5;241m=\u001b[39m load\u001b[38;5;241m.\u001b[39mdeepcleanResult(data, sensorsy\u001b[38;5;241m=\u001b[39msensorsy, numpanels\u001b[38;5;241m=\u001b[39mnumpanels, automatic\u001b[38;5;241m=\u001b[39mautomatic)\n\u001b[0;32m 319\u001b[0m F[filelist[z]]\u001b[38;5;241m=\u001b[39mfrontres\n\u001b[0;32m 320\u001b[0m B[filelist[z]]\u001b[38;5;241m=\u001b[39mbackres \n",
"File \u001b[1;32mc:\\users\\mprillim\\sam_dev\\bifacial_radiance\\bifacial_radiance\\load.py:458\u001b[0m, in \u001b[0;36mdeepcleanResult\u001b[1;34m(resultsDict, sensorsy, numpanels, automatic)\u001b[0m\n\u001b[0;32m 454\u001b[0m \u001b[38;5;28;01mpass\u001b[39;00m\n\u001b[0;32m 456\u001b[0m \u001b[38;5;66;03m# now that we know what material names to look for, filter resultsDict for \u001b[39;00m\n\u001b[0;32m 457\u001b[0m \u001b[38;5;66;03m# them, removing frames, sky, torque tube, etc. \u001b[39;00m\n\u001b[1;32m--> 458\u001b[0m Frontresults, Backresults \u001b[38;5;241m=\u001b[39m filter_sub(resultsDict, sensorsy, frontmask, backmask)\n\u001b[0;32m 460\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m Frontresults, Backresults\n",
"File \u001b[1;32mc:\\users\\mprillim\\sam_dev\\bifacial_radiance\\bifacial_radiance\\load.py:407\u001b[0m, in \u001b[0;36mdeepcleanResult.<locals>.filter_sub\u001b[1;34m(resultsDict, sensorsy, frontmask, backmask)\u001b[0m\n\u001b[0;32m 405\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m backmask:\n\u001b[0;32m 406\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 407\u001b[0m Frontresults \u001b[38;5;241m=\u001b[39m interp_sub(resultsDict[mask], sensorsy, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mWm2Front\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m 408\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m: \u001b[38;5;66;03m# no Wm2Front data passed - rear data only.\u001b[39;00m\n\u001b[0;32m 409\u001b[0m Frontresults \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n",
"File \u001b[1;32mc:\\users\\mprillim\\sam_dev\\bifacial_radiance\\bifacial_radiance\\load.py:377\u001b[0m, in \u001b[0;36mdeepcleanResult.<locals>.interp_sub\u001b[1;34m(panelDict, sensorsy, frontbackkey)\u001b[0m\n\u001b[0;32m 375\u001b[0m x_0 \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39mlinspace(\u001b[38;5;241m0\u001b[39m, \u001b[38;5;28mlen\u001b[39m(panelDict)\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m, \u001b[38;5;28mlen\u001b[39m(panelDict)) \n\u001b[0;32m 376\u001b[0m x_i \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39mlinspace(\u001b[38;5;241m0\u001b[39m, \u001b[38;5;28mlen\u001b[39m(panelDict)\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m, \u001b[38;5;28mint\u001b[39m(sensorsy))\n\u001b[1;32m--> 377\u001b[0m interp_out \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39minterp(x_i, x_0, panelDict[frontbackkey])\n\u001b[0;32m 379\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m interp_out\n",
"File \u001b[1;32m~\\AppData\\Local\\anaconda3\\Lib\\site-packages\\numpy\\lib\\function_base.py:1599\u001b[0m, in \u001b[0;36minterp\u001b[1;34m(x, xp, fp, left, right, period)\u001b[0m\n\u001b[0;32m 1596\u001b[0m xp \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39mconcatenate((xp[\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m:]\u001b[38;5;241m-\u001b[39mperiod, xp, xp[\u001b[38;5;241m0\u001b[39m:\u001b[38;5;241m1\u001b[39m]\u001b[38;5;241m+\u001b[39mperiod))\n\u001b[0;32m 1597\u001b[0m fp \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39mconcatenate((fp[\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m:], fp, fp[\u001b[38;5;241m0\u001b[39m:\u001b[38;5;241m1\u001b[39m]))\n\u001b[1;32m-> 1599\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m interp_func(x, xp, fp, left, right)\n",
"\u001b[1;31mValueError\u001b[0m: array of sample points is empty"
"3 files in the directory\n",
"Same number of sensorsy and cellsy for your module.\n",
"Saved Results to Mismatch_Results.csv\n",
"Your hourly mismatch values are now saved in the file above! :D\n"
]
}
],
Expand Down Expand Up @@ -291,7 +276,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
"version": "3.9.13"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/8 - Electrical Mismatch Method.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#
# This will generate the results over which we will perform the mismatch analysis. Here we are doing only 1 day to make this faster.

# In[1]:
# In[2]:


import bifacial_radiance
Expand All @@ -58,7 +58,7 @@
os.makedirs(testfolder)

simulationName = 'tutorial_8'
moduletype = "test-module"
moduletype = "PVModule"
albedo = 0.25
lat = 37.5
lon = -77.6
Expand Down Expand Up @@ -130,7 +130,7 @@
# - Upsample
#

# In[2]:
# In[3]:


resultfolder = os.path.join(testfolder, 'results')
Expand Down

0 comments on commit f150969

Please sign in to comment.