Importing inputs from SAM, Interdependent Variables, SSC versions

  • LKEX
  • Topic Author
More
03 Apr 2024 05:27 #13050 by LKEX
Hello,

I'm new to the topic of SAM and PySAM. For importing inputs from SAM the current documentation of PySAM suggests using PySAM JSON exports or JSON for inputs exports. These can than later imported by looping through the contents of the JSON file:
Code:
for f, m in zip(file_names, modules): with open(dir + f + ".json", 'r') as file: data = json.load(file) # loop through each key-value pair for k, v in data.items(): if k != "number_inputs": m.value(k, v)

However, for older PySAM versions I also found options to use PySSC's dict_to_ssc_table:
Code:
json_file_path = 'pvwattsdistcomm.json' f = open(json_file_path) dic = json.load(f) pv_dat = pssc.dict_to_ssc_table(dic, "pvwattsv7") grid_dat = pssc.dict_to_ssc_table(dic, "grid") f.close() pv = PVWatts.wrap(pv_dat) grid = Grid.from_existing(pv) grid.assign(Grid.wrap(grid_dat).export())

Which of the three options is the best to use? Which shall be avoided?

For me it was not so easy to find out which SSC my current SAM or PySAM version is using. It could be helpful if PySAM issues a warning if JSON files exported from SAM were created for a different SSC than the one used by the PySAM version.
It would be also nice, if the binaries of the different releases are available on downloads page .
For example PySAM 5.0.0 uses SSC288, the currently available binaries are SAM 2023.12.17 R1 (SSC290). But where can I download SAM 2023.12.17 (SSC288)?


In the examples to the interdependent variables one link refers to a PV System Design.txt file. However, all the text files in this folder have been converted to JSONs.

Many thanks for your answers in advance
Lukas

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

  • pgilman
More
03 Apr 2024 10:38 #13052 by pgilman
Hi Lukas,

For working with SSC in Python, we recommend using PySAM rather than PySSC.

We've tried to improve version information over time -- I agree there is room for more improvement here.

In SAM, you can see the SSC version by clicking Help, About. You can find the SSC version for any version of SAM in the release notes -- click the button in SAM's Help window or go to nrel.github.io/SAM/doc/releasenotes.html .

For PySAM, you can refer to the Releases page on GitHub: github.com/NREL/pysam/releases , which is referenced on the Versions page of the PySAM documentation: nrel-pysam.readthedocs.io/en/main/versions.html .

SAM does not record the SSC version number in .sam files, and SAM's code generator does not record the ssc version number in the JSON files it creates. SAM is designed to be able to open older .sam files, and PySAM should work with old JSON files -- we try to avoid changing variable names that cause incompatibility issues with old files. An exception to this is the recent change in the "adjust" variable from a table structure that used colons in the variable name to a flat structure that uses underscores, but SSC should generate a helpful error message if you use the old format for one of these variables. (For example, the old 'adjust:constant' variable in Pvsamv1 is now 'adjust_constant'.)

For each version of SAM, we only provide access to the most recent update. For example, for SAM 2023.12.17, we we only provide access to SAM 2023.12.17 r1. We no longer provide access to the original release because it has known bugs that we have fixed.

There is typically a delay between the time we release a new SAM version and when we release the equivalent PySAM version because of the time it takes to build PySAM. This was especially true with the SAM 2023.12.17 release because the new hybrids models in SAM required significant changes to the PySAM build process. As of now, SAM 2023.12.17 r1 is eqivalent to PySAM 5.1.0: Both are based on SSC 290.

Best regards,
Paul.

 

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

  • LKEX
  • Topic Author
More
31 May 2024 07:30 #13221 by LKEX
Hi Paul,

thanks for your comprehensive answer. It took a while until I found time to work with PySAM again. Now I use PySAM 5.1.0 together with SAM 2023.12.17 (SSC290).



When using using PySAM JSON exports or JSON for inputs exports togehter with the suggested PySAM input import, I receive AttributeErrors for several keys in the JSON files.

For example, all 6par (JSON for inputs) keys should be named sixpar (PySAM JSON): e.g. 6par_celltech (JSON for inputs) should be named sixpar_celltech (like in PySAM JSON)

Further when using PySAM JSON for the following keys :
adjust_constant
adjust_en_timeindex
adjust_en_periods
adjust_timeindex
adjust_periods
dc_adjust_constant
dc_adjust_en_timeindex
dc_adjust_en_periods
dc_adjust_timeindex
dc_adjust_periods

When using JSON for inputs:
adjust_en_timeindex
adjust_en_periods
adjust_timeindex
adjust_periods
dc_adjust_constant
dc_adjust_en_timeindex
dc_adjust_en_periods
dc_adjust_timeindex
dc_adjust_periods
compute_module_0
compute_module_1
metric_0
metric_0_label
metric_1
metric_1_label
metric_2
metric_2_label
metric_3
metric_3_label
number_compute_modules
number_metrics

Attached you'll find my SAM model, the python code as well a the JSON files.

BR Lukas

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

  • pgilman
More
03 Jun 2024 14:23 #13231 by pgilman
Hi Lucas,

Please use the workaround for the "adjust" issue as described here: github.com/NREL/pysam/issues/164

Best regards,
Paul.

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

Moderators: pgilman
Powered by Kunena Forum