I have xarray dataset monthly_data of just January's with following info:
lat: float64 (192)
lon: float64 (288)
time: object (1200)(monthly data)
Data Variables:
tas: (time, lat, lon)[[[45,78,...],...]...]
I have ground truth value grnd_trth which has true data of January
Coordinates:
lat: float64 (192)
lon: float64 (288)
Data Variables:
tas(lat and lon)
Now I want to calculate root squared error for each month from monthly_data with respect to grnd_trth, I tried using loops and I guess it's working fine, here's my try:
rms = []
for i in range(1200):
err = 0
for j in (grnd_trth.tas[0] - monthly_data.tas[i]).values:
for k in j:
err += k**2
rms.append(err**1/2)
I just want to know is there more efficient way or any direct function to do so?
Edit:
Output of monthly_data.tas:
xarray.Datarray 'tas': (time:1200 lat: 192 lon: 288)
array([[[45,46,45,4....],....]...]
Coordinates:
lat:
array([-90. , -89.75,...])
lon:
array([0., 1.25.,.... ])
time:
array([cftime.DatetimeNoLeap(0001-01-15 12:00:00),
cftime.DatetimeNoLeap(0002-01-15 12:00:00),
cftime.DatetimeNoLeap(0003-01-15 12:00:00), ...,
cftime.DatetimeNoLeap(1198-01-15 12:00:00),
cftime.DatetimeNoLeap(1199-01-15 12:00:00),
cftime.DatetimeNoLeap(1200-01-15 12:00:00)]
Output of grnd_trth.tas:
xarray.Datarray 'tas': (lat: 192 lon: 288)
array([[45,46,45,4....],....]
Coordinates:
lat:
array([-90. , -89.75,...])
lon:
array([0., 1.25.,.... ])
time:
array([cftime.DatetimeNoLeap(0001-01-15 12:00:00)]
But when I just use .values( ) function it'll only return me tas value array!