Coverage for webgeodyn/inout/lod.py: 0%

11 statements  

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

1#!/usr/bin/env python3 

2#-*- coding: utf-8 -*- 

3 

4import glob 

5import os 

6import numpy as np 

7 

8 

9def load(dataDirectory, dataModel, keepRealisations=True): 

10 """ 

11 :param dataDirectory: location of the files to load 

12 :type dataDirectory: str 

13 :param dataModel: data model to which the loaded data are added 

14 :type dataModel: Model 

15 :param keepRealisations: indicates if realisations must be kept or not (not used) 

16 :type keepRealisations: bool 

17 :return: 0 if no errors are raised 

18 :rtype: int 

19 """ 

20 

21 dat_files = glob.glob(os.path.join(dataDirectory, '*.dat')) 

22 

23 if len(dat_files) == 0: 

24 raise IOError("No .dat file was found in {}".format(dataDirectory)) 

25 

26 lod_data = np.genfromtxt(dat_files[0]) 

27 

28 dataModel.times = lod_data[:, 0] 

29 dataModel.notSH_measures['LOD'] = lod_data[:, 1] 

30 

31 # If everything went fine 

32 return 0