Description - As the name implies, this type of filter selects data elements based on certain criteria. This class provides a way for the user to select specific elements from inputs. It supports multiple inputs for the selection expressions, but only elements from the first input are passed through. If you want elements strung together in serial you should use a MergeFilter. If you want them in parallel with elements that have some values from one input, and some from others then a FunctionFilter can do the job.

This filter has several "modes" of operation. The simplest one allows the user to type in a simple boolean expression. If that expression is true for a given index number then the element with that index from the first input is passed through. To quickly thin out a SWIFT file with a large number of particles you can use % operator in the expression with the particle number so p[0]%10==0 would only pass through every tenth particle from a SWIFT binary file.

This is enhanced by working with subsets (taking all elements that have the same value for a certain expression). You can toggle whether you want to use subsets in a selection.

To see the value of this let's look at an example of doing a selection with subsets. You provide an expression like in the simple form as well as a subset expression. In this case it is not just single elements that are selected. Instead, it takes all elements for which the provided subset expression matches that of any selected element. This requires two passes through the data. First, the subsets that will be used are identified then all the elements in those subsets are selected. In SWIFT this can be used to select all particles which matched some simple expression at some time during the simulation. So the subset expression could be p[0] and if we only want particles whose eccentricity was greater than 0.3 the selection expression could be v[2]>0.3. Without subsets this only returns particles at times when their eccentricity is greater than 0.3. With subsets it will return the entire history of any particle that reached that state at any point in the simulation.

Sometimes you want the selection to be based on a comparison of one element to another one. The normal expression model allows you to do this with an offset or by groupings. Here we discuss doing this with groupings. For example, you want to compare all the bodies in a given timestep to one particular body. For a group to be used, the input data should have consecutive elements where the value of some formula is the same. If they aren't consecutive, you can use a sort to make them so. In the example of comparing particles at a timestep, the time is what you would want it grouped by. If you wanted to find instances where a particle was close to Jupiter and Jupiter had a particle ID of -2 then your group selection would be {v[0], p[0]=-2}. If the expression doesn't pick a unique element in a group, the first one that satisfies it will be used. If no elements in a group satisfy it the first element of the group is used by default. The values and parameters for the selected element are signified in the formula with primes (single quotes). So just comparing the difference between the semimajor axes might look like abs(v[1]-v'[1])<0.1.

If grouping were used without subsets in this case you would only get the elements for particles close to Jupiter at the time they were close to Jupiter. Combining it with a subset expression of particle ID would select the entire histories of any particles that had close encounters.

Inputs - This filter accepts multiple inputs that can be used in the selection formula, but only passes on the elements from the first input whose index produces true on the formula.

Elements - These match the format of the first input.

Memory - Because this filter does not alter elements, it only has to keep references to the elements of the first input that it is passing through. It also typically reduces the number of elements significantly. However, it should be noted that using this filter with a large source as the first input and a formula that accepts nearly all elements will negate the buffering that the large source might do.