1 """
2 This file contains classes to hold the logged data:
3 - stage measurements
4 - conductivity measurements
5
6 Nothing fancy is done here, as all this is done in
7
8 """
9 import numpy as np
10 import datetime
11 import pylab as pl
12 import matplotlib.mlab as mlab
13 from scipy import polyval, polyfit
14
15
16
17
18
19
20 from fieldpy.core.experiment_classes import *
21 import fieldpy.core.helper_fns as helper_fns
22 from fieldpy.stream_gauging.calibration import SingleCalibration
23
24 -class Stage(CampbellCr1000):
25 """
26 Class to hold and process stage data.
27
28 self.data will have the following
29 """
30 - def __init__(self, filenames, given_headers=['time', 'stage']):
31 """
32 Class to hold and process stage data.
33
34 @type filenames: list of strings
35 @param filenames: a list of TOA5 Campbell Cr1000 files in
36 chronological order with the same data format.
37
38
39 @type given_headers: list of stings
40 @param given_headers: A list of header stings to be used instead
41 of the ones given in the file header.
42
43 @note:
44 - Error checking is just marginal.
45 - Masking record arrays seems a bit tricky here is what I found:
46 - U{http://thread.gmane.org/gmane.comp.python.numeric.general/34100/focus=34125}
47 - but third creation method here seems to work:
48 U{http://docs.scipy.org/doc/numpy/reference/maskedarray.generic.html#using-numpy-ma}
49
50 >>> from fieldpy.core.stream_gauging.stream_gauging import *
51 >>> dir_ = 'test_files/stream_gauging/'
52 >>> fielns = ['TOA5_stage_1.dat','TOA5_stage_2.dat','TOA5_stage_3.dat']
53 >>> stage = Stage([dir_ + fl for fl in fielns], ['time', 'stage'])
54 """
55 super(Stage, self).__init__(filenames, given_headers)
56 self.check()
58 """
59 Applies all filters in the right order.
60 """
61
62 self.mask_value(field='stage', value=0.)
63 self.mask_jumps(field='stage', jump_size=0.15)
64 self.mask_
65 sample_rate = self.data['time'][1]-self.data['time'][0]
66 bandwidth = sample_rate * 1000
67 cutoff_freq = 1./(4*sample_rate)
68 self.filter_low_pass('stage', 'lp_stage', bandwidth, sample_rate, cutoff_freq)
69
70
71
72
74 """
75 Set a method to use to convert stage to discharge.
76 """
77 pass
80
82 """Class which holds conductivity experiment data, well actually
83 the recorded data is a voltage ratio.
84 """
85 - def __init__(self, filenames, reference_resistor=10e3):
86 """Class which holds conductivity experiment data, well actually
87 the recorded data is a voltage ratio. Fills self.data with
88 - time
89 - V_ratio: the ratio of excitation to measured voltage: this
90 is what the datalogger records.
91 - ec: is the V_ratio converted into a conductance (not
92 conductivity! for this the sensor would have to be
93 calibrated with a standard solution)
94
95
96 @type filenames: list of strings
97 @param filenames: a list of TOA5 Campbell Cr1000 files in
98 chronological order with the same data format.
99
100 @type reference_resistor: float
101
102 @param reference_resistor: The resistance of the reference
103 resistor used in the experiment in
104 Ohm. Note that for dilution
105 gauging it is not essential to use
106 the correct value for this but it
107 is essential to use the same as in
108 the calibration file. (default=1)
109
110 @note:
111 - Error checking is just marginal.
112
113 >>> from fieldpy.core.stream_gauging.stream_gauging import *
114 >>> dir_ = 'test_files/stream_gauging/'
115 >>> fielns = ['TOA5_EC_1.dat','TOA5_EC_2.dat']
116 >>> ec = Conductivity([dir_ + fl for fl in fielns])
117 """
118 given_headers= ['time', 'V_ratio']
119 super(Conductivity, self).__init__(filenames, given_headers)
120
121 self.md.reference_resistor = reference_resistor
122 self._singlecalibration_instance = SingleCalibration()
123 self._singlecalibration_instance._datetime = None
124 self._singlecalibration_instance.md.reference_resistor = reference_resistor
125
126 self.make_condctivity()
127 self.check()
128
129
131
132
133 sample_rate = self.data['time'][1]-self.data['time'][0]
134 bandwidth = sample_rate * 1e9
135 cutoff_freq = 1/(4*sample_rate)
136 self.filter_low_pass('ec', 'lp_ec', bandwidth, sample_rate, cutoff_freq)
137
141