Commit b1bd4caab035b78b04fe896478e2cb59aec82c42
1 parent
1110a353
Add csphasecrv unit test, use global ctools version and update parameter files
Showing
64 changed files
with
644 additions
and
889 deletions
cscripts/Makefile.am
| ... | ... | @@ -32,6 +32,7 @@ pythonscripts = $(top_builddir)/cscripts/__init__.py \ |
| 32 | 32 | $(srcdir)/csobsdef.py \ |
| 33 | 33 | $(srcdir)/csobsinfo.py \ |
| 34 | 34 | $(srcdir)/csobsselect.py \ |
| 35 | + $(srcdir)/csphasecrv.py \ | |
| 35 | 36 | $(srcdir)/cspull.py \ |
| 36 | 37 | $(srcdir)/csresmap.py \ |
| 37 | 38 | $(srcdir)/csroot2caldb.py \ |
| ... | ... | @@ -63,6 +64,7 @@ parfiles = $(srcdir)/cscaldb.par \ |
| 63 | 64 | $(srcdir)/csobsdef.par \ |
| 64 | 65 | $(srcdir)/csobsinfo.par \ |
| 65 | 66 | $(srcdir)/csobsselect.par \ |
| 67 | + $(srcdir)/csphasecrv.par \ | |
| 66 | 68 | $(srcdir)/cspull.par \ |
| 67 | 69 | $(srcdir)/csresmap.par \ |
| 68 | 70 | $(srcdir)/csroot2caldb.par \ |
| ... | ... | @@ -91,6 +93,7 @@ linkscripts = cscaldb \ |
| 91 | 93 | csobsdef \ |
| 92 | 94 | csobsinfo \ |
| 93 | 95 | csobsselect \ |
| 96 | + csphasecrv \ | |
| 94 | 97 | cspull \ |
| 95 | 98 | csresmap \ |
| 96 | 99 | csroot2caldb \ |
| ... | ... | @@ -183,7 +186,8 @@ testdata = $(top_srcdir)/test/data/crab.xml \ |
| 183 | 186 | $(top_srcdir)/test/data/iact_runlist_1.dat \ |
| 184 | 187 | $(top_srcdir)/test/data/iact_runlist_2.dat \ |
| 185 | 188 | $(top_srcdir)/test/data/model_temporal_phasecurve.xml \ |
| 186 | - $(top_srcdir)/test/data/model_temporal_phasecurve.fits | |
| 189 | + $(top_srcdir)/test/data/model_temporal_phasecurve.fits \ | |
| 190 | + $(top_srcdir)/test/data/phased_events.fits.gz | |
| 187 | 191 | |
| 188 | 192 | # Test data to be distributed in $(pyexecdir)/cscripts/tests/data/iactdata |
| 189 | 193 | testiactdata = $(top_srcdir)/test/data/iactdata/hdu-index.fits.gz \ | ... | ... |
cscripts/__init__.py.in
| ... | ... | @@ -35,6 +35,7 @@ __all__ = [ |
| 35 | 35 | "csobsdef", |
| 36 | 36 | "csobsinfo", |
| 37 | 37 | "csobsselect", |
| 38 | + "csphasecrv", | |
| 38 | 39 | "cspull", |
| 39 | 40 | "csresmap", |
| 40 | 41 | "csroot2caldb", |
| ... | ... | @@ -69,6 +70,7 @@ from cscripts.csobs2caldb import csobs2caldb |
| 69 | 70 | from cscripts.csobsdef import csobsdef |
| 70 | 71 | from cscripts.csobsinfo import csobsinfo |
| 71 | 72 | from cscripts.csobsselect import csobsselect |
| 73 | +from cscripts.csphasecrv import csphasecrv | |
| 72 | 74 | from cscripts.cspull import cspull |
| 73 | 75 | from cscripts.csresmap import csresmap |
| 74 | 76 | from cscripts.csroot2caldb import csroot2caldb | ... | ... |
cscripts/cscaldb.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Show the content of the ctools calibration database |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2014-2016 Juergen Knoedlseder | |
| 5 | +# Copyright (C) 2014-2017 Juergen Knoedlseder | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -55,7 +55,7 @@ class cscaldb(ctools.cscript): |
| 55 | 55 | """ |
| 56 | 56 | # Set name |
| 57 | 57 | self._name = 'cscaldb' |
| 58 | - self._version = '1.1.0' | |
| 58 | + self._version = ctools.__version__ | |
| 59 | 59 | |
| 60 | 60 | # Initialise application by calling the appropriate class |
| 61 | 61 | # constructor. | ... | ... |
cscripts/csebins.py
cscripts/csfindobs.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Find observations from an IACT data store |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2016 Michael Mayer | |
| 5 | +# Copyright (C) 2016-2017 Michael Mayer | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -40,7 +40,7 @@ class csfindobs(ctools.cscript): |
| 40 | 40 | """ |
| 41 | 41 | # Set name |
| 42 | 42 | self._name = 'csfindobs' |
| 43 | - self._version = '1.2.0' | |
| 43 | + self._version = ctools.__version__ | |
| 44 | 44 | self._datapath = os.getenv('VHEFITS','') |
| 45 | 45 | self._prodname = '' |
| 46 | 46 | self._select_radec = True | ... | ... |
cscripts/csiactcopy.py
| ... | ... | @@ -44,7 +44,7 @@ class csiactcopy(ctools.cscript): |
| 44 | 44 | """ |
| 45 | 45 | # Set name |
| 46 | 46 | self._name = 'csiactcopy' |
| 47 | - self._version = '1.2.0' | |
| 47 | + self._version = ctools.__version__ | |
| 48 | 48 | self._datapath = os.getenv('VHEFITS','') |
| 49 | 49 | self._remote_master = gammalib.GFilename() |
| 50 | 50 | self._remote_base = '' | ... | ... |
cscripts/csiactdata.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Inspect an IACT data storage |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2015-2016 Michael Mayer | |
| 5 | +# Copyright (C) 2015-2017 Michael Mayer | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -45,7 +45,7 @@ class csiactdata(ctools.cscript): |
| 45 | 45 | """ |
| 46 | 46 | # Set name |
| 47 | 47 | self._name = 'csiactdata' |
| 48 | - self._version = '1.1.0' | |
| 48 | + self._version = ctools.__version__ | |
| 49 | 49 | self._datapath = os.getenv('VHEFITS','') |
| 50 | 50 | self._prodnames = [] |
| 51 | 51 | self._master_indx = '' | ... | ... |
cscripts/csiactobs.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Generates an IACT observation definition XML file. |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2015-2016 Michael Mayer | |
| 5 | +# Copyright (C) 2015-2017 Michael Mayer | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -47,7 +47,7 @@ class csiactobs(ctools.cscript): |
| 47 | 47 | """ |
| 48 | 48 | # Set name and version |
| 49 | 49 | self._name = 'csiactobs' |
| 50 | - self._version = '1.2.0' | |
| 50 | + self._version = ctools.__version__ | |
| 51 | 51 | |
| 52 | 52 | # Initialise some members |
| 53 | 53 | self._obs = gammalib.GObservations() | ... | ... |
cscripts/cslightcrv.par
| ... | ... | @@ -36,7 +36,7 @@ emin, r, a, 0.1,,, "Lower energy limit of events (TeV)" |
| 36 | 36 | emax, r, a, 100.0,,, "Upper energy limit of events (TeV)" |
| 37 | 37 | enumbins, i, a, 0,0,100, "Number of energy bins for binned (0=unbinned)" |
| 38 | 38 | coordsys, s, a, CEL,CEL|GAL,, "Coordinate System" |
| 39 | -proj, s, a, CAR,AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" | |
| 39 | +proj, s, a, CAR,AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" | |
| 40 | 40 | xref, r, a, 83.63,0,360, "First coordinate of image center in degrees (RA or galactic l)" |
| 41 | 41 | yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DEC or galactic b)" |
| 42 | 42 | nxpix, i, a, 200,,, "Size of the X axis in pixels" | ... | ... |
cscripts/cslightcrv.py
| ... | ... | @@ -69,7 +69,7 @@ class cslightcrv(ctools.cscript): |
| 69 | 69 | """ |
| 70 | 70 | # Set name |
| 71 | 71 | self._name = 'cslightcrv' |
| 72 | - self._version = '1.3.0' | |
| 72 | + self._version = ctools.__version__ | |
| 73 | 73 | |
| 74 | 74 | # Initialise some members |
| 75 | 75 | self._srcname = '' |
| ... | ... | @@ -509,11 +509,7 @@ class cslightcrv(ctools.cscript): |
| 509 | 509 | self._get_parameters() |
| 510 | 510 | |
| 511 | 511 | # Write observation into logger |
| 512 | - if self._logTerse(): | |
| 513 | - self._log('\n') | |
| 514 | - self._log.header1(gammalib.number('Input observation',len(self._obs))) | |
| 515 | - self._log(str(self._obs)) | |
| 516 | - self._log('\n') | |
| 512 | + self._log_observations(gammalib.NORMAL, self._obs, 'Observation') | |
| 517 | 513 | |
| 518 | 514 | # Get time boundaries |
| 519 | 515 | tmin = self._tbins.tstart(0) | ... | ... |
cscripts/csmodelinfo.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Shows the content of a model container |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2015-2016 Michael Mayer | |
| 5 | +# Copyright (C) 2015-2017 Michael Mayer | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -44,7 +44,7 @@ class csmodelinfo(ctools.cscript): |
| 44 | 44 | """ |
| 45 | 45 | # Set name |
| 46 | 46 | self._name = 'csmodelinfo' |
| 47 | - self._version = '1.2.0' | |
| 47 | + self._version = ctools.__version__ | |
| 48 | 48 | |
| 49 | 49 | # Initialise class members |
| 50 | 50 | self._models = gammalib.GModels() | ... | ... |
cscripts/csmodelmerge.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Merge model definition XML files |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2015-2016 Michael Mayer | |
| 5 | +# Copyright (C) 2015-2017 Michael Mayer | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -43,7 +43,7 @@ class csmodelmerge(ctools.cscript): |
| 43 | 43 | """ |
| 44 | 44 | # Set name |
| 45 | 45 | self._name = 'csmodelmerge' |
| 46 | - self._version = '1.2.0' | |
| 46 | + self._version = ctools.__version__ | |
| 47 | 47 | |
| 48 | 48 | # Initialise class members |
| 49 | 49 | self._files = None | ... | ... |
cscripts/csmodelselect.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Selects model from a model definition XML file |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2016 Juergen Knoedlseder | |
| 5 | +# Copyright (C) 2016-2017 Juergen Knoedlseder | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -38,7 +38,7 @@ class csmodelselect(ctools.cscript): |
| 38 | 38 | """ |
| 39 | 39 | # Set name |
| 40 | 40 | self._name = 'csmodelselect' |
| 41 | - self._version = '1.2.0' | |
| 41 | + self._version = ctools.__version__ | |
| 42 | 42 | |
| 43 | 43 | # Initialise observation container from constructor arguments |
| 44 | 44 | self._obs, argv = self._set_input_obs(argv) | ... | ... |
cscripts/csobs2caldb.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Creates a calibration database entry for an IACT observation. |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2015-2016 Michael Mayer | |
| 5 | +# Copyright (C) 2015-2017 Michael Mayer | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -48,7 +48,7 @@ class csobs2caldb(ctools.cscript): |
| 48 | 48 | """ |
| 49 | 49 | # Set name and version |
| 50 | 50 | self._name = 'csobs2caldb' |
| 51 | - self._version = '1.2.0' | |
| 51 | + self._version = ctools.__version__ | |
| 52 | 52 | |
| 53 | 53 | # Initialise members |
| 54 | 54 | self._observation = gammalib.GCTAObservation() | ... | ... |
cscripts/csobsdef.py
cscripts/csobsinfo.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Dump information about observation into log file |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2015-2016 Michael Mayer | |
| 5 | +# Copyright (C) 2015-2017 Michael Mayer | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -38,7 +38,7 @@ class csobsinfo(ctools.cscript): |
| 38 | 38 | """ |
| 39 | 39 | # Set name |
| 40 | 40 | self._name = 'csobsinfo' |
| 41 | - self._version = '1.2.0' | |
| 41 | + self._version = ctools.__version__ | |
| 42 | 42 | |
| 43 | 43 | # Initialise class members |
| 44 | 44 | self._obj_dir = None | ... | ... |
cscripts/csobsselect.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Selects observations from an observation definition XML file |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2016 Juergen Knoedlseder | |
| 5 | +# Copyright (C) 2016-2017 Juergen Knoedlseder | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -38,7 +38,7 @@ class csobsselect(ctools.cscript): |
| 38 | 38 | """ |
| 39 | 39 | # Set name |
| 40 | 40 | self._name = 'csobsselect' |
| 41 | - self._version = '1.2.0' | |
| 41 | + self._version = ctools.__version__ | |
| 42 | 42 | |
| 43 | 43 | # Initialise observation container from constructor arguments |
| 44 | 44 | self._obs, argv = self._set_input_obs(argv) | ... | ... |
cscripts/csphasecrv.par
| ... | ... | @@ -27,14 +27,14 @@ outfile, f, a, phasecrv.fits,,, "Output fits file name." |
| 27 | 27 | # |
| 28 | 28 | # Script parameters |
| 29 | 29 | #================== |
| 30 | -tbinalg, s, a, LIN,LIN|FILE,, "Algorithm for defining time bins" | |
| 30 | +phbinalg, s, a, LIN,LIN|FILE,, "Algorithm for defining phase bins" | |
| 31 | 31 | phbins, i, a, 5,1,10000, "Number of phase bins" |
| 32 | 32 | phbinfile, f, a, NONE,,, "File defining the phase binning" |
| 33 | 33 | emin, r, a, 0.1,,, "Lower energy limit of events (TeV)" |
| 34 | 34 | emax, r, a, 100.0,,, "Upper energy limit of events (TeV)" |
| 35 | 35 | enumbins, i, a, 0,0,100, "Number of energy bins for binned (0=unbinned)" |
| 36 | 36 | coordsys, s, a, CEL,CEL|GAL,, "Coordinate System" |
| 37 | -proj, s, a, CAR,AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" | |
| 37 | +proj, s, a, CAR,AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" | |
| 38 | 38 | xref, r, a, 83.63,0,360, "First coordinate of image center in degrees (RA or galactic l)" |
| 39 | 39 | yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DEC or galactic b)" |
| 40 | 40 | nxpix, i, a, 200,,, "Size of the X axis in pixels" |
| ... | ... | @@ -44,6 +44,7 @@ binsz, r, a, 0.02,,, "Pixel size (deg/pixel)" |
| 44 | 44 | # |
| 45 | 45 | # Standard parameters |
| 46 | 46 | #==================== |
| 47 | +publish, b, h, no,,, "Publish phase curve on VO Hub?" | |
| 47 | 48 | chatter, i, h, 2,0,4, "Chattiness of output" |
| 48 | 49 | clobber, b, h, yes,,, "Overwrite existing output files with new output files?" |
| 49 | 50 | debug, b, h, no,,, "Debugging mode activated" | ... | ... |
cscripts/csphasecrv.py
| 1 | 1 | #! /usr/bin/env python |
| 2 | 2 | # ========================================================================== |
| 3 | -# Generates pulsar spectra as a function of phase | |
| 3 | +# Generates spectra as a function of phase | |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2014-2017 Rolf Buehler | |
| 5 | +# Copyright (C) 2017 Rolf Buehler | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -29,22 +29,22 @@ from cscripts import obsutils |
| 29 | 29 | # ================ # |
| 30 | 30 | class csphasecrv(ctools.cscript): |
| 31 | 31 | """ |
| 32 | - Generates a spectra in phase bins | |
| 32 | + Generates spectra in phase bins | |
| 33 | 33 | |
| 34 | 34 | This script computes spectra by performing a maximum likelihood fit |
| 35 | - using :doc:`ctlike` in a series of phase bins for pulsars. | |
| 36 | - The phase bins can be either specified in an ASCII file, as an interval | |
| 37 | - divided into equally sized phase bins. | |
| 35 | + using :doc:`ctlike` in a series of phase bins for pulsars. The phase bins | |
| 36 | + can be either specified in an ASCII file or as an interval divided into | |
| 37 | + equally sized phase bins. | |
| 38 | 38 | |
| 39 | 39 | Examples: |
| 40 | - >>> phrv = csphasecrv() | |
| 41 | - >>> phrv.run() | |
| 40 | + >>> phcrv = csphasecrv() | |
| 41 | + >>> phcrv.run() | |
| 42 | 42 | >>> ... (querying for parameters) ... |
| 43 | - >>> phrv = phrv.phasecrv() | |
| 43 | + >>> phcrv = phrv.phasecrv() | |
| 44 | 44 | Generates phase fits and retrieves dictionary with best fit models. |
| 45 | 45 | |
| 46 | - >>> lcrv = csphasecrv(obs) | |
| 47 | - >>> lcrv.execute() | |
| 46 | + >>> phcrv = csphasecrv(obs) | |
| 47 | + >>> phcrv.execute() | |
| 48 | 48 | >>> ... (querying for parameters) ... |
| 49 | 49 | Generates phase fits from the observations |
| 50 | 50 | and saves results in XML files. |
| ... | ... | @@ -57,13 +57,14 @@ class csphasecrv(ctools.cscript): |
| 57 | 57 | """ |
| 58 | 58 | # Set name |
| 59 | 59 | self._name = 'csphasecrv' |
| 60 | - self._version = '1.0.0' | |
| 60 | + self._version = ctools.__version__ | |
| 61 | 61 | |
| 62 | - # Initialise some members | |
| 62 | + # Initialise some members. Phases are stored in a nested list | |
| 63 | + # [[ph1min,ph1max], [ph2min,ph2max],..] | |
| 63 | 64 | self._srcname = '' |
| 64 | - # Phases are stored in a nested list [[ph1min,ph1max], [ph2min,ph2max],..] | |
| 65 | - self._phbins = [[0.0,1.0]] | |
| 65 | + self._phbins = [[0.0,1.0]] | |
| 66 | 66 | self._stacked = False |
| 67 | + self._fits = gammalib.GFits() | |
| 67 | 68 | |
| 68 | 69 | # Initialise observation container from constructor arguments. |
| 69 | 70 | self._obs, argv = self._set_input_obs(argv) |
| ... | ... | @@ -144,7 +145,7 @@ class csphasecrv(ctools.cscript): |
| 144 | 145 | # Get algorithm to use for defining the time intervals. Possible |
| 145 | 146 | # values are "FILE" or "LIN". This is enforced at |
| 146 | 147 | # parameter file level, hence no checking is needed. |
| 147 | - algorithm = self['tbinalg'].string() | |
| 148 | + algorithm = self['phbinalg'].string() | |
| 148 | 149 | |
| 149 | 150 | # If the algorithm is "FILE" then handle a FITS or an ASCII file for |
| 150 | 151 | # the time bin definition |
| ... | ... | @@ -173,8 +174,8 @@ class csphasecrv(ctools.cscript): |
| 173 | 174 | # Compute time step and setup the GTIs |
| 174 | 175 | ph_step = 1.0 / float(nbins) |
| 175 | 176 | for i in range(nbins): |
| 176 | - phmin = i *ph_step | |
| 177 | - phmax = (i+1)*ph_step | |
| 177 | + phmin = i * ph_step | |
| 178 | + phmax = (i+1) * ph_step | |
| 178 | 179 | phbins.append([phmin,phmax]) |
| 179 | 180 | |
| 180 | 181 | # Return Good Time Intervals |
| ... | ... | @@ -252,6 +253,168 @@ class csphasecrv(ctools.cscript): |
| 252 | 253 | # Return new oberservation container |
| 253 | 254 | return new_obs |
| 254 | 255 | |
| 256 | + def _get_free_par_names(self): | |
| 257 | + """ | |
| 258 | + Return list of free parameter names | |
| 259 | + | |
| 260 | + Returns | |
| 261 | + ------- | |
| 262 | + names : list of str | |
| 263 | + List of free parameter names. | |
| 264 | + """ | |
| 265 | + # Initialise empty list of free parameter names | |
| 266 | + names = [] | |
| 267 | + | |
| 268 | + # Collect list of free parameter names | |
| 269 | + for par in self._obs.models()[self._srcname]: | |
| 270 | + if par.is_free(): | |
| 271 | + names.append(par.name()) | |
| 272 | + | |
| 273 | + # Return names | |
| 274 | + return names | |
| 275 | + | |
| 276 | + def _create_fits_table(self, results): | |
| 277 | + """ | |
| 278 | + Creates FITS binary table containing light curve results | |
| 279 | + | |
| 280 | + Parameters | |
| 281 | + ---------- | |
| 282 | + results : list of dict | |
| 283 | + List of result dictionaries | |
| 284 | + | |
| 285 | + Returns | |
| 286 | + ------- | |
| 287 | + table : `~gammalib.GFitsBinTable` | |
| 288 | + FITS binary table containing light curve | |
| 289 | + """ | |
| 290 | + # Determine number of rows in FITS table | |
| 291 | + nrows = len(results) | |
| 292 | + | |
| 293 | + # Create FITS Table with extension "PHASECURVE" | |
| 294 | + table = gammalib.GFitsBinTable(nrows) | |
| 295 | + table.extname('PHASECURVE') | |
| 296 | + | |
| 297 | + # Append phase columns "PHASE_MIN" and "PHASE_MAX" | |
| 298 | + phmin = gammalib.GFitsTableDoubleCol('PHASE_MIN', nrows) | |
| 299 | + phmax = gammalib.GFitsTableDoubleCol('PHASE_MAX', nrows) | |
| 300 | + for i, result in enumerate(results): | |
| 301 | + phmin[i] = result['phmin'] | |
| 302 | + phmax[i] = result['phmax'] | |
| 303 | + table.append(phmin) | |
| 304 | + table.append(phmax) | |
| 305 | + | |
| 306 | + # Create parameter columns | |
| 307 | + for par in self._obs.models()[self._srcname]: | |
| 308 | + if par.is_free(): | |
| 309 | + name = par.name() | |
| 310 | + e_name = 'e_'+par.name() | |
| 311 | + col = gammalib.GFitsTableDoubleCol(name, nrows) | |
| 312 | + e_col = gammalib.GFitsTableDoubleCol(e_name, nrows) | |
| 313 | + col.unit(par.unit()) | |
| 314 | + e_col.unit(par.unit()) | |
| 315 | + for i, result in enumerate(results): | |
| 316 | + col[i] = result['values'][name] | |
| 317 | + e_col[i] = result['values'][e_name] | |
| 318 | + table.append(col) | |
| 319 | + table.append(e_col) | |
| 320 | + | |
| 321 | + # Return table | |
| 322 | + return table | |
| 323 | + | |
| 324 | + def _create_fits(self): | |
| 325 | + """ | |
| 326 | + Create FITS file object from fit results | |
| 327 | + """ | |
| 328 | + # Initialise list of result dictionaries | |
| 329 | + results = [] | |
| 330 | + | |
| 331 | + # Get source parameters | |
| 332 | + pars = self._get_free_par_names() | |
| 333 | + | |
| 334 | + # Loop over time bins | |
| 335 | + for i in range(len(self._phbins)): | |
| 336 | + | |
| 337 | + # Get time boundaries | |
| 338 | + phmin = self._phbins[i][0] | |
| 339 | + phmax = self._phbins[i][1] | |
| 340 | + | |
| 341 | + # Initialise result dictionary | |
| 342 | + result = {'phmin': phmin, | |
| 343 | + 'phmax': phmax, | |
| 344 | + 'pars': pars, | |
| 345 | + 'values': {}} | |
| 346 | + | |
| 347 | + # Store fit results | |
| 348 | + phname = str(phmin)+'-'+str(phmax) | |
| 349 | + source = self._fitmodels[phname][self._srcname] | |
| 350 | + for par in pars: | |
| 351 | + result['values'][par] = source[par].value() | |
| 352 | + result['values']['e_'+par] = source[par].error() | |
| 353 | + | |
| 354 | + # Append result to list of dictionaries | |
| 355 | + results.append(result) | |
| 356 | + | |
| 357 | + # Create FITS table from results | |
| 358 | + table = self._create_fits_table(results) | |
| 359 | + | |
| 360 | + # Create FITS file and append FITS table to FITS file | |
| 361 | + self._fits = gammalib.GFits() | |
| 362 | + self._fits.append(table) | |
| 363 | + | |
| 364 | + # Return | |
| 365 | + return | |
| 366 | + | |
| 367 | + def _save_fits(self): | |
| 368 | + """ | |
| 369 | + Saved phase fit results into a fits file | |
| 370 | + """ | |
| 371 | + # Write header | |
| 372 | + self._log_header1(gammalib.TERSE, 'Save phase FITS file') | |
| 373 | + | |
| 374 | + # Create FITS file | |
| 375 | + self._create_fits() | |
| 376 | + | |
| 377 | + # Get file name | |
| 378 | + outfile = self['outfile'].filename() | |
| 379 | + | |
| 380 | + # Log file name | |
| 381 | + self._log_value(gammalib.NORMAL, 'Phase curve file', outfile.url()) | |
| 382 | + | |
| 383 | + # Save to fits | |
| 384 | + self._fits.saveto(outfile, self._clobber()) | |
| 385 | + | |
| 386 | + # Return | |
| 387 | + return | |
| 388 | + | |
| 389 | + def _save_xml(self): | |
| 390 | + """ | |
| 391 | + Save phase fit results into one XML model each bin | |
| 392 | + """ | |
| 393 | + # Write header | |
| 394 | + self._log_header1(gammalib.TERSE, 'Save phase XML files') | |
| 395 | + | |
| 396 | + # Get file name | |
| 397 | + outname = self['outfile'].filename() | |
| 398 | + | |
| 399 | + # Loop over all phase bins | |
| 400 | + for phbin in self._phbins: | |
| 401 | + | |
| 402 | + # Set file name for phase bin | |
| 403 | + phname = str(phbin[0])+'-'+str(phbin[1]) | |
| 404 | + replace_name = '_phase_'+phname+'.xml' | |
| 405 | + outname_phase = (outname.file()).replace('.fits', replace_name) | |
| 406 | + outfile = outname.path() + outname_phase | |
| 407 | + | |
| 408 | + # Save XML file | |
| 409 | + self._fitmodels[phname].save(outfile) | |
| 410 | + | |
| 411 | + # Log file name | |
| 412 | + name = 'Phase [%s] file' % phname | |
| 413 | + self._log_value(gammalib.NORMAL, name, outfile) | |
| 414 | + | |
| 415 | + # Return | |
| 416 | + return | |
| 417 | + | |
| 255 | 418 | |
| 256 | 419 | # Public methods |
| 257 | 420 | def run(self): |
| ... | ... | @@ -264,24 +427,26 @@ class csphasecrv(ctools.cscript): |
| 264 | 427 | |
| 265 | 428 | # Get parameters |
| 266 | 429 | self._get_parameters() |
| 267 | - | |
| 430 | + | |
| 268 | 431 | # Write observation into logger |
| 269 | - if self._logTerse(): | |
| 270 | - self._log('\n') | |
| 271 | - self._log.header1(gammalib.number('Input observation',len(self._obs))) | |
| 272 | - self._log(str(self._obs)) | |
| 273 | - self._log('\n') | |
| 274 | - | |
| 275 | - #Store and clear observations to split them in phase | |
| 432 | + self._log_observations(gammalib.NORMAL, self._obs, 'Observation') | |
| 433 | + | |
| 434 | + # Store and clear observations to split them into phase bins | |
| 276 | 435 | orig_obs = self._obs.copy() |
| 277 | - #self._obs.clear() | |
| 278 | 436 | |
| 279 | - #Dictionary to save phase fitted models | |
| 437 | + # Dictionary to save phase fitted models | |
| 280 | 438 | self._fitmodels = {} |
| 281 | - | |
| 282 | - #Loop over all phases | |
| 439 | + | |
| 440 | + # Write header | |
| 441 | + self._log_header1(gammalib.TERSE, 'Generate phase curve') | |
| 442 | + | |
| 443 | + # Loop over all phases | |
| 283 | 444 | for phbin in self._phbins: |
| 284 | - | |
| 445 | + | |
| 446 | + # Write time bin into header | |
| 447 | + if self._logTerse(): | |
| 448 | + self._log.header2('PHASE '+str(phbin[0])+'-'+str(phbin[1])) | |
| 449 | + | |
| 285 | 450 | # Select events |
| 286 | 451 | select = ctools.ctselect(orig_obs) |
| 287 | 452 | select['emin'] = self['emin'].real() |
| ... | ... | @@ -291,13 +456,13 @@ class csphasecrv(ctools.cscript): |
| 291 | 456 | select['rad'] = 'UNDEFINED' |
| 292 | 457 | select['ra'] = 'UNDEFINED' |
| 293 | 458 | select['dec'] = 'UNDEFINED' |
| 294 | - select['expr'] = "PHASE>"+str(phbin[0])+" && PHASE<"+str(phbin[1]) | |
| 459 | + select['expr'] = 'PHASE>'+str(phbin[0])+' && PHASE<'+str(phbin[1]) | |
| 295 | 460 | select.run() |
| 296 | 461 | |
| 297 | - #Add phase to observation id | |
| 462 | + # Add phase to observation id | |
| 298 | 463 | for i in range(0,select.obs().size()): |
| 299 | 464 | oldid = select.obs()[i].id() |
| 300 | - select.obs()[i].id(oldid+"_"+str(phbin[0])+"-"+str(phbin[1])) | |
| 465 | + select.obs()[i].id(oldid+'_'+str(phbin[0])+'-'+str(phbin[1])) | |
| 301 | 466 | obs = select.obs() |
| 302 | 467 | |
| 303 | 468 | # If a stacked analysis is requested then bin the events |
| ... | ... | @@ -318,15 +483,18 @@ class csphasecrv(ctools.cscript): |
| 318 | 483 | # Renormalize models to phase selection |
| 319 | 484 | # TODO move the scaling from the temporal to the spectral component |
| 320 | 485 | for model in like.obs().models(): |
| 321 | - scaled_norm = model["Normalization"].value()/(phbin[1] - phbin[0]) | |
| 322 | - model["Normalization"].value(scaled_norm) | |
| 486 | + scaled_norm = model['Normalization'].value()/(phbin[1] - phbin[0]) | |
| 487 | + model['Normalization'].value(scaled_norm) | |
| 323 | 488 | |
| 324 | - #Store fit model | |
| 325 | - self._fitmodels[str(phbin[0])+"-"+str(phbin[1])] = like.obs().models().copy() | |
| 489 | + # Store fit model | |
| 490 | + self._fitmodels[str(phbin[0])+'-'+str(phbin[1])] = like.obs().models().copy() | |
| 491 | + | |
| 492 | + # Create FITS file | |
| 493 | + self._create_fits() | |
| 326 | 494 | |
| 327 | - ## Store observations | |
| 328 | - #for ob in select.obs(): | |
| 329 | - #self._obs.append(ob.copy()) | |
| 495 | + # Optionally publish light curve | |
| 496 | + if self['publish'].boolean(): | |
| 497 | + self.publish() | |
| 330 | 498 | |
| 331 | 499 | # Return |
| 332 | 500 | return |
| ... | ... | @@ -350,171 +518,57 @@ class csphasecrv(ctools.cscript): |
| 350 | 518 | # Return |
| 351 | 519 | return |
| 352 | 520 | |
| 353 | - def saveXML(self): | |
| 354 | - """ | |
| 355 | - Save phase fits into one XML model each | |
| 356 | - """ | |
| 357 | - # Write header | |
| 358 | - self._log_header1(gammalib.TERSE, 'Save phase XML') | |
| 359 | - | |
| 360 | - # Get out filename | |
| 361 | - outfile = str() | |
| 362 | - | |
| 363 | - # Save XMLs | |
| 364 | - for phbin in self._phbins: | |
| 365 | - phname = str(phbin[0])+"-"+str(phbin[1]) | |
| 366 | - outname = self['outfile'].filename() | |
| 367 | - outname_ph = (outname.file()).replace(".fits","_ph_"+phname+".xml") | |
| 368 | - outfile = outname.path()+outname_ph | |
| 369 | - print outfile | |
| 370 | - self._fitmodels[phname].save(outfile) | |
| 371 | - | |
| 372 | - # Return | |
| 373 | - return | |
| 374 | - | |
| 375 | 521 | def save(self): |
| 376 | 522 | """ |
| 377 | 523 | Saves results to fits and XML |
| 378 | 524 | """ |
| 379 | - print "SAVING" | |
| 380 | - self.savefits() | |
| 381 | - self.saveXML() | |
| 525 | + # Save results to FITS | |
| 526 | + self._save_fits() | |
| 527 | + | |
| 528 | + # Save results to XML files (one per phase bin) | |
| 529 | + self._save_xml() | |
| 382 | 530 | |
| 383 | 531 | # Return |
| 384 | 532 | return |
| 385 | 533 | |
| 386 | - def phaserv(self): | |
| 387 | - """ | |
| 388 | - Return dictionary with best fit models | |
| 389 | - """ | |
| 390 | - # Return | |
| 391 | - return self._fitmodels | |
| 392 | - | |
| 393 | - def _get_free_par_names(self): | |
| 534 | + def publish(self, name=''): | |
| 394 | 535 | """ |
| 395 | - Return list of free parameter names | |
| 536 | + Publish phase curve | |
| 396 | 537 | |
| 397 | - Returns | |
| 398 | - ------- | |
| 399 | - names : list of str | |
| 400 | - List of free parameter names. | |
| 401 | - """ | |
| 402 | - # Initialise empty list of free parameter names | |
| 403 | - names = [] | |
| 404 | - | |
| 405 | - # Collect list of free parameter names | |
| 406 | - for par in self._obs.models()[self._srcname]: | |
| 407 | - if par.is_free(): | |
| 408 | - names.append(par.name()) | |
| 409 | - | |
| 410 | - # Return names | |
| 411 | - return names | |
| 412 | - | |
| 413 | - def savefits(self): | |
| 414 | - """ | |
| 415 | - Saved phase fit results to a fits file | |
| 538 | + Parameters | |
| 539 | + ---------- | |
| 540 | + name : str, optional | |
| 541 | + Name of phase curve | |
| 416 | 542 | """ |
| 417 | - # Initialise list of result dictionaries | |
| 418 | - results = [] | |
| 419 | - | |
| 420 | - # Get source parameters | |
| 421 | - pars = self._get_free_par_names() | |
| 422 | - | |
| 423 | - # Loop over time bins | |
| 424 | - for i in range(len(self._phbins)): | |
| 543 | + # Write header | |
| 544 | + self._log_header1(gammalib.TERSE, 'Publish phase curve') | |
| 425 | 545 | |
| 426 | - # Get time boundaries | |
| 427 | - phmin = self._phbins[i][0] | |
| 428 | - phmax = self._phbins[i][1] | |
| 546 | + # Continue only if light curve is valid | |
| 547 | + if self._fits.contains('PHASECURVE'): | |
| 429 | 548 | |
| 430 | - # Write time bin into header | |
| 431 | - if self._logTerse(): | |
| 432 | - self._log.header2('PHASE '+str(phmin)+'-'+str(phmax)) | |
| 549 | + # Set default name is user name is empty | |
| 550 | + if not name: | |
| 551 | + user_name = self._name | |
| 552 | + else: | |
| 553 | + user_name = name | |
| 433 | 554 | |
| 434 | - # Initialise result dictionary | |
| 435 | - result = {'phmin': phmin, | |
| 436 | - 'phmax': phmax, | |
| 437 | - 'pars': pars, | |
| 438 | - 'values': {}} | |
| 439 | - # Extract parameter values | |
| 440 | - | |
| 441 | - #Store fit results | |
| 442 | - phname = str(phmin)+"-"+str(phmax) | |
| 443 | - source = self._fitmodels[phname][self._srcname] | |
| 444 | - for par in pars: | |
| 445 | - result['values'][par] = source[par].value() | |
| 446 | - result['values']['e_'+par] = source[par].error() | |
| 447 | - | |
| 448 | - # Append result to list of dictionaries | |
| 449 | - results.append(result) | |
| 450 | - | |
| 451 | - # Create FITS table from results | |
| 452 | - table = self._create_fits_table(results) | |
| 555 | + # Log file name | |
| 556 | + self._log_value(gammalib.NORMAL, 'Phase curve name', user_name) | |
| 453 | 557 | |
| 454 | - # Create FITS file and append FITS table to FITS file | |
| 455 | - self._fits = gammalib.GFits() | |
| 456 | - self._fits.append(table) | |
| 558 | + # Publish phase curve | |
| 559 | + self._fits.publish('PHASECURVE', user_name) | |
| 457 | 560 | |
| 458 | - # Save to fits | |
| 459 | - outfile = self['outfile'].filename() | |
| 460 | - print outfile | |
| 461 | - self._fits.saveto(outfile, self._clobber()) | |
| 462 | - | |
| 463 | - #Return | |
| 561 | + # Return | |
| 464 | 562 | return |
| 465 | 563 | |
| 466 | - def _create_fits_table(self, results): | |
| 564 | + def phasecurve(self): | |
| 467 | 565 | """ |
| 468 | - Creates FITS binary table containing light curve results | |
| 469 | - | |
| 470 | - Parameters | |
| 471 | - ---------- | |
| 472 | - results : list of dict | |
| 473 | - List of result dictionaries | |
| 474 | - | |
| 475 | - Returns | |
| 476 | - ------- | |
| 477 | - table : `~gammalib.GFitsBinTable` | |
| 478 | - FITS binary table containing light curve | |
| 566 | + Return dictionary with best fit models | |
| 479 | 567 | """ |
| 480 | - # Determine number of rows in FITS table | |
| 481 | - nrows = len(results) | |
| 482 | - | |
| 483 | - # Create FITS Table with extension "LIGHTCURVE" | |
| 484 | - table = gammalib.GFitsBinTable(nrows) | |
| 485 | - table.extname('PHASESPEC') | |
| 486 | - | |
| 487 | - # Append time columns "MJD" and "e_MJD" | |
| 488 | - phmin = gammalib.GFitsTableDoubleCol('PHMIN', nrows) | |
| 489 | - phmax = gammalib.GFitsTableDoubleCol('PHMAX', nrows) | |
| 490 | - #mjd.unit('days') | |
| 491 | - #e_mjd.unit('days') | |
| 492 | - for i, result in enumerate(results): | |
| 493 | - phmin[i] = result['phmin'] | |
| 494 | - phmax[i] = result['phmax'] | |
| 495 | - table.append(phmin) | |
| 496 | - table.append(phmax) | |
| 497 | - | |
| 498 | - # Create parameter columns | |
| 499 | - for par in self._obs.models()[self._srcname]: | |
| 500 | - if par.is_free(): | |
| 501 | - name = par.name() | |
| 502 | - e_name = 'e_'+par.name() | |
| 503 | - col = gammalib.GFitsTableDoubleCol(name, nrows) | |
| 504 | - e_col = gammalib.GFitsTableDoubleCol(e_name, nrows) | |
| 505 | - col.unit(par.unit()) | |
| 506 | - e_col.unit(par.unit()) | |
| 507 | - for i, result in enumerate(results): | |
| 508 | - col[i] = result['values'][name] | |
| 509 | - e_col[i] = result['values'][e_name] | |
| 510 | - table.append(col) | |
| 511 | - table.append(e_col) | |
| 512 | - | |
| 513 | - # Return table | |
| 514 | - return table | |
| 568 | + # Return | |
| 569 | + return self._fitmodels | |
| 515 | 570 | |
| 516 | 571 | |
| 517 | - | |
| 518 | 572 | # ======================== # |
| 519 | 573 | # Main routine entry point # |
| 520 | 574 | # ======================== # | ... | ... |
cscripts/cspull.par
| ... | ... | @@ -31,7 +31,7 @@ ntrials, i, a, 10,,, "Number of trials" |
| 31 | 31 | ra, r, a, 83.6331,0,360, "RA of pointing (deg)" |
| 32 | 32 | dec, r, a, 22.0145,-90,90, "Dec of pointing (deg)" |
| 33 | 33 | coordsys, s, a, CEL,CEL|GAL,, "Coordinate system (CEL - celestial, GAL - galactic)" |
| 34 | -proj, s, a, TAN,AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" | |
| 34 | +proj, s, a, TAN,AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" | |
| 35 | 35 | emin, r, a, 0.1,,, "Lower energy limit (TeV)" |
| 36 | 36 | emax, r, a, 100.0,,, "Upper energy limit (TeV)" |
| 37 | 37 | enumbins, i, a, 0,,, "Number of energy bins (0=unbinned)" | ... | ... |
cscripts/cspull.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # This script generates the pull distribution for all model parameters. |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2011-2016 Juergen Knoedlseder | |
| 5 | +# Copyright (C) 2011-2017 Juergen Knoedlseder | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -40,7 +40,7 @@ class cspull(ctools.cscript): |
| 40 | 40 | """ |
| 41 | 41 | # Set name |
| 42 | 42 | self._name = 'cspull' |
| 43 | - self._version = '1.2.0' | |
| 43 | + self._version = ctools.__version__ | |
| 44 | 44 | |
| 45 | 45 | # Initialise some members |
| 46 | 46 | self._edisp = False | ... | ... |
cscripts/csresmap.par
| ... | ... | @@ -37,7 +37,7 @@ emax, r, a, 100.0,,, "Upper energy limit (TeV)" |
| 37 | 37 | enumbins, i, h, 20,,, "Number of model cube energy bins" |
| 38 | 38 | ebinfile, f, a, NONE,,, "Name of the file containing the energy bin definition" |
| 39 | 39 | coordsys, s, a, CEL,CEL|GAL,, "Coordinate System" |
| 40 | -proj, s, a, CAR,AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" | |
| 40 | +proj, s, a, CAR,AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" | |
| 41 | 41 | xref, r, a, 83.63,0,360, "First coordinate of image center in degrees (RA or galactic l)" |
| 42 | 42 | yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DEC or galactic b)" |
| 43 | 43 | nxpix, i, a, 200,,, "Size of the X axis in pixels" | ... | ... |
cscripts/csresmap.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Generates a residual map. |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2014-2016 Michael Mayer | |
| 5 | +# Copyright (C) 2014-2017 Michael Mayer | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -38,7 +38,7 @@ class csresmap(ctools.cscript): |
| 38 | 38 | """ |
| 39 | 39 | # Set name |
| 40 | 40 | self._name = 'csresmap' |
| 41 | - self._version = '1.2.0' | |
| 41 | + self._version = ctools.__version__ | |
| 42 | 42 | |
| 43 | 43 | # Initialise class members |
| 44 | 44 | self._resmap = None | ... | ... |
cscripts/csroot2caldb.py
| ... | ... | @@ -50,7 +50,7 @@ class csroot2caldb(ctools.cscript): |
| 50 | 50 | """ |
| 51 | 51 | # Set name |
| 52 | 52 | self._name = 'csroot2caldb' |
| 53 | - self._version = '1.3.0' | |
| 53 | + self._version = ctools.__version__ | |
| 54 | 54 | |
| 55 | 55 | # Initialise application by calling the appropriate class constructor |
| 56 | 56 | self._init_cscript(argv) | ... | ... |
cscripts/cssens.py
cscripts/csspec.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Generates a spectrum. |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2014-2016 Michael Mayer | |
| 5 | +# Copyright (C) 2014-2017 Michael Mayer | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -43,7 +43,7 @@ class csspec(ctools.cscript): |
| 43 | 43 | """ |
| 44 | 44 | # Set name |
| 45 | 45 | self._name = 'csspec' |
| 46 | - self._version = '1.1.0' | |
| 46 | + self._version = ctools.__version__ | |
| 47 | 47 | |
| 48 | 48 | # Initialise some members |
| 49 | 49 | self._ebounds = gammalib.GEbounds() | ... | ... |
cscripts/cssrcdetect.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Detects sources in a sky map |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2016 Juergen Knoedlseder | |
| 5 | +# Copyright (C) 2016-2017 Juergen Knoedlseder | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -40,7 +40,7 @@ class cssrcdetect(ctools.cscript): |
| 40 | 40 | """ |
| 41 | 41 | # Set name |
| 42 | 42 | self._name = 'cssrcdetect' |
| 43 | - self._version = '1.2.0' | |
| 43 | + self._version = ctools.__version__ | |
| 44 | 44 | |
| 45 | 45 | # Set protected members |
| 46 | 46 | self._models = gammalib.GModels() | ... | ... |
cscripts/cstsdist.par
| ... | ... | @@ -36,7 +36,7 @@ ntrials, i, a, 10,,, "Number of trials" |
| 36 | 36 | ra, r, a, 83.63,0,360, "RA of pointing (deg)" |
| 37 | 37 | dec, r, a, 22.01,-90,90, "Dec of pointing (deg)" |
| 38 | 38 | coordsys, s, a, CEL,CEL|GAL,, "Coordinate system (CEL - celestial, GAL - galactic)" |
| 39 | -proj, s, a, TAN,AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" | |
| 39 | +proj, s, a, TAN,AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" | |
| 40 | 40 | emin, r, a, 0.1,,, "Lower energy limit (TeV)" |
| 41 | 41 | emax, r, a, 100.0,,, "Upper energy limit (TeV)" |
| 42 | 42 | enumbins, i, a, 0,,, "Number of energy bins (0=unbinned)" | ... | ... |
cscripts/cstsdist.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Generates the TS distribution for a particular model |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2011-2016 Juergen Knoedlseder | |
| 5 | +# Copyright (C) 2011-2017 Juergen Knoedlseder | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -41,7 +41,7 @@ class cstsdist(ctools.cscript): |
| 41 | 41 | """ |
| 42 | 42 | # Set name |
| 43 | 43 | self._name = 'cstsdist' |
| 44 | - self._version = '1.2.0' | |
| 44 | + self._version = ctools.__version__ | |
| 45 | 45 | |
| 46 | 46 | # Initialise some members |
| 47 | 47 | self._srcname = '' | ... | ... |
cscripts/cstsmapmerge.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Merge Test Statistic maps |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2015-2016 Michael Mayer | |
| 5 | +# Copyright (C) 2015-2017 Michael Mayer | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -40,7 +40,7 @@ class cstsmapmerge(ctools.cscript): |
| 40 | 40 | """ |
| 41 | 41 | # Set name |
| 42 | 42 | self._name = 'cstsmapmerge' |
| 43 | - self._version = '1.1.0' | |
| 43 | + self._version = ctools.__version__ | |
| 44 | 44 | |
| 45 | 45 | # Initialise class members |
| 46 | 46 | self._files = None | ... | ... |
cscripts/cstsmapsplit.par
| ... | ... | @@ -41,9 +41,9 @@ nxpix, i, a, 200,,, "Size of the X axis in pixels" |
| 41 | 41 | nypix, i, a, 200,,, "Size of the Y axis in pixels" |
| 42 | 42 | binsz, r, a, 0.02,,, "Image scale (in degrees/pixel)" |
| 43 | 43 | coordsys, s, a, CEL, CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)" |
| 44 | +proj, s, a, CAR, AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" | |
| 44 | 45 | xref, r, a, 83.63,0,360, "First coordinate of image center in degrees (RA or galactic l)" |
| 45 | 46 | yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DEC or galactic b)" |
| 46 | -proj, s, a, CAR, AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" | |
| 47 | 47 | |
| 48 | 48 | # |
| 49 | 49 | # Standard parameters | ... | ... |
cscripts/cstsmapsplit.py
cscripts/csviscube.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Compute a visibility cube |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2016 Juergen Knoedlseder | |
| 5 | +# Copyright (C) 2016-2017 Juergen Knoedlseder | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -50,7 +50,7 @@ class csviscube(ctools.cscript): |
| 50 | 50 | """ |
| 51 | 51 | # Set name |
| 52 | 52 | self._name = 'csviscube' |
| 53 | - self._version = '1.0.0' | |
| 53 | + self._version = ctools.__version__ | |
| 54 | 54 | |
| 55 | 55 | # Initialise members |
| 56 | 56 | self._cube = gammalib.GSkyMap() | ... | ... |
cscripts/csworkflow.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Executes analysis workflow |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2016 Juergen Knoedlseder | |
| 5 | +# Copyright (C) 2016-2017 Juergen Knoedlseder | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -53,7 +53,7 @@ class csworkflow(ctools.cscript): |
| 53 | 53 | """ |
| 54 | 54 | # Set name and version |
| 55 | 55 | self._name = 'csworkflow' |
| 56 | - self._version = '1.2.0' | |
| 56 | + self._version = ctools.__version__ | |
| 57 | 57 | |
| 58 | 58 | # Set members |
| 59 | 59 | self._workflow = gammalib.GXml() | ... | ... |
doc/source/users/reference_manual/cslightcrv.rst
| ... | ... | @@ -75,7 +75,7 @@ General parameters |
| 75 | 75 | ``coordsys <CEL|GAL> [string]`` |
| 76 | 76 | Coordinate system (CEL - celestial, GAL - galactic). |
| 77 | 77 | |
| 78 | -``proj <AIT|AZP|CAR|MER|MOL|STG|TAN> [string]`` | |
| 78 | +``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` | |
| 79 | 79 | Projection method. |
| 80 | 80 | |
| 81 | 81 | ``xref [real]`` | ... | ... |
doc/source/users/reference_manual/csphasecrv.rst
| ... | ... | @@ -9,13 +9,16 @@ Computes phase dependent spectra for a given source. |
| 9 | 9 | Synopsis |
| 10 | 10 | -------- |
| 11 | 11 | |
| 12 | -This script computes spectra by performing a maximum likelihood fit | |
| 13 | -using :doc:`ctlike` in a series of phase bins for pulsars. | |
| 14 | -The phase bins can be either specified in an ASCII file, as an interval | |
| 15 | -divided into equally sized time bins. | |
| 16 | -The format of the ASCII file is one row per time bin, each specifying the | |
| 17 | -start of stop value of the phase bin, separated by a whitespace. The phase | |
| 18 | -goes from 0.0 to 1.0 . | |
| 12 | +This script computes spectra by performing a maximum likelihood fit using | |
| 13 | +:doc:`ctlike` in a series of phase bins for pulsars. The phase bins can be | |
| 14 | +either specified in an ASCII file or as an interval divided into equally sized | |
| 15 | +phase bins. The format of the ASCII file is one row per phase bin, each | |
| 16 | +specifying the start of stop value of the phase bin, separated by a whitespace. | |
| 17 | +The phase goes from 0.0 to 1.0. | |
| 18 | + | |
| 19 | +On output the script writes the fitting results into a FITS file. The script | |
| 20 | +also produces one XML file per phase bin that contains the fitting results for | |
| 21 | +that bin. | |
| 19 | 22 | |
| 20 | 23 | |
| 21 | 24 | General parameters |
| ... | ... | @@ -25,10 +28,10 @@ General parameters |
| 25 | 28 | Input event list or observation definition XML file. |
| 26 | 29 | |
| 27 | 30 | ``inmodel [file]`` |
| 28 | - Input model XML file. | |
| 31 | + Input model definition XML file. | |
| 29 | 32 | |
| 30 | 33 | ``srcname [string]`` |
| 31 | - Name of the periodic source in the source model XML file | |
| 34 | + Name of the periodic source in the source model XML file. | |
| 32 | 35 | |
| 33 | 36 | ``caldb [string]`` |
| 34 | 37 | Calibration database. |
| ... | ... | @@ -40,10 +43,11 @@ General parameters |
| 40 | 43 | Applies energy dispersion to response computation. |
| 41 | 44 | |
| 42 | 45 | ``outfile [file]`` |
| 43 | - Name of the XML output file. The phase intervall will be automatically appended to the name. | |
| 46 | + Name of the XML output file. The phase interval will be automatically | |
| 47 | + appended to the name. | |
| 44 | 48 | |
| 45 | -``(tbinalg = LIN) <FILE|LIN> [string]`` | |
| 46 | - Algorithm for defining time bins. | |
| 49 | +``phbinalg <FILE|LIN> [string]`` | |
| 50 | + Algorithm for defining phase bins. | |
| 47 | 51 | |
| 48 | 52 | ``phbins [integer]`` |
| 49 | 53 | Number of phase bins. |
| ... | ... | @@ -63,7 +67,7 @@ General parameters |
| 63 | 67 | ``coordsys <CEL|GAL> [string]`` |
| 64 | 68 | Coordinate system (CEL - celestial, GAL - galactic). |
| 65 | 69 | |
| 66 | -``proj <AIT|AZP|CAR|MER|MOL|STG|TAN> [string]`` | |
| 70 | +``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` | |
| 67 | 71 | Projection method. |
| 68 | 72 | |
| 69 | 73 | ``xref [real]`` |
| ... | ... | @@ -81,9 +85,13 @@ General parameters |
| 81 | 85 | ``binsz [real]`` |
| 82 | 86 | Pixel size (in degrees/pixel). |
| 83 | 87 | |
| 88 | + | |
| 84 | 89 | Standard parameters |
| 85 | 90 | ------------------- |
| 86 | 91 | |
| 92 | +``(publish = no) [boolean]`` | |
| 93 | + Specifies whether the phase curve should be published on VO Hub. | |
| 94 | + | |
| 87 | 95 | ``(chatter = 2) [integer]`` |
| 88 | 96 | Verbosity of the executable: |
| 89 | 97 | chatter = 0: no information will be logged | ... | ... |
doc/source/users/reference_manual/cspull.rst
| ... | ... | @@ -71,7 +71,7 @@ General parameters |
| 71 | 71 | ``coordsys <CEL|GAL> [string]`` |
| 72 | 72 | Coordinate system (CEL - celestial, GAL - galactic). |
| 73 | 73 | |
| 74 | -``proj <AIT|AZP|CAR|MER|MOL|STG|TAN> [string]`` | |
| 74 | +``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` | |
| 75 | 75 | Projection method. |
| 76 | 76 | |
| 77 | 77 | ``emin [real]`` | ... | ... |
doc/source/users/reference_manual/csresmap.rst
| ... | ... | @@ -76,7 +76,7 @@ General parameters |
| 76 | 76 | ``coordsys <CEL|GAL> [string]`` |
| 77 | 77 | Coordinate system (CEL - celestial, GAL - galactic). |
| 78 | 78 | |
| 79 | -``proj <AIT|AZP|CAR|MER|MOL|STG|TAN> [string]`` | |
| 79 | +``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` | |
| 80 | 80 | Projection method. |
| 81 | 81 | |
| 82 | 82 | ``xref [real]`` | ... | ... |
doc/source/users/reference_manual/cstsdist.rst
| ... | ... | @@ -78,7 +78,7 @@ General parameters |
| 78 | 78 | ``coordsys <CEL|GAL> [string]`` |
| 79 | 79 | Coordinate system (CEL - celestial, GAL - galactic). |
| 80 | 80 | |
| 81 | -``proj <AIT|AZP|CAR|MER|MOL|STG|TAN> [string]`` | |
| 81 | +``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` | |
| 82 | 82 | Projection method. |
| 83 | 83 | |
| 84 | 84 | ``emin [real]`` | ... | ... |
doc/source/users/reference_manual/cstsmapsplit.rst
| ... | ... | @@ -80,16 +80,15 @@ General parameters |
| 80 | 80 | ``coordsys <CEL|GAL> [string]`` |
| 81 | 81 | Coordinate system (CEL - celestial, GAL - galactic). |
| 82 | 82 | |
| 83 | +``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` | |
| 84 | + Projection method. | |
| 85 | + | |
| 83 | 86 | ``xref [real]`` |
| 84 | 87 | Right Ascension / Galactic longitude of map centre (J2000, in degrees). |
| 85 | 88 | |
| 86 | 89 | ``yref [real]`` |
| 87 | 90 | Declination / Galactic latitude of map centre (J2000, in degrees). |
| 88 | 91 | |
| 89 | -``proj <AIT|AZP|CAR|MER|MOL|STG|TAN> [string]`` | |
| 90 | - Projection method. | |
| 91 | - | |
| 92 | - | |
| 93 | 92 | |
| 94 | 93 | Standard parameters |
| 95 | 94 | ------------------- | ... | ... |
doc/source/users/reference_manual/ctbin.rst
| ... | ... | @@ -65,15 +65,15 @@ General parameters |
| 65 | 65 | ``coordsys <CEL|GAL> [string]`` |
| 66 | 66 | Coordinate system (CEL - celestial, GAL - galactic). |
| 67 | 67 | |
| 68 | +``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` | |
| 69 | + Projection method. | |
| 70 | + | |
| 68 | 71 | ``xref [real]`` |
| 69 | 72 | Right Ascension / Galactic longitude of cube centre (J2000, in degrees). |
| 70 | 73 | |
| 71 | 74 | ``yref [real]`` |
| 72 | 75 | Declination / Galactic latitude of cube centre (J2000, in degrees). |
| 73 | 76 | |
| 74 | -``proj <AIT|AZP|CAR|MER|MOL|STG|TAN> [string]`` | |
| 75 | - Projection method. | |
| 76 | - | |
| 77 | 77 | |
| 78 | 78 | Standard parameters |
| 79 | 79 | ------------------- | ... | ... |
doc/source/users/reference_manual/ctbkgcube.rst
| ... | ... | @@ -105,15 +105,15 @@ General parameters |
| 105 | 105 | ``coordsysL <CEL|GAL> [string]`` |
| 106 | 106 | Coordinate system (CEL - celestial, GAL - galactic). |
| 107 | 107 | |
| 108 | +``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` | |
| 109 | + Projection method. | |
| 110 | + | |
| 108 | 111 | ``xref [real]`` |
| 109 | 112 | Right Ascension / Galactic longitude of cube centre (J2000, in degrees). |
| 110 | 113 | |
| 111 | 114 | ``yref [real]`` |
| 112 | 115 | Declination / Galactic latitude of cube centre (J2000, in degrees). |
| 113 | 116 | |
| 114 | -``proj <AIT|AZP|CAR|MER|MOL|STG|TAN> [string]`` | |
| 115 | - Projection method. | |
| 116 | - | |
| 117 | 117 | |
| 118 | 118 | Standard parameters |
| 119 | 119 | ------------------- | ... | ... |
doc/source/users/reference_manual/ctedispcube.rst
| ... | ... | @@ -88,15 +88,15 @@ General parameters |
| 88 | 88 | ``coordsys <CEL|GAL> [string]`` |
| 89 | 89 | Coordinate system (CEL - celestial, GAL - galactic). |
| 90 | 90 | |
| 91 | +``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` | |
| 92 | + Projection method. | |
| 93 | + | |
| 91 | 94 | ``xref [real]`` |
| 92 | 95 | Right Ascension / Galactic longitude of cube centre (J2000, in degrees). |
| 93 | 96 | |
| 94 | 97 | ``yref [real]`` |
| 95 | 98 | Declination / Galactic latitude of cube centre (J2000, in degrees). |
| 96 | 99 | |
| 97 | -``proj <AIT|AZP|CAR|MER|MOL|STG|TAN> [string]`` | |
| 98 | - Projection method. | |
| 99 | - | |
| 100 | 100 | ``(migramax = 2.0) [real]`` |
| 101 | 101 | Upper bound of ratio between reconstructed and true photon energy. |
| 102 | 102 | ... | ... |
doc/source/users/reference_manual/ctexpcube.rst
| ... | ... | @@ -95,15 +95,15 @@ General parameters |
| 95 | 95 | ``coordsys <CEL|GAL> [string]`` |
| 96 | 96 | Coordinate system (CEL - celestial, GAL - galactic). |
| 97 | 97 | |
| 98 | +``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` | |
| 99 | + Projection method. | |
| 100 | + | |
| 98 | 101 | ``xref [real]`` |
| 99 | 102 | Right Ascension / Galactic longitude of cube centre (J2000, in degrees). |
| 100 | 103 | |
| 101 | 104 | ``yref [real]`` |
| 102 | - Declination / Galactic latitude of cube centre (J2000, in degrees). | |
| 103 | - | |
| 104 | -``proj <AIT|AZP|CAR|MER|MOL|STG|TAN> [string]`` | |
| 105 | - Projection method. | |
| 106 | - | |
| 105 | + Declination / Galactic latitude of cube centre (J2000, in degrees). | |
| 106 | + | |
| 107 | 107 | |
| 108 | 108 | Standard parameters |
| 109 | 109 | ------------------- | ... | ... |
doc/source/users/reference_manual/ctmapcube.rst
| ... | ... | @@ -61,15 +61,15 @@ General parameters |
| 61 | 61 | ``coordsys <CEL|GAL> [string]`` |
| 62 | 62 | Coordinate system (CEL - celestial, GAL - galactic). |
| 63 | 63 | |
| 64 | +``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` | |
| 65 | + Projection method. | |
| 66 | + | |
| 64 | 67 | ``xref [real]`` |
| 65 | 68 | Right Ascension / Galactic longitude of cube centre (J2000, in degrees). |
| 66 | 69 | |
| 67 | 70 | ``yref [real]`` |
| 68 | 71 | Declination / Galactic latitude of cube centre (J2000, in degrees). |
| 69 | 72 | |
| 70 | -``proj <AIT|AZP|CAR|MER|MOL|STG|TAN> [string]`` | |
| 71 | - Projection method. | |
| 72 | - | |
| 73 | 73 | |
| 74 | 74 | Standard parameters |
| 75 | 75 | ------------------- | ... | ... |
doc/source/users/reference_manual/ctmodel.rst
| ... | ... | @@ -125,15 +125,15 @@ General parameters |
| 125 | 125 | ``coordsys <CEL|GAL> [string]`` |
| 126 | 126 | Coordinate system (CEL - celestial, GAL - galactic). |
| 127 | 127 | |
| 128 | +``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` | |
| 129 | + Projection method. | |
| 130 | + | |
| 128 | 131 | ``xref [real]`` |
| 129 | 132 | Right Ascension / Galactic longitude of image centre (J2000, in degrees). |
| 130 | 133 | |
| 131 | 134 | ``yref [real]`` |
| 132 | 135 | Declination / Galactic latitude of image centre (J2000, in degrees). |
| 133 | 136 | |
| 134 | -``proj <AIT|AZP|CAR|MER|MOL|STG|TAN> [string]`` | |
| 135 | - Projection method. | |
| 136 | - | |
| 137 | 137 | |
| 138 | 138 | Standard parameters |
| 139 | 139 | ------------------- | ... | ... |
doc/source/users/reference_manual/ctpsfcube.rst
| ... | ... | @@ -87,15 +87,15 @@ General parameters |
| 87 | 87 | ``coordsys <CEL|GAL> [string]`` |
| 88 | 88 | Coordinate system (CEL - celestial, GAL - galactic). |
| 89 | 89 | |
| 90 | +``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` | |
| 91 | + Projection method. | |
| 92 | + | |
| 90 | 93 | ``xref [real]`` |
| 91 | 94 | Right Ascension / Galactic longitude of cube centre (J2000, in degrees). |
| 92 | 95 | |
| 93 | 96 | ``yref [real]`` |
| 94 | 97 | Declination / Galactic latitude of cube centre (J2000, in degrees). |
| 95 | 98 | |
| 96 | -``proj <AIT|AZP|CAR|MER|MOL|STG|TAN> [string]`` | |
| 97 | - Projection method. | |
| 98 | - | |
| 99 | 99 | ``(amax = 0.3) [real]`` |
| 100 | 100 | Upper bound of angular separation between true and measued photon |
| 101 | 101 | direction (in degrees). | ... | ... |
doc/source/users/reference_manual/ctskymap.rst
| ... | ... | @@ -65,7 +65,7 @@ General parameters |
| 65 | 65 | ``coordsys <CEL|GAL> [string]`` |
| 66 | 66 | Coordinate system (CEL - celestial, GAL - galactic). |
| 67 | 67 | |
| 68 | -``proj <AIT|AZP|CAR|MER|STG|TAN> [string]`` | |
| 68 | +``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` | |
| 69 | 69 | Projection method. |
| 70 | 70 | |
| 71 | 71 | ``xref [real]`` | ... | ... |
doc/source/users/reference_manual/cttsmap.rst
| ... | ... | @@ -78,15 +78,15 @@ General parameters |
| 78 | 78 | ``coordsys <CEL|GAL> [string]`` |
| 79 | 79 | Coordinate system (CEL - celestial, GAL - galactic). |
| 80 | 80 | |
| 81 | +``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` | |
| 82 | + Projection method. | |
| 83 | + | |
| 81 | 84 | ``xref [real]`` |
| 82 | 85 | Right Ascension / Galactic longitude of map centre (J2000, in degrees). |
| 83 | 86 | |
| 84 | 87 | ``yref [real]`` |
| 85 | 88 | Declination / Galactic latitude of map centre (J2000, in degrees). |
| 86 | 89 | |
| 87 | -``proj <AIT|AZP|CAR|MER|MOL|STG|TAN> [string]`` | |
| 88 | - Projection method. | |
| 89 | - | |
| 90 | 90 | ``(binmin = -1) [integer]`` |
| 91 | 91 | First bin to compute. |
| 92 | 92 | ... | ... |
doc/source/users/reference_manual/index.rst
| ... | ... | @@ -43,13 +43,14 @@ cscripts |
| 43 | 43 | |
| 44 | 44 | cscaldb --- Lists available instrument response functions <cscaldb> |
| 45 | 45 | csebins --- Generates energy boundaries for stacked analysis <csebins> |
| 46 | - cslightcrv --- Computes lightcurve <cslightcrv> | |
| 46 | + cslightcrv --- Computes light curve <cslightcrv> | |
| 47 | 47 | csmodelinfo --- Shows model container content <csmodelinfo> |
| 48 | 48 | csmodelmerge --- Merges several model containers into one file <csmodelmerge> |
| 49 | 49 | csmodelselect --- Select models from model definition file <csmodelselect> |
| 50 | 50 | csobsdef --- Generates observation definition file <csobsdef> |
| 51 | 51 | csobsinfo --- Shows observation container content <csobsinfo> |
| 52 | 52 | csobsselect --- Select observations from observation definition file <csobsselect> |
| 53 | + csphasecrv --- Computes phase curve <csphasecrv> | |
| 53 | 54 | cspull --- Generates pull distribution <cspull> |
| 54 | 55 | csresmap --- Generates residual map <csresmap> |
| 55 | 56 | cssens --- Computes CTA sensitivity <cssens> | ... | ... |
src/ctbin/ctbin.par
| ... | ... | @@ -5,7 +5,6 @@ |
| 5 | 5 | # ------------------------------------------------------------------------- # |
| 6 | 6 | # # |
| 7 | 7 | # File: ctbin.par # |
| 8 | -# Version: 1.1.0 # | |
| 9 | 8 | # # |
| 10 | 9 | # Author: Juergen Knoedlseder # |
| 11 | 10 | # Jurgen.Knodlseder@irap.omp.eu # |
| ... | ... | @@ -37,9 +36,9 @@ nxpix, i, a, 200,,, "Size of the X axis in pixels" |
| 37 | 36 | nypix, i, a, 200,,, "Size of the Y axis in pixels" |
| 38 | 37 | binsz, r, a, 0.02,,, "Image scale (in degrees/pixel)" |
| 39 | 38 | coordsys, s, a, CEL,CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)" |
| 39 | +proj, s, a, CAR,AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" | |
| 40 | 40 | xref, r, a, 83.63,0,360, "First coordinate of image center in degrees (RA or galactic l)" |
| 41 | 41 | yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DEC or galactic b)" |
| 42 | -proj, s, a, CAR,AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" | |
| 43 | 42 | |
| 44 | 43 | # |
| 45 | 44 | # Standard parameters | ... | ... |
src/ctbkgcube/ctbkgcube.par
| ... | ... | @@ -41,10 +41,10 @@ usepnt, b, h, no,,, "Use pointing instead of xref/yref parameters?" |
| 41 | 41 | nxpix, i, a, 200,,, "Size of the X axis in pixels" |
| 42 | 42 | nypix, i, a, 200,,, "Size of the Y axis in pixels" |
| 43 | 43 | binsz, r, a, 0.02,,, "Image scale (in degrees/pixel)" |
| 44 | -coordsys, s, a, "CEL", CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)" | |
| 44 | +coordsys, s, a, CEL, CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)" | |
| 45 | +proj, s, a, CAR, AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" | |
| 45 | 46 | xref, r, a, 83.63,0,360, "First coordinate of image center in degrees (RA or galactic l)" |
| 46 | 47 | yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DEC or galactic b)" |
| 47 | -proj, s, a, "CAR", AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" | |
| 48 | 48 | |
| 49 | 49 | # |
| 50 | 50 | # Standard parameters | ... | ... |
src/ctedispcube/ctedispcube.par
| ... | ... | @@ -5,7 +5,6 @@ |
| 5 | 5 | # ------------------------------------------------------------------------- # |
| 6 | 6 | # # |
| 7 | 7 | # File: ctedispcube.par # |
| 8 | -# Version: 1.2.0 # | |
| 9 | 8 | # # |
| 10 | 9 | # Author: Maria Haupt # |
| 11 | 10 | # maria.haupt@desy.de # |
| ... | ... | @@ -40,10 +39,10 @@ usepnt, b, h, no,,, "Use pointing instead of xref/yref parameters?" |
| 40 | 39 | nxpix, i, a, 10,,, "Size of the X axis in pixels" |
| 41 | 40 | nypix, i, a, 10,,, "Size of the Y axis in pixels" |
| 42 | 41 | binsz, r, a, 1.0,,, "Image scale (in degrees/pixel)" |
| 43 | -coordsys, s, a, "CEL", CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)" | |
| 42 | +coordsys, s, a, CEL, CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)" | |
| 43 | +proj, s, a, CAR, AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" | |
| 44 | 44 | xref, r, a, 83.63,0,360, "First coordinate of image center in degrees (RA or galactic l)" |
| 45 | 45 | yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DEC or galactic b)" |
| 46 | -proj, s, a, "CAR", AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" | |
| 47 | 46 | |
| 48 | 47 | # |
| 49 | 48 | # Angular separation binning parameters | ... | ... |
src/ctexpcube/ctexpcube.par
| ... | ... | @@ -5,7 +5,6 @@ |
| 5 | 5 | # ------------------------------------------------------------------------- # |
| 6 | 6 | # # |
| 7 | 7 | # File: ctexpcube.par # |
| 8 | -# Version: 1.2.0 # | |
| 9 | 8 | # # |
| 10 | 9 | # Author: Juergen Knoedlseder # |
| 11 | 10 | # Jurgen.Knodlseder@irap.omp.eu # |
| ... | ... | @@ -40,10 +39,10 @@ usepnt, b, h, no,,, "Use pointing instead of xref/yref parameters?" |
| 40 | 39 | nxpix, i, a, 200,,, "Size of the X axis in pixels" |
| 41 | 40 | nypix, i, a, 200,,, "Size of the Y axis in pixels" |
| 42 | 41 | binsz, r, a, 0.02,,, "Image scale (in degrees/pixel)" |
| 43 | -coordsys, s, a, "CEL", CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)" | |
| 42 | +coordsys, s, a, CEL, CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)" | |
| 43 | +proj, s, a, CAR, AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" | |
| 44 | 44 | xref, r, a, 83.63,0,360, "First coordinate of image center in degrees (RA or galactic l)" |
| 45 | 45 | yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DEC or galactic b)" |
| 46 | -proj, s, a, "CAR", AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" | |
| 47 | 46 | |
| 48 | 47 | # |
| 49 | 48 | # Standard parameters | ... | ... |
src/ctmapcube/ctmapcube.par
| ... | ... | @@ -5,7 +5,6 @@ |
| 5 | 5 | # ------------------------------------------------------------------------- # |
| 6 | 6 | # # |
| 7 | 7 | # File: ctmapcube.par # |
| 8 | -# Version: 1.0.0 # | |
| 9 | 8 | # # |
| 10 | 9 | # Author: Juergen Knoedlseder # |
| 11 | 10 | # Jurgen.Knodlseder@irap.omp.eu # |
| ... | ... | @@ -37,9 +36,9 @@ nxpix, i, a, 200,,, "Size of the X axis in pixels" |
| 37 | 36 | nypix, i, a, 200,,, "Size of the Y axis in pixels" |
| 38 | 37 | binsz, r, a, 0.02,,, "Image scale (in degrees/pixel)" |
| 39 | 38 | coordsys, s, a, CEL,CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)" |
| 39 | +proj, s, a, CAR,AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" | |
| 40 | 40 | xref, r, a, 83.63,0,360, "First coordinate of image center in degrees (RA or galactic l)" |
| 41 | 41 | yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DEC or galactic b)" |
| 42 | -proj, s, a, CAR,AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" | |
| 43 | 42 | |
| 44 | 43 | # |
| 45 | 44 | # Standard parameters | ... | ... |
src/ctmodel/ctmodel.par
| ... | ... | @@ -54,10 +54,10 @@ usepnt, b, h, no,,, "Use pointing instead of xref/yref parameters?" |
| 54 | 54 | nxpix, i, a, 200,,, "Size of the X axis in pixels" |
| 55 | 55 | nypix, i, a, 200,,, "Size of the Y axis in pixels" |
| 56 | 56 | binsz, r, a, 0.02,,, "Image scale (in degrees/pixel)" |
| 57 | -coordsys, s, a, "CEL", CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)" | |
| 57 | +coordsys, s, a, CEL, CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)" | |
| 58 | +proj, s, a, CAR, AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" | |
| 58 | 59 | xref, r, a, 83.63,0,360, "First coordinate of image center in degrees (RA or galactic l)" |
| 59 | 60 | yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DEC or galactic b)" |
| 60 | -proj, s, a, "CAR", AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" | |
| 61 | 61 | |
| 62 | 62 | # |
| 63 | 63 | # Standard parameters | ... | ... |
src/ctpsfcube/ctpsfcube.par
| ... | ... | @@ -5,7 +5,6 @@ |
| 5 | 5 | # ------------------------------------------------------------------------- # |
| 6 | 6 | # # |
| 7 | 7 | # File: ctpsfcube.par # |
| 8 | -# Version: 1.2.0 # | |
| 9 | 8 | # # |
| 10 | 9 | # Author: Chia-Chun Lu # |
| 11 | 10 | # c.lu@mpi-hd.mpg.de # |
| ... | ... | @@ -40,10 +39,10 @@ usepnt, b, h, no,,, "Use pointing instead of xref/yref parameters?" |
| 40 | 39 | nxpix, i, a, 10,,, "Size of the X axis in pixels" |
| 41 | 40 | nypix, i, a, 10,,, "Size of the Y axis in pixels" |
| 42 | 41 | binsz, r, a, 1.0,,, "Image scale (in degrees/pixel)" |
| 43 | -coordsys, s, a, "CEL", CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)" | |
| 42 | +coordsys, s, a, CEL, CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)" | |
| 43 | +proj, s, a, CAR, AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" | |
| 44 | 44 | xref, r, a, 83.63,0,360, "First coordinate of image center in degrees (RA or galactic l)" |
| 45 | 45 | yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DEC or galactic b)" |
| 46 | -proj, s, a, "CAR", AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" | |
| 47 | 46 | |
| 48 | 47 | # |
| 49 | 48 | # Angular separation binning parameters | ... | ... |
src/ctselect/ctselect.par
| ... | ... | @@ -5,7 +5,6 @@ |
| 5 | 5 | # ------------------------------------------------------------------------- # |
| 6 | 6 | # # |
| 7 | 7 | # File: ctselect.par # |
| 8 | -# Version: 1.2.0 # | |
| 9 | 8 | # # |
| 10 | 9 | # Author: Jurgen Knodlseder # |
| 11 | 10 | # Jurgen.Knodlseder@irap.omp.eu # |
| ... | ... | @@ -32,8 +31,8 @@ tmin, r, a, 0.0,,, "Start time (CTA MET in seconds)" |
| 32 | 31 | tmax, r, a, 0.0,,, "End time (CTA MET in seconds)" |
| 33 | 32 | emin, r, a, 0.1,,, "Lower energy limit (TeV)" |
| 34 | 33 | emax, r, a, 100.0,,, "Upper energy limit (TeV)" |
| 35 | -expr, s, h, "",,, "Additional selection expression" | |
| 36 | -usethres,s, h, "NONE",NONE|DEFAULT|USER,, "Energy threshold type" | |
| 34 | +expr, s, h, ,,, "Additional selection expression" | |
| 35 | +usethres,s, h, NONE,NONE|DEFAULT|USER,, "Energy threshold type" | |
| 37 | 36 | |
| 38 | 37 | # |
| 39 | 38 | # Standard parameters | ... | ... |
src/ctskymap/ctskymap.par
| ... | ... | @@ -35,7 +35,7 @@ nxpix, i, a, 200,,, "Size of the X axis in pixels" |
| 35 | 35 | nypix, i, a, 200,,, "Size of the Y axis in pixels" |
| 36 | 36 | binsz, r, a, 0.02,,, "Image scale (in degrees/pixel)" |
| 37 | 37 | coordsys, s, a, CEL, CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)" |
| 38 | -proj, s, a, CAR, AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" | |
| 38 | +proj, s, a, CAR, AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" | |
| 39 | 39 | xref, r, a, 83.63,0,360, "First coordinate of image center in degrees (RA or galactic l)" |
| 40 | 40 | yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DEC or galactic b)" |
| 41 | 41 | ... | ... |
src/cttsmap/cttsmap.par
| ... | ... | @@ -40,10 +40,10 @@ usepnt, b, h, no,,, "Use pointing instead of xref/yref parameters?" |
| 40 | 40 | nxpix, i, a, 200,,, "Size of the X axis in pixels" |
| 41 | 41 | nypix, i, a, 200,,, "Size of the Y axis in pixels" |
| 42 | 42 | binsz, r, a, 0.02,,, "Image scale (in degrees/pixel)" |
| 43 | -coordsys, s, a, "CEL", CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)" | |
| 43 | +coordsys, s, a, CEL, CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)" | |
| 44 | +proj, s, a, CAR, AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" | |
| 44 | 45 | xref, r, a, 83.63,0,360, "First coordinate of image center in degrees (RA or galactic l)" |
| 45 | 46 | yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DEC or galactic b)" |
| 46 | -proj, s, a, "CAR", AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" | |
| 47 | 47 | |
| 48 | 48 | # |
| 49 | 49 | # Parameters for splitting and speed purpose | ... | ... |
test/data/phased_events.fits deleted
No preview for this file type
test/data/phased_events.fits.gz
0 → 100644
No preview for this file type
test/test_csphasecrv.py
0 → 100755
| 1 | +#! /usr/bin/env python | |
| 2 | +# ========================================================================== | |
| 3 | +# This scripts performs unit tests for the csphasecrv script. | |
| 4 | +# | |
| 5 | +# Copyright (C) 2017 Juergen Knoedlseder | |
| 6 | +# | |
| 7 | +# This program is free software: you can redistribute it and/or modify | |
| 8 | +# it under the terms of the GNU General Public License as published by | |
| 9 | +# the Free Software Foundation, either version 3 of the License, or | |
| 10 | +# (at your option) any later version. | |
| 11 | +# | |
| 12 | +# This program is distributed in the hope that it will be useful, | |
| 13 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | +# GNU General Public License for more details. | |
| 16 | +# | |
| 17 | +# You should have received a copy of the GNU General Public License | |
| 18 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 19 | +# | |
| 20 | +# ========================================================================== | |
| 21 | +import gammalib | |
| 22 | +import cscripts | |
| 23 | +from testing import test | |
| 24 | + | |
| 25 | + | |
| 26 | +# ================================ # | |
| 27 | +# Test class for csphasecrv script # | |
| 28 | +# ================================ # | |
| 29 | +class Test(test): | |
| 30 | + """ | |
| 31 | + Test class for csphasecrv script | |
| 32 | + | |
| 33 | + This test class makes unit tests for the csphasecrv script by using it | |
| 34 | + from the command line and from Python. | |
| 35 | + """ | |
| 36 | + | |
| 37 | + # Constructor | |
| 38 | + def __init__(self): | |
| 39 | + """ | |
| 40 | + Constructor | |
| 41 | + """ | |
| 42 | + # Call base class constructor | |
| 43 | + test.__init__(self) | |
| 44 | + | |
| 45 | + # Set test data | |
| 46 | + self._phased_events = self._datadir + '/phased_events.fits' | |
| 47 | + | |
| 48 | + # Return | |
| 49 | + return | |
| 50 | + | |
| 51 | + # Set test functions | |
| 52 | + def set(self): | |
| 53 | + """ | |
| 54 | + Set all test functions. | |
| 55 | + """ | |
| 56 | + # Set test name | |
| 57 | + self.name('csphasecrv') | |
| 58 | + | |
| 59 | + # Append tests | |
| 60 | + self.append(self._test_cmd, 'Test csphasecrv on command line') | |
| 61 | + self.append(self._test_python, 'Test csphasecrv from Python') | |
| 62 | + | |
| 63 | + # Return | |
| 64 | + return | |
| 65 | + | |
| 66 | + # Test csphasecrv on command line | |
| 67 | + def _test_cmd(self): | |
| 68 | + """ | |
| 69 | + Test csphasecrv on the command line. | |
| 70 | + """ | |
| 71 | + # Set script name | |
| 72 | + csphasecrv = self._script('csphasecrv') | |
| 73 | + | |
| 74 | + # Setup csphasecrv command | |
| 75 | + cmd = csphasecrv+' inobs="'+self._phased_events+'"'+ \ | |
| 76 | + ' inmodel="'+self._model+'" srcname="Crab"'+ \ | |
| 77 | + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ | |
| 78 | + ' phbinalg="LIN" phbins=5'+ \ | |
| 79 | + ' enumbins=0 emin=0.1 emax=100.0'+ \ | |
| 80 | + ' outfile="csphasecrv_cmd1.fits"'+ \ | |
| 81 | + ' logfile="csphasecrv_cmd1.log" chatter=1' | |
| 82 | + | |
| 83 | + # Check if execution of wrong command fails | |
| 84 | + self.test_assert(self._execute('command_that_does_not_exist') != 0, | |
| 85 | + 'Self test of test script') | |
| 86 | + | |
| 87 | + # Check if execution was successful | |
| 88 | + self.test_assert(self._execute(cmd) == 0, | |
| 89 | + 'Check successful execution from command line') | |
| 90 | + | |
| 91 | + # Check phase curve | |
| 92 | + self._check_phase_curve('csphasecrv_cmd1.fits', 5) | |
| 93 | + | |
| 94 | + # Setup csphasecrv command | |
| 95 | + cmd = csphasecrv+' inobs="events_that_do_not_exist.fits"'+ \ | |
| 96 | + ' inmodel="'+self._model+'" srcname="Crab"'+ \ | |
| 97 | + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ | |
| 98 | + ' phbinalg="LIN" phbins=5'+ \ | |
| 99 | + ' enumbins=0 emin=0.1 emax=100.0'+ \ | |
| 100 | + ' outfile="csphasecrv_cmd2.fits"'+ \ | |
| 101 | + ' logfile="csphasecrv_cmd2.log" chatter=1' | |
| 102 | + | |
| 103 | + # Check if execution failed | |
| 104 | + self.test_assert(self._execute(cmd) != 0, | |
| 105 | + 'Check invalid input file when executed from command line') | |
| 106 | + | |
| 107 | + # Return | |
| 108 | + return | |
| 109 | + | |
| 110 | + # Test csphasecrv from Python | |
| 111 | + def _test_python(self): | |
| 112 | + """ | |
| 113 | + Test csphasecrv from Python | |
| 114 | + """ | |
| 115 | + # Set-up unbinned csphasecrv | |
| 116 | + pcrv = cscripts.csphasecrv() | |
| 117 | + pcrv['inobs'] = self._phased_events | |
| 118 | + pcrv['inmodel'] = self._model | |
| 119 | + pcrv['srcname'] = 'Crab' | |
| 120 | + pcrv['caldb'] = self._caldb | |
| 121 | + pcrv['irf'] = self._irf | |
| 122 | + pcrv['phbinalg'] = 'LIN' | |
| 123 | + pcrv['phbins'] = 5 | |
| 124 | + pcrv['enumbins'] = 0 | |
| 125 | + pcrv['emin'] = 0.1 | |
| 126 | + pcrv['emax'] = 100.0 | |
| 127 | + pcrv['outfile'] = 'csphasecrv_py1.fits' | |
| 128 | + pcrv['logfile'] = 'csphasecrv_py1.log' | |
| 129 | + pcrv['chatter'] = 2 | |
| 130 | + pcrv['publish'] = True | |
| 131 | + | |
| 132 | + # Run csphasecrv script and save phase curve | |
| 133 | + pcrv.logFileOpen() # Make sure we get a log file | |
| 134 | + pcrv.run() | |
| 135 | + pcrv.save() | |
| 136 | + | |
| 137 | + # Check phase curve | |
| 138 | + self._check_phase_curve('csphasecrv_py1.fits', 5) | |
| 139 | + | |
| 140 | + # Now use FILE as time bin algorithm. For this we need first to | |
| 141 | + # create an ASCII file. We use now 2 phase bins. The ASCII file | |
| 142 | + # is saved into the file "csphasecrv_py2.dat". | |
| 143 | + csv = gammalib.GCsv(2,2) | |
| 144 | + phmin = 0.0 | |
| 145 | + phdelta = 1.0 / float(csv.nrows()) | |
| 146 | + for i in range(csv.nrows()): | |
| 147 | + csv[i,0] = '%.5f' % (phmin + i * phdelta) | |
| 148 | + csv[i,1] = '%.5f' % (phmin + (i+1) * phdelta) | |
| 149 | + csv.save('csphasecrv_py2.dat', ' ', True) | |
| 150 | + | |
| 151 | + # Set-up unbinned csphasecrv | |
| 152 | + pcrv = cscripts.csphasecrv() | |
| 153 | + pcrv['inobs'] = self._phased_events | |
| 154 | + pcrv['inmodel'] = self._model | |
| 155 | + pcrv['srcname'] = 'Crab' | |
| 156 | + pcrv['caldb'] = self._caldb | |
| 157 | + pcrv['irf'] = self._irf | |
| 158 | + pcrv['phbinalg'] = 'FILE' | |
| 159 | + pcrv['phbinfile'] = 'csphasecrv_py2.dat' | |
| 160 | + pcrv['enumbins'] = 0 | |
| 161 | + pcrv['emin'] = 0.1 | |
| 162 | + pcrv['emax'] = 100.0 | |
| 163 | + pcrv['outfile'] = 'csphasecrv_py2.fits' | |
| 164 | + pcrv['logfile'] = 'csphasecrv_py2.log' | |
| 165 | + pcrv['chatter'] = 3 | |
| 166 | + | |
| 167 | + # Execute csphasecrv script | |
| 168 | + pcrv.logFileOpen() # Make sure we get a log file | |
| 169 | + pcrv.execute() | |
| 170 | + | |
| 171 | + # Check phase curve | |
| 172 | + self._check_phase_curve('csphasecrv_py2.fits', csv.nrows()) | |
| 173 | + | |
| 174 | + # Now we setup an observation container on input. We attached the | |
| 175 | + # model to the observation container so that csphasecrv should | |
| 176 | + # no longer query for the parameter. | |
| 177 | + cta = gammalib.GCTAObservation(self._phased_events) | |
| 178 | + obs = gammalib.GObservations() | |
| 179 | + obs.append(cta) | |
| 180 | + obs.models(self._model) | |
| 181 | + | |
| 182 | + # Set-up unbinned csphasecrv from observation container. Now use | |
| 183 | + # the GTI algorithm so that we test all timing algorithms. | |
| 184 | + pcrv = cscripts.csphasecrv(obs) | |
| 185 | + pcrv['srcname'] = 'Crab' | |
| 186 | + pcrv['caldb'] = self._caldb | |
| 187 | + pcrv['irf'] = self._irf | |
| 188 | + pcrv['phbinalg'] = 'LIN' | |
| 189 | + pcrv['phbins'] = 5 | |
| 190 | + pcrv['enumbins'] = 0 | |
| 191 | + pcrv['emin'] = 0.1 | |
| 192 | + pcrv['emax'] = 100.0 | |
| 193 | + pcrv['outfile'] = 'csphasecrv_py3.fits' | |
| 194 | + pcrv['logfile'] = 'csphasecrv_py3.log' | |
| 195 | + pcrv['chatter'] = 4 | |
| 196 | + | |
| 197 | + # Execute csphasecrv script | |
| 198 | + pcrv.logFileOpen() # Make sure we get a log file | |
| 199 | + pcrv.execute() | |
| 200 | + | |
| 201 | + # Check phase curve | |
| 202 | + self._check_phase_curve('csphasecrv_py3.fits', 5) | |
| 203 | + | |
| 204 | + # Finally we set-up a binned csphasecrv | |
| 205 | + pcrv = cscripts.csphasecrv() | |
| 206 | + pcrv['inobs'] = self._phased_events | |
| 207 | + pcrv['inmodel'] = self._model | |
| 208 | + pcrv['srcname'] = 'Crab' | |
| 209 | + pcrv['caldb'] = self._caldb | |
| 210 | + pcrv['irf'] = self._irf | |
| 211 | + pcrv['phbinalg'] = 'LIN' | |
| 212 | + pcrv['phbins'] = 2 | |
| 213 | + pcrv['emin'] = 0.1 | |
| 214 | + pcrv['emax'] = 100.0 | |
| 215 | + pcrv['enumbins'] = 10 | |
| 216 | + pcrv['coordsys'] = 'CEL' | |
| 217 | + pcrv['proj'] = 'TAN' | |
| 218 | + pcrv['xref'] = 83.63 | |
| 219 | + pcrv['yref'] = 22.01 | |
| 220 | + pcrv['nxpix'] = 20 | |
| 221 | + pcrv['nypix'] = 20 | |
| 222 | + pcrv['binsz'] = 0.02 | |
| 223 | + pcrv['outfile'] = 'csphasecrv_py4.fits' | |
| 224 | + pcrv['logfile'] = 'csphasecrv_py4.log' | |
| 225 | + pcrv['chatter'] = 4 | |
| 226 | + | |
| 227 | + # Execute csphasecrv script | |
| 228 | + pcrv.logFileOpen() # Make sure we get a log file | |
| 229 | + pcrv.execute() | |
| 230 | + | |
| 231 | + # Check phase curve | |
| 232 | + self._check_phase_curve('csphasecrv_py4.fits', 2) | |
| 233 | + | |
| 234 | + # Return | |
| 235 | + return | |
| 236 | + | |
| 237 | + # Check phase curve result file | |
| 238 | + def _check_phase_curve(self, filename, bins): | |
| 239 | + """ | |
| 240 | + Check phase curve file | |
| 241 | + """ | |
| 242 | + # Expected column names | |
| 243 | + cols = ['PHASE_MIN', 'PHASE_MAX', 'Prefactor', 'e_Prefactor', | |
| 244 | + 'Index', 'e_Index'] | |
| 245 | + | |
| 246 | + # Open FITS file | |
| 247 | + fits = gammalib.GFits(filename) | |
| 248 | + | |
| 249 | + # Check FITS file structure | |
| 250 | + self.test_value(fits.size(), 2, | |
| 251 | + 'Check for 2 extensions in phase curve FITS file') | |
| 252 | + self.test_assert(fits.contains('PHASECURVE'), | |
| 253 | + 'FITS file contains "PHASECURVE" extension') | |
| 254 | + | |
| 255 | + # Get PHASECURVE table | |
| 256 | + table = fits['PHASECURVE'] | |
| 257 | + | |
| 258 | + # Check FITS table structure | |
| 259 | + self.test_value(table.ncols(), len(cols), | |
| 260 | + 'Check for %d columns in phase curve FITS table' % len(cols)) | |
| 261 | + self.test_value(table.nrows(), bins, | |
| 262 | + 'Check for %d rows in phase curve FITS table' % bins) | |
| 263 | + for col in cols: | |
| 264 | + self.test_assert(table.contains(col), | |
| 265 | + 'FITS file contains "'+col+'" column') | |
| 266 | + | |
| 267 | + # Close FITS file | |
| 268 | + fits.close() | |
| 269 | + | |
| 270 | + # Return | |
| 271 | + return | ... | ... |
test/test_python_cscripts.py
| ... | ... | @@ -36,6 +36,7 @@ import test_csobs2caldb |
| 36 | 36 | import test_csobsdef |
| 37 | 37 | import test_csobsinfo |
| 38 | 38 | import test_csobsselect |
| 39 | +import test_csphasecrv | |
| 39 | 40 | import test_cspull |
| 40 | 41 | import test_csresmap |
| 41 | 42 | import test_csroot2caldb |
| ... | ... | @@ -124,6 +125,7 @@ def test(installed=False, debug=False): |
| 124 | 125 | test_csobsdef.Test(), |
| 125 | 126 | test_csobsinfo.Test(), |
| 126 | 127 | test_csobsselect.Test(), |
| 128 | + test_csphasecrv.Test(), | |
| 127 | 129 | test_cspull.Test(), |
| 128 | 130 | test_csresmap.Test(), |
| 129 | 131 | test_csroot2caldb.Test(), | ... | ... |