Skip to content
Snippets Groups Projects
Commit e2b17e95 authored by Rob Moss's avatar Rob Moss
Browse files

Save simulated observations for regression tests

As a general, these outputs should remain consistent unless we modify
the PRNG, the PRNG seed, or other fundamental components.
parent a7c6db10
Branches
Tags
No related merge requests found
date value
1 1.403933
2 1.190422
3 1.477227
4 0.916595
5 0.794995
6 0.585725
7 0.775698
8 1.000713
9 1.463746
10 1.557791
11 1.654735
12 0.794288
13 0.713317
14 0.659150
15 1.126689
date value
1 0.456042
2 0.152997
3 0.668645
4 0.711037
5 0.837072
6 0.673318
7 0.133188
8 0.056321
9 0.264425
10 0.299256
11 0.729363
12 0.803457
13 0.731722
14 0.517535
15 0.215541
fs_date date value
1 1 x 1.070862
1 1 x 1.613679
1 1 y 0.602618
1 1 y 0.315129
1 2 x 1.043339
1 2 x 1.932096
1 2 y 1.008079
1 2 y 0.649420
1 3 x 0.592838
1 3 x 1.512923
1 3 y 0.862200
1 3 y 0.963009
1 4 x 0.531867
1 4 x 1.014131
1 4 y 0.736581
1 4 y 1.020064
1 5 x 0.344741
1 5 x 0.859832
1 5 y 0.210133
1 5 y 0.948124
1 6 x 0.587501
1 6 x 0.441767
1 6 y 0.063504
1 6 y 0.316157
1 7 x 0.804867
1 7 x 0.403132
1 7 y 0.426062
1 7 y 0.326053
1 8 x 1.517841
1 8 x 0.586477
1 8 y 0.347976
1 8 y 0.094142
1 9 x 1.308058
1 9 x 1.612668
1 9 y 0.791791
1 9 y 0.180631
1 10 x 0.748884
1 10 x 1.585551
1 10 y 1.084060
1 10 y 0.208586
1 11 x 0.419950
1 11 x 1.475274
1 11 y 0.757717
1 11 y 0.712158
1 12 x 0.273355
1 12 x 0.916839
1 12 y 0.527738
1 12 y 0.878602
1 13 x 0.665148
1 13 x 0.674794
1 13 y 0.478047
1 13 y 0.816481
1 14 x 1.028584
1 14 x 0.563400
1 14 y 0.428332
1 14 y 0.179932
1 15 x 1.186531
1 15 x 0.753580
1 15 y 0.261235
1 15 y 0.526659
3 3 x 1.377728
3 3 x 0.980069
3 3 y 0.502682
3 3 y 0.735865
3 4 x 0.590348
3 4 x 0.586417
3 4 y 0.618670
3 4 y 0.474148
3 5 x 0.375687
3 5 x 0.350127
3 5 y 0.622115
3 5 y 0.808404
3 6 x 0.513645
3 6 x 0.421016
3 6 y 0.150771
3 6 y 0.471616
3 7 x 0.833217
3 7 x 0.561371
3 7 y 0.379380
3 7 y 0.380925
3 8 x 1.186575
3 8 x 0.595469
3 8 y 0.135377
3 8 y 0.062616
3 9 x 1.528011
3 9 x 0.644704
3 9 y 0.032730
3 9 y 0.458074
3 10 x 1.556120
3 10 x 1.645668
3 10 y 0.702400
3 10 y 0.666497
3 11 x 1.300924
3 11 x 1.066495
3 11 y 0.577968
3 11 y 0.461429
3 12 x 0.267146
3 12 x 0.838286
3 12 y 0.809613
3 12 y 0.951155
3 13 x 0.170266
3 13 x 0.439770
3 13 y 0.387366
3 13 y 0.889084
3 14 x 0.377540
3 14 x 0.740342
3 14 y 0.191034
3 14 y 0.647980
3 15 x 0.497127
3 15 x 0.345544
3 15 y 0.419379
3 15 y 0.566345
5 5 x 1.749118
5 5 x 0.819490
5 5 y 0.869461
5 5 y 0.529545
5 6 x 0.796071
5 6 x 1.212364
5 6 y 0.764810
5 6 y 0.393032
5 7 x 0.733533
5 7 x 0.495068
5 7 y 0.749009
5 7 y 0.361320
5 8 x 0.352894
5 8 x 0.428760
5 8 y 0.390695
5 8 y 0.278401
5 9 x 0.600212
5 9 x 0.969963
5 9 y 0.084158
5 9 y 0.307440
5 10 x 0.785866
5 10 x 1.220709
5 10 y 0.238988
5 10 y 0.157637
5 11 x 1.182099
5 11 x 0.936835
5 11 y 0.366868
5 11 y 0.428564
5 12 x 1.188601
5 12 x 1.039916
5 12 y 0.574482
5 12 y 0.802183
5 13 x 1.064808
5 13 x 0.752094
5 13 y 0.692273
5 13 y 0.567205
5 14 x 1.206697
5 14 x 0.821208
5 14 y 0.704961
5 14 y 0.715741
5 15 x 0.718249
5 15 x 0.681799
5 15 y 0.896498
5 15 y 0.606577
7 7 x 0.757454
7 7 x 0.801219
7 7 y 0.598796
7 7 y 0.610233
7 8 x 0.713691
7 8 x 0.921642
7 8 y 0.363011
7 8 y 0.030043
7 9 x 1.185090
7 9 x 1.182957
7 9 y 0.373297
7 9 y 0.347266
7 10 x 1.475102
7 10 x 1.221262
7 10 y 0.203750
7 10 y 0.113711
7 11 x 1.364442
7 11 x 1.466064
7 11 y 0.743178
7 11 y 0.410979
7 12 x 1.114618
7 12 x 1.445021
7 12 y 0.913442
7 12 y 1.212810
7 13 x 1.054041
7 13 x 1.111697
7 13 y 0.865833
7 13 y 0.876714
7 14 x 0.846708
7 14 x 0.843954
7 14 y 0.422704
7 14 y 0.771752
7 15 x 0.898871
7 15 x 0.955760
7 15 y 0.458028
7 15 y 0.253669
9 9 x 0.668280
9 9 x 0.469675
9 9 y 0.571540
9 9 y 0.177975
9 10 x 1.058615
9 10 x 0.734312
9 10 y -0.067411
9 10 y 0.362426
9 11 x 1.353942
9 11 x 1.385223
9 11 y 0.468127
9 11 y 0.286807
9 12 x 1.204176
9 12 x 1.802338
9 12 y 0.480378
9 12 y 0.246995
9 13 x 1.189448
9 13 x 1.512623
9 13 y 0.554929
9 13 y 0.456668
9 14 x 1.073272
9 14 x 1.297334
9 14 y 0.234591
9 14 y 0.872280
9 15 x 0.845244
9 15 x 1.002192
9 15 y 0.379876
9 15 y 0.695099
......@@ -373,6 +373,20 @@ def test_simulated_obs():
num_particles = np.sum(sim_obs['date'] == fs_time)
assert len(sim_obs) == num_particles * int(t1 - fs_time + 1)
# Save the simulated observations as plain-text files in the tests
# directory, which we can version-track and use for regression tests.
all_sim_obs = tuple(state[fs_time]['summary']['simulated_obs']
for fs_time in fs_times)
all_sim_obs = np.concatenate(all_sim_obs)
all_sim_obs = all_sim_obs[['fs_date', 'date', 'unit', 'value']]
# Only retain every 500th row: 2 for each observation type, each day.
sim_obs_tbl = all_sim_obs[::500]
save_dir = os.path.abspath('tests')
sim_obs_file = os.path.join(save_dir, 'simulated_obs.ssv')
np.savetxt(sim_obs_file, sim_obs_tbl,
fmt='%d %d %s %0.6f',
header='fs_date date value', comments='')
def simulate_from_model(time_scale, t0, t1, px_count):
seed = 42
......@@ -425,4 +439,16 @@ def test_simulate_from_model():
assert any(obs_at_t['unit'] == 'x')
assert any(obs_at_t['unit'] == 'y')
# pypfilt.examples.predation.save_scalar_observations(sim_obs)
# Save the simulated observations as plain-text files in the tests
# directory, which we can version-track and use for regression tests.
save_dir = os.path.abspath('tests')
x_obs_file = os.path.join(save_dir, 'simulate_from_model-x.ssv')
y_obs_file = os.path.join(save_dir, 'simulate_from_model-y.ssv')
x_tbl = sim_obs[sim_obs['unit'] == 'x'][['date', 'value']]
y_tbl = sim_obs[sim_obs['unit'] == 'y'][['date', 'value']]
x_tbl = x_tbl[x_tbl['date'] > 0]
y_tbl = y_tbl[y_tbl['date'] > 0]
np.savetxt(x_obs_file, x_tbl, fmt='%d %0.6f',
header='date value', comments='')
np.savetxt(y_obs_file, y_tbl, fmt='%d %0.6f',
header='date value', comments='')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment