PyMPDATA_examples.utils.error_norms

 1import numpy as np
 2
 3
 4def L2(numerical, analytical, nt):
 5    assert numerical.shape == analytical.shape
 6    N = analytical.size
 7    err2 = np.log(np.sqrt(sum(pow(numerical - analytical, 2)) / nt / N)) / np.log(2)
 8    return err2
 9
10
11def Smolarkiewicz_Grabowski_1990_eq21(numerical, analytical, T):
12    assert numerical.shape == analytical.shape
13    NX = analytical.size
14    err = np.sqrt(sum(pow(numerical - analytical, 2)) / NX) / T
15    return err
16
17
18def modified_Smolarkiewicz_Rasch_r0(numerical, analytical, T, g_factor):
19    NX = analytical.size
20    err = (
21        np.sqrt(sum(pow(numerical - analytical, 2) * g_factor) / NX)
22        / np.amax(analytical)
23        / T
24    )
25    return err
def L2(numerical, analytical, nt):
5def L2(numerical, analytical, nt):
6    assert numerical.shape == analytical.shape
7    N = analytical.size
8    err2 = np.log(np.sqrt(sum(pow(numerical - analytical, 2)) / nt / N)) / np.log(2)
9    return err2
def Smolarkiewicz_Grabowski_1990_eq21(numerical, analytical, T):
12def Smolarkiewicz_Grabowski_1990_eq21(numerical, analytical, T):
13    assert numerical.shape == analytical.shape
14    NX = analytical.size
15    err = np.sqrt(sum(pow(numerical - analytical, 2)) / NX) / T
16    return err
def modified_Smolarkiewicz_Rasch_r0(numerical, analytical, T, g_factor):
19def modified_Smolarkiewicz_Rasch_r0(numerical, analytical, T, g_factor):
20    NX = analytical.size
21    err = (
22        np.sqrt(sum(pow(numerical - analytical, 2) * g_factor) / NX)
23        / np.amax(analytical)
24        / T
25    )
26    return err