How to use a EPW file in PySAM

  • Ayman
  • Topic Author
More
12 Apr 2021 08:06 #9447 by Ayman
How to use a EPW file in PySAM was created by Ayman
Hello All,

I am importing my weather file from Europa in a EPW format. I can not import it to PySAM as PySAM only supports CSV files in a specific manner.
I was wondering if there was any way to convert the EPW file into a CSV file as a built in function in python ( or use the macros through python ), I know this is possible using the macros in SAM, but I would like to do it through code.
In the ssc_guide , I noticed that the input file can be taken as EPW in C code, so I figured that, that should be possible using PySAM.
In summary, how can I use a EPW file in PySAM 

Thank you,
Ayman Matar

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

  • Paul Gilman
More
12 Apr 2021 22:38 #9450 by Paul Gilman
Replied by Paul Gilman on topic How to use a EPW file in PySAM
Hi Ayman,

PySAM should be able to read the .epw file directly. It uses the same weather file reader as SAM, which can read weather files in the SAM CSV, EPW, old TMY2 and old TMY3 file formats.

You could also use SAM's "Solar Resource File Converter" macro to convert the file from EPW to SAM CSV format.

The Resource Tools helper functions in PySAM may also be helpful: nrel-pysam.readthedocs.io/en/master/Tools.html.

Best regards,
Paul.

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

  • Ayman
  • Topic Author
More
13 Apr 2021 06:18 #9453 by Ayman
Replied by Ayman on topic How to use a EPW file in PySAM
Hello and thank you Mr. Gilman for the fast reply,

So I tried entering a EPW file directly to PySAM, but it did not work as the function SAM_CSV_to_solar_data did not accept my EPW from Europa., as you can see in my ide It is telling me that my Time Zone field is not in my EPW file. ( I also the line that caused this error in the resource file, but it still raised an error for each of the parameters that are after the Time Zone field.). I also searched the  Resource tools helper functions , but I did not find anything for EPW files.
Attached you can find an image of my code which was taken from the PySAM tutorial, and the ResourceTools section that is causing the problem in my code. 

Thanks again for your time!
Ayman Matar

 

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

  • Paul Gilman
More
14 Apr 2021 21:16 #9465 by Paul Gilman
Replied by Paul Gilman on topic How to use a EPW file in PySAM
Hi Ayman,

Your code is attempting to use the tools.SAM_CSV_to_solar_data() helper function to read the data from the EPW file for the solar_resource_data input variable. That function is designed to read a file in the SAM CSV format, so you would have to convert the EPW file to SAM CSV before calling the function.

A different approach is to use the solar_resource_file variable, which you can set to the path to the EPW file. Then, the Pvsamv1 module will read the data directly from the file and you don't have to use the helper function. Here is the documentation for those input variables:

nrel-pysam.readthedocs.io/en/master/modules/Pvsamv1.html#solarresource-group



Best regards,
Paul.

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

Moderators: Paul Gilman
Powered by Kunena Forum