ksmet1977 / luxpy

Python toolbox for lighting and color science
GNU General Public License v3.0
112 stars 30 forks source link

Can't open user-provided IES files #21

Closed chadwickcasp closed 2 years ago

chadwickcasp commented 2 years ago

Hi, I'm trying to use luxpy to read photometric data from a .ies file into an array. However, I can't seem to get it to open the file from a file path correctly.

I import modules like so:

import luxpy as lx
from luxpy import iolidfiles as iolid
from io import StringIO

Our .ies file path (placed the file in the iolid data directory as I thought this could be the problem):

typeB_20deg_filepath = iolid._PATH_DATA + 'TypeB_20degBeam.ies'

I've apparently tried all three ways of ingesting .ies data in using the read_lamp_data function, with varying errors:

Using this raw text path:

LID_typeB_20deg = iolid.read_lamp_data(typeB_20deg_filepath, verbosity=1)

yields: image

Using a StringIO object:

typeB_20deg_path_stringio = StringIO(typeB_20deg_filepath)
LID_typeB_20deg = iolid.read_lamp_data(typeB_20deg_path_stringio, verbosity=1)

yields: image

And using the raw text from the file:

typeB_20deg_string = ""
with open(typeB_20deg_filepath, 'r') as f:
    typeB_20deg_string = f.read()
LID_typeB_20deg = iolid.read_lamp_data(typeB_20deg_string, verbosity=1)

yields: image

Using one of the given examples in the iolid data directory:

LID_path = iolid._PATH_DATA + 'luxpy_test_lid_file.ies'

And checking various parameters yields no major inconsistencies between the two file paths: image

Any guidance would be appreciated.

ksmet1977 commented 2 years ago

Using python v3.7 on a Windows 10 operating system, I have tried to replicate your first read error with: LID_path = iolid._PATH_DATA + 'luxpy_test_lid_file.ies' But all works fine. As for one of your other input method: the stringIO object should be the LID file itself, not the path. If you indeed read it first and convert it to a string, like you do above with the "with open()", then everything also seems to work fine.

Btw, you didn't tell whether you could read 'luxpy_test_lid_file.ies'. If you can read that and not your own file that would be strange. Have you tried reading your file from a (much shorter) different folder, like the desktop? Or just from the working directory?

In any case, I can't replicate your errors, so can't try to solve it. May be it has something to do with your installation, python version, windows operating system,...?

So I'm closing this issue for now.

chadwickcasp commented 2 years ago

Ah, I did fail to mention that. I was able to get the file 'luxpy_test_lid_file.ies' open using the read_lamp data function as attempted above for our own file. I'll attempt a different, shorter directory to read our custom .ies file from.

chadwickcasp commented 2 years ago

BTW I've tried this with systems that are running Windows 10, python 3.7.3 and 3.7.6, luxpy 1.9.6.

chadwickcasp commented 2 years ago

The error may be due to the file I'm using. I just tried a different file we produced that's smaller in size and I'm getting a different error. Seems to be getting past the file read now: image

chadwickcasp commented 2 years ago

Here's the file I'm trying to open.

ksmet1977 commented 2 years ago

Hi, I've had a look at your file, but I think your IES format is wrong. Have a look at: https://www.lisungroup.com/wp-content/uploads/2020/02/IESNA-LM-63-2-2002-Standard-Free-Download.pdf or http://lumen.iee.put.poznan.pl/kw/iesna.txt

You have a bunch or CR LF that should not be there after TILT=NONE. The following fields are on the same line, not on different lines:

single line: <# of lamps> <# of vertical angles> <# of horizontal angles> <units type> single line:

So you should have:

....

TILT=NONE 1 100.000000 1.0 37 73 1 2 0.000000 0.000000 0.000000 1.0 1 1 0.000000 5.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000

...

I also noticed that you have a TYPE360 geometry, but the code was only for a single phi-angle being given (I then replicate the intensity values for all the other values). This was giving an error, when trying to call np.arange() on a array. I've changed that, so it now recognizes if more than 1 phi angle is given and the type if TYPE360 then it should just use those (of course, if one supplies just 0° and 360°, there is still trouble, so make sure to provide sufficient intermediate values). The updated code is on github (a new release will be made later, not sure when).

regards,

Kevin

Op wo 23 feb. 2022 om 23:58 schreef Chadwick Casper < @.***>:

Here's the file https://drive.google.com/file/d/1jMSMNLrWkjY9Pj8-2h-QmvEzWj4mg3I4/view?usp=sharing I'm trying to open.

— Reply to this email directly, view it on GitHub https://github.com/ksmet1977/luxpy/issues/21#issuecomment-1049296942, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACS4LX6Y7OA7UALN3LUZXOLU4VRCDANCNFSM5PDDBFWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you modified the open/close state.Message ID: @.***>

chadwickcasp commented 2 years ago

Interesting. I'll directly download the repo and run this file formatting issue by our optical engineer. We generated the file using LightTools, so I wonder if there is some configuring he can do on his end.

chadwickcasp commented 2 years ago

I was able to get the Type C file working with the new version of 'io_lid_files.py'.

Test Patter Type C 20deg

Thanks for your help Kevin! -Chad