nodes: 0, module; 1, function_definition; 2, function_name:plot_pseudodepths; 3, parameters; 4, block; 5, identifier:configs; 6, identifier:nr_electrodes; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, dictionary_splat_pattern; 12, expression_statement; 13, comment:# for each configuration type we have different ways of computing; 14, comment:# pseudodepths; 15, expression_statement; 16, expression_statement; 17, comment:# sort the configurations into the various types of configurations; 18, expression_statement; 19, expression_statement; 20, comment:# loop through all measurement types; 21, expression_statement; 22, expression_statement; 23, for_statement; 24, if_statement; 25, identifier:spacing; 26, integer:1; 27, identifier:grid; 28, None; 29, identifier:ctypes; 30, None; 31, identifier:dd_merge; 32, False; 33, identifier:kwargs; 34, comment:"""Plot pseudodepths for the measurements. If grid is given, then the
      actual electrode positions are used, and the parameter 'spacing' is
      ignored'
  
      Parameters
      ----------
      configs: :class:`numpy.ndarray`
          Nx4 array containing the quadrupoles for different measurements
      nr_electrodes: int
          The overall number of electrodes of the dataset. This is used to plot
          the surface electrodes
      spacing: float, optional
          assumed distance between electrodes. Default=1
      grid: crtomo.grid.crt_grid instance, optional
          grid instance. Used to infer real electrode positions
      ctypes: list of strings, optional
          a list of configuration types that will be plotted. All
          configurations that can not be sorted into these types will not be
          plotted! Possible types:
  
          * dd
          * schlumberger
  
      dd_merge: bool, optional
          if True, merge all skips. Otherwise, generate individual plots for
          each skip
  
      Returns
      -------
      figs: matplotlib.figure.Figure instance or list of Figure instances
          if only one type was plotted, then the figure instance is returned.
          Otherwise, return a list of figure instances.
      axes: axes object or list of axes ojects
          plot axes
  
      Examples
      --------
  
      .. plot::
          :include-source:
  
          from reda.plotters.plots2d import plot_pseudodepths
          # define a few measurements
          import numpy as np
          configs = np.array((
              (1, 2, 4, 3),
              (1, 2, 5, 4),
              (1, 2, 6, 5),
              (2, 3, 5, 4),
              (2, 3, 6, 5),
              (3, 4, 6, 5),
          ))
          # plot
          fig, axes = plot_pseudodepths(configs, nr_electrodes=6, spacing=1,
                                        ctypes=['dd', ])
  
      .. plot::
          :include-source:
  
          from reda.plotters.plots2d import plot_pseudodepths
          # define a few measurements
          import numpy as np
          configs = np.array((
              (4, 7, 5, 6),
              (3, 8, 5, 6),
              (2, 9, 5, 6),
              (1, 10, 5, 6),
          ))
          # plot
          fig, axes = plot_pseudodepths(configs, nr_electrodes=10, spacing=1,
                                        ctypes=['schlumberger', ])
  
      """; 35, assignment; 36, assignment; 37, assignment; 38, assignment; 39, assignment; 40, assignment; 41, identifier:key; 42, call; 43, block; 44, comparison_operator:len(figs) == 1; 45, block; 46, else_clause; 47, identifier:pseudo_d_functions; 48, dictionary; 49, identifier:titles; 50, dictionary; 51, identifier:only_types; 52, boolean_operator; 53, identifier:results; 54, call; 55, identifier:figs; 56, list; 57, identifier:axes; 58, list; 59, identifier:sorted; 60, argument_list; 61, expression_statement; 62, if_statement; 63, expression_statement; 64, comment:# it is possible that we want to generate multiple plots for one; 65, comment:# type of measurement, i.e., to separate skips of dipole-dipole; 66, comment:# measurements. Therefore we generate two lists:; 67, comment:# 1) list of list of indices to plot; 68, comment:# 2) corresponding labels; 69, if_statement; 70, expression_statement; 71, comment:# generate plots; 72, for_statement; 73, call; 74, integer:1; 75, return_statement; 76, block; 77, pair; 78, pair; 79, pair; 80, pair; 81, pair; 82, pair; 83, identifier:ctypes; 84, list; 85, attribute; 86, argument_list; 87, call; 88, call; 89, comparison_operator:key == 'not_sorted'; 90, block; 91, assignment; 92, boolean_operator; 93, block; 94, else_clause; 95, assignment; 96, pattern_list; 97, call; 98, block; 99, identifier:len; 100, argument_list; 101, expression_list; 102, return_statement; 103, string; 104, identifier:_pseudodepths_dd_simple; 105, string; 106, identifier:_pseudodepths_schlumberger; 107, string; 108, identifier:_pseudodepths_wenner; 109, string; 110, string; 111, string; 112, string; 113, string; 114, string; 115, string; 116, identifier:fT; 117, identifier:filter; 118, identifier:configs; 119, keyword_argument; 120, attribute; 121, argument_list; 122, identifier:print; 123, argument_list; 124, identifier:key; 125, string; 126, continue_statement; 127, identifier:index_dict; 128, subscript; 129, comparison_operator:key == 'dd'; 130, not_operator; 131, expression_statement; 132, expression_statement; 133, for_statement; 134, comment:# merge all indices; 135, block; 136, identifier:grid; 137, None; 138, identifier:indices; 139, identifier:label_add; 140, identifier:zip; 141, argument_list; 142, if_statement; 143, expression_statement; 144, expression_statement; 145, expression_statement; 146, expression_statement; 147, comment:# plot electrodes; 148, if_statement; 149, expression_statement; 150, expression_statement; 151, expression_statement; 152, expression_statement; 153, expression_statement; 154, expression_statement; 155, expression_statement; 156, identifier:figs; 157, subscript; 158, subscript; 159, expression_list; 160, string_content:dd; 161, string_content:schlumberger; 162, string_content:wenner; 163, string_content:dd; 164, string_content:dipole-dipole configurations; 165, string_content:schlumberger; 166, string_content:Schlumberger configurations; 167, string_content:wenner; 168, string_content:Wenner configurations; 169, string_content:dd; 170, identifier:settings; 171, dictionary; 172, identifier:results; 173, identifier:keys; 174, string; 175, identifier:key; 176, string_content:not_sorted; 177, identifier:results; 178, identifier:key; 179, identifier:key; 180, string; 181, identifier:dd_merge; 182, assignment; 183, assignment; 184, identifier:skip; 185, call; 186, block; 187, expression_statement; 188, expression_statement; 189, expression_statement; 190, identifier:plot_list; 191, identifier:labels_add; 192, comparison_operator:len(indices) == 0; 193, block; 194, assignment; 195, assignment; 196, assignment; 197, call; 198, comparison_operator:grid is not None; 199, block; 200, else_clause; 201, call; 202, call; 203, call; 204, call; 205, call; 206, call; 207, call; 208, identifier:figs; 209, integer:0; 210, identifier:axes; 211, integer:0; 212, identifier:figs; 213, identifier:axes; 214, pair; 215, string_content:plotting:; 216, string_content:dd; 217, identifier:plot_list; 218, list; 219, identifier:labels_add; 220, list; 221, identifier:sorted; 222, argument_list; 223, expression_statement; 224, expression_statement; 225, assignment; 226, call; 227, assignment; 228, call; 229, integer:0; 230, continue_statement; 231, identifier:ddc; 232, subscript; 233, pattern_list; 234, call; 235, pattern_list; 236, call; 237, attribute; 238, argument_list; 239, identifier:grid; 240, None; 241, expression_statement; 242, expression_statement; 243, block; 244, attribute; 245, argument_list; 246, attribute; 247, argument_list; 248, attribute; 249, argument_list; 250, attribute; 251, argument_list; 252, attribute; 253, argument_list; 254, attribute; 255, argument_list; 256, attribute; 257, argument_list; 258, string; 259, identifier:only_types; 260, call; 261, call; 262, call; 263, identifier:plot_list; 264, list; 265, identifier:print; 266, argument_list; 267, identifier:labels_add; 268, list; 269, identifier:len; 270, argument_list; 271, identifier:configs; 272, identifier:indices; 273, identifier:px; 274, identifier:pz; 275, subscript; 276, argument_list; 277, identifier:fig; 278, identifier:ax; 279, attribute; 280, argument_list; 281, identifier:ax; 282, identifier:scatter; 283, identifier:px; 284, identifier:pz; 285, keyword_argument; 286, keyword_argument; 287, assignment; 288, call; 289, expression_statement; 290, identifier:ax; 291, identifier:set_title; 292, binary_operator:titles[key] + label_add; 293, identifier:ax; 294, identifier:set_aspect; 295, string; 296, identifier:ax; 297, identifier:set_xlabel; 298, string; 299, identifier:ax; 300, identifier:set_ylabel; 301, string; 302, identifier:fig; 303, identifier:tight_layout; 304, identifier:figs; 305, identifier:append; 306, identifier:fig; 307, identifier:axes; 308, identifier:append; 309, identifier:ax; 310, string_content:only_types; 311, attribute; 312, argument_list; 313, attribute; 314, argument_list; 315, attribute; 316, argument_list; 317, call; 318, string; 319, identifier:plot_list; 320, string; 321, identifier:indices; 322, identifier:pseudo_d_functions; 323, identifier:key; 324, identifier:ddc; 325, identifier:spacing; 326, identifier:grid; 327, identifier:plt; 328, identifier:subplots; 329, keyword_argument; 330, identifier:color; 331, string; 332, identifier:alpha; 333, float:0.5; 334, identifier:electrodes; 335, call; 336, attribute; 337, argument_list; 338, call; 339, subscript; 340, identifier:label_add; 341, string_content:equal; 342, string_content:x [m]; 343, string_content:x [z]; 344, identifier:index_dict; 345, identifier:keys; 346, identifier:plot_list; 347, identifier:append; 348, subscript; 349, identifier:labels_add; 350, identifier:append; 351, call; 352, attribute; 353, argument_list; 354, string_content:schlumberger; 355, identifier:figsize; 356, tuple; 357, string_content:k; 358, attribute; 359, argument_list; 360, identifier:ax; 361, identifier:scatter; 362, subscript; 363, subscript; 364, keyword_argument; 365, keyword_argument; 366, attribute; 367, argument_list; 368, identifier:titles; 369, identifier:key; 370, identifier:index_dict; 371, identifier:skip; 372, attribute; 373, argument_list; 374, identifier:np; 375, identifier:hstack; 376, call; 377, binary_operator:15 / 2.54; 378, binary_operator:5 / 2.54; 379, identifier:grid; 380, identifier:get_electrode_positions; 381, identifier:electrodes; 382, slice; 383, integer:0; 384, identifier:electrodes; 385, slice; 386, integer:1; 387, identifier:color; 388, string; 389, identifier:label; 390, string; 391, identifier:ax; 392, identifier:scatter; 393, binary_operator:np.arange(0, nr_electrodes) * spacing; 394, call; 395, keyword_argument; 396, keyword_argument; 397, string; 398, identifier:format; 399, identifier:skip; 400, attribute; 401, argument_list; 402, integer:15; 403, float:2.54; 404, integer:5; 405, float:2.54; 406, string_content:b; 407, string_content:electrodes; 408, call; 409, identifier:spacing; 410, attribute; 411, argument_list; 412, identifier:color; 413, string; 414, identifier:label; 415, string; 416, string_content:- skip {0}; 417, identifier:index_dict; 418, identifier:values; 419, attribute; 420, argument_list; 421, identifier:np; 422, identifier:zeros; 423, identifier:nr_electrodes; 424, string_content:b; 425, string_content:electrodes; 426, identifier:np; 427, identifier:arange; 428, integer:0; 429, identifier:nr_electrodes
code: def plot_pseudodepths(configs, nr_electrodes, spacing=1, grid=None,
                        ctypes=None, dd_merge=False, **kwargs):
      """Plot pseudodepths for the measurements. If grid is given, then the
      actual electrode positions are used, and the parameter 'spacing' is
      ignored'
  
      Parameters
      ----------
      configs: :class:`numpy.ndarray`
          Nx4 array containing the quadrupoles for different measurements
      nr_electrodes: int
          The overall number of electrodes of the dataset. This is used to plot
          the surface electrodes
      spacing: float, optional
          assumed distance between electrodes. Default=1
      grid: crtomo.grid.crt_grid instance, optional
          grid instance. Used to infer real electrode positions
      ctypes: list of strings, optional
          a list of configuration types that will be plotted. All
          configurations that can not be sorted into these types will not be
          plotted! Possible types:
  
          * dd
          * schlumberger
  
      dd_merge: bool, optional
          if True, merge all skips. Otherwise, generate individual plots for
          each skip
  
      Returns
      -------
      figs: matplotlib.figure.Figure instance or list of Figure instances
          if only one type was plotted, then the figure instance is returned.
          Otherwise, return a list of figure instances.
      axes: axes object or list of axes ojects
          plot axes
  
      Examples
      --------
  
      .. plot::
          :include-source:
  
          from reda.plotters.plots2d import plot_pseudodepths
          # define a few measurements
          import numpy as np
          configs = np.array((
              (1, 2, 4, 3),
              (1, 2, 5, 4),
              (1, 2, 6, 5),
              (2, 3, 5, 4),
              (2, 3, 6, 5),
              (3, 4, 6, 5),
          ))
          # plot
          fig, axes = plot_pseudodepths(configs, nr_electrodes=6, spacing=1,
                                        ctypes=['dd', ])
  
      .. plot::
          :include-source:
  
          from reda.plotters.plots2d import plot_pseudodepths
          # define a few measurements
          import numpy as np
          configs = np.array((
              (4, 7, 5, 6),
              (3, 8, 5, 6),
              (2, 9, 5, 6),
              (1, 10, 5, 6),
          ))
          # plot
          fig, axes = plot_pseudodepths(configs, nr_electrodes=10, spacing=1,
                                        ctypes=['schlumberger', ])
  
      """
      # for each configuration type we have different ways of computing
      # pseudodepths
      pseudo_d_functions = {
          'dd': _pseudodepths_dd_simple,
          'schlumberger': _pseudodepths_schlumberger,
          'wenner': _pseudodepths_wenner,
      }
  
      titles = {
          'dd': 'dipole-dipole configurations',
          'schlumberger': 'Schlumberger configurations',
          'wenner': 'Wenner configurations',
      }
  
      # sort the configurations into the various types of configurations
      only_types = ctypes or ['dd', ]
      results = fT.filter(configs, settings={'only_types': only_types, })
  
      # loop through all measurement types
      figs = []
      axes = []
      for key in sorted(results.keys()):
          print('plotting: ', key)
          if key == 'not_sorted':
              continue
          index_dict = results[key]
          # it is possible that we want to generate multiple plots for one
          # type of measurement, i.e., to separate skips of dipole-dipole
          # measurements. Therefore we generate two lists:
          # 1) list of list of indices to plot
          # 2) corresponding labels
          if key == 'dd' and not dd_merge:
              plot_list = []
              labels_add = []
              for skip in sorted(index_dict.keys()):
                  plot_list.append(index_dict[skip])
                  labels_add.append(' - skip {0}'.format(skip))
          else:
              # merge all indices
              plot_list = [np.hstack(index_dict.values()), ]
              print('schlumberger', plot_list)
              labels_add = ['', ]
  
          grid = None
          # generate plots
          for indices, label_add in zip(plot_list, labels_add):
              if len(indices) == 0:
                  continue
              ddc = configs[indices]
              px, pz = pseudo_d_functions[key](ddc, spacing, grid)
  
              fig, ax = plt.subplots(figsize=(15 / 2.54, 5 / 2.54))
              ax.scatter(px, pz, color='k', alpha=0.5)
  
              # plot electrodes
              if grid is not None:
                  electrodes = grid.get_electrode_positions()
                  ax.scatter(
                      electrodes[:, 0],
                      electrodes[:, 1],
                      color='b',
                      label='electrodes', )
              else:
                  ax.scatter(
                      np.arange(0, nr_electrodes) * spacing,
                      np.zeros(nr_electrodes),
                      color='b',
                      label='electrodes', )
              ax.set_title(titles[key] + label_add)
              ax.set_aspect('equal')
              ax.set_xlabel('x [m]')
              ax.set_ylabel('x [z]')
  
              fig.tight_layout()
              figs.append(fig)
              axes.append(ax)
  
      if len(figs) == 1:
          return figs[0], axes[0]
      else:
          return figs, axes