evt.binning

Module encapsulating the FITS spectra structure and related facilities.

class ximpol.evt.binning.xBinTableHDULC(data=None, keywords=[], comments=[])[source]

Binary table for binned LC data.

class ximpol.evt.binning.xBinTableHDUMCUBE(data=None, keywords=[], comments=[])[source]

Binary table for binned MCUBE data.

Mind the field for the actual phi distribution depends on the binning, which is specified at run time, and therefore the corresponding data specs must be set dinamically.

classmethod set_phi_spec(phibins)[source]

Add the specification for the PHIHIST field.

class ximpol.evt.binning.xBinTableHDUPHA1(data=None, keywords=[], comments=[])[source]

Binary table for binned PHA1 data.

class ximpol.evt.binning.xBinTableHDUPHASG(data=None, keywords=[], comments=[])[source]

Binary table for binned PHASG data.

class ximpol.evt.binning.xBinTableHDUSCUBE(data=None, keywords=[], comments=[])[source]

Binary table for binned SCUBE data.

class ximpol.evt.binning.xBinnedAreaRateMap(file_path)[source]

Display interface to binned ARATE files.

plot(show=True, subplot=(1, 1, 1))[source]

Plot the data.

class ximpol.evt.binning.xBinnedCountSpectrum(file_path)[source]

Binned phasogram.

plot(show=True)[source]

Overloaded plot method.

class ximpol.evt.binning.xBinnedFileBase(file_path)[source]

Base class for binned files.

plot(*args, **kwargs)[source]

Do nothing method.

primary_header()[source]

Return the primary header.

primary_header_keyword(key)[source]

Return the value of a primary header keyword.

class ximpol.evt.binning.xBinnedLightCurve(file_path)[source]

Binned light curve.

plot(show=True)[source]

Overloaded plot method.

class ximpol.evt.binning.xBinnedMap(file_path)[source]

Display interface to binned CMAP files.

plot(show=True, subplot=(1, 1, 1))[source]

Plot the data.

class ximpol.evt.binning.xBinnedModulationCube(file_path)[source]

Read-mode interface to a MCUBE FITS file.

fit()[source]

Fit the azimuthal distribution for all the energy bins.

fit_bin(i)[source]

Fit the azimuthal distribution for the i-th energy slice.

plot(show=True, fit=True, analyze=True, xsubplot=0, full_range=True, simple_stat=False)[source]

Plot the azimuthal distributions for all the energy bins.

plot_bin(i, show=True, fit=True)[source]

Plot the azimuthal distribution for the i-th energy slice.

plot_polarization_angle(show=True, degree=False, **kwargs)[source]

Plot the polarization angle as a function of energy.

plot_polarization_degree(show=True, **kwargs)[source]

Plot the polarization degree as a function of energy.

class ximpol.evt.binning.xBinnedPhasogram(file_path)[source]

Binned phasogram.

plot(show=True, **kwargs)[source]

Overloaded plot method.

class ximpol.evt.binning.xBinnedStokesCube(file_path)[source]

Read-mode interface to a SCUBE FITS file.

I(ebin=0)[source]

Return the I counts map (slice=0) in the selected ebin.

Q(ebin=0)[source]

Return the Q map (slice=1) in the selected ebin.

U(ebin=0)[source]

Return the U map (slice=2) in the selected ebin.

getIQU(ebin=0)[source]

Return the I, Q, U maps in the selected ebin.

plot(ebin=0, slice=0, show=True, zlabel=None, subplot=(1, 1, 1))[source]

Plot the Stokes parameters (I, Q or U) map in the selected ebin.

plot_polarization_degree_angle(pol_list, show=True)[source]

Plot the polarization degree and angle maps.

polarization_degree_angle(ebin, smooth=0, I_cut=15, sigma=2, degree=True)[source]

Return the polarization degree, angle and errors maps in the selected ebin.

smooth(ebin=0, width=1)[source]

Smooth the I, Q, U maps making the sum over the adjacent pixels in the selected ebin.

Warning

