from ximpol.evt.binning import xBinnedLightCurve from ximpol.evt.binning import xBinnedPhasogram VIEW_DICT = { 'PHA1' : xBinnedCountSpectrum, 'LC' : xBinnedLightCurve, 'PHASG': xBinnedPhasogram, 'CMAP' : xBinnedMap, 'MCUBE': xBinnedModulationCube } def xpviewbin(file_path): """Quick FITS image viewer. """ try: binalg = fits.open(file_path)[0].header['BINALG'] except Exception as e: abort('Could not determine file type (%s)' % e) VIEW_DICT[binalg](file_path).plot(show=True) if __name__ == '__main__': import argparse parser = argparse.ArgumentParser(description=__description__) parser.add_argument('file_path', type=str, help='the input FITS image file') args = parser.parse_args() startmsg() xpviewbin(args.file_path)
time_integrated_spectrum = count_spectrum.build_time_integral() else: tsamples = source.sampling_time(kwargs['tstart'], kwargs['tstop']) logger.info('Sampling times: %s' % tsamples) count_spectrum = xCountSpectrum(source.energy_spectrum, aeff, tsamples) time_integrated_spectrum = count_spectrum.build_time_integral() # Thuis should be a callable method in the binning module. ebinning = _make_binning(kwargs['ebinalg'], kwargs['emin'], kwargs['emax'], kwargs['ebins'], kwargs['ebinning']) # And this might be implemented in the irf.mrf module. _x = time_integrated_spectrum.x _y = time_integrated_spectrum.y * modf(_x) mu_spectrum = xInterpolatedUnivariateSplineLinear(_x, _y) for _emin, _emax in zip(ebinning[:-1], ebinning[1:]) +\ [(ebinning[0], ebinning[-1])]: num_counts = count_spectrum.num_expected_counts(emin=_emin, emax=_emax) mu_average = mu_spectrum.integral(_emin, _emax) / num_counts mdp = 4.29 / mu_average / numpy.sqrt(num_counts) logger.info('%.2f--%.2f keV: %d counts in %d s, mu %.3f, MDP %.2f%%' %\ (_emin, _emax, num_counts, observation_time, mu_average, 100*mdp)) if __name__ == '__main__': args = PARSER.parse_args() startmsg() xpmdp(**args.__dict__)