-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArgosSelectionTool.py
More file actions
61 lines (51 loc) · 2.03 KB
/
Copy pathArgosSelectionTool.py
File metadata and controls
61 lines (51 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#-------------------------------------------------------------
# ArgosSelectionTool.py
#
# Description: Reads in an Argos tracking data file and allows
# the user to identify the tracked sitings found within a
# specified bounding box.
#
# Author: John Fay (john.fay@duke.edu)
# Date: Fall 2026
#--------------------------------------------------------------
# Create the geogrpahic selection box
the_box = {
'x_min': 34.00,
'y_min': -76.0,
'x_max': 34.50,
'y_max': -75.00
}
#Create a variable pointing to the data file
file_name = 'data/raw/Satellite tracking of black-capped petrels 2019-argos.csv'
#Read the contents of the file into a list of lines
f = open(file_name,'r')
#Read the headerline
headerLine = f.readline()
#Read contents of one line
lineString = f.readline()
#Pretend we read one line of data from the file
while lineString != "":
# Use the split command to parse the items in lineString into a list object
line_data = lineString.split(',')
# Assign variables to specfic items in the list
event_id = line_data[0] # Argos tracking event ID ("event-id")
timestamp = line_data[2] # Observation date ("timestamp")
lc = line_data[14] # Observation location class ("argos:lc")
if lc not in ['"1"','"2"','"3"']:
lineString = f.readline()
continue
lat = float(line_data[3]) # Observation latitude ("location-lat")
lon = float(line_data[4]) # Observation longitude ("location-lon")
tag_id = line_data[-3] # Tag identifier ("tag-local-identifier")
#Evaluate latitude and longitude conditions
lat_condition = the_box['y_min'] < lat < the_box['y_max']
lon_condition = the_box['x_min'] < lon < the_box['x_max']
#Report the status of the points
if lat_condition & lon_condition:
print(f'Record {event_id}: {tag_id} was IN the box at {timestamp}')
else:
print(f'Record {event_id}: {tag_id} was NOT IN the box at {timestamp}')
#Update line string
lineString = f.readline()
#Close the file
f.close()