Coverage for /usr/local/lib/python3.11/dist-packages/pyrocko/__init__.py: 49%

39 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2024-03-07 11:54 +0000

1# https://pyrocko.org - GPLv3 

2# 

3# The Pyrocko Developers, 21st Century 

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

5 

6''' 

7A toolbox and library for seismology. 

8''' 

9 

10import sys 

11 

12try: 

13 from .info import * # noqa 

14 __version__ = version # noqa 

15except ImportError: 

16 pass # not available in dev mode 

17 

18grumpy = 0 # noqa 

19 

20 

21def get_logger(): 

22 from .util import logging 

23 return logging.getLogger('pyrocko') 

24 

25 

26class ExternalProgramMissing(Exception): 

27 pass 

28 

29 

30def app_init(log_level='info', progress_viewer='terminal', program_name=None): 

31 ''' 

32 Setup logging and progress indicators for Pyrocko scripts. 

33 

34 This is a shortcut for calling :py:func:`pyrocko.util.setup_logging` and 

35 :py:func:`pyrocko.progress.set_default_viewer`. 

36 

37 :param program_name: 

38 ``programname`` argument for :py:func:`pyrocko.util.setup_logging` 

39 :type program_name: 

40 str 

41 

42 :param log_level: 

43 ``levelname`` argument for :py:func:`pyrocko.util.setup_logging` 

44 :type log_level: 

45 str 

46 

47 :param progress_viewer: 

48 ``viewer`` argument for 

49 :py:func:`pyrocko.progress.set_default_viewer` 

50 ''' 

51 from pyrocko import util, progress 

52 if program_name is None: 

53 program_name = sys.argv[0] 

54 

55 util.setup_logging(sys.argv[0], log_level) 

56 progress.set_default_viewer(progress_viewer) 

57 

58 

59def make_squirrel(*args, **kwargs): 

60 from pyrocko.squirrel import Squirrel 

61 return Squirrel(*args, **kwargs) 

62 

63 

64def snuffle(*args, **kwargs): 

65 ''' 

66 Start Snuffler. 

67 

68 Calls :py:func:`pyrocko.gui.snuffler.snuffler.snuffle` 

69 ''' 

70 

71 from pyrocko import deps 

72 

73 deps.require('PyQt5.Qt') 

74 

75 from pyrocko.gui.snuffler import snuffler 

76 return snuffler.snuffle(*args, **kwargs) 

77 

78 

79def sparrow(*args, **kwargs): 

80 ''' 

81 Start Sparrow. 

82 

83 Calls :py:func:`pyrocko.gui.sparrow.main`. 

84 ''' 

85 

86 from pyrocko import deps 

87 

88 deps.require('vtk') 

89 deps.require('PyQt5.Qt') 

90 # deps.import_optional('kite', 'InSAR visualization') 

91 

92 from pyrocko.gui.sparrow.main import main 

93 return main(*args, **kwargs) 

94 

95 

96def drum(*args, **kwargs): 

97 ''' 

98 Start Drum Plot. 

99 

100 Calls :py:func:`pyrocko.gui.drum.main`. 

101 ''' 

102 

103 from pyrocko import deps 

104 

105 deps.require('PyQt5.Qt') 

106 deps.require('serial') 

107 

108 from pyrocko.gui.drum.main import main 

109 return main(*args, **kwargs)