nodes: 0, module; 1, function_definition; 2, function_name:make_qq_plot; 3, parameters; 4, block; 5, identifier:kev; 6, identifier:obs; 7, identifier:mdl; 8, identifier:unit; 9, identifier:key_text; 10, expression_statement; 11, import_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, expression_statement; 17, expression_statement; 18, expression_statement; 19, expression_statement; 20, expression_statement; 21, comment:# HACK: this range of numbers is chosen to give reasonable sampling for my; 22, comment:# sources, which are typically quite soft.; 23, expression_statement; 24, expression_statement; 25, expression_statement; 26, for_statement; 27, expression_statement; 28, expression_statement; 29, return_statement; 30, comment:"""Make a quantile-quantile plot comparing events and a model.
  
      *kev*
        A 1D, sorted array of event energy bins measured in keV.
      *obs*
        A 1D array giving the number or rate of events in each bin.
      *mdl*
        A 1D array giving the modeled number or rate of events in each bin.
      *unit*
        Text describing the unit in which *obs* and *mdl* are measured; will
        be shown on the plot axes.
      *key_text*
        Text describing the quantile-quantile comparison quantity; will be
        shown on the plot legend.
      Returns:
        An :class:`omega.RectPlot` instance.
  
      *TODO*: nothing about this is Sherpa-specific. Same goes for some of the
      plotting routines in :mod:`pkwit.environments.casa.data`; might be
      reasonable to add a submodule for generic X-ray-y plotting routines.
  
      """; 31, aliased_import; 32, assignment; 33, assignment; 34, assignment; 35, assignment; 36, assignment; 37, assignment; 38, assignment; 39, call; 40, call; 41, assignment; 42, assignment; 43, assignment; 44, identifier:loc; 45, identifier:locs; 46, block; 47, call; 48, assignment; 49, identifier:p; 50, dotted_name; 51, identifier:om; 52, identifier:kev; 53, call; 54, identifier:obs; 55, call; 56, identifier:mdl; 57, call; 58, identifier:c_obs; 59, call; 60, identifier:c_mdl; 61, call; 62, identifier:mx; 63, call; 64, identifier:p; 65, call; 66, attribute; 67, argument_list; 68, attribute; 69, argument_list; 70, identifier:locs; 71, binary_operator:np.array([0, 0.05, 0.08, 0.11, 0.17, 0.3, 0.4, 0.7, 1]) * (kev.size - 2); 72, identifier:c0; 73, binary_operator:mx * 1.05; 74, identifier:c1; 75, binary_operator:mx * 1.1; 76, expression_statement; 77, expression_statement; 78, expression_statement; 79, expression_statement; 80, expression_statement; 81, expression_statement; 82, expression_statement; 83, attribute; 84, argument_list; 85, attribute; 86, float:0.3; 87, identifier:omega; 88, attribute; 89, argument_list; 90, attribute; 91, argument_list; 92, attribute; 93, argument_list; 94, attribute; 95, argument_list; 96, attribute; 97, argument_list; 98, identifier:max; 99, argument_list; 100, attribute; 101, argument_list; 102, identifier:p; 103, identifier:addXY; 104, list; 105, list; 106, string; 107, identifier:p; 108, identifier:addXY; 109, identifier:c_mdl; 110, identifier:c_obs; 111, identifier:key_text; 112, call; 113, parenthesized_expression; 114, identifier:mx; 115, float:1.05; 116, identifier:mx; 117, float:1.1; 118, assignment; 119, assignment; 120, assignment; 121, assignment; 122, assignment; 123, call; 124, call; 125, identifier:p; 126, identifier:setLabels; 127, binary_operator:'Cumulative model ' + unit; 128, binary_operator:'Cumulative data ' + unit; 129, attribute; 130, identifier:vAlign; 131, identifier:np; 132, identifier:asarray; 133, identifier:kev; 134, identifier:np; 135, identifier:asarray; 136, identifier:obs; 137, identifier:np; 138, identifier:asarray; 139, identifier:mdl; 140, identifier:np; 141, identifier:cumsum; 142, identifier:obs; 143, identifier:np; 144, identifier:cumsum; 145, identifier:mdl; 146, subscript; 147, subscript; 148, identifier:om; 149, identifier:RectPlot; 150, integer:0; 151, identifier:mx; 152, integer:0; 153, identifier:mx; 154, string_content:1:1; 155, attribute; 156, argument_list; 157, binary_operator:kev.size - 2; 158, identifier:i0; 159, call; 160, identifier:frac; 161, binary_operator:loc - i0; 162, identifier:kevval; 163, binary_operator:(1 - frac) * kev[i0] + frac * kev[i0+1]; 164, identifier:mdlval; 165, binary_operator:(1 - frac) * c_mdl[i0] + frac * c_mdl[i0+1]; 166, identifier:obsval; 167, binary_operator:(1 - frac) * c_obs[i0] + frac * c_obs[i0+1]; 168, attribute; 169, argument_list; 170, attribute; 171, argument_list; 172, string; 173, identifier:unit; 174, string; 175, identifier:unit; 176, identifier:p; 177, identifier:defaultKeyOverlay; 178, identifier:c_obs; 179, unary_operator; 180, identifier:c_mdl; 181, unary_operator; 182, identifier:np; 183, identifier:array; 184, list; 185, attribute; 186, integer:2; 187, identifier:int; 188, argument_list; 189, identifier:loc; 190, identifier:i0; 191, binary_operator:(1 - frac) * kev[i0]; 192, binary_operator:frac * kev[i0+1]; 193, binary_operator:(1 - frac) * c_mdl[i0]; 194, binary_operator:frac * c_mdl[i0+1]; 195, binary_operator:(1 - frac) * c_obs[i0]; 196, binary_operator:frac * c_obs[i0+1]; 197, identifier:p; 198, identifier:addXY; 199, list; 200, list; 201, binary_operator:'%.2f keV' % kevval; 202, keyword_argument; 203, identifier:p; 204, identifier:addXY; 205, list; 206, list; 207, None; 208, keyword_argument; 209, string_content:Cumulative model; 210, string_content:Cumulative data; 211, integer:1; 212, integer:1; 213, integer:0; 214, float:0.05; 215, float:0.08; 216, float:0.11; 217, float:0.17; 218, float:0.3; 219, float:0.4; 220, float:0.7; 221, integer:1; 222, identifier:kev; 223, identifier:size; 224, call; 225, parenthesized_expression; 226, subscript; 227, identifier:frac; 228, subscript; 229, parenthesized_expression; 230, subscript; 231, identifier:frac; 232, subscript; 233, parenthesized_expression; 234, subscript; 235, identifier:frac; 236, subscript; 237, identifier:mdlval; 238, identifier:mdlval; 239, identifier:c0; 240, identifier:c1; 241, string; 242, identifier:kevval; 243, identifier:dsn; 244, integer:2; 245, identifier:c0; 246, identifier:c1; 247, identifier:obsval; 248, identifier:obsval; 249, identifier:dsn; 250, integer:2; 251, attribute; 252, argument_list; 253, binary_operator:1 - frac; 254, identifier:kev; 255, identifier:i0; 256, identifier:kev; 257, binary_operator:i0+1; 258, binary_operator:1 - frac; 259, identifier:c_mdl; 260, identifier:i0; 261, identifier:c_mdl; 262, binary_operator:i0+1; 263, binary_operator:1 - frac; 264, identifier:c_obs; 265, identifier:i0; 266, identifier:c_obs; 267, binary_operator:i0+1; 268, string_content:%.2f keV; 269, identifier:np; 270, identifier:floor; 271, identifier:loc; 272, integer:1; 273, identifier:frac; 274, identifier:i0; 275, integer:1; 276, integer:1; 277, identifier:frac; 278, identifier:i0; 279, integer:1; 280, integer:1; 281, identifier:frac; 282, identifier:i0; 283, integer:1
code: def make_qq_plot(kev, obs, mdl, unit, key_text):
      """Make a quantile-quantile plot comparing events and a model.
  
      *kev*
        A 1D, sorted array of event energy bins measured in keV.
      *obs*
        A 1D array giving the number or rate of events in each bin.
      *mdl*
        A 1D array giving the modeled number or rate of events in each bin.
      *unit*
        Text describing the unit in which *obs* and *mdl* are measured; will
        be shown on the plot axes.
      *key_text*
        Text describing the quantile-quantile comparison quantity; will be
        shown on the plot legend.
      Returns:
        An :class:`omega.RectPlot` instance.
  
      *TODO*: nothing about this is Sherpa-specific. Same goes for some of the
      plotting routines in :mod:`pkwit.environments.casa.data`; might be
      reasonable to add a submodule for generic X-ray-y plotting routines.
  
      """
      import omega as om
  
      kev = np.asarray(kev)
      obs = np.asarray(obs)
      mdl = np.asarray(mdl)
  
      c_obs = np.cumsum(obs)
      c_mdl = np.cumsum(mdl)
      mx = max(c_obs[-1], c_mdl[-1])
  
      p = om.RectPlot()
      p.addXY([0, mx], [0, mx], '1:1')
      p.addXY(c_mdl, c_obs, key_text)
  
      # HACK: this range of numbers is chosen to give reasonable sampling for my
      # sources, which are typically quite soft.
      locs = np.array([0, 0.05, 0.08, 0.11, 0.17, 0.3, 0.4, 0.7, 1]) * (kev.size - 2)
      c0 = mx * 1.05
      c1 = mx * 1.1
  
      for loc in locs:
          i0 = int(np.floor(loc))
          frac = loc - i0
          kevval = (1 - frac) * kev[i0] + frac * kev[i0+1]
          mdlval = (1 - frac) * c_mdl[i0] + frac * c_mdl[i0+1]
          obsval = (1 - frac) * c_obs[i0] + frac * c_obs[i0+1]
          p.addXY([mdlval, mdlval], [c0, c1], '%.2f keV' % kevval, dsn=2)
          p.addXY([c0, c1], [obsval, obsval], None, dsn=2)
  
      p.setLabels('Cumulative model ' + unit, 'Cumulative data ' + unit)
      p.defaultKeyOverlay.vAlign = 0.3
      return p