pyhdf5_handler.tutorial.complementary_test
Created on Tue Oct 14 09:38:05 2025
@author: maxime
1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3""" 4Created on Tue Oct 14 09:38:05 2025 5 6@author: maxime 7""" 8 9if __name__ == "__main__": 10 11 import smash 12 import pyhdf5_handler 13 14 setup, mesh = smash.factory.load_dataset("Lez") 15 16 setup.update({"start_time": "2014-01-01 00:00", "end_time": "2014-02-02 00:00"}) 17 18 model = smash.Model(setup, mesh) 19 20 model.forward_run() 21 22 # save dict : 23 pyhdf5_handler.save_dict_to_hdf5file( 24 "./test.hdf5", 25 { 26 "smash_rr_initial_states": { 27 "keys": model.rr_initial_states.keys, 28 "values": model.rr_initial_states.values, 29 } 30 }, 31 ) 32 33 test = pyhdf5_handler.read_hdf5file_as_dict( 34 "./test.hdf5", location="smash_rr_initial_states" 35 ) 36 37 # save part of object model: 38 pyhdf5_handler.save_object_to_hdf5file( 39 "./test.hdf5", 40 model.rr_initial_states, 41 location="./smash_object_rr_initial_states", 42 ) 43 44 test = pyhdf5_handler.read_hdf5file_as_dict( 45 "./test.hdf5", location="smash_object_rr_initial_states" 46 ) 47 48 # save full model object 49 pyhdf5_handler.save_object_to_hdf5file( 50 "./test.hdf5", model, location="./full_smash_object" 51 ) 52 53 test = pyhdf5_handler.read_hdf5file_as_dict( 54 "./test.hdf5", location="full_smash_object" 55 )