def filter_desc(self, graintype=None, group=None, reference=None,<EOL>size=None, phase=None):
<EOL>if graintype != None:<EOL><INDENT>indexing = []<EOL>if type(graintype) == str:<EOL><INDENT>graintype = [graintype]<EOL><DEDENT>for typ in graintype:<EOL><INDENT>for i in range(len(self.desc)):<EOL><INDENT>if self.desc[i][self.descdict['<STR_LIT>']] == typ:<EOL><INDENT>indexing.append(i)<EOL><DEDENT><DEDENT><DEDENT>self._filter_desc(indexing)<EOL><DEDENT>if phase != None:<EOL><INDENT>indexing = []<EOL>if type(phase) == str:<EOL><INDENT>phase = [phase]<EOL><DEDENT>for typ in phase:<EOL><INDENT>for i in range(len(self.desc)):<EOL><INDENT>if self.desc[i][self.descdict['<STR_LIT>']] == typ:<EOL><INDENT>indexing.append(i)<EOL><DEDENT><DEDENT><DEDENT>self._filter_desc(indexing)<EOL><DEDENT>if group != None:<EOL><INDENT>indexing = []<EOL>if type(group) != list:<EOL><INDENT>group = [group]<EOL><DEDENT>for grp in group:<EOL><INDENT>for i in range(len(self.desc)):<EOL><INDENT>if self.desc[i][self.descdict['<STR_LIT>']] == str(int(grp)):<EOL><INDENT>indexing.append(i)<EOL><DEDENT><DEDENT><DEDENT>self._filter_desc(indexing)<EOL><DEDENT>if reference != None:<EOL><INDENT>indexing = []<EOL>if type(reference) != list:<EOL><INDENT>reference = [reference]<EOL><DEDENT>for ri in range(len(reference)):<EOL><INDENT>for i in range(len(self.desc)):<EOL><INDENT>if self.desc[i][self.descdict['<STR_LIT>']] == reference[ri]:<EOL><INDENT>indexing.append(i)<EOL><DEDENT><DEDENT><DEDENT>self._filter_desc(indexing)<EOL><DEDENT>if size != None:<EOL><INDENT>indexing = []<EOL>operator = size[<NUM_LIT:0>:<NUM_LIT:1>]<EOL>size = float(size[<NUM_LIT:1>:len(size)])<EOL>for i in range(len(self.desc)):<EOL><INDENT>if  self.desc[i][self.descdict['<STR_LIT>']] != '<STR_LIT>':<EOL><INDENT>try:<EOL><INDENT>comperator1 = self.desc[i][self.descdict['<STR_LIT>']].split('<STR_LIT:x>')[<NUM_LIT:0>]<EOL>comperator2 = self.desc[i][self.descdict['<STR_LIT>']].split('<STR_LIT:x>')[<NUM_LIT:1>]<EOL>comperator = [float(comperator1),float(comperator2)]<EOL>if operator == '<STR_LIT:<>':<EOL><INDENT>comperator = np.min(comperator)<EOL><DEDENT>else:<EOL><INDENT>comperator = np.max(comperator)<EOL><DEDENT><DEDENT>except IndexError or AttributeError:<EOL><INDENT>try:<EOL><INDENT>comperator = float(self.desc[i][self.descdict['<STR_LIT>']])<EOL><DEDENT>except ValueError:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>if operator == '<STR_LIT:>>':<EOL><INDENT>if comperator > size:<EOL><INDENT>indexing.append(i)<EOL><DEDENT><DEDENT>elif operator == '<STR_LIT:<>':<EOL><INDENT>if comperator < size:<EOL><INDENT>indexing.append(i)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>continue<EOL><DEDENT><DEDENT><DEDENT>self._filter_desc(indexing)<EOL><DEDENT>
This routine is to filter for description elements.  You can
check what is available in the description by running,

>>> i.header_desc()

where i is the instance you loaded.

You can run the filter multiple times!  You can filter for the
following types:

Parameters
----------
graintype : string or list
    Give graintypes as either 'M' for only mainstream or more
    than one ['M','Z'].
group : integer or list
    Group of graintypes, important for oxides and silicates,
    since they are split into groups and not into types.
    Example 1, or give a list [1,3].
reference : string or list
    Give the reference you want to filter for, try an i.info()
    to pick the right name!  You can select a single
    referennce as string or multiple references in as a list.
size : string
    Filter for grain sizes, give '<5.0' or '>5.0' as a string
    for larger or smaller than a given grainsize in um.  Only
    data with known grainsizes are chosen.  Often grain sizes
    are given in a times b, where a and b are the minumum and
    maximum measurements from an image.  If you give a >5.0
    then grains with the smaller dimension >5um are taken into
    account.  If you want <5.0 then grains with the upper
    dimension <5um are taken into account.