@classmethod
def from_dict(cls, data):
    """Create SkyModel from dict"""
    from gammapy.modeling.models import SPATIAL_MODELS, SPECTRAL_MODELS, TEMPORAL_MODELS
    model_class = SPECTRAL_MODELS.get_cls(data['spectral']['type'])
    spectral_model = model_class.from_dict(data['spectral'])
    spatial_data = data.get('spatial')
    if spatial_data is not None:
        model_class = SPATIAL_MODELS.get_cls(spatial_data['type'])
        spatial_model = model_class.from_dict(spatial_data)
    else:
        spatial_model = None
    temporal_data = data.get('temporal')
    if temporal_data is not None:
        model_class = TEMPORAL_MODELS.get_cls(temporal_data['type'])
        temporal_model = model_class.from_dict(temporal_data)
    else:
        temporal_model = None
    return cls(name=data['name'], spatial_model=spatial_model,
        spectral_model=spectral_model, temporal_model=temporal_model,
        apply_irf=data.get('apply_irf', cls._apply_irf_default),
        datasets_names=data.get('datasets_names'))
