Coverage for webgeodyn/inout/coreflo-ll.py: 0%

16 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 os.path 

5import numpy as np 

6 

7 

8def load(dataDirectory, dataModel, keepRealisations=False): 

9 """ Loading function for the CoreFlo-LL model (https://doi.org/10.1093/gji/ggy545). Also adds the data to the dataModel. 

10 

11 :param dataDirectory: directory where the data is located 

12 :type dataDirectory: str (path) 

13 :param dataModel: Model to which the data should be added 

14 :type dataModel: Model 

15 :param keepRealisations: indicating if realisations should be kept or averaged (not used) 

16 :type keepRealisations: bool (default: False) 

17 :return: 0 if everything went well, -1 otherwise 

18 :rtype: int 

19 """ 

20 

21 # Reading measure U 

22 filename = os.path.join(dataDirectory, 'CoreFlo-LL.1_coeffs.dat') 

23 if not os.path.isfile(filename): 

24 print('{} does not contain a CoreFlo-LL file !'.format(filename)) 

25 

26 full_data = np.genfromtxt(filename, comments="#", delimiter=',') 

27 full_Nu = (full_data.shape[1] - 1)//2 

28 # Truncating at 18 for now 

29 Lu = 18 

30 Nu = Lu*(Lu+2) 

31 times = full_data[:, 0] 

32 toro_data = full_data[:, 1:Nu+1] 

33 polo_data = full_data[:, full_Nu+1:full_Nu+Nu+1] 

34 flow_data = np.concatenate((toro_data, polo_data), axis=1) 

35 

36 dataModel.addMeasure("U", "U", Lu, "km/yr", flow_data, times=times) 

37 

38 return 0