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
def make_qq_plot ( kev , obs , mdl , unit , key_text ) : 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 ) 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
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.