|
14 | 14 | from gp_emulator import MultivariateEmulator
|
15 | 15 | from gp_emulator.emulation_helpers import integrate_passbands
|
16 | 16 | from gp_emulator.emulation_helpers import create_single_band_emulators
|
| 17 | +from gp_emulator.emulation_helpers import create_inverse_emulators |
17 | 18 |
|
18 | 19 | @fixture
|
19 | 20 | def datadir(tmpdir, request):
|
@@ -64,3 +65,19 @@ def test_singlebandemulators(datadir):
|
64 | 65 |
|
65 | 66 | rho_pred, _, _ = gps[0].predict(np.atleast_2d(gp.y_train[10, :]))
|
66 | 67 | np.allclose(rho_pred, 0.10881985)
|
| 68 | + |
| 69 | +def test_inverseemulators(datadir): |
| 70 | + |
| 71 | + gp = MultivariateEmulator(dump=datadir("prosail_000_000_0000.npz")) |
| 72 | + # Process the S2A spectral response functions into something useable |
| 73 | + srf = np.loadtxt(datadir("S2A_SRS.csv"), skiprows=1, |
| 74 | + delimiter=",")[100:, :] |
| 75 | + srf[:, 1:] = srf[:, 1:]/np.sum(srf[:, 1:], axis=0) |
| 76 | + srf_land = srf[:, [1, 2, 3, 4, 5, 6, 7, 8, 11, 12]].T |
| 77 | + |
| 78 | + #parameters = ["n", "cab", "car", "cbrown", "cw", "cm", "lai", "ala", "bsoil", "psoil"] |
| 79 | + parameters = ["lai"] |
| 80 | + inverse_ems = create_inverse_emulators (gp, srf_land, parameters, |
| 81 | + n_tries=2) |
| 82 | + test_k = set(inverse_ems.keys()) |
| 83 | + assert set(parameters) == test_k |
0 commit comments