Created
November 29, 2019 14:28
-
-
Save cdeil/3cb466921b87b79acd91dffb930916be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_________________________________________________________________ test_map_dataset_fits_io __________________________________________________________________ | |
tmp_path = PosixPath('/private/var/folders/t_/_mywtcj146lbk2c99bnxw7z40000gp/T/pytest-of-deil/pytest-78/test_map_dataset_fits_io0') | |
sky_model = SkyModel(spatial_model=<gammapy.modeling.models.spatial.GaussianSpatialModel object at 0x11329ad30>, spectral_model=<gammapy.modeling.models.spectral.PowerLawSpectralModel object at 0x11329ac50>) | |
geom = WcsGeom | |
axes : ['lon', 'lat', 'energy'] | |
shape : (100, 100, 2) | |
ndim : 3 | |
coordsys : CEL | |
projection : CAR | |
center : 266.4 deg, -28.9 deg | |
width : 2.0 deg x 2.0 deg | |
geom_etrue = WcsGeom | |
axes : ['lon', 'lat', 'energy'] | |
shape : (100, 100, 3) | |
ndim : 3 | |
coordsys : CEL | |
projection : CAR | |
center : 266.4 deg, -28.9 deg | |
width : 2.0 deg x 2.0 deg | |
@requires_data() | |
def test_map_dataset_fits_io(tmp_path, sky_model, geom, geom_etrue): | |
dataset = get_map_dataset(sky_model, geom, geom_etrue) | |
dataset.counts = dataset.npred() | |
dataset.mask_safe = dataset.mask_fit | |
gti = GTI.create([0 * u.s], [1 * u.h], reference_time="2010-01-01T00:00:00") | |
dataset.gti = gti | |
hdulist = dataset.to_hdulist() | |
actual = [hdu.name for hdu in hdulist] | |
desired = [ | |
"PRIMARY", | |
"COUNTS", | |
"COUNTS_BANDS", | |
"EXPOSURE", | |
"EXPOSURE_BANDS", | |
"BACKGROUND", | |
"BACKGROUND_BANDS", | |
"EDISP", | |
"EDISP_BANDS", | |
"EDISP_EXPOSURE", | |
"EDISP_EXPOSURE_BANDS", | |
"PSF", | |
"PSF_BANDS", | |
"PSF_EXPOSURE", | |
"PSF_EXPOSURE_BANDS", | |
"MASK_SAFE", | |
"MASK_SAFE_BANDS", | |
"MASK_FIT", | |
"MASK_FIT_BANDS", | |
"GTI", | |
] | |
assert actual == desired | |
dataset.write(tmp_path / "test.fits") | |
dataset_new = MapDataset.read(tmp_path / "test.fits") | |
> assert len(dataset_new.models) == 0 | |
E TypeError: object of type 'NoneType' has no len() | |
gammapy/cube/tests/test_fit.py:257: TypeError | |
_________________________________________________________________ test_datasets_io_no_model _________________________________________________________________ | |
tmpdir = local('/private/var/folders/t_/_mywtcj146lbk2c99bnxw7z40000gp/T/pytest-of-deil/pytest-78/test_datasets_io_no_model0') | |
def test_datasets_io_no_model(tmpdir): | |
axis = MapAxis.from_energy_bounds("1 TeV", "10 TeV", nbin=2) | |
geom = WcsGeom.create(npix=(5, 5), axes=[axis]) | |
dataset_1 = MapDataset.create(geom, name="1") | |
dataset_2 = MapDataset.create(geom, name="2") | |
datasets = Datasets([dataset_1, dataset_2]) | |
> datasets.to_yaml(path=tmpdir, prefix="test") | |
gammapy/cube/tests/test_fit.py:677: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
gammapy/modeling/datasets.py:184: in to_yaml | |
datasets_dict, components_dict = datasets_to_dict(self, path, prefix, overwrite) | |
gammapy/modeling/serialize.py:127: in datasets_to_dict | |
datasets_dictlist.append(dataset.to_dict(filename=filename)) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <gammapy.cube.fit.MapDataset object at 0x1146a2128> | |
filename = PosixPath('/private/var/folders/t_/_mywtcj146lbk2c99bnxw7z40000gp/T/pytest-of-deil/pytest-78/test_datasets_io_no_model0/test_data_1.fits') | |
def to_dict(self, filename=""): | |
"""Convert to dict for YAML serialization.""" | |
return { | |
"name": self.name, | |
"type": self.tag, | |
"likelihood": self.likelihood_type, | |
> "models": [_.name for _ in self.models], | |
"background": self.background_model.name, | |
"filename": str(filename), | |
} | |
E TypeError: 'NoneType' object is not iterable | |
gammapy/cube/fit.py:814: TypeError | |
======================================================== 2 failed, 1 passed, 50 deselected in 3.93s ========================================================= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment