Commit 47654a0
authored
Support list of weather input for ModelChain with a single-array PVSystem (#1157)
* Add tests covering singleton input to ModelChain entry points
Covers passing a length-one list of weather DataFrames to each of
- `ModelChain.run_model()`
- `ModelChain.run_model_from_poa()`
- `ModelChain.run_model_from_effective_irradiance()`
When the PVSystem being modeled has only one Array. In this case
the output stored in each field of `ModelChain.results` should be
a length-one tuple.
* Support tuple input to PVSystem.get_ac for single-array systems
Allow p_dc and v_dc to be length-1 tuples even when the system has
only one Array. This helps keep the API consistent so that if the
dc power methods are called with `unwrap=False` their output can be
passed directly to `PVSystem.get_ac()`.
* Add ModelChain._assign_result() method
This method is responsible for ensuring that per-array results match
the type of ModelChain.weather. This is an issue when
ModelChain.system has only one Array, but ModelChain.weather is a
tuple of length 1. In this case we want the results attributes to also
be length-1 tuples for the sake of consistency and to ensure that
calculations down-stream can proceed without needing to worry about
mixed types (e.g. total_irrad is a Series, but weather is a tuple).
* Clean up whitespace in test_modelchain.py
Accidentally under-indented a whole test:
test_run_model_from_poa_singleton_weather_single_array()
* Support singleton weather input for ModelChain with spectral loss
Add tests for spectral_model != 'no_loss' and aoi_model != 'no_loss'
when calling ModelChain.run_model([weather]) on a system with 1 Array.
Handles the type of ModelChain.weather correctly in
ModelChain.first_solar_spectral_loss() by using _tuple_from_dfs() to
get 'precipitable_water'.
Still needs support for constant spectral loss
* PVSystem.first_solar_spectral_loss() validates `pw` param against
Extends `PVSystem.first_solar_spectral_loss()` to treat `pw` as a
per-Array or system wide parameter.
* Use itertools.starmap in in PVSystem.first_solar_spectral_loss()
A bit cleaner than using a generator expression.
* Refactor: replace _assign_result() with ModelChainResult.__setattr__
Add a configuration step in ModelChain._assign_weather() that
sets a flag on the ModelChain.results to indicate whether non-tuples
assigned to per-array fields should be wrapped in length-1 tuples.
This is accomplished by a custom __setattr__ methon on
ModelChainResult. The setter checks whether the attribute is a
per-array attribute and coerces it if the _singleton_tuples flag
is set.
* Add float to the type for ModelChainResult.aoi_modifier
Covers the case where the aoi_model is 'no_loss'.
* Tidy up ModelChainResult
Re-order fields and comments. Add docstring to _result_type()
method.1 parent 975b798 commit 47654a0
4 files changed
Lines changed: 206 additions & 48 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
271 | 278 | | |
272 | 279 | | |
273 | 280 | | |
274 | 281 | | |
275 | | - | |
276 | 282 | | |
| 283 | + | |
| 284 | + | |
277 | 285 | | |
278 | 286 | | |
279 | | - | |
280 | | - | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
281 | 291 | | |
282 | 292 | | |
283 | 293 | | |
284 | 294 | | |
285 | 295 | | |
286 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
287 | 312 | | |
288 | 313 | | |
289 | 314 | | |
| |||
684 | 709 | | |
685 | 710 | | |
686 | 711 | | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | | - | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
693 | 715 | | |
694 | 716 | | |
695 | 717 | | |
| |||
745 | 767 | | |
746 | 768 | | |
747 | 769 | | |
748 | | - | |
749 | | - | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
759 | | - | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
760 | 778 | | |
761 | 779 | | |
762 | 780 | | |
| |||
866 | 884 | | |
867 | 885 | | |
868 | 886 | | |
869 | | - | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
870 | 890 | | |
871 | 891 | | |
872 | 892 | | |
873 | | - | |
874 | | - | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
875 | 897 | | |
876 | 898 | | |
877 | 899 | | |
878 | | - | |
879 | | - | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
880 | 904 | | |
881 | 905 | | |
882 | 906 | | |
883 | 907 | | |
884 | | - | |
885 | | - | |
| 908 | + | |
| 909 | + | |
886 | 910 | | |
887 | 911 | | |
888 | 912 | | |
| |||
934 | 958 | | |
935 | 959 | | |
936 | 960 | | |
937 | | - | |
938 | | - | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
939 | 964 | | |
940 | 965 | | |
941 | 966 | | |
942 | 967 | | |
943 | | - | |
| 968 | + | |
| 969 | + | |
944 | 970 | | |
945 | 971 | | |
946 | 972 | | |
| |||
1066 | 1092 | | |
1067 | 1093 | | |
1068 | 1094 | | |
1069 | | - | |
| 1095 | + | |
1070 | 1096 | | |
1071 | 1097 | | |
1072 | 1098 | | |
| |||
1271 | 1297 | | |
1272 | 1298 | | |
1273 | 1299 | | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
1274 | 1311 | | |
1275 | 1312 | | |
1276 | 1313 | | |
| |||
1286 | 1323 | | |
1287 | 1324 | | |
1288 | 1325 | | |
| 1326 | + | |
1289 | 1327 | | |
1290 | 1328 | | |
1291 | 1329 | | |
| |||
1383 | 1421 | | |
1384 | 1422 | | |
1385 | 1423 | | |
1386 | | - | |
| 1424 | + | |
| 1425 | + | |
1387 | 1426 | | |
1388 | 1427 | | |
1389 | 1428 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
811 | 812 | | |
812 | 813 | | |
813 | 814 | | |
| 815 | + | |
814 | 816 | | |
815 | | - | |
| 817 | + | |
816 | 818 | | |
817 | 819 | | |
818 | 820 | | |
| |||
828 | 830 | | |
829 | 831 | | |
830 | 832 | | |
831 | | - | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
832 | 836 | | |
833 | 837 | | |
834 | 838 | | |
| |||
891 | 895 | | |
892 | 896 | | |
893 | 897 | | |
| 898 | + | |
| 899 | + | |
894 | 900 | | |
895 | | - | |
896 | | - | |
897 | | - | |
898 | | - | |
899 | | - | |
900 | | - | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
901 | 904 | | |
902 | 905 | | |
903 | 906 | | |
| 907 | + | |
904 | 908 | | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | | - | |
909 | | - | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
910 | 913 | | |
911 | 914 | | |
912 | 915 | | |
913 | 916 | | |
914 | 917 | | |
915 | | - | |
916 | | - | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
917 | 923 | | |
918 | 924 | | |
919 | 925 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1080 | 1080 | | |
1081 | 1081 | | |
1082 | 1082 | | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
1083 | 1131 | | |
1084 | 1132 | | |
1085 | 1133 | | |
| |||
1324 | 1372 | | |
1325 | 1373 | | |
1326 | 1374 | | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
1327 | 1391 | | |
1328 | 1392 | | |
1329 | 1393 | | |
| |||
1382 | 1446 | | |
1383 | 1447 | | |
1384 | 1448 | | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
1385 | 1464 | | |
1386 | 1465 | | |
1387 | 1466 | | |
| |||
0 commit comments