I want to read and calculate a nc file but getting KeyError: ‘sum’. It works with the file that has (time,lat, lon) coordinates but not with the one that has (time,TSTEP,lat, lon). I do not understand what the TSTEP does.
datafile = 'Methane_2000.nc'
data = xr.open_mfdataset(datafile, engine='netcdf4', decode_times=False)
data
# get latitude weights
weights = np.cos(np.deg2rad(data.lat))
weights.name = "weights"
data_weighted = data.weighted(weights)
# need to convert from kg m-2 s-1 to kg yr-1 over whole globe
area=510.1*1000000 #km²
secs=30*24*60*60 # sec/month
np.sum(global_mean_data['sum'].values*area*secs)
#I should get a value at the end.
1