Linting scripts/analyze.py

This commit is contained in:
Jake Herbst
2022-05-24 12:27:31 -04:00
parent 298b2a85e7
commit 01456ce583
+56 -15
View File
@@ -11,6 +11,7 @@ ADDR = (SERVER, PORT)
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(ADDR)
def send(msg):
message = msg.encode(FORMAT)
msg_length = len(message)
@@ -20,6 +21,7 @@ def send(msg):
client.send(message)
print(client.recv(2048).decode(FORMAT))
def main():
global INCLUDE_LIST
@@ -28,16 +30,52 @@ def main():
# Parse passed arguments
parser = argparse.ArgumentParser()
parser.add_argument('--i', help='Path to input file.')
parser.add_argument('--o', default='result.csv', help='Path to output file. Defaults to result.csv.')
parser.add_argument('--lat', type=float, default=-1, help='Recording location latitude. Set -1 to ignore.')
parser.add_argument('--lon', type=float, default=-1, help='Recording location longitude. Set -1 to ignore.')
parser.add_argument('--week', type=int, default=-1, help='Week of the year when the recording was made. Values in [1, 48] (4 weeks per month). Set -1 to ignore.')
parser.add_argument('--overlap', type=float, default=0.0, help='Overlap in seconds between extracted spectrograms. Values in [0.0, 2.9]. Defaults tp 0.0.')
parser.add_argument('--sensitivity', type=float, default=1.0, help='Detection sensitivity; Higher values result in higher sensitivity. Values in [0.5, 1.5]. Defaults to 1.0.')
parser.add_argument('--min_conf', type=float, default=0.1, help='Minimum confidence threshold. Values in [0.01, 0.99]. Defaults to 0.1.')
parser.add_argument('--include_list', default='null', help='Path to text file containing a list of included species. Not used if not provided.')
parser.add_argument('--exclude_list', default='null', help='Path to text file containing a list of excluded species. Not used if not provided.')
parser.add_argument('--birdweather_id', default='99999', help='Private Station ID for BirdWeather.')
parser.add_argument(
'--o',
default='result.csv',
help='Path to output file. Defaults to result.csv.')
parser.add_argument(
'--lat',
type=float,
default=-1,
help='Recording location latitude. Set -1 to ignore.')
parser.add_argument(
'--lon',
type=float,
default=-1,
help='Recording location longitude. Set -1 to ignore.')
parser.add_argument(
'--week',
type=int,
default=-1,
help='Week of the year when the recording was made. Values in [1, 48] (4 weeks per month). Set -1 to ignore.')
parser.add_argument(
'--overlap',
type=float,
default=0.0,
help='Overlap in seconds between extracted spectrograms. Values in [0.0, 2.9]. Defaults tp 0.0.')
parser.add_argument(
'--sensitivity',
type=float,
default=1.0,
help='Detection sensitivity; Higher values result in higher sensitivity. Values in [0.5, 1.5]. Defaults to 1.0.')
parser.add_argument(
'--min_conf',
type=float,
default=0.1,
help='Minimum confidence threshold. Values in [0.01, 0.99]. Defaults to 0.1.')
parser.add_argument(
'--include_list',
default='null',
help='Path to text file containing a list of included species. Not used if not provided.')
parser.add_argument(
'--exclude_list',
default='null',
help='Path to text file containing a list of excluded species. Not used if not provided.')
parser.add_argument(
'--birdweather_id',
default='99999',
help='Private Station ID for BirdWeather.')
args = parser.parse_args()
@@ -64,14 +102,15 @@ def main():
sockParams += 'lat=' + str(args.lat) + '||'
if args.lon:
sockParams += 'lon=' + str(args.lon) + '||'
send(sockParams)
send(DISCONNECT_MESSAGE)
#time.sleep(3)
# time.sleep(3)
###############################################################################
###############################################################################
###############################################################################
###############################################################################
if __name__ == '__main__':
@@ -79,4 +118,6 @@ if __name__ == '__main__':
# Example calls
# python3 analyze.py --i 'example/XC558716 - Soundscape.mp3' --lat 35.4244 --lon -120.7463 --week 18
# python3 analyze.py --i 'example/XC563936 - Soundscape.mp3' --lat 47.6766 --lon -122.294 --week 11 --overlap 1.5 --min_conf 0.25 --sensitivity 1.25 --custom_list 'example/custom_species_list.txt'
# python3 analyze.py --i 'example/XC563936 - Soundscape.mp3' --lat 47.6766
# --lon -122.294 --week 11 --overlap 1.5 --min_conf 0.25 --sensitivity
# 1.25 --custom_list 'example/custom_species_list.txt'