Author Topic: Annoying glitch in PixelMath  (Read 1213 times)

Offline ppistor

  • Newcomer
  • Posts: 22
Annoying glitch in PixelMath
« on: 2016 November 23 07:26:08 »
When I copy txt-Data like this one

(d2seg(2076,  37,2076,  96)<=1.2)|
(d2seg(2131,   1,2131,  33)<=1.2)|
(d2seg(2131,  48,2131, 241)<=1.2)|
(d2seg(1414,   1,1414, 876)<=1.2)|
(d2seg(2527, 115,2527, 441)<=1.5)|
(d2seg(2621,   1,2621, 737)<=1.1)|
(d2seg(2876,   1,2876, 737)<=1.1)

into the expression editor field of PixelMath, leave the Editor by pressing "OK" and issue the "Apply" button in the main PM menue, PM usually issues a "...<*failed*> message.
There are several ways to get PM working, e.g.
_go to Expression Edito once more, simply return to themain panel and issue "Apply";
_before leaving the Expression Editor, simply add a blank space character at the end of the text, then go to "Apply";
_before leaving the Expression Editor, issue a "Parse" command; if successful, proceed to "Apply".
Is there an issue with blank, carriage return, line end or similar characters in the components of PixelMath?

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Annoying glitch in PixelMath
« Reply #1 on: 2016 November 24 01:02:55 »
Quote
Is there an issue with blank, carriage return, line end or similar characters in the components of PixelMath?

Not that I am aware of. If I copy the PixelMath expression you've posted directly from the forum post and paste it in the Expression Editor window, then I can reproduce the same problem you are describing. However, if I paste it on a new text document in Script Editor, then copy it from the document and paste it in Expression Editor, it works without problems. I am using Mozilla Firefox on OS X.

Web browsers, text processors, email clients and other rich-text applications tend to insert special control characters at the end of text lines. This is a very frequent issue. Use a good plain text editor, such as PixInsight's Script Editor, to write and maintain complex PixelMath expressions.

The next version of PixelMath, along with a considerable extension of its function collection, will have a redesigned tool window with the current expression editor dialog integrated in the interface. This will facilitate using complex, multiline expressions, which currently are not being managed comfortably.

On a side note, the expression you are using can be rewritten in a simpler and more efficient way:

d2seg( 2076,  37, 2076,  96 ) <= 1.2 ||
d2seg( 2131,   1, 2131,  33 ) <= 1.2 ||
d2seg( 2131,  48, 2131, 241 ) <= 1.2 ||
d2seg( 1414,   1, 1414, 876 ) <= 1.2 ||
d2seg( 2527, 115, 2527, 441 ) <= 1.5 ||
d2seg( 2621,   1, 2621, 737 ) <= 1.1 ||
d2seg( 2876,   1, 2876, 737 ) <= 1.1


Note the use of the logical OR operator (||) instead of bitwise OR (|). Since you are building a logical (binary) expression, logical operators are much faster. Note also that since relational operators have higher precedence than logical operators, you don't need to enclose them in parentheses.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/