Custom EPW file import in Ladybug Grasshopper from PC folder

Hello! I am surviving some kind of a crisis here:)
The aim of my research is to compare the two summer temperature scenarios (the current situation VS the R.C.P. 4.5 projection to the 2050). I managed to successfully modify existing EPW file with “R studio”, and from the excel visualization all the modified data seems to be accurate.
The major problem I am having now, is how to import the modified EPW from my directory folder to the grasshopper ladybug canvas. From the information I have now, it seems that it is only possible to upload the URL link from open sources to Ladybug, and there is no evident way on uploading it immediately from the PC.
The problem is that the ladybug “import epw” component gives the following error: “1. Solution exception:index out of range: 1”, which makes me think or about the epw file integrity/structure (even if I tried to connect the original unmodified file as well with the same result), or about the way ladybug reads the file path format.

I attach the screen.
I sincerely hope that there is an evident or banal solution for this problem that I missed!
Please, let me know if there is a solution of any kind!
Thank you!
Best regards,
Anastasiia, the saddest sustainability student

Hi @Anastasiia

Perhaps your EPW files contains incorect data:
You could try to use the dragonfly tool for creating the EPW file. (“DF create EPW”)

Hi @Anastasiia! It sounds like there is something incorrect in the file. Perhaps an extra comma. Can you upload the morphed file and the original here? Also you can try using https://www.morphepw.app to make the weather file. I built this and am still beta testing it. It relies on the CMIP6 models and the SSP scenario set, not RCP though.

Thank you for your advice Justin, I will take a look! For my research I have determined values to follow, but it will be definitely useful in the future.
Unfortunately, as a new user I can’t upload files here, so I attach the link to the google drive with the two epw files. EPW morphed - Google Drive

Thank you, Erik! I will take a look at this component

Hi @Anastasiia ,

I’m not familiar with R studio but your EPW file clearly has a few issues with it. One is that it’s using semicolons instead of commas and, as a standard, all EPW files use commas:

Another issue is that it has a bunch of trailing semicolons. Nothing that couldn’t be fixed with a small Python script:

epw_file = 'C:/Users/[USERNAME]/Downloads/MORPHED_ITA_PM_Torino.2050.epw'

with open(epw_file, 'r') as inf:
    contents = inf.read()

contents = contents.replace(';', ',')
new_contents = []
for line in contents.split('\n'):
    new_contents.append(line.rstrip(','))

with open(epw_file, 'w') as of:
    of.write('\n'.join(new_contents))

… And copy/pasting the original header back onto the morphed EPW.

Now it imports successfully:

Here’s the fixed file:
MORPHED_ITA_PM_Torino.2050.epw (1.4 MB)

1 Like

Thank you very much, Chris! You saved one life today:)
I will learn more about EPW structure, and try to work with Python next time.