The N outer pixels per side are set to zero (N==width).

class ximpol.evt.binning.xEventBinningARATE(file_path, **kwargs)[source]

Class for ARATE binning.

bin_()[source]

Overloaded method.

Warning

This is horrible, as I shamelessly copied the CMAP code and added the missing bits. We should refactor the code in common instead.

process_kwargs()[source]

Overloaded method.

class ximpol.evt.binning.xEventBinningBase(file_path, **kwargs)[source]

Base class for the event binning.

bin_()[source]

Do-nothing method to be reimplemented in the derived classes.

classmethod bin_centers(bin_edges)[source]

Return an array of bin centers given an array of bin edges.

Parameters:bin_edges (1-d array of length (n + 1)) – The array with the bin edges.
Returns:The array with the values of the bin centers.
Return type:1-d array of length n.
classmethod bin_edge_pairs(bin_edges, uber=False)[source]

Return a list of (min, max) tuples of length 2 given an array of bin edges. This is handy when one needs to loop explicitly over the intervals defined by the array bounds, e.g., when running xpselect in specific energy, time or phase intervals.

Parameters:
  • bin_edges (1-d array of length (n + 1)) – The array with the bin edges.
  • uber (bool) – If true, add the overall interval (i.e., a tuple with the absolute minimum and maximum in the binning) at the end.

Example

>>> import numpy
>>> from ximpol.evt.binning import xEventBinningBase
>>>
>>> energy_binning = numpy.array([2., 4., 8.])
>>> print(xEventBinningBase.bin_edge_pairs(energy_binning))
>>> [(2.0, 4.0), (4.0, 8.0)]
>>> print(xEventBinningBase.bin_edge_pairs(energy_binning, uber=True))
>>> [(2.0, 4.0), (4.0, 8.0), (2.0, 8.0)]
classmethod bin_widths(bin_edges)[source]

Return an array of bin widths given an array of bin edges.

Parameters:bin_edges (1-d array of length (n + 1)) – The array with the bin edges.
Returns:The array with the values of the bin widths.
Return type:1-d array of length n.
build_primary_hdu()[source]

Build the primary HDU for the output file.

classmethod equipopulated_binning(num_bins, vector, min_value=None, max_value=None)[source]
get(key, default=None)[source]

Convenience method to address the keyword aguments.

process_kwargs()[source]

Check the keyword arguments.

classmethod read_binning(file_path)[source]

Read a custom binning from file and return a numpy array.

set(key, value)[source]

Convenience method to set keyword arguments.

class ximpol.evt.binning.xEventBinningCMAP(file_path, **kwargs)[source]

Class for CMAP binning.

bin_()[source]

Overloaded method.

process_kwargs()[source]

Overloaded method.

class ximpol.evt.binning.xEventBinningLC(file_path, **kwargs)[source]

Class for LC binning.

bin_()[source]

Overloaded method.

make_binning()[source]

Build the light-curve binning.

process_kwargs()[source]

Overloaded method.

class ximpol.evt.binning.xEventBinningMCUBE(file_path, **kwargs)[source]

Class for MCUBE binning.

bin_()[source]

Overloaded method.

make_binning()[source]

Build the modulation cube binning.

process_kwargs()[source]

Overloaded method.

class ximpol.evt.binning.xEventBinningPHA1(file_path, **kwargs)[source]

Class for PHA1 binning.

bin_()[source]

Overloaded method.

process_kwargs()[source]

Overloaded method.

class ximpol.evt.binning.xEventBinningPHASG(file_path, **kwargs)[source]

Class for LC binning.

bin_()[source]

Overloaded method.

make_binning()[source]

Build the light-curve binning.

process_kwargs()[source]

Overloaded method.

class ximpol.evt.binning.xEventBinningSCUBE(file_path, **kwargs)[source]

Class for SCUBE binning.

bin_()[source]

Overloaded method.

make_binning()[source]

Build the stokes cube energy binning.

This is copied form modulation cube binning and should be factored out.

process_kwargs()[source]

Overloaded method.