<s>[INST] import xarray as xr

# reading netCDF file
ds1 = xr.open_dataset('path/to/file.nc')
ds2 = xr.open_dataset('another/path/to/file.nc')
# data are ocean currents
data1 = ds1['u'][0,0,...] # assuming 4d data (time, z, y, x) for u current
data2 = ds2['v'][0,0,...] # assuming 4d data (time, z, y, x) for v current

# open new netCDF file for writing
with xr.open_dataset('desired/path/filename.nc', 'w') as ds:
    ds['latitude'] = xr.DataArray(ds1['lat'])
    ds['longitude'] = xr.DataArray(ds1['lon'])
    ds['u'] = xr.DataArray(data1)
    ds['v'] = xr.DataArray(data2)

xr.open_dataset('desired/path/filename.nc')

AttributeError: 'function' object has no attribute 'lat'

What's wrong?[/INST]