Variable from JSON for PySAM not being read

  • Henry Foss
  • Topic Author
More
09 Jan 2023 10:29 #11811 by Henry Foss
 
Hello,

File Attachment:

File Name: SAM to zip.zip
File Size:10 KB

As usual, thanks to NREL for this great tool.

I'm having trouble using Pvsamv1 model in PySAM. I'm basically trying to load a SAM GUI configuration using the PySAM JSON export and generate the annual hourly generation from a whole series of weather files. I was able to do this successfully for a wind model, but it's not working for my solar model. The code doesn't seem to be able to read the variable 'system_capacity' from the JSON, despite me being able to see it in the file.

I have loaded my python code showing both the working wind code and the not working PV code. And the JSON file I'm using as an input for the PV model.

Apologies for the basic question and thanks in advance for the help.

Best regards,
Henry
Attachments:

Please Log in or Create an account to join the conversation.

  • Paul Gilman
More
10 Jan 2023 18:14 - 10 Jan 2023 18:18 #11822 by Paul Gilman
Replied by Paul Gilman on topic Variable from JSON for PySAM not being read
Hi Henry,

The 'system_capacity' input to the pvsamv1 module is an example of an interdependent variable.

In the pvsamv1 documentation, you can see a list of variables on which 'system_capacity' depends:

nrel-pysam.readthedocs.io/en/master/modules/Pvsamv1.html#PySAM.Pvsamv1.Pvsamv1.SystemDesign.system_capacity.

See the section on interdependent variables for more information:

nrel-pysam.readthedocs.io/en/master/interdependent-variables.html

However, I think the problem in your script is with the way you are importing modules from PySAM. For the wind model you have:
PySAM.Windpower as WindPower

And, then, later on:
gs_dat = dict_to_ssc_table(dic, "WindPower")
Windmodel = WindPower.wrap(gs_dat)

But for the PV model:
import PySAM.Pvsamv1 as pv1

And, then:
PVmodel_dat = dict_to_ssc_table(dic, "FlatPlatePVNone")
gridmodel_dat = dict_to_ssc_table(dic, "grid")
PVmodel = pv1.wrap(PVmodel_dat)
gridmodel = grid.wrap(gridmodel_dat)

It doesn't look like the pvsamv1 inputs are getting loaded properly. I think your call to dict_to_ssc_table() here should use 'pv1' instead of 'FlatPlatePVNone' as a parameter.

It might be easier to use the one of the methods described here to import your inputs from json instead of dict_to_ssc_table():

nrel-pysam.readthedocs.io/en/master/inputs-from-sam.html

If that information does not help, and you would like me to help troubleshoot, please attach minimal code along with a weather file that causes the error you are trying to fix.

Best regards,
Paul.

 
Last edit: 10 Jan 2023 18:18 by Paul Gilman.

Please Log in or Create an account to join the conversation.

  • Henry Foss
  • Topic Author
More
18 Jan 2023 06:52 #11838 by Henry Foss
Replied by Henry Foss on topic Variable from JSON for PySAM not being read
Hi Paul,Thank you for your quick response. I took my time as I wanted to fix the error. Alas, it was not to be.I've attached the minimum code, JSON and resource file. I replaced the dict_to_ssc method with the 'for m in modules' method found in the link you shared (nrel-pysam.readthedocs.io/en/master/inputs-from-sam.html). Unfortunately I now get the error 'AttributeError: 'value' error, could not find attribute: use_spatial_albedos' even though it is in the json (as 0).It would be very helpful if you could please review and check.On an additional note, in the code samples in the link above, the suggested code for the 'JSON for inputs' method is the same as the PySAM JSON method. Is that correct?Best regards,Henry
Attachments:

Please Log in or Create an account to join the conversation.

  • Paul Gilman
More
18 Jan 2023 23:49 #11839 by Paul Gilman
Replied by Paul Gilman on topic Variable from JSON for PySAM not being read
Hi Henry,

See the attached Jupyter notebook and supporting files. My changes are marked with "#cpg", so you can search for those.

There were two problems with this once I removed file paths pointing to files outside of this collection of files:

1. The pvsamv1 JSON file sets subarray1_rotlim = 90, but the maximum allowed value is 85. I set the rotation limit to 85 in Python, but if you remove that you will see a pvsamv1 simulation error telling you about that.

2. The weather file path was being loaded from the pvsamv1 JSON file. After loading the inputs from the JSON file, you need to set solar_resource_file to the weather file path -- you can see how I did that.

Best regards,
Paul.
Attachments:

Please Log in or Create an account to join the conversation.

Moderators: Paul Gilman
Powered by Kunena Forum