Skip to content

Commit d37c260

Browse files
author
Tobin Ford
committed
Fix: spectral degradation (#3) df index
1 parent 131337a commit d37c260

File tree

1 file changed

+27
-69
lines changed

1 file changed

+27
-69
lines changed

tutorials_and_tools/tutorials_and_tools/3 - Spectral Degradation.ipynb

+27-69
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
{
3232
"cell_type": "code",
33-
"execution_count": 2,
33+
"execution_count": 1,
3434
"metadata": {},
3535
"outputs": [],
3636
"source": [
@@ -43,7 +43,7 @@
4343
},
4444
{
4545
"cell_type": "code",
46-
"execution_count": 3,
46+
"execution_count": 2,
4747
"metadata": {},
4848
"outputs": [
4949
{
@@ -86,7 +86,7 @@
8686
},
8787
{
8888
"cell_type": "code",
89-
"execution_count": null,
89+
"execution_count": 3,
9090
"metadata": {},
9191
"outputs": [
9292
{
@@ -174,7 +174,7 @@
174174
"2021-03-09 14:00:00 25 39 "
175175
]
176176
},
177-
"execution_count": 4,
177+
"execution_count": 3,
178178
"metadata": {},
179179
"output_type": "execute_result"
180180
}
@@ -199,7 +199,7 @@
199199
},
200200
{
201201
"cell_type": "code",
202-
"execution_count": 12,
202+
"execution_count": 18,
203203
"metadata": {},
204204
"outputs": [
205205
{
@@ -375,7 +375,7 @@
375375
"2021-03-09 19:00:00 0.729311 0.606430 "
376376
]
377377
},
378-
"execution_count": 12,
378+
"execution_count": 18,
379379
"metadata": {},
380380
"output_type": "execute_result"
381381
}
@@ -387,14 +387,20 @@
387387
"spectra_df = spectra.str.strip(\"[]\").str.split(\",\", expand=True).astype(float)\n",
388388
"spectra_df.columns = wavelengths\n",
389389
"\n",
390+
"# convert to pandas datetimeindex (usually don't need to do this)\n",
391+
"spectra_df.index = pd.DatetimeIndex(spectra_df.index)\n",
392+
"\n",
393+
"# create conditions dataframe with relative_humidity and temperature columns\n",
390394
"conditions_df = pd.DataFrame(\n",
391-
" index=spectra_df.index,\n",
392395
" data={\n",
393396
" \"relative_humidity\": SPECTRA[\"RH\"],\n",
394397
" \"temperature\": SPECTRA[\"Temperature\"],\n",
395398
" }\n",
396399
")\n",
397400
"\n",
401+
"# create matching indexes\n",
402+
"conditions_df.index = spectra_df.index\n",
403+
"\n",
398404
"spectra_df"
399405
]
400406
},
@@ -404,12 +410,14 @@
404410
"source": [
405411
"### 2. Calculate Degradation\n",
406412
"\n",
407-
"The spectral degradation function has several optional paramters. For more information, refer to the documentation. Below is a function call with the minimum required information."
413+
"The spectral degradation function has several optional paramters. For more information, refer to the documentation. Below is a function call with the minimum required information.\n",
414+
"\n",
415+
"The temperature column of `conditions_df` should be in $\\degree K$ but this example is in $\\degree C$ so this number is not accurate. However, this still works for demonstration purposes and has a simple fix. Add 273.15 all values in the temperature column."
408416
]
409417
},
410418
{
411419
"cell_type": "code",
412-
"execution_count": null,
420+
"execution_count": 22,
413421
"metadata": {},
414422
"outputs": [
415423
{
@@ -418,7 +426,7 @@
418426
"4.496994351804118e-38"
419427
]
420428
},
421-
"execution_count": 14,
429+
"execution_count": 22,
422430
"metadata": {},
423431
"output_type": "execute_result"
424432
}
@@ -433,69 +441,19 @@
433441
},
434442
{
435443
"cell_type": "code",
436-
"execution_count": 15,
444+
"execution_count": 21,
437445
"metadata": {},
438446
"outputs": [
439447
{
440-
"name": "stdout",
441-
"output_type": "stream",
442-
"text": [
443-
"Removing brackets from spectral irradiance data\n",
444-
"arr integral timestamp\n",
445-
"2021-03-09 10:00:00 2.193695e-45\n",
446-
"2021-03-09 11:00:00 1.833548e-46\n",
447-
"2021-03-09 12:00:00 1.508690e-34\n",
448-
"2021-03-09 13:00:00 4.256451e-47\n",
449-
"2021-03-09 14:00:00 1.041473e-82\n",
450-
"2021-03-09 15:00:00 5.746285e-189\n",
451-
"2021-03-09 16:00:00 2.430948e-62\n",
452-
"2021-03-09 17:00:00 1.440645e-46\n",
453-
"2021-03-09 18:00:00 2.196529e-64\n",
454-
"2021-03-09 19:00:00 1.433768e-103\n",
455-
"Name: Arr_integrand, dtype: float64\n",
456-
"wavelength integral timestamp\n",
457-
"2021-03-09 10:00:00 0.000358\n",
458-
"2021-03-09 11:00:00 0.000287\n",
459-
"2021-03-09 12:00:00 0.000298\n",
460-
"2021-03-09 13:00:00 0.000258\n",
461-
"2021-03-09 14:00:00 0.000338\n",
462-
"2021-03-09 15:00:00 0.000412\n",
463-
"2021-03-09 16:00:00 0.000275\n",
464-
"2021-03-09 17:00:00 0.000309\n",
465-
"2021-03-09 18:00:00 0.000311\n",
466-
"2021-03-09 19:00:00 0.000284\n",
467-
"Name: G_integral, dtype: float64\n",
468-
"delta degradation timestamp\n",
469-
"2021-03-09 10:00:00 7.861213e-49\n",
470-
"2021-03-09 11:00:00 5.263019e-50\n",
471-
"2021-03-09 12:00:00 4.496994e-38\n",
472-
"2021-03-09 13:00:00 1.099005e-50\n",
473-
"2021-03-09 14:00:00 3.519596e-86\n",
474-
"2021-03-09 15:00:00 2.369241e-192\n",
475-
"2021-03-09 16:00:00 6.696099e-66\n",
476-
"2021-03-09 17:00:00 4.452817e-50\n",
477-
"2021-03-09 18:00:00 6.827920e-68\n",
478-
"2021-03-09 19:00:00 4.071628e-107\n",
479-
"Name: dD, dtype: float64\n"
448+
"ename": "TypeError",
449+
"evalue": "degradation() got an unexpected keyword argument 'spectra'",
450+
"output_type": "error",
451+
"traceback": [
452+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
453+
"\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
454+
"Cell \u001b[1;32mIn[21], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m degradation \u001b[38;5;241m=\u001b[39m \u001b[43mpvdeg\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdegradation\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdegradation\u001b[49m\u001b[43m(\u001b[49m\u001b[43mspectra\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mSPECTRA\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mSpectra\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 2\u001b[0m \u001b[43m \u001b[49m\u001b[43mrh_module\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mSPECTRA\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mRH\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 3\u001b[0m \u001b[43m \u001b[49m\u001b[43mtemp_module\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mSPECTRA\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mTemperature\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 4\u001b[0m \u001b[43m \u001b[49m\u001b[43mwavelengths\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mwavelengths\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 6\u001b[0m degradation\n",
455+
"\u001b[1;31mTypeError\u001b[0m: degradation() got an unexpected keyword argument 'spectra'"
480456
]
481-
},
482-
{
483-
"name": "stderr",
484-
"output_type": "stream",
485-
"text": [
486-
"C:\\Users\\tford\\AppData\\Local\\Temp\\2\\ipykernel_26040\\2414568496.py:1: DeprecationWarning: Call to deprecated function degradation (old double integral degradation function will be replaced 'pvdegradation' in an updated version of pvdeg).\n",
487-
" degradation = pvdeg.degradation.degradation(spectra=SPECTRA['Spectra'],\n"
488-
]
489-
},
490-
{
491-
"data": {
492-
"text/plain": [
493-
"4.496994351804118e-38"
494-
]
495-
},
496-
"execution_count": 15,
497-
"metadata": {},
498-
"output_type": "execute_result"
499457
}
500458
],
501459
"source": [

0 commit comments

Comments
 (0)