Skip to content

Commit 0b1aa22

Browse files
committed
Reset SR file, update params, docstring
1 parent 98f1560 commit 0b1aa22

File tree

1 file changed

+85
-15
lines changed

1 file changed

+85
-15
lines changed

pvdeg/standards.py

+85-15
Original file line numberDiff line numberDiff line change
@@ -778,12 +778,12 @@ def vertical_POA(
778778

779779
return df_res
780780

781-
# this may only work with PVGIS
782781
def pysam(
783782
weather_df: pd.DataFrame,
784783
meta: dict,
785-
model: str,
786-
model_default: str,
784+
pv_model: str,
785+
pv_model_default: str,
786+
files: dict[str: str] = None,
787787
results: list[str] = None,
788788
) -> dict:
789789
"""
@@ -795,19 +795,85 @@ def pysam(
795795
DataFrame of weather data. As returned by ``pvdeg.weather.get``
796796
meta: dict
797797
Dictionary of metadata for the weather data. As returned by ``pvdeg.weather.get``
798-
model: str
799-
choose pySam module.
800-
801-
options: ``pvwatts8``, ``pysamv1``
798+
pv_model: str
799+
choose pySam photovoltaic system model.
800+
Some models are less thorough and run faster.
801+
pvwatts8 is ~50x faster than pysamv1 but only calculates 46 parameters while pysamv1 calculates 195.
802+
803+
options: ``pvwatts8``, ``pysamv1``, etc.
804+
805+
pv_model_default: str
806+
choose pysam config for pv model. [Pysam Modules](https://nrel-pysam.readthedocs.io/en/main/ssc-modules.html)
807+
808+
On the docs some modules have availabile defaults listed.
809+
810+
For example:
811+
[Pvwattsv8](https://nrel-pysam.readthedocs.io/en/main/modules/Pvwattsv8.html)
812+
- "FuelCellCommercial"
813+
- "FuelCellSingleOwner"
814+
- "GenericPVWattsWindFuelCellBatteryHybridHostDeveloper"
815+
- "GenericPVWattsWindFuelCellBatteryHybridSingleOwner"
816+
- "PVWattsBatteryCommercial"
817+
- "PVWattsBatteryHostDeveloper"
818+
- "PVWattsBatteryResidential"
819+
- "PVWattsBatteryThirdParty"
820+
- "PVWattsWindBatteryHybridHostDeveloper"
821+
- "PVWattsWindBatteryHybridSingleOwner"
822+
- "PVWattsWindFuelCellBatteryHybridHostDeveloper"
823+
- "PVWattsWindFuelCellBatteryHybridSingleOwner"
824+
- "PVWattsAllEquityPartnershipFlip"
825+
- "PVWattsCommercial"
826+
- "PVWattsCommunitySolar"
827+
- "PVWattsHostDeveloper"
828+
- "PVWattsLCOECalculator"
829+
- "PVWattsLeveragedPartnershipFlip"
830+
- "PVWattsMerchantPlant"
831+
- "PVWattsNone"
832+
- "PVWattsResidential"
833+
- "PVWattsSaleLeaseback"
834+
- "PVWattsSingleOwner"
835+
- "PVWattsThirdParty"
836+
837+
[Pvsamv1](https://nrel-pysam.readthedocs.io/en/main/modules/Pvsamv1.html)
838+
- "FlatPlatePVAllEquityPartnershipFlip"
839+
- "FlatPlatePVCommercial"
840+
- "FlatPlatePVHostDeveloper"
841+
- "FlatPlatePVLCOECalculator"
842+
- "FlatPlatePVLeveragedPartnershipFlip"
843+
- "FlatPlatePVMerchantPlant"
844+
- "FlatPlatePVNone"
845+
- "FlatPlatePVResidential"
846+
- "FlatPlatePVSaleLeaseback"
847+
- "FlatPlatePVSingleOwner"
848+
- "FlatPlatePVThirdParty"
849+
- "PVBatteryAllEquityPartnershipFlip"
850+
- "PVBatteryCommercial"
851+
- "PVBatteryHostDeveloper"
852+
- "PVBatteryLeveragedPartnershipFlip"
853+
- "PVBatteryMerchantPlant"
854+
- "PVBatteryResidential"
855+
- "PVBatterySaleLeaseback"
856+
- "PVBatterySingleOwner"
857+
- "PVBatteryThirdParty"
858+
- "PhotovoltaicWindBatteryHybridHostDeveloper"
859+
- "PhotovoltaicWindBatteryHybridSingleOwner"
802860
803861
results: list[str]
804-
list of strings corresponding to pysam outputs.
862+
list of strings corresponding to pysam outputs to return.
863+
Pysam models such as `Pvwatts8` and `Pvsamv1` return hundreds of results.
864+
So we can chose to take only the specified results while throwing away the others.
865+
866+
To grab only 'annual_energy' and 'ac' from the model results.
867+
868+
>>> results = ['annual_energy', 'ac']
869+
870+
This may cause some undesired behavior with geospatial calculations if the lengths of the results within the list are different.
805871
806872
Returns
807873
-------
808874
pysam_res: dict
809-
dictionary of outputs
810-
875+
dictionary of outputs. Keys are result name and value is the corresponding result.
876+
If `results` is not specified, the dictionary will contain every calculation from the model.
811877
"""
812878
import PySAM.Pvwattsv8 as pv8
813879
import PySAM.Pvsamv1 as pv1
@@ -834,12 +900,16 @@ def pysam(
834900

835901
# https://nrel-pysam.readthedocs.io/en/main/modules/Pvwattsv8.html
836902
# https://nrel-pysam.readthedocs.io/en/main/modules/Pvsamv1.html
837-
if model == "pvwatts8":
838-
pysam_model = pv8.default(model_default) # PVWattsCommercial
839-
elif model == "pysamv1":
840-
pysam_model = pv1.default(model_default) # FlatPlatePVCommercial
903+
if pv_model == "pvwatts8":
904+
pysam_model = pv8.default(pv_model_default) # PVWattsCommercial
905+
elif pv_model == "pysamv1":
906+
pysam_model = pv1.default(pv_model_default) # FlatPlatePVCommercial
907+
908+
pysam_model.unassign('solar_resource_file') # unassign file
841909

842-
pysam_model.SolarResource.solar_resource_data = solar_resource
910+
# Duplicate Columns in the dataframe seem to cause this issue
911+
# Error (-4) converting nested tuple 0 into row in matrix.
912+
pysam_model.SolarResource.solar_resource_data = solar_resource
843913
pysam_model.execute()
844914
outputs = pysam_model.Outputs.export()
845915

0 commit comments

Comments
 (0)