@classmethod
def new_from_obj(cls, obj, data=None, var=None, copy=False, unit=None):
    """Create a new object from another one, copying its attributes.

        Parameters
        ----------
        obj  : `mpdaf.obj.DataArray`
            The object to use as the template for the new object. This
            should be an object based on DataArray, such as an Image,
            Cube or Spectrum.
        data : array-like, optional
            An optional data array, or None to indicate that
            ``obj.data`` should be used. The default is None.
        var : array-like, optional
            An optional variance array, or None to indicate that
            ``obj.var`` should be used, or False to indicate that the
            new object should not have any variances. The default
            is None.
        copy : bool
            Copy the data and variance arrays if True (default False).

        """
    data = obj.data if data is None else data
    if var is None:
        var = obj._var
    elif var is False:
        var = None
    if unit is None:
        unit = obj.unit
    kwargs = dict(filename=obj.filename, data=data, unit=unit, var=var, ext
        =(obj._data_ext, obj._var_ext, obj._dq_ext), copy=copy, data_header
        =obj.data_header.copy(), primary_header=obj.primary_header.copy())
    if cls._has_wcs:
        kwargs['wcs'] = obj.wcs
    if cls._has_wave:
        kwargs['wave'] = obj.wave
    return cls(**kwargs)
