def model(sample_model, output_dir): model = sample_model['model'] rel_start_pos = sample_model['release_start_pos'] rel_end_pos = sample_model['release_end_pos'] model.start_time = datetime(2015, 5, 14, 0) model.cache_enabled = True model.uncertain = True N = 10 # a line of ten points line_pos = np.zeros((N, 3), dtype=np.float64) line_pos[:, 0] = np.linspace(rel_start_pos[0], rel_end_pos[0], N) line_pos[:, 1] = np.linspace(rel_start_pos[1], rel_end_pos[1], N) start_pos = (-164.01696, 72.921024, 0) model.spills += point_line_release_spill(1, start_position=start_pos, release_time=model.start_time, end_position=start_pos) release = SpatialRelease(start_position=line_pos, release_time=model.start_time) model.spills += Spill(release) model.movers += c_ice_mover model.outputters += IceJsonOutput([c_ice_mover]) model.rewind() return model
def test_save_load_model(uncertain, zipsave, saveloc_): ''' create a model, save it, then load it back up and check it is equal to original model ''' model = make_model(uncertain) ice_mover = IceMover(testdata['IceMover']['ice_curr_curv'], testdata['IceMover']['ice_top_curv']) model.movers += ice_mover model.outputters += IceJsonOutput([ice_mover]) model.zipsave = zipsave print 'saving scenario to {}...'.format(saveloc_) _json_, savefile, _refs = model.save(saveloc_) print 'loading scenario ...' model2 = Model.load(savefile) assert model == model2
def test_init(): 'simple initialization passes' g = IceJsonOutput([c_ice_mover]) assert g.ice_movers[0] == c_ice_mover