Esempio n. 1
0
_color = numpy.random.random((3, len(blazar_list)))
# numpy.random.seed(1)
# _disp = numpy.random.uniform(0.7, 2., len(blazar_list))

plt.figure("Average polarization degree", (11, 8))
_x = numpy.logspace(-13, -7, 100)
for obs_time in [1.0e3, 10.0e3, 100.0e3, 1.0e6]:
    _y = 100.0 * mdp_ref * numpy.sqrt(OBS_TIME_REF / obs_time * FLUX_REF / _x)
    plt.plot(_x, _y, color=GRID_COLOR, ls="dashed", lw=0.6)
    _i = 51
    if obs_time is 1.0e3:
        _x_text = _x[_i]
        _y_text = _y[_i]
    plt.text(_x_text, _y_text, "$T_{obs} =$ %d ks" % (obs_time / 1000.0), color=GRID_COLOR, rotation=-43.0, size=14)
    _x_text /= 10
plt.xscale("log")
plt.yscale("log")
plt.xlabel("Integral energy flux %.0f-%.0f keV [erg cm$^{-2}$ s$^{-1}$]" % (E_MIN, E_MAX))
plt.ylabel("MDP 99% CL [%]")

for j, blazar in enumerate(blazar_list):
    _x_max = blazar["flux_max"]
    _x_min = blazar["flux_min"]
    _y_max = blazar["p_opt_max"]
    _y_min = blazar["p_opt_min"]
    plt.plot([_x_min, _x_max, _x_max], [_y_max, _y_max, _y_min], color=_color[:, j], lw=1.5)
    _x_text = numpy.sqrt((_x_max) * (_x_min))
    if j in mirror_list:
        _y_text = 0.88 * _y_max
    else:
        _y_text = 1.02 * _y_max
Esempio n. 2
0
def plot(save=False):
    """Plot the stuff in the analysis file.
    """
    def draw_time_grid(color='blue'):
        """
        """
        times = [3600., 3600. * 24., 3600. * 24. * 7.]
        labels = ['1 hour', '1 day', '1 week']
        for t, l in zip(times, labels):
            plt.axvline(t, linestyle='dashed', color=color)
            ymin, ymax = plt.gca().get_ylim()
            y = ymin + 1.05 * (ymax - ymin)
            plt.text(t, y, l, ha='center', color=color)

    sim_label = 'XIPE'
    mod_label = 'Input model'
    lc_label = 'Light curve'
    _time, _time_errp, _time_errm, _pol_deg, _pol_deg_err, _pol_angle,\
        _pol_angle_err, _index, _index_err, _norm,\
        _norm_err = numpy.loadtxt(ANALYSIS_FILE_PATH, unpack=True)
    logger.info(_time)
    logger.info((_time_errp + _time_errm) / 3600.)
    _pol_angle = numpy.degrees(_pol_angle)
    _pol_angle_err = numpy.degrees(_pol_angle_err)
    plt.figure('Polarization degree')
    pol_degree_spline.plot(show=False, label=mod_label, logx=True)
    plt.errorbar(_time,
                 _pol_deg,
                 xerr=[_time_errm, _time_errp],
                 yerr=_pol_deg_err,
                 fmt='o',
                 label=sim_label)
    plt.axis([100., 1e6, 0., 0.6])
    plt.legend(bbox_to_anchor=(0.4, 0.95))
    draw_time_grid()
    if save:
        save_current_figure('grb130427_swift_polarization_degree',
                            OUTPUT_FOLDER, False)
    plt.figure('Polarization angle')
    _x = pol_degree_spline.x
    _y = numpy.full(len(_x), polarization_angle(_x, None, None, None))
    _y = numpy.degrees(_y)
    fmt = dict(xname='Time',
               xunits='s',
               yname='Polarization angle',
               yunits=r'$^\circ$')
    _s = xInterpolatedUnivariateSpline(_x, _y, **fmt)
    _s.plot(logx=True, show=False, label=mod_label)
    plt.errorbar(_time,
                 _pol_angle,
                 xerr=[_time_errm, _time_errp],
                 yerr=_pol_angle_err,
                 fmt='o',
                 label=sim_label)
    plt.axis([100., 1e6, None, None])
    plt.legend(bbox_to_anchor=(0.4, 0.95))
    draw_time_grid()
    if save:
        save_current_figure('grb130427_swift_polarization_angle',
                            OUTPUT_FOLDER, False)
    plt.figure('PL index')
    _y = numpy.full(len(_x), PL_INDEX)
    fmt = dict(xname='Time', xunits='s', yname='PL index')
    _s = xInterpolatedUnivariateSpline(_x, _y, **fmt)
    _s.plot(logx=True, show=False, label=mod_label)
    plt.errorbar(_time,
                 _index,
                 xerr=[_time_errm, _time_errp],
                 yerr=_index_err,
                 fmt='o',
                 label=sim_label)
    plt.axis([100., 1e6, None, None])
    plt.legend(bbox_to_anchor=(0.4, 0.95))
    draw_time_grid()
    if save:
        save_current_figure('grb130427_swift_pl_index', OUTPUT_FOLDER, False)
    #plt.figure('PL normalization')
    #plt.errorbar(_time, _norm, xerr=[_time_errm, _time_errp], yerr=_norm_err,
    #             fmt='o', label=sim_label)
    #pl_normalization_spline.plot(show=False, label=mod_label)
    #plt.axis([100., 1e6, None, None])
    #plt.legend(bbox_to_anchor=(0.4, 0.95))
    #draw_time_grid()
    #if save:
    #    save_current_figure('grb130427_swift_pl_norm', OUTPUT_FOLDER, False)
    plt.figure('Light curve')
    lc = xBinnedLightCurve(_lc_file_path())
    lc.plot(show=False)
    # This should be implemented in the binned LC class.
    plt.xscale('log')
    plt.yscale('log')
    plt.axis([100., 1e6, None, None])
    draw_time_grid()
    if save:
        save_current_figure('grb130427_swift_lc', OUTPUT_FOLDER, False)
    plt.show()
