Exemplo n.º 1
0
#put together the flux for the source starting from the txt file
_energy, _flux = numpy.loadtxt(FLUX_FILE_PATH, unpack=True)
_mask = (_energy >= MIN_ENERGY) * (_energy <= MAX_ENERGY)
_energy = _energy[_mask]
_flux = _flux[_mask]
fmt = dict(xname='Energy',
           xunits='keV',
           yname='Flux',
           yunits='cm$^{-2}$ s$^{-1}$ keV$^{-1}$')

_energy_spectrum = xInterpolatedUnivariateSpline(_energy, _flux, **fmt)
#"""

ROI_MODEL = xROIModel(CYGX1_RA, CYGX1_DEC)

src = xPointSource('Cyg-X1', ROI_MODEL.ra, ROI_MODEL.dec, energy_spectrum,
                   polarization_degree, polarization_angle)

ROI_MODEL.add_source(src)

if __name__ == '__main__':
    print(ROI_MODEL)
    from ximpol.utils.matplotlib_ import pyplot as plt
    fig = plt.figure('Spectrum')
    _energy_spectrum.plot(show=False)
    fig = plt.figure('Polarization angle')
    pol_angle_spline.plot(show=False)
    fig = plt.figure('Polarization degree')
    pol_degree_spline.plot(show=False)
    plt.show()
Exemplo n.º 2
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

import numpy

from ximpol.srcmodel.roi import xPointSource, xROIModel
from ximpol.srcmodel.spectrum import power_law
from ximpol.srcmodel.polarization import constant

ROI_MODEL = xROIModel(10., 10.)

energy_spectrum1 = power_law(10., 2.)
polarization_degree1 = constant(1.0)
polarization_angle1 = constant(numpy.radians(65.))
src1 = xPointSource('Point source 1', 9.9750, 9.9833, energy_spectrum1,
                    polarization_degree1, polarization_angle1)

energy_spectrum2 = power_law(15., 3.)
polarization_degree2 = constant(0.0)
polarization_angle2 = constant(numpy.radians(0))
src2 = xPointSource('Point source 2', 10., 10., energy_spectrum2,
                    polarization_degree2, polarization_angle2)

ROI_MODEL.add_sources(src1, src2)

if __name__ == '__main__':
    print(ROI_MODEL)
Exemplo n.º 3
0
               yunits='cm$^{-2}$ s$^{-1}$ keV$^{-1}$')
    return xInterpolatedUnivariateSplineLinear(_energy, _flux, **fmt)


ROI_MODEL = xROIModel(63.3363, 10.4764)

# Read in the spectral models.
spectral_model_spline = parse_spectral_model('Abell_478.txt')

def energy_spectrum(E, t):
    return spectral_model_spline(E)

polarization_degree = constant(0.)
polarization_angle = constant(0.)

abell478 = xPointSource('Abell 478', ROI_MODEL.ra, ROI_MODEL.dec,
                       energy_spectrum, polarization_degree, polarization_angle)

ROI_MODEL.add_source(abell478)


def display():
    """Display the source model.
    """
    from ximpol.utils.matplotlib_ import pyplot as plt
    from ximpol.srcmodel.img import xFITSImage

    print(ROI_MODEL)
    fig = plt.figure('Energy spectrum')
    spectral_model_spline.plot(logy=True, show=False, label='Total')
    plt.show()
Exemplo n.º 4
0
    return spectral_model(E)


def polarization_degree(E, t, ra, dec):
    return pol_degree(E)


def polarization_angle(E, t, ra, dec):
    return numpy.radians(pol_angle(E))


RA = 203.973
DEC = -34.2960
ROI_MODEL = xROIModel(RA, DEC)

source = xPointSource('MCG-6-30-15', RA, DEC, energy_spectrum,
                      polarization_degree, polarization_angle)

ROI_MODEL.add_source(source)


def display():
    """Display the source model.
    """
    print(ROI_MODEL)
    from ximpol.utils.matplotlib_ import pyplot as plt
    fig = plt.figure('Energy spectrum')
    spectral_model.plot(show=False, logy=True)
    fig = plt.figure('Polarization degree')
    pol_degree.plot(show=False)
    fig = plt.figure('Polarization angle')
    pol_angle.plot(show=False)
Exemplo n.º 5
0
"""
_t = integral_flux_spline.x
_p = 0.6*(1. - (_t/integral_flux_spline.xmax())**0.1)
fmt = dict(xname='Time', xunits='s', yname='Polarization degree')
pol_degree_spline = xInterpolatedUnivariateSplineLinear(_t, _p, **fmt)

def energy_spectrum(E, t):
    return pl_normalization_spline(t)*numpy.power(E, -PL_INDEX)

def polarization_degree(E, t, ra, dec):
    return pol_degree_spline(t)

polarization_angle = constant(numpy.radians(28.))

grb = xPointSource('GRB', GRB_RA, GRB_DEC, energy_spectrum, polarization_degree,
                   polarization_angle,
                   min_validity_time=integral_flux_spline.xmin(),
                   max_validity_time=integral_flux_spline.xmax())

def sampling_time(tstart, tstop):
    return numpy.logspace(numpy.log10(tstart), numpy.log10(tstop), 100)

grb.sampling_time = sampling_time


ROI_MODEL.add_source(grb)


if __name__=='__main__':
    from ximpol.utils.matplotlib_ import pyplot as plt
    from ximpol.utils.matplotlib_ import save_current_figure
    from ximpol import XIMPOL_DOC
Exemplo n.º 6
0
               yunits='cm$^{-2}$ s$^{-1}$ keV$^{-1}$')
    return xInterpolatedUnivariateSplineLinear(_energy, _flux, **fmt)


ROI_MODEL = xROIModel(54.6471, 9.9650)

# Read in the spectral models.
spectral_model_spline = parse_spectral_model('2a0335_096.txt')

def energy_spectrum(E, t):
    return spectral_model_spline(E)

polarization_degree = constant(0.)
polarization_angle = constant(0.)

a0335 = xPointSource('2A 0335+096', ROI_MODEL.ra, ROI_MODEL.dec,
                       energy_spectrum, polarization_degree, polarization_angle)

ROI_MODEL.add_source(a0335)


def display():
    """Display the source model.
    """
    from ximpol.utils.matplotlib_ import pyplot as plt
    from ximpol.srcmodel.img import xFITSImage

    print(ROI_MODEL)
    fig = plt.figure('Energy spectrum')
    spectral_model_spline.plot(logy=True, show=False, label='Total')
    plt.show()
Exemplo n.º 7
0
#put together the flux for the source starting from the txt file
_energy, _flux = numpy.loadtxt(FLUX_FILE_PATH, unpack=True)
_mask = (_energy >= MIN_ENERGY)*(_energy <= MAX_ENERGY)
_energy = _energy[_mask]
_flux = _flux[_mask]
fmt = dict(xname='Energy', xunits='keV', yname='Flux',
               yunits='cm$^{-2}$ s$^{-1}$ keV$^{-1}$')

_energy_spectrum = xInterpolatedUnivariateSpline(_energy, _flux, **fmt)
#"""

ROI_MODEL = xROIModel(CYGX1_RA, CYGX1_DEC)



src = xPointSource('Cyg-X1', ROI_MODEL.ra, ROI_MODEL.dec, energy_spectrum,
                   polarization_degree, polarization_angle)

ROI_MODEL.add_source(src)



if __name__ == '__main__':
    print(ROI_MODEL)
    from ximpol.utils.matplotlib_ import pyplot as plt
    fig = plt.figure('Spectrum')
    _energy_spectrum.plot(show=False)
    fig = plt.figure('Polarization angle')
    pol_angle_spline.plot(show=False)
    fig = plt.figure('Polarization degree')
    pol_degree_spline.plot(show=False)
    plt.show()
Exemplo n.º 8
0
               yunits='cm$^{-2}$ s$^{-1}$ keV$^{-1}$')
    return xInterpolatedUnivariateSplineLinear(_energy, _flux, **fmt)


ROI_MODEL = xROIModel(10.4075, -9.3425)

# Read in the spectral models.
spectral_model_spline = parse_spectral_model('abell_85.csv')

def energy_spectrum(E, t):
    return spectral_model_spline(E)

polarization_degree = constant(0.)
polarization_angle = constant(0.)

abell85 = xPointSource('Abell 85', ROI_MODEL.ra, ROI_MODEL.dec,
                       energy_spectrum, polarization_degree, polarization_angle)

ROI_MODEL.add_source(abell85)


def display():
    """Display the source model.
    """
    from ximpol.utils.matplotlib_ import pyplot as plt
    from ximpol.srcmodel.img import xFITSImage

    print(ROI_MODEL)
    fig = plt.figure('Energy spectrum')
    spectral_model_spline.plot(logy=True, show=False, label='Total')
    plt.show()
