pymast 0.0.1__py3-none-any.whl → 0.0.3__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 +3 -4
- pymast/formatter.py +34 -34
- pymast/parsers.py +11 -8
- pymast/predictors.py +1 -0
- pymast/radio_project.py +8 -12
- {pymast-0.0.1.dist-info → pymast-0.0.3.dist-info}/METADATA +1 -1
- pymast-0.0.3.dist-info/RECORD +14 -0
- {pymast-0.0.1.dist-info → pymast-0.0.3.dist-info}/WHEEL +1 -1
- pymast-0.0.1.dist-info/RECORD +0 -14
- {pymast-0.0.1.dist-info → pymast-0.0.3.dist-info}/LICENSE.txt +0 -0
- {pymast-0.0.1.dist-info → pymast-0.0.3.dist-info}/top_level.txt +0 -0
pymast/__init__.py
CHANGED
|
@@ -14,9 +14,8 @@ from .overlap_removal import *
|
|
|
14
14
|
from .parsers import *
|
|
15
15
|
|
|
16
16
|
# Finally, import the radio_project class, which depends on parsers, predictor, and naive_bayes
|
|
17
|
-
|
|
18
|
-
from .radio_project import *
|
|
19
|
-
=======
|
|
17
|
+
|
|
20
18
|
from .radio_project import *
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
|
|
21
|
+
|
pymast/formatter.py
CHANGED
|
@@ -15,7 +15,7 @@ import sqlite3
|
|
|
15
15
|
import datetime
|
|
16
16
|
from matplotlib import rcParams
|
|
17
17
|
from scipy import interpolate
|
|
18
|
-
from
|
|
18
|
+
from pymast.radio_project import radio_project
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
font = {'family': 'serif','size': 6}
|
|
@@ -43,15 +43,19 @@ class cjs_data_prep():
|
|
|
43
43
|
query_parts.append(f"rec_id == '{key}'")
|
|
44
44
|
qry = " & ".join(query_parts)
|
|
45
45
|
|
|
46
|
-
recap_data = pd.read_hdf(project.db,
|
|
47
|
-
'recaptures'
|
|
48
|
-
where = qry)
|
|
46
|
+
self.recap_data = pd.read_hdf(project.db,
|
|
47
|
+
'recaptures')#,
|
|
48
|
+
#where = qry)
|
|
49
49
|
|
|
50
|
-
self.recap_data.set_index('freq_code', inplace = True)
|
|
51
|
-
project.tags.
|
|
52
|
-
self.recap_data = pd.merge(recap_data,
|
|
50
|
+
#self.recap_data.set_index('freq_code', inplace = True)
|
|
51
|
+
project.tags.reset_index('freq_code', inplace = True)
|
|
52
|
+
self.recap_data = pd.merge(self.recap_data,
|
|
53
|
+
project.tags,
|
|
54
|
+
left_on = 'freq_code',
|
|
55
|
+
right_on = 'freq_code',
|
|
56
|
+
how = 'left')
|
|
53
57
|
self.recap_data.reset_index(drop = False, inplace = True)
|
|
54
|
-
project.tags.reset_index(drop = False, inplace = True)
|
|
58
|
+
#project.tags.reset_index(drop = False, inplace = True)
|
|
55
59
|
|
|
56
60
|
# filter out tag data we don't want mucking up our staistical model
|
|
57
61
|
if species != None:
|
|
@@ -77,46 +81,42 @@ class cjs_data_prep():
|
|
|
77
81
|
'''
|
|
78
82
|
|
|
79
83
|
print ("Adding release time for this fish")
|
|
80
|
-
|
|
81
|
-
relDat = pd.read_sql_query(sql,con = conn, parse_dates = 'RelDate')
|
|
84
|
+
rel_dat = project.tags
|
|
82
85
|
if self.rel_loc is not None:
|
|
83
|
-
|
|
86
|
+
rel_dat = rel_dat[rel_dat.rel_loc == rel_loc]
|
|
84
87
|
if self.cap_loc is not None:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
self.data = self.data.append(relDat)
|
|
93
|
-
|
|
88
|
+
rel_dat = rel_dat[rel_dat.cap_loc == cap_loc]
|
|
89
|
+
rel_dat['rel_date'] = pd.to_datetime(rel_dat.rel_date)
|
|
90
|
+
rel_dat['epoch'] = (rel_dat['rel_date'] - datetime.datetime(1970,1,1)).dt.total_seconds()
|
|
91
|
+
rel_dat.rename(columns = {'rel_date':'time_stamp'}, inplace = True)
|
|
92
|
+
rel_dat['recap_occasion'] = np.repeat('R00',len(rel_dat))
|
|
93
|
+
rel_dat['overlapping'] = np.zeros(len(rel_dat))
|
|
94
|
+
self.recap_data = pd.concat([self.recap_data,rel_dat],axis = 0)
|
|
94
95
|
|
|
95
96
|
else:
|
|
96
97
|
print ("Starting Initial Recap Release Procedure")
|
|
97
98
|
# Identify first recapture times
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
start_times = self.recap_data[self.recap_data.recap_occasion == "R00"].groupby(['freq_code'])['epoch'].min().to_frame()
|
|
100
|
+
start_times.reset_index(drop = False, inplace = True)
|
|
101
|
+
start_times.set_index('freq_code',inplace = True)
|
|
102
|
+
start_times.rename(columns = {'epoch':'first_recapture'},inplace = True)
|
|
102
103
|
|
|
103
104
|
# make sure fish start from the first recapture occassion and that there are no recaps before release
|
|
104
|
-
for fish in self.
|
|
105
|
+
for fish in self.recap_data.freq_code.unique():
|
|
105
106
|
|
|
106
|
-
if fish not in
|
|
107
|
+
if fish not in start_times.index.values:
|
|
107
108
|
# fish never made it to the initial state
|
|
108
|
-
self.
|
|
109
|
+
self.recap_data.drop(self.recap_data[self.recap_data.freq_code == fish].index, inplace = True)
|
|
109
110
|
else:
|
|
110
111
|
# fish arrived at the initial state but their may be recaptures before arrival at initial state
|
|
111
|
-
t =
|
|
112
|
-
self.
|
|
112
|
+
t = start_times.at[fish,'first_recapture']
|
|
113
|
+
self.recap_data.drop(self.recap_data[(self.recap_data.freq_code == fish) & (self.recap_data.epoch < t)].index, inplace = True)
|
|
113
114
|
|
|
114
|
-
print (self.
|
|
115
|
-
c.close()
|
|
115
|
+
print (self.recap_data.head())
|
|
116
116
|
|
|
117
|
-
def input_file(self,
|
|
117
|
+
def input_file(self,model_name, output_ws):
|
|
118
118
|
#Step 1: Create cross tabulated data frame with FreqCode as row index and recap occasion as column
|
|
119
|
-
cross_tab = pd.pivot_table(self.
|
|
119
|
+
cross_tab = pd.pivot_table(self.recap_data, values = 'epoch', index = 'freq_code', columns = 'recap_occasion', aggfunc = 'min')
|
|
120
120
|
|
|
121
121
|
#Step 2: Fill in those nan values with 0, we can't perform logic on nothing!'''
|
|
122
122
|
cross_tab.fillna(value = 0, inplace = True)
|
|
@@ -134,7 +134,7 @@ class cjs_data_prep():
|
|
|
134
134
|
self.cross = cross_tab
|
|
135
135
|
# Check your work
|
|
136
136
|
print (cross_tab.head(100))
|
|
137
|
-
cross_tab.to_csv(os.path.join(
|
|
137
|
+
cross_tab.to_csv(os.path.join(output_ws,'%s_cjs.csv'%(model_name)))
|
|
138
138
|
|
|
139
139
|
class lrdr_data_prep():
|
|
140
140
|
'''Class creates input files for Live Recapture Dead Recovery modeling in MARK'''
|
pymast/parsers.py
CHANGED
|
@@ -4,7 +4,7 @@ import pandas as pd
|
|
|
4
4
|
import numpy as np
|
|
5
5
|
import datetime
|
|
6
6
|
import os
|
|
7
|
-
import
|
|
7
|
+
import pymast.predictors as predictors
|
|
8
8
|
|
|
9
9
|
def ares(file_name,
|
|
10
10
|
db_dir,
|
|
@@ -222,7 +222,7 @@ def orion_import(file_name,
|
|
|
222
222
|
|
|
223
223
|
telem_dat_sub = telem_dat_sub.astype({'power':'float32',
|
|
224
224
|
'freq_code':'object',
|
|
225
|
-
'time_stamp':'datetime64',
|
|
225
|
+
'time_stamp':'datetime64[ns]',
|
|
226
226
|
'scan_time':'float32',
|
|
227
227
|
'channels':'int32',
|
|
228
228
|
'rec_type':'object',
|
|
@@ -495,7 +495,7 @@ def srx1200(file_name,
|
|
|
495
495
|
# format frequency code
|
|
496
496
|
telem_dat['FreqNo'] = telem_dat['Freq [MHz]'].apply(lambda x: f"{x:.3f}" )
|
|
497
497
|
telem_dat = telem_dat[telem_dat['Tag/BPM'] != 999]
|
|
498
|
-
telem_dat['freq_code'] = telem_dat['FreqNo'] + ' ' + telem_dat['Tag/BPM'].astype(
|
|
498
|
+
telem_dat['freq_code'] = telem_dat['FreqNo'] + ' ' + telem_dat['Tag/BPM'].astype(str)
|
|
499
499
|
|
|
500
500
|
# calculate
|
|
501
501
|
telem_dat['noise_ratio'] = predictors.noise_ratio(600,
|
|
@@ -572,7 +572,7 @@ def srx1200(file_name,
|
|
|
572
572
|
telem_dat['FreqNo'] = telem_dat['Freq [MHz]'].apply(lambda x: f"{x:.3f}" )
|
|
573
573
|
telem_dat = telem_dat[telem_dat['TagID/BPM'] != 999]
|
|
574
574
|
|
|
575
|
-
telem_dat['freq_code'] = telem_dat['FreqNo'] + ' ' + telem_dat['TagID/BPM'].astype(
|
|
575
|
+
telem_dat['freq_code'] = telem_dat['FreqNo'] + ' ' + telem_dat['TagID/BPM'].astype(str)
|
|
576
576
|
|
|
577
577
|
# calculate
|
|
578
578
|
telem_dat['noise_ratio'] = predictors.noise_ratio(600,
|
|
@@ -741,7 +741,7 @@ def srx800(file_name,
|
|
|
741
741
|
split = setup_df['change_date'].str.split(' ', expand=True)
|
|
742
742
|
setup_df['day0'] = np.repeat(pd.to_datetime("1900-01-01"),len(setup_df))
|
|
743
743
|
setup_df['Date'] = setup_df['day0'] + pd.to_timedelta(split[1].astype(int), unit='d')
|
|
744
|
-
setup_df['change_date'] = setup_df.Date.astype(
|
|
744
|
+
setup_df['change_date'] = setup_df.Date.astype(str) + ' ' + split[2]
|
|
745
745
|
|
|
746
746
|
|
|
747
747
|
setup_df['change_date'] = pd.to_datetime(setup_df.change_date)
|
|
@@ -851,8 +851,11 @@ def srx800(file_name,
|
|
|
851
851
|
telem_dat_sub['epoch'] = np.round((telem_dat_sub.time_stamp - pd.Timestamp("1970-01-01")) / pd.Timedelta('1s'),6)
|
|
852
852
|
|
|
853
853
|
# get setup number for every row
|
|
854
|
-
|
|
855
|
-
|
|
854
|
+
try:
|
|
855
|
+
telem_dat_sub['setup'] = get_setup(telem_dat_sub.epoch.values,
|
|
856
|
+
setup_df.epoch.values)
|
|
857
|
+
except:
|
|
858
|
+
print ('why you fail?')
|
|
856
859
|
|
|
857
860
|
# get frequency from channel
|
|
858
861
|
telem_dat_sub['Frequency'] = get_frequency(telem_dat_sub.setup.values,
|
|
@@ -890,7 +893,7 @@ def srx800(file_name,
|
|
|
890
893
|
# write to hdf
|
|
891
894
|
telem_dat_sub = telem_dat_sub.astype({'power':'float32',
|
|
892
895
|
'freq_code':'object',
|
|
893
|
-
'time_stamp':'datetime64',
|
|
896
|
+
'time_stamp':'datetime64[ns]',
|
|
894
897
|
'scan_time':'float32',
|
|
895
898
|
'channels':'int32',
|
|
896
899
|
'rec_type':'object',
|
pymast/predictors.py
CHANGED
|
@@ -121,6 +121,7 @@ def detection_history (epoch, pulse_rate, num_detects, num_channels, scan_time,
|
|
|
121
121
|
lower_limit_dict[i] = np.where(scan_time > 2 * pulse_rate,
|
|
122
122
|
epoch + (pulse_rate * i - 1),
|
|
123
123
|
epoch + ((scan_time * channels * i) - 1))
|
|
124
|
+
|
|
124
125
|
upper_limit_dict[i] = np.where(scan_time > 2 * pulse_rate,
|
|
125
126
|
epoch + (pulse_rate * i + 1),
|
|
126
127
|
epoch + ((scan_time * channels * i) + 1))
|
pymast/radio_project.py
CHANGED
|
@@ -9,9 +9,9 @@ import pandas as pd
|
|
|
9
9
|
import os
|
|
10
10
|
import h5py
|
|
11
11
|
import datetime
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
12
|
+
import pymast.naive_bayes as naive_bayes
|
|
13
|
+
import pymast.parsers as parsers
|
|
14
|
+
import pymast.predictors as predictors
|
|
15
15
|
import matplotlib.pyplot as plt
|
|
16
16
|
from matplotlib import rcParams
|
|
17
17
|
from scipy import interpolate
|
|
@@ -295,7 +295,7 @@ class radio_project():
|
|
|
295
295
|
# make sure data types are correct - these next steps are critical
|
|
296
296
|
try:
|
|
297
297
|
train_dat = train_dat.astype({'power': 'float32',
|
|
298
|
-
'time_stamp': 'datetime64',
|
|
298
|
+
'time_stamp': 'datetime64[ns]',
|
|
299
299
|
'epoch': 'float32',
|
|
300
300
|
'freq_code': 'object',
|
|
301
301
|
'noise_ratio': 'float32',
|
|
@@ -486,12 +486,8 @@ class radio_project():
|
|
|
486
486
|
min_itemsize = {'freq_code':20,
|
|
487
487
|
'rec_type':20,
|
|
488
488
|
'rec_id':20,
|
|
489
|
-
<<<<<<< Updated upstream:mast/radio_project.py
|
|
490
489
|
'det_hist':20})
|
|
491
|
-
|
|
492
|
-
'det_hist':20})
|
|
493
|
-
>>>>>>> Stashed changes:biotas_refactor/radio_project.py
|
|
494
|
-
|
|
490
|
+
|
|
495
491
|
def undo_import(self, rec_id):
|
|
496
492
|
# Read the table from the HDF5 file
|
|
497
493
|
with pd.HDFStore(self.db, 'r+') as store:
|
|
@@ -712,7 +708,7 @@ class radio_project():
|
|
|
712
708
|
class_dat = class_dat.astype({'freq_code': 'object',
|
|
713
709
|
'epoch': 'float32',
|
|
714
710
|
'rec_id': 'object',
|
|
715
|
-
'time_stamp': 'datetime64',
|
|
711
|
+
'time_stamp': 'datetime64[ns]',
|
|
716
712
|
'power': 'float32',
|
|
717
713
|
'noise_ratio': 'float32',
|
|
718
714
|
'scan_time': 'int32',
|
|
@@ -1133,7 +1129,7 @@ class radio_project():
|
|
|
1133
1129
|
rec_dat = rec_dat.astype({'freq_code': 'object',
|
|
1134
1130
|
'epoch': 'float32',
|
|
1135
1131
|
'rec_id': 'object',
|
|
1136
|
-
'time_stamp': 'datetime64',
|
|
1132
|
+
'time_stamp': 'datetime64[ns]',
|
|
1137
1133
|
'power': 'float32',
|
|
1138
1134
|
'noise_ratio': 'float32',
|
|
1139
1135
|
'lag': 'float32',
|
|
@@ -1167,4 +1163,4 @@ class radio_project():
|
|
|
1167
1163
|
|
|
1168
1164
|
|
|
1169
1165
|
|
|
1170
|
-
|
|
1166
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
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=WNIp-D8P0978SjZlQbur9BZ5iY27AnTTaQUELWapMRI,59220
|
|
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.3.dist-info/LICENSE.txt,sha256=CX_nvzXXwOA7SPq4-ivN4Q9NIK2PfK-KGHt3ZQKldsw,1143
|
|
11
|
+
pymast-0.0.3.dist-info/METADATA,sha256=lpPvKs8ks4V3nLe6Zx6ROdXxeN7_69THPm_ngfBYBF8,572
|
|
12
|
+
pymast-0.0.3.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
13
|
+
pymast-0.0.3.dist-info/top_level.txt,sha256=LDZpLLge9zI4yvuMYoABLrsOrZzE3bYDRULmHoZQc4k,7
|
|
14
|
+
pymast-0.0.3.dist-info/RECORD,,
|
pymast-0.0.1.dist-info/RECORD
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
pymast/__init__.py,sha256=c5E_2yJ_rNRScps1oZDeDDbMmIg-9EhEJXHlT5Kr83s,667
|
|
2
|
-
pymast/fish_history.py,sha256=XaubGDRLfR89v2rIrFvkf7AKOLMTA5z--KyCJoXqnv4,6822
|
|
3
|
-
pymast/formatter.py,sha256=ayiiEkXWEM91FUXF1E1qd3kZOHPMJ2irzoHiDJG3ymY,58422
|
|
4
|
-
pymast/naive_bayes.py,sha256=pjB8LSIFM8-fW7sohy5gCuFgKk1VP5yh63raMp9mdEU,6475
|
|
5
|
-
pymast/overlap_removal.py,sha256=4SwP8qZDqEYZ6_I0xGlI6647bTt45EaGDP5FxbqddZo,25416
|
|
6
|
-
pymast/parsers.py,sha256=rTccM2QMIw7YBuBljyftuyiFiaXZXPfDz6jMrOA3ygA,59131
|
|
7
|
-
pymast/predictors.py,sha256=Nxbq9MdX4hru9ZiVdSneYKovpspJPjs3LA-SKCJxuLM,8016
|
|
8
|
-
pymast/radio_project.py,sha256=mFJlPkoq30n7I5YOV0QBH-NQVZS6YObxG14Db7mC5aE,55674
|
|
9
|
-
pymast/table_merge.py,sha256=7_z4F_q3DW3RFXruRH6Qanum7E5QQQnu_w6qyyW-YVc,7921
|
|
10
|
-
pymast-0.0.1.dist-info/LICENSE.txt,sha256=CX_nvzXXwOA7SPq4-ivN4Q9NIK2PfK-KGHt3ZQKldsw,1143
|
|
11
|
-
pymast-0.0.1.dist-info/METADATA,sha256=G8LRwAQXKnjS_RC58imwpHgKq5843Dt889LA_atmKB4,572
|
|
12
|
-
pymast-0.0.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
13
|
-
pymast-0.0.1.dist-info/top_level.txt,sha256=LDZpLLge9zI4yvuMYoABLrsOrZzE3bYDRULmHoZQc4k,7
|
|
14
|
-
pymast-0.0.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|