Esempio n. 3
0
def plot(save=False):
    """Plot the stuff in the analysis file.
    """

    def draw_time_grid(color='blue'):
        """
        """
        times = [3600., 3600.*24., 3600.*24.*7.]
        labels = ['1 hour', '1 day', '1 week']
        for t, l in zip(times, labels):
            plt.axvline(t, linestyle='dashed', color=color)
            ymin, ymax = plt.gca().get_ylim()
            y = ymin + 1.05*(ymax - ymin)
            plt.text(t, y, l, ha='center', color=color)

    sim_label = 'XIPE'
    mod_label = 'Input model'
    lc_label = 'Light curve'
    _time, _time_errp, _time_errm, _pol_deg, _pol_deg_err, _pol_angle,\
        _pol_angle_err, _index, _index_err, _norm,\
        _norm_err = numpy.loadtxt(ANALYSIS_FILE_PATH, unpack=True)
    logger.info(_time)
    logger.info((_time_errp + _time_errm)/3600.)
    _pol_angle = numpy.degrees(_pol_angle)
    _pol_angle_err = numpy.degrees(_pol_angle_err)
    plt.figure('Polarization degree')
    pol_degree_spline.plot(show=False, label=mod_label, logx=True)
    plt.errorbar(_time, _pol_deg, xerr=[_time_errm, _time_errp],
                 yerr=_pol_deg_err, fmt='o', label=sim_label)
    plt.axis([100., 1e6, 0., 0.6])
    plt.legend(bbox_to_anchor=(0.4, 0.95))
    draw_time_grid()
    if save:
        save_current_figure('grb130427_swift_polarization_degree',
                            OUTPUT_FOLDER, False)
    plt.figure('Polarization angle')
    _x = pol_degree_spline.x
    _y = numpy.full(len(_x), polarization_angle(_x, None, None, None))
    _y = numpy.degrees(_y)
    fmt = dict(xname='Time', xunits='s', yname='Polarization angle',
               yunits=r'$^\circ$')
    _s = xInterpolatedUnivariateSpline(_x, _y, **fmt)
    _s.plot(logx=True, show=False, label=mod_label)
    plt.errorbar(_time, _pol_angle, xerr=[_time_errm, _time_errp],
                 yerr=_pol_angle_err, fmt='o', label=sim_label)
    plt.axis([100., 1e6, None, None])
    plt.legend(bbox_to_anchor=(0.4, 0.95))
    draw_time_grid()
    if save:
        save_current_figure('grb130427_swift_polarization_angle',
                            OUTPUT_FOLDER, False)
    plt.figure('PL index')
    _y = numpy.full(len(_x), PL_INDEX)
    fmt = dict(xname='Time', xunits='s', yname='PL index')
    _s = xInterpolatedUnivariateSpline(_x, _y, **fmt)
    _s.plot(logx=True, show=False, label=mod_label)
    plt.errorbar(_time, _index, xerr=[_time_errm, _time_errp], yerr=_index_err,
                 fmt='o', label=sim_label)
    plt.axis([100., 1e6, None, None])
    plt.legend(bbox_to_anchor=(0.4, 0.95))
    draw_time_grid()
    if save:
        save_current_figure('grb130427_swift_pl_index', OUTPUT_FOLDER, False)
    #plt.figure('PL normalization')
    #plt.errorbar(_time, _norm, xerr=[_time_errm, _time_errp], yerr=_norm_err,
    #             fmt='o', label=sim_label)
    #pl_normalization_spline.plot(show=False, label=mod_label)
    #plt.axis([100., 1e6, None, None])
    #plt.legend(bbox_to_anchor=(0.4, 0.95))
    #draw_time_grid()
    #if save:
    #    save_current_figure('grb130427_swift_pl_norm', OUTPUT_FOLDER, False)
    plt.figure('Light curve')
    lc = xBinnedLightCurve(_lc_file_path())
    lc.plot(show=False)
    # This should be implemented in the binned LC class.
    plt.xscale('log')
    plt.yscale('log')
    plt.axis([100., 1e6, None, None])
    draw_time_grid()
    if save:
        save_current_figure('grb130427_swift_lc', OUTPUT_FOLDER, False)
    plt.show()
Esempio n. 4
0
mirror_list = [5, 6, 7, 8]

numpy.random.seed(1)
_color = numpy.random.random((3, len(obs_plan_list)))
numpy.random.seed(17)
_disp = numpy.random.uniform(0.9, 1.4, len(obs_plan_list))

plt.figure('Average polarization degree', (14, 10))
_x = numpy.logspace(-13, -7, 100)
for obs_time in [1.e3, 10.e3, 100.e3, 1.e6]:
    _y = 100.* mdp_ref * numpy.sqrt(OBS_TIME_REF/obs_time * FLUX_REF/_x)
    plt.plot(_x, _y, color=GRID_COLOR, ls='dashed', lw=0.5)
    _i = 53
    plt.text(_x[_i], _y[_i], '$T_{obs} =$ %d ks' % (obs_time/1000.),
             color=GRID_COLOR, rotation=-45.)
plt.xscale('log')
plt.yscale('log')
plt.xlabel('Integral energy flux %.0f-%.0f keV [erg cm$^{-2}$ s$^{-1}$]' %\
           (E_MIN, E_MAX))
plt.ylabel('MDP 99% CL [%]')

for j, source in enumerate(obs_plan_list):
    _x = source['flux']
    _y = source['mdp']*_disp[j]
    plt.plot(_x, _y, 'o', color=_color[:,j])
    _text = source['name']
    if source['notes'] is not '':
        _text += '\n' + source['notes']
    if j in mirror_list:
        _y *= 0.8
    else: