Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

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

 

from obspy.xseed.blockette import Blockette 

from obspy.xseed.fields import Float, Integer, VariableString, Loop 

from obspy.xseed.utils import formatRESP 

 

 

class Blockette048(Blockette): 

    """ 

    Blockette 048: Channel Sensitivity/Gain Dictionary Blockette. 

 

    See Channel Sensitivity/Gain Blockette [58] for more information. 

    """ 

 

    id = 48 

    name = "Channel Sensivitity Gain Dictionary" 

    fields = [ 

        Integer(3, "Response Lookup Key", 4), 

        VariableString(4, "Response Name", 1, 25, 'UN_'), 

        Float(5, "Sensitivity gain", 12, mask='%+1.5e'), 

        Float(6, "Frequency", 12, mask='%+1.5e'), 

        Integer(7, "Number of history values", 2), 

        # REPEAT fields 8 — 10 for the Number of history values: 

        Loop('History', "Number of history values", [ 

            Float(8, "Sensitivity for calibration", 12, mask='%+1.5e'), 

            Float(9, "Frequency of calibration sensitivity", 12, 

                  mask='%+1.5e'), 

            VariableString(10, "Time of above calibration", 1, 22, 'T') 

        ]) 

    ] 

 

    def getRESP(self, station, channel, abbreviations): 

        """ 

        Returns RESP string. 

        """ 

        string = \ 

        '#\t\t+                  +---------------------------------------+' + \ 

        '                  +\n' + \ 

        '#\t\t+                  |   Channel Sensitivity,' + \ 

        '%6s ch %s   |                  +\n' % (station, channel) + \ 

        '#\t\t+                  +---------------------------------------+' + \ 

        '                  +\n' + \ 

        '#\t\t\n' + \ 

        'B048F05     Sensitivity:                           %s\n' \ 

                    % formatRESP(self.sensitivity_gain, 6) + \ 

        'B048F06     Frequency of sensitivity:              %s\n' \ 

                    % formatRESP(self.frequency, 6) + \ 

        'B048F07     Number of calibrations:                %s\n' \ 

                    % self.number_of_history_values 

        if self.number_of_history_values > 1: 

            string += \ 

                '#\t\tCalibrations:\n' + \ 

                '#\t\t i, sensitivity, frequency, time of calibration\n' 

            for _i in xrange(self.number_of_history_values): 

                string += \ 

                'B048F08-09   %2s %13s %13s %s\n' \ 

                % (formatRESP(self.sensitivity_for_calibration[_i], 6), 

                formatRESP(self.frequency_of_calibration_sensitivity[_i], 6), 

                self.time_of_above_calibration[_i].formatSEED()) 

        elif self.number_of_history_values == 1: 

            string += \ 

                '#\t\tCalibrations:\n' + \ 

                '#\t\t i, sensitivity, frequency, time of calibration\n' + \ 

                'B048F08-09    0 %13s %13s %s\n' \ 

                    % (formatRESP(self.sensitivity_for_calibration, 6), 

                      formatRESP(self.frequency_of_calibration_sensitivity, 6), 

                      self.time_of_above_calibration.formatSEED()) 

        string += '#\t\t\n' 

        return string