Skip to content

Instantly share code, notes, and snippets.

@cdeil
Created July 24, 2018 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdeil/0656f59e21842c3a2e594a8355b5bbc5 to your computer and use it in GitHub Desktop.
Save cdeil/0656f59e21842c3a2e594a8355b5bbc5 to your computer and use it in GitHub Desktop.
____________________________________________________________________________ test_cube_fit _____________________________________________________________________________
sky_model = SkyModel(spatial_model=<gammapy.image.models.new.SkyGaussian object at 0x112d57748>, spectral_model=PowerLaw())
counts = WcsNDMap
geom : Wcs
unit :
data shape: (2, 100, 100)
data mean : 6.0e-02
data min : 9.6e-16
data max : 1.7e+00
exposure = WcsNDMap
geom : Wcs
unit : m2 s
data shape: (2, 100, 100)
data mean : 6.7e+09 m2 s
data min : 1.7e+09 m2 s
data max : 1.2e+10 m2 s
psf = <gammapy.cube.psf_kernel.PSFKernel object at 0x112d5b5f8>
background = WcsNDMap
geom : Wcs
unit :
data shape: (2, 100, 100)
data mean : 1.0e-05
data min : 1.0e-05
data max : 1.0e-05
edisp = <gammapy.irf.energy_dispersion.EnergyDispersion object at 0xb196cdf60>
@requires_dependency('scipy')
@requires_dependency('iminuit')
@requires_data('gammapy-extra')
def test_cube_fit(sky_model, counts, exposure, psf, background, edisp):
input_model = sky_model.copy()
input_model.parameters['lon_0'].value = 0.5
input_model.parameters['index'].value = 2
input_model.parameters['lat_0'].value = 0.5
input_model.parameters['sigma'].frozen = True
input_model.parameters.set_parameter_errors({
'lon_0': '0.1 deg',
'index': '0.1',
'amplitude': '1e-12 cm-2 s-1 TeV-1',
})
fit = MapFit(
model=input_model,
counts=counts,
exposure=exposure,
psf=psf,
background=background,
edisp=edisp,
)
fit.fit()
assert_allclose(fit.model.parameters['index'].value,
sky_model.parameters['index'].value,
> rtol=1e-2)
E AssertionError:
E Not equal to tolerance rtol=0.01, atol=0
E
E (mismatch 100.0%)
E x: array(2)
E y: array(3)
gammapy/cube/tests/test_fit.py:133: AssertionError
------------------------------------------------------------------------ Captured stderr setup -------------------------------------------------------------------------
WARNING: AstropyDeprecationWarning: The truth value of a Quantity is ambiguous. In the future this will raise a ValueError. [astropy.units.quantity]
-------------------------------------------------------------------------- Captured log setup --------------------------------------------------------------------------
logger.py 200 WARNING AstropyDeprecationWarning: The truth value of a Quantity is ambiguous. In the future this will raise a ValueError.
------------------------------------------------------------------------- Captured stdout call -------------------------------------------------------------------------
**************************************************
* MIGRAD *
**************************************************
**********************************************************************
---------------------------------------------------------------------------------------
fval = 3840.046570122887 | total call = 149 | ncalls = 149
edm = 3.2061646788782003e-06 (Goal: 1e-05) | up = 1.0
---------------------------------------------------------------------------------------
| Valid | Valid Param | Accurate Covar | Posdef | Made Posdef |
---------------------------------------------------------------------------------------
| True | True | True | True | False |
---------------------------------------------------------------------------------------
| Hesse Fail | Has Cov | Above EDM | | Reach calllim |
---------------------------------------------------------------------------------------
| False | True | False | '' | False |
---------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------
| | Name | Value | Para Err | Err- | Err+ | Limit- | Limit+ | |
--------------------------------------------------------------------------------------------------
| 0 | lon_0 = 0.2 | 0.005895 | | | | | |
| 1 | lat_0 = 0.1 | 0.005895 | | | | | |
| 2 | sigma = 0.2 | 0 | | | | | FIXED |
| 3 | index = 3 | 0.05617 | | | | | |
| 4 | amplitude = 9.997E-12 | 3.936E-13 | | | | | |
| 5 | reference = 1 | 0 | | | | | FIXED |
--------------------------------------------------------------------------------------------------
**********************************************************************
================================================================= 1 failed, 51 passed in 6.90 seconds ==================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment