Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem getting zGetZernike about list indices #101

Open
g-velarde opened this issue Mar 28, 2020 · 12 comments
Open

Problem getting zGetZernike about list indices #101

g-velarde opened this issue Mar 28, 2020 · 12 comments

Comments

@g-velarde
Copy link

First of all thank you for this amazing code! :)
I am getting this error code:
9775, in zGetZernike
meta_line = line_list[_getFirstLineOfInterest(line_list, pat)]

TypeError: list indices must be integers or slices, not NoneType

When I write:
zInfo, zCoeff = ln.zGetZernike(which='fringe')

Thank you in advance!

@LucVV
Copy link
Contributor

LucVV commented Apr 29, 2020

Hi @g-velarde, sorry for the delayed reply.

It looks like the pattern does not match any part of the file. Could you check that Zemax actually has a result for your analysis? When to many rays are vignetted, it could be that the analysis was not performed, in which case the output might not be handled correctly. I fixed this issue in this pull request, which is merged online, but not released yet. Does that work for you?

@g-velarde
Copy link
Author

g-velarde commented Dec 30, 2020

still some issues with this topic but I get them just dumping the file zernike 'txt' file and searching lines for the zernike coeffs.
Thanks anyway!

@turygj
Copy link

turygj commented Oct 20, 2021

still some issues with this topic but I get them just dumping the file zernike 'txt' file and searching lines for the zernike coeffs. Thanks anyway!

I have the same problem. Have you solved this problem? If so, could you please provide the solution?

@LucVV
Copy link
Contributor

LucVV commented Oct 22, 2021

I'm not sure what is causing your errors if it's not an empty text file. Which OpticStudio version are you on?

@turygj, if you are looking for a function that finds the Zernike coefficients for you, I have implemented one for the Standard Zernike Coefficients here. I assume you should be able to apply this function without many modifications.

@turygj
Copy link

turygj commented Oct 25, 2021

I'm not sure what is causing your errors if it's not an empty text file. Which OpticStudio version are you on?

@turygj, if you are looking for a function that finds the Zernike coefficients for you, I have implemented one for the Standard Zernike Coefficients here. I assume you should be able to apply this function without many modifications.

The OpticStudio version is 181119.
I have got the zernike 'txt' by zGetTextFile.
Thank you for taking the time to respond to my questions!

@LucVV
Copy link
Contributor

LucVV commented Oct 25, 2021

Just to be sure, if you open the textfile yourself, does it contain the analysis result that you would also see in OpticStudio?

@turygj
Copy link

turygj commented Oct 25, 2021

Just to be sure, if you open the textfile yourself, does it contain the analysis result that you would also see in OpticStudio?

Yes. But If you have any more code after that, python will output an error and cannot run.

@LucVV
Copy link
Contributor

LucVV commented Oct 25, 2021

I see, I guess that one of the following meta patterns is not found:

meta_patterns = ["Peak to Valley\s+\(to chief\)",
                 "Peak to Valley\s+\(to centroid\)",
                 "RMS\s+\(to chief\)",
                 "RMS\s+\(to centroid\)",
                 "Variance",
                 "Strehl Ratio",
                 "RMS fit error",
                 "Maximum fit error"]

As a results, it tries to index with a None, which is not possible. I have adressed that in this pull request, but the version on PyPi does not have that. You could try to change your line 9775 to:

if line_index is not None:
    meta_line = line_list[line_index]
    meta.append(float(_re.search(r'\d{1,3}\.\d{4,8}', meta_line).group()))
else:
    meta.append(_math.nan)

Which should handle the NoneTypes

@turygj
Copy link

turygj commented Oct 25, 2021

Your guess is right. Now I can output the "zCoeff", but the "zInfo" becomes "nan" for everyone.

@LucVV
Copy link
Contributor

LucVV commented Oct 25, 2021

Oke, I guess the regex patterns are failing for some reason. Could you upload/post an example of the output?

@turygj
Copy link

turygj commented Oct 26, 2021

When I imput "zInfo, zCoeff = ln.zGetZernike(which='fringe')" and "print(zInfo, zCoeff)", the output is that "zInfo(pToVChief=nan, pToVCentroid=nan, rmsTochief=nan,……) andzCoeff(Z1=0.0012021, Z2=0, Z3=-0.77952288,……)"
Thank you for taking the time to respond to my questions!

@LucVV
Copy link
Contributor

LucVV commented Oct 26, 2021

I understand, but could you paste the content of the actual .txt file? I assume something goes wrong in reading it in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants