pymast 0.0.5__py3-none-any.whl → 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pymast/__init__.py +31 -2
- pymast/fish_history.py +59 -6
- pymast/formatter.py +886 -548
- pymast/logger.py +58 -0
- pymast/naive_bayes.py +116 -9
- pymast/overlap_removal.py +2327 -490
- pymast/parsers.py +1111 -239
- pymast/predictors.py +302 -116
- pymast/radio_project.py +1382 -512
- pymast/validation.py +224 -0
- pymast-1.0.0.dist-info/METADATA +636 -0
- pymast-1.0.0.dist-info/RECORD +15 -0
- {pymast-0.0.5.dist-info → pymast-1.0.0.dist-info}/WHEEL +1 -1
- pymast/table_merge.py +0 -154
- pymast-0.0.5.dist-info/METADATA +0 -19
- pymast-0.0.5.dist-info/RECORD +0 -14
- {pymast-0.0.5.dist-info → pymast-1.0.0.dist-info/licenses}/LICENSE.txt +0 -0
- {pymast-0.0.5.dist-info → pymast-1.0.0.dist-info}/top_level.txt +0 -0
pymast/table_merge.py
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""
|
|
3
|
-
Modules contains all of the functions to merge individual radio telemetry receiver
|
|
4
|
-
tables into a tblRecaptures.
|
|
5
|
-
"""
|
|
6
|
-
# import modules required for function dependencies
|
|
7
|
-
import numpy as np
|
|
8
|
-
import pandas as pd
|
|
9
|
-
import os
|
|
10
|
-
import sqlite3
|
|
11
|
-
import datetime
|
|
12
|
-
import matplotlib.pyplot as plt
|
|
13
|
-
import matplotlib
|
|
14
|
-
import matplotlib.dates as mdates
|
|
15
|
-
from mpl_toolkits.mplot3d import Axes3D
|
|
16
|
-
import statsmodels.api as sm
|
|
17
|
-
import statsmodels.formula.api as smf
|
|
18
|
-
import networkx as nx
|
|
19
|
-
from matplotlib import rcParams
|
|
20
|
-
from scipy import interpolate
|
|
21
|
-
|
|
22
|
-
font = {'family': 'serif','size': 6}
|
|
23
|
-
rcParams['font.size'] = 6
|
|
24
|
-
rcParams['font.family'] = 'serif'
|
|
25
|
-
|
|
26
|
-
def the_big_merge(outputWS,projectDB, hitRatio_Filter = False, pre_release_Filter = False, rec_list = None, con_rec_filter = None):
|
|
27
|
-
'''function takes classified data, merges across sites and then joins presence
|
|
28
|
-
and overlapping data into one big file for model building.'''
|
|
29
|
-
conn = sqlite3.connect(projectDB) # connect to the database
|
|
30
|
-
if rec_list != None:
|
|
31
|
-
recSQL = "SELECT * FROM tblMasterReceiver WHERE recID = '%s'"%(rec_list[0])
|
|
32
|
-
for i in rec_list[1:]:
|
|
33
|
-
recSQL = recSQL + " OR recID = '%s'"%(i)
|
|
34
|
-
else:
|
|
35
|
-
recSQL = "SELECT * FROM tblMasterReceiver" # SQL code to import data from this node
|
|
36
|
-
receivers = pd.read_sql(recSQL,con = conn) # import data
|
|
37
|
-
receivers = receivers.recID.unique() # get the unique receivers associated with this node
|
|
38
|
-
recapdata = pd.DataFrame()#columns = ['FreqCode','Epoch','recID','timeStamp','fileName']) # set up an empty data frame
|
|
39
|
-
c = conn.cursor()
|
|
40
|
-
|
|
41
|
-
bouts = False
|
|
42
|
-
for i in receivers: # for every receiver
|
|
43
|
-
|
|
44
|
-
print ("Start selecting and merging data for receiver %s"%(i))
|
|
45
|
-
c.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;")
|
|
46
|
-
tbls = c.fetchall()
|
|
47
|
-
tblList = []
|
|
48
|
-
for j in tbls:
|
|
49
|
-
if i in j[0]:
|
|
50
|
-
tblList.append(j[0])
|
|
51
|
-
if j[0] == 'tblPresence' or j[0]== 'tblOverlap':
|
|
52
|
-
bouts = True
|
|
53
|
-
del j
|
|
54
|
-
# iterate over the receivers to find the final classification (aka the largest _n)
|
|
55
|
-
max_iter_dict = {} # receiver:max iter
|
|
56
|
-
curr_idx = 0
|
|
57
|
-
max_iter = 1
|
|
58
|
-
while curr_idx <= len(tblList) - 1:
|
|
59
|
-
for j in tblList:
|
|
60
|
-
if int(j[-1]) >= max_iter:
|
|
61
|
-
max_iter = int(j[-1])
|
|
62
|
-
max_iter_dict[i] = j
|
|
63
|
-
curr_idx = curr_idx + 1
|
|
64
|
-
curr_idx = 0
|
|
65
|
-
|
|
66
|
-
# once we have a hash table of receiver to max classification, extract the classification dataset
|
|
67
|
-
for j in max_iter_dict:
|
|
68
|
-
|
|
69
|
-
cursor = conn.execute('select * from %s'%(max_iter_dict[j]))
|
|
70
|
-
names = [description[0] for description in cursor.description]
|
|
71
|
-
|
|
72
|
-
if bouts == True:
|
|
73
|
-
if 'hitRatio_A' in names:
|
|
74
|
-
sql = '''SELECT %s.FreqCode, %s.Epoch, %s.recID, timeStamp,presence_number, overlapping, hitRatio_A, hitRatio_M, detHist_A, detHist_M, conRecLength_A, conRecLength_M, lag, lagDiff, test, RelDate
|
|
75
|
-
FROM %s
|
|
76
|
-
LEFT JOIN tblMasterTag ON %s.FreqCode = tblMasterTag.FreqCode
|
|
77
|
-
LEFT JOIN tblOverlap ON %s.FreqCode = tblOverlap.FreqCode AND %s.Epoch = tblOverlap.Epoch AND %s.recID = tblOverlap.recID
|
|
78
|
-
LEFT JOIN tblPresence ON %s.FreqCode = tblPresence.FreqCode AND %s.Epoch = tblPresence.Epoch AND %s.recID = tblPresence.recID'''%(max_iter_dict[j],max_iter_dict[j],max_iter_dict[j],max_iter_dict[j],max_iter_dict[j],max_iter_dict[j],max_iter_dict[j],max_iter_dict[j],max_iter_dict[j],max_iter_dict[j],max_iter_dict[j])
|
|
79
|
-
else:
|
|
80
|
-
sql = '''SELECT %s.FreqCode, %s.Epoch, %s.recID, timeStamp,presence_number, overlapping,test, RelDate
|
|
81
|
-
FROM %s
|
|
82
|
-
LEFT JOIN tblMasterTag ON %s.FreqCode = tblMasterTag.FreqCode
|
|
83
|
-
LEFT JOIN tblOverlap ON %s.FreqCode = tblOverlap.FreqCode AND %s.Epoch = tblOverlap.Epoch AND %s.recID = tblOverlap.recID
|
|
84
|
-
LEFT JOIN tblPresence ON %s.FreqCode = tblPresence.FreqCode AND %s.Epoch = tblPresence.Epoch AND %s.recID = tblPresence.recID'''%(max_iter_dict[j],max_iter_dict[j],max_iter_dict[j],max_iter_dict[j],max_iter_dict[j],max_iter_dict[j],max_iter_dict[j],max_iter_dict[j],max_iter_dict[j],max_iter_dict[j],max_iter_dict[j])
|
|
85
|
-
dat = pd.read_sql(sql, con = conn, coerce_float = True) # get data for this receiver
|
|
86
|
-
dat['overlapping'].fillna(0,inplace = True)
|
|
87
|
-
#dat = dat[dat.overlapping == 0]
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
else:
|
|
91
|
-
|
|
92
|
-
if 'hitRatio_A' in names:
|
|
93
|
-
sql = '''SELECT %s.FreqCode, %s.Epoch, %s.recID, timeStamp, hitRatio_A, hitRatio_M, detHist_A, detHist_M, conRecLength_A, conRecLength_M, lag, lagDiff, test, RelDate
|
|
94
|
-
FROM %s
|
|
95
|
-
LEFT JOIN tblMasterTag ON %s.FreqCode = tblMasterTag.FreqCode'''%(max_iter_dict[j],max_iter_dict[j],max_iter_dict[j],max_iter_dict[j],max_iter_dict[j])
|
|
96
|
-
|
|
97
|
-
else:
|
|
98
|
-
sql = '''SELECT %s.FreqCode, %s.Epoch, %s.recID, timeStamp, test, RelDate
|
|
99
|
-
FROM %s
|
|
100
|
-
LEFT JOIN tblMasterTag ON %s.FreqCode = tblMasterTag.FreqCode'''%(max_iter_dict[j],max_iter_dict[j],max_iter_dict[j],max_iter_dict[j],max_iter_dict[j])
|
|
101
|
-
|
|
102
|
-
dat = pd.read_sql(sql, con = conn, coerce_float = True) # get data for this receiver
|
|
103
|
-
dat['presence_number'] = np.zeros(len(dat))
|
|
104
|
-
dat['overlapping'] = np.zeros(len(dat))
|
|
105
|
-
|
|
106
|
-
dat = dat[dat.test == 1]
|
|
107
|
-
dat['RelDate'] = pd.to_datetime(dat.RelDate)
|
|
108
|
-
dat['timeStamp'] = pd.to_datetime(dat.timeStamp)
|
|
109
|
-
if hitRatio_Filter == True:
|
|
110
|
-
dat = dat[(dat.hitRatio_A > 0.10)]# | (dat.hitRatio_M > 0.10)]
|
|
111
|
-
if con_rec_filter == True:
|
|
112
|
-
dat = dat[dat.conRecLength_A >= 2]
|
|
113
|
-
if pre_release_Filter == True:
|
|
114
|
-
dat = dat[(dat.timeStamp >= dat.RelDate)]
|
|
115
|
-
recapdata = recapdata.append(dat)
|
|
116
|
-
del dat
|
|
117
|
-
c.close()
|
|
118
|
-
|
|
119
|
-
recapdata.drop_duplicates(keep = 'first', inplace = True)
|
|
120
|
-
return recapdata
|
|
121
|
-
|
|
122
|
-
def vr2_recaps(projectDB, pre_release_Filter = False):
|
|
123
|
-
'''If the VR2 acoustic study uses large random pulse widths, the false positive
|
|
124
|
-
reduction algorithm used in BIOTAS is moot. We will never be able to create
|
|
125
|
-
a useful detection history, which is central to the algorithm. However,
|
|
126
|
-
we can still use BIOTAS for data management, model building and analysis.
|
|
127
|
-
|
|
128
|
-
This function creates tblRecaptures from tblRaw
|
|
129
|
-
'''
|
|
130
|
-
# connect to project database and get tags
|
|
131
|
-
conn = sqlite3.connect(projectDB) #
|
|
132
|
-
c = conn.cursor()
|
|
133
|
-
|
|
134
|
-
tags = pd.read_sql("SELECT * FROM tblMasterTag WHERE TagType == 'Study'", con = conn)
|
|
135
|
-
tags = tags.FreqCode.unique()
|
|
136
|
-
|
|
137
|
-
recapdata = pd.DataFrame()
|
|
138
|
-
|
|
139
|
-
# build a recaptures table
|
|
140
|
-
for tag in tags:
|
|
141
|
-
tag_dat = pd.read_sql("SELECT * FROM tblRaw WHERE FreqCode =='%s'"%(tag), con = conn)
|
|
142
|
-
recapdata = recapdata.append(tag_dat)
|
|
143
|
-
|
|
144
|
-
c.close()
|
|
145
|
-
|
|
146
|
-
recapdata.drop_duplicates(keep = 'first', inplace = True)
|
|
147
|
-
|
|
148
|
-
# make all test = 1 and overlapping = 1
|
|
149
|
-
recapdata['test'] = np.repeat(1,len(recapdata))
|
|
150
|
-
recapdata['overlapping'] = np.zeros(len(recapdata))
|
|
151
|
-
|
|
152
|
-
# return dataframe
|
|
153
|
-
return recapdata
|
|
154
|
-
|
pymast-0.0.5.dist-info/METADATA
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: pymast
|
|
3
|
-
Version: 0.0.5
|
|
4
|
-
Summary: Movement Analysis Software for Telemetry (MAST) for
|
|
5
|
-
Home-page: https://github.com/knebiolo/mast
|
|
6
|
-
Author: Kevin P. Nebiolo and Theodore Castro-Santos
|
|
7
|
-
Author-email: kevin.nebiolo@kleinschmidtgroup.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Requires-Python: >=3.5
|
|
10
|
-
License-File: LICENSE.txt
|
|
11
|
-
Requires-Dist: numpy >=1.17.4
|
|
12
|
-
Requires-Dist: pandas >=0.25.3
|
|
13
|
-
Requires-Dist: matplotlib >=3.1.1
|
|
14
|
-
Requires-Dist: statsmodels >=0.10.1
|
|
15
|
-
Requires-Dist: networkx >=2.2
|
|
16
|
-
Requires-Dist: scipy >=1.7.1
|
|
17
|
-
Requires-Dist: scikit-learn
|
|
18
|
-
Requires-Dist: h5py
|
|
19
|
-
|
pymast-0.0.5.dist-info/RECORD
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
pymast/__init__.py,sha256=lvDHHvhI7UL2F5QLDU_2b62OUnRTlhybslr6aTn27Z0,538
|
|
2
|
-
pymast/fish_history.py,sha256=XaubGDRLfR89v2rIrFvkf7AKOLMTA5z--KyCJoXqnv4,6822
|
|
3
|
-
pymast/formatter.py,sha256=Iq0VYtA-U7j7z7e-5H1OfRd0uP5dod2ptOKs2GK8hlc,58555
|
|
4
|
-
pymast/naive_bayes.py,sha256=pjB8LSIFM8-fW7sohy5gCuFgKk1VP5yh63raMp9mdEU,6475
|
|
5
|
-
pymast/overlap_removal.py,sha256=4SwP8qZDqEYZ6_I0xGlI6647bTt45EaGDP5FxbqddZo,25416
|
|
6
|
-
pymast/parsers.py,sha256=b5H_a6tv0RxlNe_NhdnjJilA30Uo9kDq8w8WGP6bT8s,59248
|
|
7
|
-
pymast/predictors.py,sha256=VEWnhxgJcbnag8h6DNpWbeWgGiK9YyV_3N4xkcJFjdo,8018
|
|
8
|
-
pymast/radio_project.py,sha256=QT9l_qyZTKWqTu55kpgIESPDR1dnjajEQlUBYSg0H8Q,55502
|
|
9
|
-
pymast/table_merge.py,sha256=7_z4F_q3DW3RFXruRH6Qanum7E5QQQnu_w6qyyW-YVc,7921
|
|
10
|
-
pymast-0.0.5.dist-info/LICENSE.txt,sha256=CX_nvzXXwOA7SPq4-ivN4Q9NIK2PfK-KGHt3ZQKldsw,1143
|
|
11
|
-
pymast-0.0.5.dist-info/METADATA,sha256=JQhu_VTKXY3Hxr6-boeylXBqVR3ywx4iiwu0dymRM1M,577
|
|
12
|
-
pymast-0.0.5.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
13
|
-
pymast-0.0.5.dist-info/top_level.txt,sha256=LDZpLLge9zI4yvuMYoABLrsOrZzE3bYDRULmHoZQc4k,7
|
|
14
|
-
pymast-0.0.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|