- Posts: 1
Error message related to utf-8 encoding in parabolic trough LCOH calculator
- Chris8048
- Topic Author
Less
More
17 Sep 2024 13:50 #13442
by Chris8048
Error message related to utf-8 encoding in parabolic trough LCOH calculator was created by Chris8048
Hello,
I am new to PySAM. I'm trying to create a Python script to calculate the LCOH of a parabolic trough solar IPH field with a variety of input parameter conditions (outlet temperatures, solar multiples, thermal storage capacities, etc.).
Disfortunately, I'm getting the following error message when I run my script (attached):
This ^ error pops up on line 67, which is the first time I try to customize an input parameter (
). Thus, it appears there's some issue with reading / writing onto the input parameters in SAM, and it has something to do with a "utf-8 encoding" issue that I don't quite understand.
I saw that there was a similar post back in March, where a user had the same error message when trying to run the first example case on the " Getting Started " page. It looks like the issue was caused by a naming inconsistency with variables that include the term "
" in PySAM, and Paul Gilman (
pgilman
) provided a fix as follows:for k, v in pv_inputs.items():
if 'adjust' in k:
k = k.split('adjust_')[1]As you will see in the commented-out section of my code (lines 33-61), I tried to apply this fix directly to my own script, but disfortunately it didn't work.
Are there additional known issues with naming inconsistencies for input parameters in PySAM? Will this issue be fixed in an upcoming version release, and is there a temporary fix (similar to the one above) that I can use in the meantime?
For context, I just recently downloaded SAM for the first time, so I'm on the most recent version (SAM 2023.12.17). My Python version is 3.11, and as you can see from line 1 of my script, it uses "utf-8" encoding. My
package version is 5.1.0.
Thank you,
Chris
I am new to PySAM. I'm trying to create a Python script to calculate the LCOH of a parabolic trough solar IPH field with a variety of input parameter conditions (outlet temperatures, solar multiples, thermal storage capacities, etc.).
Disfortunately, I'm getting the following error message when I run my script (attached):
Code:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc8 in position 41: invalid continuation byte
This ^ error pops up on line 67, which is the first time I try to customize an input parameter (
Code:
lcoh_model.value('sales_tax_rate', 0)
I saw that there was a similar post back in March, where a user had the same error message when trying to run the first example case on the " Getting Started " page. It looks like the issue was caused by a naming inconsistency with variables that include the term "
Code:
adjust_
if 'adjust' in k:
k = k.split('adjust_')[1]As you will see in the commented-out section of my code (lines 33-61), I tried to apply this fix directly to my own script, but disfortunately it didn't work.
Are there additional known issues with naming inconsistencies for input parameters in PySAM? Will this issue be fixed in an upcoming version release, and is there a temporary fix (similar to the one above) that I can use in the meantime?
For context, I just recently downloaded SAM for the first time, so I'm on the most recent version (SAM 2023.12.17). My Python version is 3.11, and as you can see from line 1 of my script, it uses "utf-8" encoding. My
Code:
nrel-pysam
Thank you,
Chris
Attachments:
Please Log in or Create an account to join the conversation.
- pgilman
Less
More
- Posts: 5447
17 Sep 2024 16:55 #13444
by pgilman
Replied by pgilman on topic Error message related to utf-8 encoding in parabolic trough LCOH calculator
Hi Chris,
When I run your script, I get the following error:
It indicates a problem with Line 67, which involves the 'sales_tax_rate' variable.
Your model is based on the default "PhysicalTroughIPHLCOHCalculator" configuration, which is described here in the PySAM documentation: nrel-pysam.readthedocs.io/en/main/sam-configurations.html#parabolic-trough .
The documentation lists the two models required for that configuration:
That documentation does not list 'sales_tax_rate' as an input. Line 67 of your script attempts to assign a value to an input that does not exist for the configuration you are modeling, which causes the error.
Please use that information to use the PySAM documentation to try to debug the rest of your code. If you run into another problem, please attach a minimal reproducible example of code that illustrates the problem and I will try to help.
Best regards,
Paul.
When I run your script, I get the following error:
Code:
Traceback (most recent call last): File "solar_thermal_LCOH_optimizer.py", line 67, in lcoh_model.value('sales_tax_rate', 0) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf9 in position 42: invalid start byte
It indicates a problem with Line 67, which involves the 'sales_tax_rate' variable.
Your model is based on the default "PhysicalTroughIPHLCOHCalculator" configuration, which is described here in the PySAM documentation: nrel-pysam.readthedocs.io/en/main/sam-configurations.html#parabolic-trough .
The documentation lists the two models required for that configuration:
- TroughPhysicalIph
- LcoefcrDesign
That documentation does not list 'sales_tax_rate' as an input. Line 67 of your script attempts to assign a value to an input that does not exist for the configuration you are modeling, which causes the error.
Please use that information to use the PySAM documentation to try to debug the rest of your code. If you run into another problem, please attach a minimal reproducible example of code that illustrates the problem and I will try to help.
Best regards,
Paul.
Please Log in or Create an account to join the conversation.
Moderators: pgilman