pythonattributespython-xarrayintegrate

integrate attribute of xarray


I am new to xarray and need it to handle larger netcdf files. I have one with dimensions 'time','level','latitude', and 'longitude'. I try to integrate along the 'level' dimension below and get an error that a 'DataArray' object has no attribute 'integrate'. From this page I understand that it does. Very simple code below. Thanks for any help.

dataDIR = basedir + 'vt_' + str(yr) + monstr + '_sub.nc'
DS = xr.open_dataset(dataDIR)
vt = DS.v
ivt = vt.integrate('level')

Solution

  • The integrate method was added in Xarray v0.12. Upgrading to (at least) that version should fix your problem.

    pip install -U xarray
    

    or

    conda update -c conda-forge xarray