pymast 0.0.1__tar.gz → 0.0.2__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pymast
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: Movement Analysis Software for Telemetry (MAST) for
5
5
  Home-page: https://github.com/knebiolo/mast
6
6
  Author: Kevin P. Nebiolo and Theodore Castro-Santos
@@ -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
- <<<<<<< Updated upstream:mast/__init__.py
18
- from .radio_project import *
19
- =======
17
+
20
18
  from .radio_project import *
21
19
 
22
- >>>>>>> Stashed changes:biotas_refactor/__init__.py
20
+
21
+
@@ -15,7 +15,7 @@ import sqlite3
15
15
  import datetime
16
16
  from matplotlib import rcParams
17
17
  from scipy import interpolate
18
- from mast.radio_project import radio_project
18
+ from pymast.radio_project import radio_project
19
19
 
20
20
 
21
21
  font = {'family': 'serif','size': 6}
@@ -77,46 +77,42 @@ class cjs_data_prep():
77
77
  '''
78
78
 
79
79
  print ("Adding release time for this fish")
80
- sql = "SELECT FreqCode, TagType, RelDate, RelLoc, CapLoc FROM tblMasterTag WHERE TagType = 'Study'"
81
- relDat = pd.read_sql_query(sql,con = conn, parse_dates = 'RelDate')
80
+ rel_dat = project.tags
82
81
  if self.rel_loc is not None:
83
- relDat = relDat[relDat.RelLoc == rel_loc]
82
+ rel_dat = rel_dat[rel_dat.rel_loc == rel_loc]
84
83
  if self.cap_loc is not None:
85
- relDat = relDat[relDat.CapLoc == cap_loc]
86
- relDat['RelDate'] = pd.to_datetime(relDat.RelDate)
87
- relDat['Epoch'] = (relDat['RelDate'] - datetime.datetime(1970,1,1)).dt.total_seconds()
88
- relDat.rename(columns = {'RelDate':'timeStamp'}, inplace = True)
89
- relDat['RecapOccasion'] = np.repeat('R00',len(relDat))
90
- #relDat.dropna(inplace =True)
91
- relDat['overlapping'] = np.zeros(len(relDat))
92
- self.data = self.data.append(relDat)
93
-
84
+ rel_dat = rel_dat[rel_dat.cap_loc == cap_loc]
85
+ rel_dat['rel_date'] = pd.to_datetime(rel_dat.rel_date)
86
+ rel_dat['epoch'] = (rel_dat['rel_date'] - datetime.datetime(1970,1,1)).dt.total_seconds()
87
+ rel_dat.rename(columns = {'rel_date':'time_stamp'}, inplace = True)
88
+ rel_dat['recap_occasion'] = np.repeat('R00',len(rel_dat))
89
+ rel_dat['overlapping'] = np.zeros(len(rel_dat))
90
+ self.recap_data = pd.concat([self.recap_data,rel_dat],axis = 0)
94
91
 
95
92
  else:
96
93
  print ("Starting Initial Recap Release Procedure")
97
94
  # Identify first recapture times
98
- startTimes = self.data[self.data.RecapOccasion == "R00"].groupby(['FreqCode'])['Epoch'].min().to_frame()
99
- startTimes.reset_index(drop = False, inplace = True)
100
- startTimes.set_index('FreqCode',inplace = True)
101
- startTimes.rename(columns = {'Epoch':'FirstRecapture'},inplace = True)
95
+ start_times = self.recap_data[self.recap_data.recap_occasion == "R00"].groupby(['freq_code'])['epoch'].min().to_frame()
96
+ start_times.reset_index(drop = False, inplace = True)
97
+ start_times.set_index('freq_code',inplace = True)
98
+ start_times.rename(columns = {'epoch':'first_recapture'},inplace = True)
102
99
 
103
100
  # make sure fish start from the first recapture occassion and that there are no recaps before release
104
- for fish in self.data.FreqCode.unique():
101
+ for fish in self.recap_data.freq_code.unique():
105
102
 
106
- if fish not in startTimes.index.values:
103
+ if fish not in start_times.index.values:
107
104
  # fish never made it to the initial state
108
- self.data.drop(self.data[self.data.FreqCode == fish].index, inplace = True)
105
+ self.recap_dat.drop(self.recap_dat[self.recap_data.freq_code == fish].index, inplace = True)
109
106
  else:
110
107
  # fish arrived at the initial state but their may be recaptures before arrival at initial state
111
- t = startTimes.at[fish,'FirstRecapture']
112
- self.data.drop(self.data[(self.data.FreqCode == fish) & (self.data.Epoch < t)].index, inplace = True)
108
+ t = start_times.at[fish,'first_recapture']
109
+ self.recap_data.drop(self.recap_data[(self.recap_data.freq_code == fish) & (self.recap_data.epoch < t)].index, inplace = True)
113
110
 
114
- print (self.data.head())
115
- c.close()
111
+ print (self.recap_data.head())
116
112
 
117
- def input_file(self,modelName, outputWS):
113
+ def input_file(self,model_name, output_ws):
118
114
  #Step 1: Create cross tabulated data frame with FreqCode as row index and recap occasion as column
119
- cross_tab = pd.pivot_table(self.data, values = 'Epoch', index = 'FreqCode', columns = 'RecapOccasion', aggfunc = 'min')
115
+ cross_tab = pd.pivot_table(self.recap_data, values = 'epoch', index = 'freq_code', columns = 'recap_occasion', aggfunc = 'min')
120
116
 
121
117
  #Step 2: Fill in those nan values with 0, we can't perform logic on nothing!'''
122
118
  cross_tab.fillna(value = 0, inplace = True)
@@ -134,7 +130,7 @@ class cjs_data_prep():
134
130
  self.cross = cross_tab
135
131
  # Check your work
136
132
  print (cross_tab.head(100))
137
- cross_tab.to_csv(os.path.join(outputWS,'%s_cjs.csv'%(modelName)))
133
+ cross_tab.to_csv(os.path.join(output_ws,'%s_cjs.csv'%(model_name)))
138
134
 
139
135
  class lrdr_data_prep():
140
136
  '''Class creates input files for Live Recapture Dead Recovery modeling in MARK'''
@@ -4,7 +4,7 @@ import pandas as pd
4
4
  import numpy as np
5
5
  import datetime
6
6
  import os
7
- import mast.predictors as predictors
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',
@@ -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
- telem_dat_sub['setup'] = get_setup(telem_dat_sub.epoch.values,
855
- setup_df.epoch.values)
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',
@@ -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))
@@ -9,9 +9,9 @@ import pandas as pd
9
9
  import os
10
10
  import h5py
11
11
  import datetime
12
- import mast.naive_bayes as naive_bayes
13
- import mast.parsers as parsers
14
- import mast.predictors as predictors
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
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pymast
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: Movement Analysis Software for Telemetry (MAST) for
5
5
  Home-page: https://github.com/knebiolo/mast
6
6
  Author: Kevin P. Nebiolo and Theodore Castro-Santos
@@ -1,7 +1,7 @@
1
1
  from setuptools import setup
2
2
 
3
3
  setup(name = 'pymast',
4
- version = '0.0.1',
4
+ version = '0.0.2',
5
5
  description = '''Movement Analysis Software for Telemetry (MAST) for
6
6
  use in removing false positive and overlap detections from radio telemetry
7
7
  projects and assessing 1D movement patterns.''',
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes