diff --git a/jetset/cosmo_tools.py b/jetset/cosmo_tools.py index a8946ec5..81bc76ff 100644 --- a/jetset/cosmo_tools.py +++ b/jetset/cosmo_tools.py @@ -67,7 +67,6 @@ def get_DL_cm(self,z=None): return _d def _serialize_model(self): - #print("serializing cosmo") _model = {} if self._c is not None: _model['_astropy_cosmo']=Table(self._c.to_format('astropy.table')) @@ -82,6 +81,11 @@ def __getstate__(self): def __setstate__(self,state): astropy_cosmo,DL_cm=self._decode_model(state) self.__init__(astropy_cosmo=astropy_cosmo,DL_cm=DL_cm) + + @classmethod + def from_model(cls,model): + astropy_cosmo,DL_cm = cls._decode_model(model) + return cls(astropy_cosmo,DL_cm) @staticmethod diff --git a/jetset/jet_model.py b/jetset/jet_model.py index 5da3d0ef..74766363 100644 --- a/jetset/jet_model.py +++ b/jetset/jet_model.py @@ -272,8 +272,7 @@ def _decode_model(self,_model): self._set_version(_model['version']) else: self._set_version(v='unknown(<1.1.2)') - - self.cosmo = Cosmo(astropy_cosmo=_model['cosmo']['_astropy_cosmo'],DL_cm=_model['cosmo']['_DL_cm']) + self.cosmo = Cosmo.from_model(_model['cosmo']) self.model_type = 'jet' self.name = _model['name'] if 'geometry' in _model.keys():