srcmodel.roi

ximpol.srcmodel.roi.main()[source]

Simple test code.

class ximpol.srcmodel.roi.xEphemeris(t0, nu0, nudot=0.0, nuddot=0.0, min_validity_time=0.0, max_validity_time=10000000.0)[source]

Convenience class encapsulating a pulsar ephemeris.

nu(t)[source]

Return the source frequency at a given time.

period(t)[source]

Return the source period at a given time.

class ximpol.srcmodel.roi.xExtendedSource(name, img_file_path, energy_spectrum, polarization_degree, polarization_angle, column_density=0.0, redshift=0.0, min_validity_time=0.0, max_validity_time=10000000.0, identifier=None)[source]

Class representing an extended source. See ximpol.srcmodel.roi.xModelComponentBase for the signature of the base class.

Parameters:img_file_path (string) – The path to the FITS file containing the image of the source.
rvs_sky_coordinates(size=1)[source]

Generate random coordinates for the model component.

Parameters:size (float) – The number of sky coordinate pairs to be generated.
class ximpol.srcmodel.roi.xGaussianDisk(name, ra, dec, sigma, energy_spectrum, polarization_degree, polarization_angle, column_density=0.0, redshift=0.0, min_validity_time=0.0, max_validity_time=10000000.0, identifier=None)[source]

Class representing a (azimuthally simmetric) gaussian disk. See ximpol.srcmodel.roi.xModelComponentBase for the signature of the base class.

Parameters:
  • ra (float) – The right ascension of the disk center (in decimal degrees).
  • dec (float) – The declination of the disk center (in decimal degrees).
  • sigma (float) – The root mean square of the disk (in degrees).
rvs_sky_coordinates(size=1)[source]

Generate random coordinates for the model component.

This is returning an array of the proper length with identical values.

Parameters:size (float) – The number of sky coordinate pairs to be generated.
class ximpol.srcmodel.roi.xModelComponentBase(name, energy_spectrum, polarization_degree, polarization_angle, column_density=0.0, redshift=0.0, min_validity_time=0.0, max_validity_time=10000000.0, identifier=None)[source]

Base class for the source object.

Note that the source identifier defaults to none and is typically assign after the fact when the source itself is added to a source model.

Parameters:
  • name (string) – The name of the source.
  • energy_spectrum (function) – The function object representing the energy spectrum.
  • polarization_degree (function) – The function object representing the polarization degree.
  • polarization_angle (function) – The function object representing the polarization angle.
  • column_density (float) – The value of the column density (in cm^-2) used to calculate the Galactic absorption. Defaults to 0.
  • redshift (float) – The source redshift. Defaults to 0.
  • min_validity_time (float) – The minimum validity time for the source model. Defaults to 0.
  • max_validity_time (float) – The maximum validity time for the source model. Defaults to 10 Ms.
  • identifier (int) – A unique identifier of the source within a ROI model. Defaults to None and is, generally, automatically assigned when building the ROI (i.e., you don’t have to worry about it, but it’s handy to have in the output event list).
integral_flux(emin=2.0, emax=8.0, t=None, erg=True)[source]

Return the integral source flux at a generic time.

This is achieved by taking a “slice” of the source spectrum at that time and integrating between a minimum and maximum energy.

Parameters:
  • emin (float) – The minimum integration energy (default 2 keV).
  • emax (float) – The maximum integration energy (default 2 keV).
  • t (float) – The time (default is the minimum source validity time).
rvs_event_list(aeff, psf, modf, edisp, **kwargs)[source]

Extract a random event list for the model component.

rvs_sky_coordinates(size=1)[source]

Generate random coordinates for the model component.

This is a do-nothing function and should be re-implemented by each derived class.

Parameters:size (float) – The number of sky coordinate pairs to be generated.
classmethod sampling_time(tstart, tstop)[source]

Return the sampling time used for the lightcurve when generating events.

Warning

We have an issue open for this and at some point we should go back to it and make sure it is properly addressed.

set_energy_spectrum(energy_spectrum)[source]

Set the energy spectrum for the model component.

Parameters:energy_spectrum (function) – The function object representing the energy spectrum.
set_polarization_angle(polarization_angle)[source]

Set the polarization angle for the model component.

Parameters:polarization_angle (function) – The function object representing the polarization angle.
set_polarization_degree(polarization_degree)[source]

Set the polarization degree for the model component.

Parameters:polarization_degree (function) – The function object representing the polarization degree.
setup(energy_spectrum, polarization_degree, polarization_angle)[source]

Setup the model component in terms of energy spectrum and polarization degree and angle.

class ximpol.srcmodel.roi.xPeriodicPointSource(name, ra, dec, energy_spectrum, polarization_degree, polarization_angle, ephemeris, column_density=0.0, redshift=0.0, min_validity_time=None, max_validity_time=None, identifier=None)[source]

Class representing a periodic point source (e.g., a pulsar). See ximpol.srcmodel.roi.xModelComponentBase for the signature of the base class.

Parameters:
  • ra (float) – The right ascension of the source (in decimal degrees).
  • dec (float) – The declination of the source (in decimal degrees).
  • ephemeris (:py:class:`ximpol.srcmodel.roi.xEphemeris object) – The source ephemeris.
rvs_event_list(aeff, psf, modf, edisp, **kwargs)[source]

Extract a random event list for the model component.

TODO: here we should pass the sampling phase, instead?

TODO: properly take into account the derivatives in the ephemeris.

class ximpol.srcmodel.roi.xPointSource(name, ra, dec, energy_spectrum, polarization_degree, polarization_angle, column_density=0.0, redshift=0.0, min_validity_time=0.0, max_validity_time=10000000.0, identifier=None)[source]

Class representing a steady point source. See ximpol.srcmodel.roi.xModelComponentBase for the signature of the base class.

Parameters:
  • ra (float) – The right ascension of the source (in decimal degrees).
  • dec (float) – The declination of the source (in decimal degrees).
rvs_sky_coordinates(size=1)[source]

Generate random coordinates for the model component.

This is returning an array of the proper length with identical values.

Parameters:size (float) – The number of sky coordinate pairs to be generated.
class ximpol.srcmodel.roi.xROIModel(ra_center, dec_center)[source]

Class describing a full ROI (region of interest) model.

This is essentially an (ordered) collection of component objects (i.e., instances of classes inheriting from xModelComponentBase) than can be accessed by source name.

Parameters:
  • ra_center (float) – The right ascension of the center of the ROI (in decimal degrees).
  • dec_center (float) – The declination of the center of the ROI (in decimal degrees).
add_source(source)[source]

Add a source to the ROI.

add_sources(*sources)[source]

Add an arbitrary number of sources to the ROI.

build_hdu()[source]

Build a FITS HDU for the source model.

This can be used to be written in the output file.

max_validity_time()[source]

Return the maximum validity time for the ROI model.

min_validity_time()[source]

Return the minimum validity time for the ROI model.

rvs_event_list(aeff, psf, modf, edisp, **kwargs)[source]

Extract an event list for the full ROI.

Parameters:

Warning

The sampling_time should not be the same for all sources, and each source should be able to decide its own in a sensible way. (See issue #44.)

class ximpol.srcmodel.roi.xUniformDisk(name, ra, dec, radius, energy_spectrum, polarization_degree, polarization_angle, column_density=0.0, redshift=0.0, min_validity_time=0.0, max_validity_time=10000000.0, identifier=None)[source]

Class representing a uniform disk. See ximpol.srcmodel.roi.xModelComponentBase for the signature of the base class.

Parameters:
  • ra (float) – The right ascension of the disk center (in decimal degrees).
  • dec (float) – The declination of the disk center (in decimal degrees).
  • radius (float) – The radius of the disk (in degrees).
rvs_sky_coordinates(size=1)[source]

Generate random coordinates for the model component.

This is returning an array of the proper length with identical values.

The algorithm is taken from http://mathworld.wolfram.com/DiskPointPicking.html

Parameters:size (float) – The number of sky coordinate pairs to be generated.