Exemplo n.º 9
0

def energy_spectrum(E, t):
    return pl_normalization_spline(t) * numpy.power(E, -PL_INDEX)


def polarization_degree(E, t, ra, dec):
    return pol_degree_spline(t)


polarization_angle = constant(numpy.radians(28.))

grb = xPointSource('GRB',
                   GRB_RA,
                   GRB_DEC,
                   energy_spectrum,
                   polarization_degree,
                   polarization_angle,
                   min_validity_time=integral_flux_spline.xmin(),
                   max_validity_time=integral_flux_spline.xmax())


def sampling_time(tstart, tstop):
    return numpy.logspace(numpy.log10(tstart), numpy.log10(tstop), 100)


grb.sampling_time = sampling_time

ROI_MODEL.add_source(grb)

if __name__ == '__main__':
    from ximpol.utils.matplotlib_ import pyplot as plt
Exemplo n.º 10
0
#"""
#put together the flux for the source starting from the txt file
_energy, _flux = numpy.loadtxt(FLUX_FILE_PATH, unpack=True)
_mask = (_energy >= MIN_ENERGY)*(_energy <= MAX_ENERGY)
_energy = _energy[_mask]
_flux = _flux[_mask]
fmt = dict(xname='Energy', xunits='keV', yname='Flux',
               yunits='cm$^{-2}$ s$^{-1}$ keV$^{-1}$')

_energy_spectrum = xInterpolatedUnivariateSpline(_energy, _flux, **fmt)


ROI_MODEL = xROIModel(GRS1915_RA, GRS1915_DEC)


src = xPointSource('GRS1915_105', ROI_MODEL.ra, ROI_MODEL.dec, energy_spectrum,
                   polarization_degree, polarization_angle)

ROI_MODEL.add_source(src)



if __name__ == '__main__':
    print(ROI_MODEL)
    from ximpol.utils.matplotlib_ import pyplot as plt
    fig = plt.figure('Spectrum')
    _energy_spectrum.plot(show=False)
    fig = plt.figure('Polarization angle')
    pol_angle_spline.plot(show=False)
    fig = plt.figure('Polarization degree')
    pol_degree_spline.plot(show=False)
    plt.show()
Exemplo n.º 11
0
energy, flux, degree, angle = parse(file_path)
flux = scale_flux(energy, flux)
fmt = dict(xname='Energy', xunits='keV', yname='Flux',
           yunits='cm$^{-2}$ s$^{-1}$ keV$^{-1}$')
spectral_model = xInterpolatedUnivariateSplineLinear(energy, flux, **fmt)
fmt = dict(xname='Energy', xunits='keV', yname='Polarization degree')
pol_degree = xInterpolatedUnivariateSplineLinear(energy, degree, **fmt)
fmt = dict(xname='Energy', xunits='keV', yname='Polarization angle',
           yunits='$^\\circ$')
pol_angle = xInterpolatedUnivariateSplineLinear(energy, angle, **fmt)

ROI_MODEL = xROIModel(RA, DEC)

source = xPointSource('MCG-6-30-15', RA, DEC, energy_spectrum,
                      polarization_degree, polarization_angle,
                      max_validity_time=50000000.)

ROI_MODEL.add_source(source)

def display():
    """Display the source model.
    """
    print(ROI_MODEL)
    from ximpol.utils.matplotlib_ import pyplot as plt
    fig = plt.figure('Energy spectrum')
    spectral_model.plot(show=False, logy=True)
    fig = plt.figure('Polarization degree')
    pol_degree.plot(show=False)
    fig = plt.figure('Polarization angle')
    pol_angle.plot(show=False)
Exemplo n.º 12
0
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.


import numpy

from ximpol.srcmodel.roi import xPointSource, xROIModel
from ximpol.srcmodel.spectrum import power_law
from ximpol.srcmodel.polarization import constant


ROI_MODEL = xROIModel(10.0, 10.0)

energy_spectrum1 = power_law(10.0, 2.0)
polarization_degree1 = constant(1.0)
polarization_angle1 = constant(numpy.radians(65.0))
src1 = xPointSource("Point source 1", 9.9750, 9.9833, energy_spectrum1, polarization_degree1, polarization_angle1)

