Commit cee51042ca4eb9de3dbe58475ac3c217413c5025
1 parent
1503f96a
se file function constructor in csspec (#3626)
Showing
5 changed files
with
25 additions
and
24 deletions
ChangeLog
| 1 | -2021-04-29 | |
| 1 | +2021-04-30 | |
| 2 | 2 | |
| 3 | 3 | * Version 2.0.0 released |
| 4 | 4 | ======================== |
| 5 | 5 | |
| 6 | 6 | Add ASCL shields to "About" page (#3630) |
| 7 | + Use file function constructor in csspec (#3626) | |
| 7 | 8 | Add BINS method to csspec (#3606) |
| 8 | 9 | Add hidden "fix_spat" parameter to cttsmap (#3562) |
| 9 | 10 | Add optimizer setter to ctlikelihood base class | ... | ... |
NEWS
| 1 | 1 | New Features and Important Changes in ctools 2.0.0 |
| 2 | 2 | |
| 3 | -29 April 2021 | |
| 3 | +30 April 2021 | |
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | Introduction |
| ... | ... | @@ -287,6 +287,9 @@ None |
| 287 | 287 | |
| 288 | 288 | csspec - Generates Spectral Energy Distribution |
| 289 | 289 | ----------------------------------------------- |
| 290 | +The GModelSpectralFunc spectral model constructor is now used to convert any | |
| 291 | +spectral model into a file function before spectral model fitting (#3626). | |
| 292 | + | |
| 290 | 293 | Added BINS method that replaces the spectral model by a bin function that is |
| 291 | 294 | implemented by the GammaLib class GModelSpectralBins. Using a bin function |
| 292 | 295 | assures that spectral points are statistically independent (#3606). | ... | ... |
README.md
| 1 | 1 | ctools information |
| 2 | 2 | ================== |
| 3 | -* Version: 2.0.0.dev (29 April 2021) | |
| 3 | +* Version: 2.0.0.dev (30 April 2021) | |
| 4 | 4 | * GammaLib dependency: 2.0.0.dev |
| 5 | 5 | |
| 6 | 6 | [](https://cta-jenkins.irap.omp.eu/job/ctools-integrate-os/) |
| ... | ... | @@ -127,8 +127,8 @@ the following: |
| 127 | 127 | $ conda install ctools |
| 128 | 128 | |
| 129 | 129 | |
| 130 | -Unix Installation | |
| 131 | -================= | |
| 130 | +Linux Installation | |
| 131 | +================== | |
| 132 | 132 | To build and install ctools, simply type the following: |
| 133 | 133 | |
| 134 | 134 | $ ./configure |
| ... | ... | @@ -161,14 +161,14 @@ ctools was correctly built. Make sure that all tests were successful. |
| 161 | 161 | |
| 162 | 162 | Macintosh OS X Installation |
| 163 | 163 | ============================ |
| 164 | -ctools is known to work on various flavors of OS X. To cope with | |
| 164 | +ctools is known to work on various flavors of Mac OS. To cope with | |
| 165 | 165 | different system versions and architectures, there are two Mac |
| 166 | 166 | specific configure options: |
| 167 | 167 | |
| 168 | 168 | $ ./configure --enable-universalsdk[=PATH] |
| 169 | 169 | |
| 170 | 170 | creates a universal build of ctools. The optional argument specifies |
| 171 | -which OSX SDK should be used to perform the build. This defaults to | |
| 171 | +which MacOS SDK should be used to perform the build. This defaults to | |
| 172 | 172 | "/Developer/SDKs/MacOSX.10.4u.sdk". Specify "/" when building on a 10.5 |
| 173 | 173 | system or higher, especially when building 64-bit code. |
| 174 | 174 | |
| ... | ... | @@ -221,7 +221,8 @@ shared library (see "Known problems" below). |
| 221 | 221 | |
| 222 | 222 | Windows Installation |
| 223 | 223 | ==================== |
| 224 | -There have been no efforts so far to compile ctools under Windows. | |
| 224 | +On Windows ctools needs to be installed into a virtual machine running | |
| 225 | +a Linux distribution. | |
| 225 | 226 | |
| 226 | 227 | |
| 227 | 228 | Testing | ... | ... |
cscripts/csspec.py
| ... | ... | @@ -368,23 +368,17 @@ class csspec(ctools.csobservation): |
| 368 | 368 | ' Fixing "'+par.name()+'"') |
| 369 | 369 | par.fix() |
| 370 | 370 | |
| 371 | - # Kludge: convert spectral model into a file function | |
| 372 | - nbins = self._ebounds.size() | |
| 373 | - num = nbins * 20 | |
| 374 | - energies = gammalib.GEnergies(num, self._ebounds.emin(0), | |
| 375 | - self._ebounds.emax(nbins-1)) | |
| 376 | - _, filename = tempfile.mkstemp() | |
| 377 | - f = open(filename, 'w') | |
| 378 | - spectral = model.spectral() | |
| 379 | - for energy in energies: | |
| 380 | - value = spectral.eval(energy) | |
| 381 | - f.write('%20.6f %20e\n' % (energy.MeV(), value)) | |
| 382 | - f.close() | |
| 383 | - spectral = gammalib.GModelSpectralFunc(filename, 1.0) | |
| 371 | + # Convert spectral model into a file function. The file | |
| 372 | + # function is logarithmically sampled in energy, with with | |
| 373 | + # 20 times the number of spectral bins | |
| 374 | + nbins = self._ebounds.size() | |
| 375 | + num = nbins * 50 | |
| 376 | + energies = gammalib.GEnergies(num, self._ebounds.emin(0), | |
| 377 | + self._ebounds.emax(nbins-1)) | |
| 378 | + spectral = gammalib.GModelSpectralFunc(model.spectral(), energies) | |
| 384 | 379 | model.spectral(spectral) |
| 385 | 380 | self._log_string(gammalib.EXPLICIT, ' Converting spectral model ' |
| 386 | - 'into file function via temporary file "%s"' % | |
| 387 | - filename) | |
| 381 | + 'into file function') | |
| 388 | 382 | |
| 389 | 383 | # Free the normalisation parameter which is assumed to be |
| 390 | 384 | # the first spectral parameter | ... | ... |
doc/source/admin/release_history/2.0.rst
| 1 | 1 | .. _2.0: |
| 2 | 2 | |
| 3 | -ctools 2.0 release (29 April 2021) | |
| 3 | +ctools 2.0 release (30 April 2021) | |
| 4 | 4 | ================================== |
| 5 | 5 | |
| 6 | 6 | Overview |
| ... | ... | @@ -26,6 +26,8 @@ Improvements |
| 26 | 26 | |
| 27 | 27 | * [`3630 <https://cta-redmine.irap.omp.eu/issues/3630>`_] - |
| 28 | 28 | Add ASCL shields to **About** page |
| 29 | +* [`3626 <https://cta-redmine.irap.omp.eu/issues/3626>`_] - | |
| 30 | + Use file function constructor in csspec | |
| 29 | 31 | * [`3606 <https://cta-redmine.irap.omp.eu/issues/3606>`_] - |
| 30 | 32 | Add ``BINS`` method to :ref:`csspec` |
| 31 | 33 | * [`3562 <https://cta-redmine.irap.omp.eu/issues/3562>`_] - | ... | ... |