Coverage for webgeodyn/example.py: 0%

13 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-12-18 09:33 +0000

1""" 

2An example file showing how to start the webgeodyn server 

3""" 

4import os.path 

5import webgeodyn.server 

6import webgeodyn.models 

7 

8 

9def run(): 

10 """ 

11 Runs the webgeodyn example 

12 """ 

13 # Initialise the list of the models 

14 models = webgeodyn.models.Models() 

15 

16 # Load a model into the list of models (several can be loaded at once) 

17 # Syntax: models.loadModel('/path/to/the/model/directory', "Name of the model", "Format of the model") 

18 # Example for CHAOS: 

19 models.loadModel(os.path.join(os.path.dirname(__file__), 'example_data', './CHAOS-7'), 'CHAOS-7 model', 'CHAOS') 

20 # Example for current pygeodyn computation: 

21 home_dir = os.path.expanduser('~') 

22 pygeodyn_dir = os.path.join(home_dir, 'pygeodyn_results', 'Current_computation') 

23 if(os.path.isfile(os.path.join(pygeodyn_dir, 'Current_computation.hdf5'))): 

24 models.loadModel(os.path.join(home_dir, 'pygeodyn_results', 'Current_computation'), 'Current pygeodyn computation', 'pygeodyn_hdf5') 

25 

26 # Start the server with the loaded models 

27 webgeodyn.server.startServer(models,{}) 

28 

29 

30if __name__ == "__main__": 

31 run()