How to take the mean of a netcdf file from the dimensions of the file?

23 Views Asked by At

Problem: I have a netcdf file of data taken every 3 hours however, instead of this being in the time dimension, my netcdf file has another day_period dimension.

Expected output I would like to take the daily mean of the file

The structure of my file is shown below

NetCDF Structure

I have tried this:

import xarray as xr

ds = xr.open_dataset('2015_2016_SMAPGPH_monmean.nc')
day_mean1 = ds.sel(day_period = range(0,7)).mean()

but this gave me just one value of the mean. I would like to have a daily mean value from 2015-2022.

Thank you.

0

There are 0 best solutions below