I am a bit of a netCDF in python noob so please excuse this noob question.
I have a folder filled with circa 3650 netCDF4 files. One file per day for a decade. the niles are named yyyymmdd.nc (e.g. 20100101,20100102,20100103,etc.). Each .nc file contains latitude, longitude, and temperature at one-time point for the same area - a section of the Tonga EEZ.
What I am trying to do is compute the average temperature for each lat and lon from across all files, i.e. I want to end up with one .nc file that has all the same lats and lons and average temperature across 10 years.
I have tried different things/versions of code, usually, they end up looking something like this.....
files = glob('*.nc')
ds = xr.open_mfdataset(files,)
mean = np.mean(ds['temp'][:, 0].values)
...... This code would give me the average temperature within a .nc file for all .nc files and not the average temperature based on lat and lon across a decade worth of files.
All and any help is much appreciated.
Thank you.