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

Functionalities #92

Merged
merged 6 commits into from
Jun 27, 2019
Merged

Functionalities #92

merged 6 commits into from
Jun 27, 2019

Conversation

LucVV
Copy link
Contributor

@LucVV LucVV commented Nov 30, 2018

Hi Indranil,

I've added some functionalities to the zDDE library, which might be of interest. The functionalities include:

1) The addition of a property to check the current connection status

2) I ran into problems with some command that are based on writing the result to a text file and then reading the textfile (such as zGetZernike()). On some computers, the decimal separators in these files are commas in stead of points. This resulted in ValueErrors, for instance in
meta.append(float(_re.search(r'\d{1,3}\.\d{4,8}', meta_line).group()))
in line 9790 of the zdde code.

To circumvent this valueError, I added the function checkDecimalSeparators(string) to pyzdde/zfileutils.py and implemented it in the _getDecodedLineFromFile() function in pyzdde/zdde.py.

The function uses the regular expression '((?<=\d)|(?<=\A)|(?<=-)|(?<=\s))' to search for commas in strings that represent decimal separators and replace them by points.

It will do perform the following conversions:
'0,0' --> '0.0'
',0' --> '.0'
' ,0' --> ' .0'
'-,0' --> '-.0'

It will not perform the following conversions:
'1,' --> 1.

This separator is not expected to be a decimal separator, but rather a word separator, e.g. in:
A = 1, B= 2

'a,1' --> a.1
'1,a' -->1.a
'a,a' --> 'a.a'
'a,' --> 'a.'
',a' --> '.a
' ,a' --> ' .a

I've updated the regex twice in additional commits, if necessary, it can be updated for different behavior.

3) I updated zGetZernike() to handle instances where the Zernikes cannot be traced. For now, I chose to return a namedTuple filled with np.NaN on these occurrences, where the tuple is filled with the maximum amount of Zernike coefficients that you can acquire (37 for fringe, 231 for standard and annular Zernikes), in order to circumvent loops from running into errors.

Kind regards,

Luc

@LucVV LucVV merged commit 379db53 into xzos:master Jun 27, 2019
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

Successfully merging this pull request may close these issues.

None yet

1 participant