Presentation is loading. Please wait.

Presentation is loading. Please wait.

GammaLib based analysis of TeV data Proposal for a CTA High-level Science Analysis framework J. Knödlseder (CESR, Toulouse)

Similar presentations


Presentation on theme: "GammaLib based analysis of TeV data Proposal for a CTA High-level Science Analysis framework J. Knödlseder (CESR, Toulouse)"— Presentation transcript:

1 GammaLib based analysis of TeV data Proposal for a CTA High-level Science Analysis framework J. Knödlseder (CESR, Toulouse)

2 Observing gamma rays All measure photons ! - localization - time - energy (- polarization) MeV keV GeV TeV

3 Analysing gamma rays Common features Data are photon based (event lists or event histograms) Background is important or dominating (reduction techniques are crucial) Instruments are complex (time variable background and instrument properties, indirect imaging) Common formats, methods and issues All community data are in FITS format (OGIP) http://heasarc.gsfc.nasa.gov/docs/heasarc/ofwg/ofwg_recomm.html (ftools, DS9, …) Most analysis systems break down analysis tasks in executables (bricks of science analysis) (ftools like executables; analysis pipeline by chaining executables) Many missions use the IRAF parameter interface (ftools, Chandra, INTEGRAL, SWIFT, Fermi, …) Most systems rely on a maximum likelihood optimizer (Poisson statistics) (INTEGRAL/SPI, Fermi, COMPTEL, …) Execution time and data volume is an issue …

4 Stop re-inventing the wheel GammaLib keep what is common add only what is really needed Towards GammaLib: spi_toolslib developed by CESR for INTEGRAL/SPI analysis (delivered with OSA via ISDC) see also http://www.cesr.fr/~jurgen/isdc/http://www.cesr.fr/~jurgen/isdc/ re-implementation of ideas initially developped for CGRO/COMPTEL analysis still many things are SPI specific

5 The GammaLib idea Write a generic, self-contained, open source, multi-platform C++ library that implements all code required for high-level science analysis of gamma-ray data generic: GammaLib core code does not depend on a specific instrument type or architecture self-contained: does not depend on any other library (considerable cost-reduction for maintenance; not fully fulfilled since dependence on cfitsio) open source: GNU licence (http://sourceforge.net/projects/gammalib/) multi-platform C++: should compile on any POSIX-compliant platform (32 and 64 bit) Implement instrument specific modules need no re-compilation of GammaLib core either add-on libraries or embedded in GammaLib (core+inst)

6 The GammaLib concept Generic core services such as input/output in standard formats and numerical support (e.g. matrix handling/solving) Instrument specific support (data content, response function, background handling) Generic analysis services (abstract combination of observations and events) High-level analysis support (model fitting) yellow = prototype exists

7 CTA specific support Derive instrument specific C++ classes from pure virtual base classes GObservation: observation specific data (time interval, GTI, energy range, region of interest, event container, response function) GEventList & GEventCube: unbinned and binned data containers GEventAtom & GEventBin: individual event and event bin (collection of events with similar properties) GResponse: instrument specific response function (effective area, point spread function, energy dispersion, time dispersion, livetime) GInstDir: event direction in instrument coordinates (sky direction for imaging instruments like CTA, Fermi/LAT, detector coordinates otherwise) GRoi: region of interest (region of event directions to be used for analysis; e.g. cone for CTA, Fermi/LAT) GPointing: instrument pointing (pointing direction, livetime information, etc.) CTA implementation Prototype classes using simple response function (based on Konrad’s analysis results on http://www.cta-observatory.org/ctawpcwiki/index.php/WP_MC assuming Gaussian PSF, no zenith angle dependence, no energy and time dispersion)http://www.cta-observatory.org/ctawpcwiki/index.php/WP_MC

8 Using GammaLib as a toolbox ftools like analysis use GammaLib as API to create specific analysis tasks analysis executables derive from GApplication base class native implementation of IRAF parameter interface native implementation of reporting interface (not yet prototyped)

9 Example: ctbin tool Class definition class ctbin : public GApplication { public: ctbin(int argc, char *argv[]) : GApplication(“ctbin”, “1.0”, argc, argv) {;} int run(void); }; Tool & class implementation int main (int argc, char *argv[]) { ctbin application(argc, argv); int rc = application.run(); return rc; } int ctbin::run(void) { // Get parameters std::string evfile = par("evfile")->value(); std::string outfile = par("outfile")->value(); int enumbins = toint(par("enumbins")->value()); // Code.... // End of tool return 0; } Tool derives from GApplication base class using default constructor. run method does the job … GApplication class provides access to parameters in ctbin.par file Creates instance of application class and runs application

10 Example: ctbin.par file # General parameters #=================== evfile, f, a, "eventlist_reco.fits.gz",,,"Event data file name" outfile, f, a, "cntmap.fits",,, "Output file name" # Energy binning parameters #========================== ebinalg, s, a, "LOG", FILE|LIN|LOG,,"Algorithm for defining energy bins" emin, r, a, 0.02,,,"Start value for first energy bin in TeV" emax, r, a, 100.0,,,"Stop value for last energy bin in TeV" enumbins, i, a, 20,,,"Number of energy bins" ebinfile, f, a, "NONE",,,"Name of the file containing the energy bin definition" # Spatial binning parameters #=========================== nxpix, i, a, 200,,, "Size of the X axis in pixels" nypix, i, a, 200,,, "Size of the Y axis in pixels" binsz, r, a, 0.02,,, "Image scale (in degrees/pixel)" coordsys, s, a, "CEL", CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)" xref, r, a, 117.02,,, "First coordinate of image center in degrees (RA or galactic l)" yref, r, a, -33.35,,, "Second coordinate of image center in degrees (DEC or galactic b)" axisrot, r, a, 0.0,,, "Rotation angle of image axis, in degrees" proj, s, a, "CAR",,, "Projection method e.g. AIT|ARC|CAR|GLS|MER|NCP|SIN|STG|TAN" # Standard parameters #==================== chatter, i, h, 1,0,4, "Chattiness of output" clobber, b, h, yes,,, "Overwrite existing output files with new output files?" debug, b, h, no,,, "Debugging mode activated" mode, s, h, "ql",,, "Mode of automatic parameters" Parameter type (file, string, real, integer, boolean) Parameter mode (auto, hidden, query, learn) Parameter value Parameter minimum / maximum or options Text for parameter query

11 Example: running ctbin Interactively: Queries for all automatic parameters $./ctbin Event data file name [eventlist_reco.fits.gz] Output file name [cntmap.fits] Start value for first energy bin in TeV [0.02] Stop value for last energy bin in TeV [100.0] Number of energy bins [20] Projection method e.g. AIT|ARC|CAR|GLS|MER|NCP|SIN|STG|TAN [CAR] Coordinate system (CEL - celestial, GAL - galactic) (CEL|GAL) [CEL] First coordinate of image center in degrees (RA or galactic l) [117.02] Second coordinate of image center in degrees (DEC or galactic b) [-33.35] Image scale (in degrees/pixel) [0.02] Size of the X axis in pixels [200] Size of the Y axis in pixels [200] $ Command line: Specify all automatic parameters as arguments $./ctbin evfile=eventlist_reco.fits.gz outfile=cntmap.fits emin=0.02 emax=100.0 enumbins=20 proj=CAR coordsys=CEL xref=117.02 yref=-33.35 binsz=0.02 nxpix=200 nypix=200 $ Default value

12 Example: ctbin usage of GammaLib // Load events as unbinned data GCTAObservation run; run.load_unbinned(evfile); // Create skymap std::string wcs = par("proj")->value(); std::string coords = par("coordsys")->value(); double x = todouble(par("xref")->value()); double y = todouble(par("yref")->value()); double dx = todouble(par("binsz")->value()); double dy = todouble(par("binsz")->value()); int nx = toint(par("nxpix")->value()); int ny = toint(par("nypix")->value()); GSkymap map = GSkymap(wcs, coords, x, y, dx, dy, nx, ny, enumbins); // Fill sky map GCTAEventList* events = (GCTAEventList*)run.events(); for (GCTAEventList::iterator event = events->begin(); event != events->end(); ++event) { GSkyDir dir = ((GCTAInstDir*)event->dir())->skydir(); GSkyPixel pixel = map.dir2xy(dir); int index = run.ebounds()->index(*(event->energy())); map(pixel, index) += 1.0; } // Save counts map GFits file; map.write(&file); file.saveto(outfile, clobber); Load CTA events into an instance of an observation. Create skymap that will hold the binned counts map Fill skymap by iterating over all events. Save skymap as FITS file GammaLib natively implements WCS, including HealPix

13 Example: ctbin counts map

14 ctatools: a GammaLib based analysis framework

15 Scripting ctatools Python bindings for ctatools SWIG (Simplified Wrapper and Interface Generator - http://www.swig.org) builds interfaces for C/C++ programs for Python, Tcl, Perl, PHP, Ruby, Java, …http://www.swig.org Requires only one interface definition file per C++ class (almost identical to class definiton header file; e.g. GApplication.h => GApplication.i) Highly portable and exists for many platforms (UNIX, LINUX, Mac OSX, Windows) Python interface implemented for ctatools Running ctbin under python $ python >>> from ctatools import * >>> task = ctbin() >>> print task === GApplication === Name......................: ctbin Version...................: v1r0p0 >>> task.par("evfile").value("eventlist_reco.fits.gz") >>> task.par("outfile").value("cntmap.fits") >>>... >>> task.par("nypix").value("200") >>> task.run() 0 >>>

16 Scripting GammaLib CTA analysis without ctatools (scripting GammaLib directly) $ python >>> from gammalib import * >>> >>> run = GCTAObservation() >>> run.load_binned("cntmap.fits.gz") >>> run.response("kb_E_50h_v3", "../inst/cta/test/irf") >>> >>> obs = GObservations() >>> obs.append(run) >>> >>> dir = GSkyDir() >>> dir.radec_deg(117.0, -33.0) >>> point_source = GModelSpatialPtsrc(dir) >>> power_law = GModelSpectralPlaw(1.0e-7, -2.1) >>> power_law.par(0).min(1.0e-12) >>> crab = GModel(point_source, power_law) >>> crab.name("Crab") >>> models = GModels() >>> models.append(crab) >>> obs.models(models) >>> >>> opt = GOptimizerLM() >>> opt.max_iter(1000) >>> obs.optimize(opt) >>> print obs Parameter 2..............: Prefactor: 1.269e-08 +/- 0.000e+00 [1.000e-12,infty[ ph/cm2/s/MeV Parameter 3..............: Index: -2.163e+00 +/- 0.000e+00 Load counts map into CTA observation object and set instrument response function (only CTA specific part!). Append CTA observation to list of observations (just one here). Define model to be fitted to data: point source at (RA,Dec)=(117,-33) with simple power law spectrum (positively constrained). Append point-source model to list of models (just one here) and attach list to observations. Maximum likelihood optimization using Levenberg-Marquardt optimizer.

17 Binned likelihood analysis Merit function (to be maximized) Model value for bin i Number of counts in bin i Number of bins

18 Finely binned likelihood analysis Reduce binsize until one event at maximum in each bin: Total number of model counts within the dataspace (region-of-interest). Implicitely a sum over all events.

19 Unbinned likelihood analysis Reduce binsize until one event at maximum in each bin: Total number of model counts within the dataspace (region-of-interest). Implicitely a sum over all events. Binsize  0: unbinned analysis Explicit sum over all events. Probability that event k originates from model. Integration over region-of-interest (energy, measured direction, time). Number of events

20 GammaLib / ctatools development Developement under CVS http://fusionforge.org/ Hudson continuous integration server (http://hudson-ci.org/) Required development efforts ~200 man months (GammaLib & ctatools) CESR contribution shaped to meet these requirements Your contribution is welcome! (i.e. non-CTA instrument interfaces, library extension, code optimisation, scripts, …)

21 Conclusions Status Prototype GammaLib software available (not everything is already implemented …) Prototype CTA and LAT instrument interfaces are implemented Simple CTA data analysis possible (point source fitting) Next steps Add missing core components to GammaLib (reporting, XML interface for model specification, …) Enhance existing GammaLib core components (extended / diffuse models, more complex spectral laws, parameter error estimation, …) Enhance CTA instrument interface (more realistic response function, background handling) Add / enhance ctatools to complete analysis chain Conclusion The prototype software demonstrates that a generic gamma-ray high-level analysis framework is feasible. CTA analysis in this framework will profit from multi-mission interfaces enabling broad-band spectral analysis of sources from a few tens of keV up to tens of TeV.


Download ppt "GammaLib based analysis of TeV data Proposal for a CTA High-level Science Analysis framework J. Knödlseder (CESR, Toulouse)"

Similar presentations


Ads by Google