In [1]:
%pylab inline
from SimPEG import DCIP as DC


Populating the interactive namespace from numpy and matplotlib
Efficiency Warning: Interpolation will be slow, use setup.py!

            python setup.py build_ext --inplace
    

In [9]:
import pandas as pd

In [10]:
directory = "../data/waterlevel/"

In [11]:
df = pd.read_excel(directory+'WaterBH12.xlsx',sheetname='sheet1')

In [13]:
df


Out[13]:
Date Upper Down
0 2015-01-16 15:50:00 35.512 19.596
1 2015-01-16 16:00:00 35.508 19.608
2 2015-01-16 16:10:00 35.503 19.614
3 2015-01-16 17:00:00 35.551 19.666
4 2015-01-16 18:00:00 35.541 19.721
5 2015-01-16 19:00:00 35.532 19.776
6 2015-01-16 20:00:00 35.525 19.826
7 2015-01-16 21:00:00 35.517 19.872
8 2015-01-16 22:00:00 35.510 19.917
9 2015-01-16 23:00:00 35.504 19.962
10 2015-01-17 00:00:00 35.501 20.001
11 2015-01-17 01:00:00 35.499 20.037
12 2015-01-17 02:00:00 35.495 20.076
13 2015-01-17 03:00:00 35.491 20.111
14 2015-01-17 04:00:00 35.487 20.144
15 2015-01-17 05:00:00 35.483 20.173
16 2015-01-17 06:00:00 35.480 20.203
17 2015-01-17 07:00:00 35.475 20.233
18 2015-01-17 08:00:00 35.470 20.261
19 2015-01-17 09:00:00 35.464 20.286
20 2015-01-17 10:00:00 35.458 20.309
21 2015-01-17 11:00:00 35.451 20.335
22 2015-01-17 12:00:00 35.449 20.346
23 2015-01-17 13:00:00 35.450 20.354
24 2015-01-17 14:00:00 35.452 20.363
25 2015-01-17 15:00:00 35.453 20.374
26 2015-01-17 16:00:00 35.455 20.384
27 2015-01-17 17:00:00 35.456 20.395
28 2015-01-17 18:00:00 35.456 20.410
29 2015-01-17 19:00:00 35.453 20.426
... ... ... ...
34794 2015-10-13 11:40:00 29.746 20.410
34795 2015-10-13 11:50:00 29.747 20.409
34796 2015-10-13 12:00:00 29.746 20.407
34797 2015-10-13 12:10:00 29.744 20.409
34798 2015-10-13 12:20:00 29.744 20.407
34799 2015-10-13 12:30:00 29.742 20.407
34800 2015-10-13 12:40:00 29.743 20.406
34801 2015-10-13 12:50:00 29.744 20.405
34802 2015-10-13 13:00:00 29.743 20.404
34803 2015-10-13 13:10:00 29.743 20.402
34804 2015-10-13 13:20:00 29.744 20.402
34805 2015-10-13 13:30:00 29.746 20.400
34806 2015-10-13 13:40:00 29.743 20.399
34807 2015-10-13 13:50:00 29.745 20.399
34808 2015-10-13 14:00:00 29.746 20.398
34809 2015-10-13 14:10:00 29.747 20.399
34810 2015-10-13 14:20:00 29.748 20.398
34811 2015-10-13 14:30:00 29.744 20.397
34812 2015-10-13 14:40:00 29.746 20.397
34813 2015-10-13 14:50:00 29.747 20.396
34814 2015-10-13 15:00:00 29.748 20.394
34815 2015-10-13 15:10:00 29.746 20.395
34816 2015-10-13 15:20:00 29.748 20.394
34817 2015-10-13 15:30:00 29.746 20.394
34818 2015-10-13 15:40:00 29.745 20.392
34819 2015-10-13 15:50:00 29.746 20.392
34820 2015-10-13 16:00:00 29.746 20.392
34821 2015-10-13 16:10:00 29.748 20.392
34822 2015-10-13 16:20:00 29.749 20.391
34823 2015-10-13 16:30:00 29.747 20.392

