Page 1 of 1

Match more then two columns using sddsprocess

Posted: 25 Jul 2018, 11:00
by Florian
Hi,

I was trying to match more than two columns using sddsprocess, but this always returns me:

Code: Select all

sddsprocess FLASH2_TDS_astra.sig -pipe=out \
"-match=column,ElementName=DISTDBC2,ElementName=DISTUBC2,ElementName=DISTUBC3,|" \
| sddsprintout -pipe -col=ElementName -col=s -col=St -col=Ss
Error (sddsprocess): invalid -match syntax
Error for sddsprintout:
Unable to read layout--no header lines found (SDDS_ReadLayout)
Trying with only two columns works fine:

Code: Select all

sddsprocess FLASH2_TDS_astra.sig -pipe=out \
> "-match=column,ElementName=DISTDBC2,ElementName=DISTUBC2,|" \
> | sddsprintout -pipe -col=ElementName -col=s -col=St -col=Ss
Printout for SDDS file stdin

 ElementName        s              St             Ss      
                    m              s              m       
----------------------------------------------------------
    DISTUBC2   1.859100e+01   1.721518e-12   5.167607e-04 
    DISTDBC2   2.263874e+01   1.764048e-13   5.362120e-05
Is it not possible to match more than two columns or am I missing something?

Re: Match more then two columns using sddsprocess

Posted: 25 Jul 2018, 14:11
by soliday
Try this:
"-match=column,ElementName=DISTDBC2,ElementName=DISTUBC2,|,ElementName=DISTUBC3,|"

Re: Match more then two columns using sddsprocess

Posted: 26 Jul 2018, 10:51
by michael_borland
Florian,

To explain Bob's reply a little, it is important to understand that the logic is implemented using reverse-polish notation.

We can understand Bob's solution

Code: Select all

"-match=column,ElementName=DISTDBC2,ElementName=DISTUBC2,|,ElementName=DISTUBC3,|"
as the following algorithm, executed row by row:
  1. Test ElementName=DISTDBC2 and push the result (true or false) on the stack.
  2. Test ElementName=DISTUBC2 and push the result (true or false) on the stack. The stack now contains two true/false values.
  3. Peform a logical 'or' operation on the top two values on the stack, and push the result back on the stack (the stack now contains a single true/false value).
  4. Test ElementName=DISTUBC3 and push the result (true or false) on the stack.
  5. Peform a logical 'or' operation on the top two values on the stack, and push the result back on the stack.
  6. If the stack contains 'true', then keep the row, otherwise discard it.
Using this notation and the |, &, and ! operators, we can create selection criteria of arbitrary complexity. E.g., here's how you'd select all elements with Q in the name that are not KQUADs:

Code: Select all

"-match=col,ElementName=*Q*,ElementType=KQUAD,!,&"
In your case, you could also use wildcards, e.g.,

Code: Select all

"-match=column,ElementName=DISTDBC2,ElementName=DISTUBC[23],|"
--Michael