energy_spectrum2 = power_law(15.0, 3.0)
polarization_degree2 = constant(0.0)
polarization_angle2 = constant(numpy.radians(0))
src2 = xPointSource("Point source 2", 10.0, 10.0, energy_spectrum2, polarization_degree2, polarization_angle2)

ROI_MODEL.add_sources(src1, src2)


if __name__ == "__main__":
    print(ROI_MODEL)

def energy_spectrum(E, t):
    return spectral_model(E)

def polarization_degree(E, t, ra, dec):
    return pol_degree(E)

def polarization_angle(E, t, ra, dec):
    return numpy.radians(pol_angle(E))

RA = 336.7183
DEC = -03.4271
ROI_MODEL = xROIModel(RA, DEC)

source = xPointSource('J1650-500', RA, DEC, energy_spectrum,
                      polarization_degree, polarization_angle)

ROI_MODEL.add_source(source)

def display():
    """Display the source model.
    """
    print(ROI_MODEL)
    from ximpol.utils.matplotlib_ import pyplot as plt
    fig = plt.figure('Energy spectrum')
    spectral_model.plot(show=False, logy=True)
    fig = plt.figure('Polarization degree')
    pol_degree.plot(show=False)
    fig = plt.figure('Polarization angle')
    pol_angle.plot(show=False)
    plt.show()
Exemplo n.º 14
0
    return spectral_model(E)


def polarization_degree(E, t, ra, dec):
    return pol_degree(E)


def polarization_angle(E, t, ra, dec):
    return numpy.radians(pol_angle(E))


RA = 336.7183
DEC = -03.4271
ROI_MODEL = xROIModel(RA, DEC)

source = xPointSource('J1650-500', RA, DEC, energy_spectrum,
                      polarization_degree, polarization_angle)

ROI_MODEL.add_source(source)


def display():
    """Display the source model.
    """
    print(ROI_MODEL)
    from ximpol.utils.matplotlib_ import pyplot as plt
    fig = plt.figure('Energy spectrum')
    spectral_model.plot(show=False, logy=True)
    fig = plt.figure('Polarization degree')
    pol_degree.plot(show=False)
    fig = plt.figure('Polarization angle')
    pol_angle.plot(show=False)

def energy_spectrum(E, t):
    return spectral_model(E)

def polarization_degree(E, t, ra, dec):
    return pol_degree(E)

def polarization_angle(E, t, ra, dec):
    return numpy.radians(pol_angle(E))

RA = 203.973
DEC = -34.2960
ROI_MODEL = xROIModel(RA, DEC)

source = xPointSource('MCG-6-30-15', RA, DEC, energy_spectrum,
                      polarization_degree, polarization_angle)

ROI_MODEL.add_source(source)

def display():
    """Display the source model.
    """
    print(ROI_MODEL)
    from ximpol.utils.matplotlib_ import pyplot as plt
    fig = plt.figure('Energy spectrum')
    spectral_model.plot(show=False, logy=True)
    fig = plt.figure('Polarization degree')
    pol_degree.plot(show=False)
    fig = plt.figure('Polarization angle')
    pol_angle.plot(show=False)
    plt.show()
Exemplo n.º 16
0
energy, flux, degree, angle = parse(file_path)
flux = scale_flux(energy, flux)
fmt = dict(xname='Energy', xunits='keV', yname='Flux',
           yunits='cm$^{-2}$ s$^{-1}$ keV$^{-1}$')
spectral_model = xInterpolatedUnivariateSplineLinear(energy, flux, **fmt)
fmt = dict(xname='Energy', xunits='keV', yname='Polarization degree')
pol_degree = xInterpolatedUnivariateSplineLinear(energy, degree, **fmt)
fmt = dict(xname='Energy', xunits='keV', yname='Polarization angle',
           yunits='$^\\circ$')
pol_angle = xInterpolatedUnivariateSplineLinear(energy, angle, **fmt)
column_density = GAL_NH

ROI_MODEL = xROIModel(RA, DEC)

source = xPointSource('Ark 120', RA, DEC, energy_spectrum,
                      polarization_degree, polarization_angle)

ROI_MODEL.add_source(source)

def display():
    """Display the source model.
    """
    print(ROI_MODEL)
    from ximpol.utils.matplotlib_ import pyplot as plt
    fig = plt.figure('Energy spectrum')
    spectral_model.plot(show=False, logy=True)
    fig = plt.figure('Polarization degree')
    pol_degree.plot(show=False)
    fig = plt.figure('Polarization angle')
    pol_angle.plot(show=False)
    plt.show()