34824 rows × 3 columns


In [4]:
df.at[date[-1]+1, 0]


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-4-e1ecdcaaf0be> in <module>()
----> 1 df.at[date[-1]+1, 0]

NameError: name 'df' is not defined

In [22]:
df.to_excel('path_to_file.xlsx', sheet_name='Sheet1')

In [ ]:


In [12]:
df.loc['2015-10-11':'2015-10-13']


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-12-1a77f0c3ed85> in <module>()
----> 1 df.loc['2015-10-11':'2015-10-13']

C:\Users\sungkeun\Anaconda2\lib\site-packages\pandas\core\indexing.pyc in __getitem__(self, key)
   1225             return self._getitem_tuple(key)
   1226         else:
-> 1227             return self._getitem_axis(key, axis=0)
   1228 
   1229     def _getitem_axis(self, key, axis=0):

C:\Users\sungkeun\Anaconda2\lib\site-packages\pandas\core\indexing.pyc in _getitem_axis(self, key, axis)
   1340         if isinstance(key, slice):
   1341             self._has_valid_type(key, axis)
-> 1342             return self._get_slice_axis(key, axis=axis)
   1343         elif is_bool_indexer(key):
   1344             return self._getbool_axis(key, axis=axis)

C:\Users\sungkeun\Anaconda2\lib\site-packages\pandas\core\indexing.pyc in _get_slice_axis(self, slice_obj, axis)
   1247         labels = obj._get_axis(axis)
   1248         indexer = labels.slice_indexer(slice_obj.start, slice_obj.stop,
-> 1249                                        slice_obj.step)
   1250 
   1251         if isinstance(indexer, slice):

C:\Users\sungkeun\Anaconda2\lib\site-packages\pandas\core\index.pyc in slice_indexer(self, start, end, step, kind)
   2568         This function assumes that the data is sorted, so use at your own peril
   2569         """
-> 2570         start_slice, end_slice = self.slice_locs(start, end, step=step, kind=kind)
   2571 
   2572         # return a slice

C:\Users\sungkeun\Anaconda2\lib\site-packages\pandas\core\index.pyc in slice_locs(self, start, end, step, kind)
   2712         start_slice = None
   2713         if start is not None:
-> 2714             start_slice = self.get_slice_bound(start, 'left', kind)
   2715         if start_slice is None:
   2716             start_slice = 0

C:\Users\sungkeun\Anaconda2\lib\site-packages\pandas\core\index.pyc in get_slice_bound(self, label, side, kind)
   2650         # For datetime indices label may be a string that has to be converted
   2651         # to datetime boundary according to its resolution.
-> 2652         label = self._maybe_cast_slice_bound(label, side, kind)
   2653 
   2654         # we need to look up the label

C:\Users\sungkeun\Anaconda2\lib\site-packages\pandas\core\index.pyc in _maybe_cast_slice_bound(self, label, side, kind)
   3649         # integer/floats directly
   3650         if not (is_integer(label) or is_float(label)):
-> 3651             self._invalid_indexer('slice',label)
   3652 
   3653         return label

C:\Users\sungkeun\Anaconda2\lib\site-packages\pandas\core\index.pyc in _invalid_indexer(self, form, key)
   1015                                                            klass=type(self),
   1016                                                            key=key,
-> 1017                                                            kind=type(key)))
   1018 
   1019     def get_duplicates(self):

TypeError: cannot do slice indexing on <class 'pandas.core.index.Int64Index'> with these indexers [2015-10-11] of <type 'str'>

In [8]:
def readReservoirDC(fname):
    f = open(fname, 'r')
    data = f.readlines()
    temp = data[3].split()
    nelec, ndata, aspacing = int(temp[0]), int(temp[1]), float(temp[2])
    ntx = nelec-2
    datalist = []
    for iline, line in enumerate(data[4:4+ndata]):
    #     line = line.replace(ignorevalue, 'nan')
        linelist = line.split()    
        datalist.append(np.array(map(float, linelist)))
    DAT = np.vstack(datalist)
    datalistSRC = []
    srcList = []
#     for i in range(ntx-1):
    for i in range(ntx-1):        
        txloc = np.array([i+2, i+1.])
        ind = (DAT[:,:2] == txloc).sum(axis=1) == 2.
        temp = DAT[ind,:]
        datalistSRC.append(temp)
        e = np.zeros_like(temp[:,2])
        rxtemp = DC.RxDipole(np.c_[temp[:,2]*aspacing, e, e], np.c_[temp[:,3]*aspacing, e, e])
        srctemp = DC.SrcDipole([rxtemp], np.r_[txloc[1]*aspacing, 0., 0.], np.r_[txloc[0]*aspacing, 0., 0.])
        srcList.append(srctemp)
    DAT_src = np.vstack(datalistSRC)    
    survey = DC.SurveyDC(srcList)
    survey.dobs = DAT_src[:,-1]
    return survey

In [13]:
fname1 = "../data/ChungCheonDC/20150101000000.apr"
fname2 = "../data/ChungCheonDC/20150108120000.apr"

In [14]:
survey1 = readReservoirDC(fname1)
survey2 = readReservoirDC(fname2)
survey12 = readReservoirDC(fname2)

In [15]:
# ind = (survey1.dobs > 200.) | (survey2.dobs > 200.)
# survey1.dobs[ind] = np.median(survey1.dobs)
# survey2.dobs[ind] = np.median(survey2.dobs)

In [16]:
hist(survey1.dobs, bins=20)


Out[16]:
(array([  41.,  117.,  114.,   62.,   30.,   12.,    3.,    0.,    0.,
           0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,
           0.,    1.]),
 array([  52.0794 ,   67.07093,   82.06246,   97.05399,  112.04552,
         127.03705,  142.02858,  157.02011,  172.01164,  187.00317,
         201.9947 ,  216.98623,  231.97776,  246.96929,  261.96082,
         276.95235,  291.94388,  306.93541,  321.92694,  336.91847,  351.91   ]),
 <a list of 20 Patch objects>)

In [19]:
hist(survey2.dobs, bins=20)


Out[19]:
(array([  1.,   0.,   0.,   1.,   0.,   4.,  14.,  39.,  57.,  69.,  62.,
         40.,  24.,  27.,  17.,  10.,   7.,   6.,   1.,   1.]),
 array([  11.9585  ,   19.259575,   26.56065 ,   33.861725,   41.1628  ,
          48.463875,   55.76495 ,   63.066025,   70.3671  ,   77.668175,
          84.96925 ,   92.270325,   99.5714  ,  106.872475,  114.17355 ,
         121.474625,  128.7757  ,  136.076775,  143.37785 ,  150.678925,
         157.98    ]),
 <a list of 20 Patch objects>)

In [20]:
survey12.dobs = abs(survey2.dobs-survey1.dobs) / abs(survey1.dobs)

In [21]:
fig, ax = plt.subplots(1,1, figsize = (12*2, 3*2))
DC.plot_pseudoSection(survey1, ax, "dpdp", dtype="appr", clim=[52, 150.])


Out[21]:
<matplotlib.axes._subplots.AxesSubplot at 0x7989ef0>

In [22]:
fig, ax = plt.subplots(1,1, figsize = (12*2, 3*2))
DC.plot_pseudoSection(survey2, ax, "dpdp", dtype="appr", clim=[52, 150.])


Out[22]:
<matplotlib.axes._subplots.AxesSubplot at 0x797b240>

In [23]:
fig, ax = plt.subplots(1,1, figsize = (12*2, 3*2))
DC.plot_pseudoSection(survey12, ax, "dpdp", dtype="appr", clim=[0., 0.1])


Out[23]:
<matplotlib.axes._subplots.AxesSubplot at 0x85c2128>

In [ ]:


In [ ]:


In [ ]: