1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

# http://pyrocko.org - GPLv3 

# 

# The Pyrocko Developers, 21st Century 

# ---|P------/S----------~Lg---------- 

 

from __future__ import absolute_import, print_function 

 

import os.path as op 

import logging 

 

from pyrocko.guts import List, load 

 

from ..has_paths import HasPaths 

from . import client 

from .error import SquirrelError 

 

guts_prefix = 'pf' 

 

logger = logging.getLogger('pyrocko.squirrel.dataset') 

 

 

class Dataset(HasPaths): 

sources = List.T(client.Source.T()) 

 

def setup(self, squirrel, check=True, progress_viewer='terminal'): 

for source in self.sources: 

source.setup( 

squirrel, check=check, progress_viewer=progress_viewer) 

 

 

def read_dataset(path): 

try: 

dataset = load(filename=path) 

except OSError: 

raise SquirrelError( 

'Cannot read dataset file: %s' % path) 

 

if not isinstance(dataset, Dataset): 

raise SquirrelError('Invalid dataset file "%s".' % path) 

 

dataset.set_basepath(op.dirname(path) or '.') 

return dataset