-
Notifications
You must be signed in to change notification settings - Fork 64
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
Comments
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? |
still some issues with this topic but I get them just dumping the file zernike 'txt' file and searching lines for the zernike coeffs. |
I have the same problem. Have you solved this problem? If so, could you please provide the solution? |
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. |
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. |
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 |
Your guess is right. Now I can output the "zCoeff", but the "zInfo" becomes "nan" for everyone. |
Oke, I guess the regex patterns are failing for some reason. Could you upload/post an example of the output? |
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,……)" |
I understand, but could you paste the content of the actual .txt file? I assume something goes wrong in reading it in. |
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!
The text was updated successfully, but these errors were encountered: