Dev for the P190.describe_* methods


In [42]:
import matplotlib.pyplot as plt
import numpy as np
from rockfish2.navigation.ukooa.p190.p190 import P190
from rockfish2.utils.loaders import get_example_file

test_p190_file = get_example_file('MGL1407MCS15.TEST.p190')

print test_p190_file


/Users/ncm/Dev/Rockfish2/rockfish2/navigation/1.p190/tests/data/MGL1407MCS15.TEST.p190

In [3]:
p190 = P190(input_srid=32619)
p190.read_p190(test_p190_file)


[2015-03-04 15:58] INFO: rockfish: Creating new database: :memory:
[2015-03-04 15:58] INFO: rockfish: Reading P190 data from: /Users/ncm/Dev/Rockfish2/rockfish2/navigation/1.p190/tests/data/MGL1407MCS15.TEST.p190

In [4]:
sql = "SELECT line, point, cable_id, chan, DISTANCE(src_pt, rec_pt) AS offset, rec_depth AS depth FROM p190_src_rec_view"

dat = p190.read_sql(sql)

dat.describe()


Out[4]:
point cable_id chan offset
count 24336.000000 24336 24336.00000 24336.000000
mean 91035.500000 1 234.50000 4757.992250
std 15.008639 0 135.10243 1888.270803
min 91010.000000 1 1.00000 157.689600
25% 91022.750000 1 117.75000 3351.798862
50% 91035.500000 1 234.50000 4814.750021
75% 91048.250000 1 351.25000 6256.409155
max 91061.000000 1 468.00000 8005.403104

In [5]:
dat = p190.read_sql('select * from p190_src_rec_view')

stat = dat.describe()

In [14]:
stat.ix['count']


Out[14]:
rec_pt_rowid    24336
point           24336
cable_id        24336
chan            24336
Name: count, dtype: float64

Plot shots and midpoints


In [13]:
fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(111)


nrp = p190.read_sql("SELECT X(geom) AS x, Y(geom) AS y FROM p190_coords WHERE record_id='V'")
cos = p190.read_sql("SELECT X(geom) AS x, Y(geom) AS y FROM p190_coords WHERE record_id='S'")
tb = p190.read_sql("SELECT X(geom) AS x, Y(geom) AS y FROM p190_coords WHERE record_id='T'")
mp = p190.read_sql("SELECT X(mid_pt) AS x, Y(mid_pt) AS y FROM p190_src_rec_view")



ax.plot(mp.x, mp.y, '.b')
ax.plot(nrp.x, nrp.y, '.k')
ax.plot(cos.x, cos.y, '.r')
ax.plot(tb.x, tb.y, '.g')


Out[13]:
[<matplotlib.lines.Line2D at 0x1154b8ed0>]

In [14]:
sql = "SELECT X(rec_pt) - X(src_pt) AS x, Y(rec_pt) - Y(src_pt) AS y FROM p190_src_rec_view"

rel = p190.read_sql(sql)

In [24]:
fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(111)

ax.plot(0, 0, '*r', markersize=20)
ax.plot(rel.x, rel.y, '.-k')

plt.xlim(-8500, 8500)
plt.ylim(-8500, 8500)


Out[24]:
(-8500, 8500)

In [38]:
sql = "SELECT chan, DISTANCE(src_pt, rec_pt) AS offset FROM p190_src_rec_view"
dat = p190.read_sql(sql)

#sql = "SELECT chan, AVG(DISTANCE(src_pt, rec_pt)) AS offset FROM p190_src_rec_view GROUP BY chan"
#dat_mean = p190.read_sql(sql)

dat.groupby('chan').describe()


Out[38]:
offset
chan
1 count 52.000000
mean 6040.876859
std 6.882069
min 6032.381899
25% 6034.802359
50% 6039.991848
75% 6043.824921
max 6057.237282
2 count 52.000000
mean 6013.512422
std 6.824413
min 6005.045465
25% 6007.553535
50% 6012.597167
75% 6016.395481
max 6029.749170
3 count 52.000000
mean 5986.159700
std 6.761193
min 5977.791392
25% 5980.290576
50% 5985.264994
75% 5988.947046
max 6002.336147
4 count 52.000000
mean 5958.797529
std 6.707155
min 5950.597248
25% 5952.992907
50% 5957.902687
... ... ...
465 std 0.189651
min 192.076287
25% 192.283125
50% 192.363900
75% 192.406120
max 193.453069
466 count 52.000000
mean 180.905751
std 0.364073
min 180.540577
25% 180.734425
50% 180.874694
75% 181.022043
max 183.178738
467 count 52.000000
mean 169.608721
std 0.556728
min 169.039433
25% 169.410329
50% 169.576030
75% 169.733681
max 173.161312
468 count 52.000000
mean 158.502629
std 0.783752
min 157.689600
25% 158.206637
50% 158.420752
75% 158.696463
max 163.526756

3744 rows × 1 columns


In [35]:
plot(dat.chan, dat.offset, '.k')
plot(dat_mean.chan, dat_mean.offset, '.r')


Out[35]:
[<matplotlib.lines.Line2D at 0x1139bd090>]

In [36]:
dat_mean


Out[36]:
chan offset
0 1 6040.876859
1 2 6013.512422
2 3 5986.159700
3 4 5958.797529
4 5 5931.454768
5 6 5904.092599
6 7 7983.601693
7 8 7971.134024
8 9 7958.660867
9 10 7946.194471
10 11 7933.725286
11 12 7921.254908
12 13 7908.778598
13 14 7896.314117
14 15 7883.843250
15 16 7871.372583
16 17 5891.638638
17 18 5754.842013
18 19 7833.960576
19 20 7821.486157
20 21 7809.019302
21 22 7796.548282
22 23 7784.083291
23 24 7771.605902
24 25 7759.142101
25 26 7746.672109
26 27 7734.200524
27 28 7721.745061
28 29 5742.392169
29 30 5605.596061
... ... ...
438 439 2602.546626
439 440 2590.088939
440 441 2577.618573
441 442 2565.151233
442 443 2552.680576
443 444 2540.220220
444 445 2527.749164
445 446 2515.274835
446 447 507.690330
447 448 462.260642
448 449 416.950123
449 450 371.807500
450 451 2452.921085
451 452 2440.461150
452 453 2427.989946
453 454 2415.524027
454 455 2403.039944
455 456 2390.557654
456 457 2378.090670
457 458 2365.614078
458 459 2353.143972
459 460 2340.669284
460 461 359.548077
461 462 226.509456
462 463 215.675295
463 464 203.957367
464 465 192.349498
465 466 180.905751
466 467 169.608721
467 468 158.502629

468 rows × 2 columns


In [39]:
sql = "SELECT chan, DISTANCE(src_pt, rec_pt) AS offset FROM p190_src_rec_view"
dat = p190.read_sql(sql)

In [41]:
dat.boxplot(by='chan')


Out[41]:
<matplotlib.axes.AxesSubplot at 0x1150708d0>

In [45]:
sql = "SELECT chan, DISTANCE(src_pt, rec_pt) AS offset FROM p190_src_rec_view ORDER BY chan"
dat = p190.read_sql(sql)

dx = np.diff(dat.offset)

In [48]:
np.median(dx)


Out[48]:
-0.23325556503641565

In [ ]: