ecoscape-utilities 0.0.40__tar.gz → 0.0.41__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.
Potentially problematic release.
This version of ecoscape-utilities might be problematic. Click here for more details.
- {ecoscape_utilities-0.0.40 → ecoscape_utilities-0.0.41}/PKG-INFO +1 -1
- {ecoscape_utilities-0.0.40 → ecoscape_utilities-0.0.41}/ecoscape_utilities/ebird_db.py +121 -3
- {ecoscape_utilities-0.0.40 → ecoscape_utilities-0.0.41}/ecoscape_utilities.egg-info/PKG-INFO +1 -1
- {ecoscape_utilities-0.0.40 → ecoscape_utilities-0.0.41}/pyproject.toml +1 -1
- {ecoscape_utilities-0.0.40 → ecoscape_utilities-0.0.41}/LICENSE.md +0 -0
- {ecoscape_utilities-0.0.40 → ecoscape_utilities-0.0.41}/README.md +0 -0
- {ecoscape_utilities-0.0.40 → ecoscape_utilities-0.0.41}/ecoscape_utilities/__init__.py +0 -0
- {ecoscape_utilities-0.0.40 → ecoscape_utilities-0.0.41}/ecoscape_utilities/bird_runs.py +0 -0
- {ecoscape_utilities-0.0.40 → ecoscape_utilities-0.0.41}/ecoscape_utilities.egg-info/SOURCES.txt +0 -0
- {ecoscape_utilities-0.0.40 → ecoscape_utilities-0.0.41}/ecoscape_utilities.egg-info/dependency_links.txt +0 -0
- {ecoscape_utilities-0.0.40 → ecoscape_utilities-0.0.41}/ecoscape_utilities.egg-info/requires.txt +0 -0
- {ecoscape_utilities-0.0.40 → ecoscape_utilities-0.0.41}/ecoscape_utilities.egg-info/top_level.txt +0 -0
- {ecoscape_utilities-0.0.40 → ecoscape_utilities-0.0.41}/requirements.txt +0 -0
- {ecoscape_utilities-0.0.40 → ecoscape_utilities-0.0.41}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ecoscape-utilities
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.41
|
|
4
4
|
Summary: A collection of EcoScape utilities.
|
|
5
5
|
Author-email: Luca de Alfaro <luca@ucsc.edu>, Coen Adler <ctadler@ucsc.edu>, Artie Nazarov <anazarov@ucsc.edu>, Natalia Ocampo-Peñuela <nocampop@ucsc.edu>, Jasmine Tai <cjtai@ucsc.edu>, Natalie Valett <nvalett@ucsc.edu>
|
|
6
6
|
Project-URL: Homepage, https://github.com/ecoscape-earth/ecoscape-utilities
|
|
@@ -4,6 +4,7 @@ import os
|
|
|
4
4
|
import pandas as pd
|
|
5
5
|
import sqlite3
|
|
6
6
|
from sqlite3 import Error
|
|
7
|
+
import warnings
|
|
7
8
|
|
|
8
9
|
from collections import defaultdict
|
|
9
10
|
from pyproj import Transformer
|
|
@@ -170,6 +171,8 @@ class EbirdObservations(Connection):
|
|
|
170
171
|
:param min_time (int): minimum time in minutes for the checklist for any observation we consider
|
|
171
172
|
:returns: num_checklists, num_bird_checklists, num_birds for the given square.
|
|
172
173
|
"""
|
|
174
|
+
# Adds deprecation warning.
|
|
175
|
+
warnings.warn("This function is deprecated. Use get_square_checklists instead.", DeprecationWarning)
|
|
173
176
|
# Gets the number of checklists, the total time, the total distance, and the total number of birds.
|
|
174
177
|
query_string=['select COUNT(*), SUM("EFFORT DISTANCE KM"), SUM("DURATION MINUTES")',
|
|
175
178
|
'FROM checklist where SQUARE = :square']
|
|
@@ -268,6 +271,119 @@ class EbirdObservations(Connection):
|
|
|
268
271
|
total_km=total_km,
|
|
269
272
|
total_minutes=total_minutes,
|
|
270
273
|
)
|
|
274
|
+
|
|
275
|
+
def get_state_checklists(self, state, bird,
|
|
276
|
+
breeding=None, date_range=None,
|
|
277
|
+
lat_range=None, lng_range=None, max_dist=2,
|
|
278
|
+
verbose=False):
|
|
279
|
+
"""Returns a dataframe consisting of all checklists in a square, with data
|
|
280
|
+
on a (possible) occurrence of a bird."""
|
|
281
|
+
query_string = [
|
|
282
|
+
'SELECT checklist."SQUARE", ',
|
|
283
|
+
'checklist."SAMPLING EVENT IDENTIFIER", ',
|
|
284
|
+
'checklist."PROTOCOL TYPE", ',
|
|
285
|
+
'checklist."EFFORT DISTANCE KM", ',
|
|
286
|
+
'checklist."DURATION MINUTES", ',
|
|
287
|
+
'checklist."OBSERVATION DATE", ',
|
|
288
|
+
'checklist."TIME OBSERVATIONS STARTED", ',
|
|
289
|
+
'checklist."OBSERVER ID", ',
|
|
290
|
+
'checklist."LATITUDE", ',
|
|
291
|
+
'checklist."LONGITUDE", ',
|
|
292
|
+
'observation."OBSERVATION COUNT" ',
|
|
293
|
+
'FROM checklist LEFT JOIN observation ',
|
|
294
|
+
'ON checklist."SAMPLING EVENT IDENTIFIER" = observation."SAMPLING EVENT IDENTIFIER" ',
|
|
295
|
+
'AND observation."COMMON NAME" = :bird ',
|
|
296
|
+
'WHERE ',
|
|
297
|
+
'checklist."STATE CODE" = :state',
|
|
298
|
+
'and checklist."ALL SPECIES REPORTED" = 1',
|
|
299
|
+
'and checklist."PROTOCOL TYPE" != "Incidental" ',
|
|
300
|
+
'and checklist."EFFORT DISTANCE KM" <= :dist',
|
|
301
|
+
]
|
|
302
|
+
# Main query parameters
|
|
303
|
+
d = {"state": state, "dist": max_dist, "bird": bird.name}
|
|
304
|
+
# Adds breeding portion
|
|
305
|
+
if breeding is not None:
|
|
306
|
+
query_string.extend([
|
|
307
|
+
'and substr(checklist."OBSERVATION DATE", 6, 2) >= :br1',
|
|
308
|
+
'and substr(checklist."OBSERVATION DATE", 6, 2) <= :br2',
|
|
309
|
+
])
|
|
310
|
+
d['br1'], d['br2'] = breeding
|
|
311
|
+
if date_range is not None:
|
|
312
|
+
query_string.append('and checklist."OBSERVATION DATE" >= :min_date')
|
|
313
|
+
query_string.append('and checklist."OBSERVATION DATE" <= :max_date')
|
|
314
|
+
d["min_date"], d["max_date"] = date_range
|
|
315
|
+
if lat_range is not None:
|
|
316
|
+
query_string.append('and checklist."LATITUDE" >= :min_lat')
|
|
317
|
+
query_string.append('and checklist."LATITUDE" <= :max_lat')
|
|
318
|
+
d["min_lat"], d["max_lat"] = lat_range
|
|
319
|
+
if lng_range is not None:
|
|
320
|
+
query_string.append('and checklist."LONGITUDE" >= :min_lng')
|
|
321
|
+
query_string.append('and checklist."LONGITUDE" <= :max_lng')
|
|
322
|
+
d["min_lng"], d["max_lng"] = lng_range
|
|
323
|
+
# Submits the query.
|
|
324
|
+
query_string = " ".join(query_string)
|
|
325
|
+
if verbose:
|
|
326
|
+
print("Query:", query_string)
|
|
327
|
+
print("Expanded query:", expand_sqlite_query(query_string, d))
|
|
328
|
+
checklists_df = pd.read_sql_query(query_string, self.conn, params=d)
|
|
329
|
+
return checklists_df
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
def get_square_checklists(self, square, bird,
|
|
333
|
+
breeding=None, date_range=None,
|
|
334
|
+
lat_range=None, lng_range=None, max_dist=2,
|
|
335
|
+
verbose=False):
|
|
336
|
+
"""Returns a dataframe consisting of all checklists in a square, with data
|
|
337
|
+
on a (possible) occurrence of a bird."""
|
|
338
|
+
query_string = [
|
|
339
|
+
'SELECT checklist."SQUARE", ',
|
|
340
|
+
'checklist."SAMPLING EVENT IDENTIFIER", ',
|
|
341
|
+
'checklist."PROTOCOL TYPE", ',
|
|
342
|
+
'checklist."EFFORT DISTANCE KM", ',
|
|
343
|
+
'checklist."DURATION MINUTES", ',
|
|
344
|
+
'checklist."OBSERVATION DATE", ',
|
|
345
|
+
'checklist."TIME OBSERVATIONS STARTED", ',
|
|
346
|
+
'checklist."OBSERVER ID", ',
|
|
347
|
+
'checklist."LATITUDE", ',
|
|
348
|
+
'checklist."LONGITUDE", ',
|
|
349
|
+
'observation."OBSERVATION COUNT" ',
|
|
350
|
+
'FROM checklist LEFT JOIN observation ',
|
|
351
|
+
'ON checklist."SAMPLING EVENT IDENTIFIER" = observation."SAMPLING EVENT IDENTIFIER" ',
|
|
352
|
+
'AND observation."COMMON NAME" = :bird ',
|
|
353
|
+
'WHERE ',
|
|
354
|
+
'checklist.SQUARE = :square',
|
|
355
|
+
'and checklist."ALL SPECIES REPORTED" = 1',
|
|
356
|
+
'and checklist."PROTOCOL TYPE" != "Incidental" ',
|
|
357
|
+
'and checklist."EFFORT DISTANCE KM" <= :dist',
|
|
358
|
+
]
|
|
359
|
+
# Main query parameters
|
|
360
|
+
d = {"square": square, "dist": max_dist, "bird": bird.name}
|
|
361
|
+
# Adds breeding portion
|
|
362
|
+
if breeding is not None:
|
|
363
|
+
query_string.extend([
|
|
364
|
+
'and substr(checklist."OBSERVATION DATE", 6, 2) >= :br1',
|
|
365
|
+
'and substr(checklist."OBSERVATION DATE", 6, 2) <= :br2',
|
|
366
|
+
])
|
|
367
|
+
d['br1'], d['br2'] = breeding
|
|
368
|
+
if date_range is not None:
|
|
369
|
+
query_string.append('and checklist."OBSERVATION DATE" >= :min_date')
|
|
370
|
+
query_string.append('and checklist."OBSERVATION DATE" <= :max_date')
|
|
371
|
+
d["min_date"], d["max_date"] = date_range
|
|
372
|
+
if lat_range is not None:
|
|
373
|
+
query_string.append('and checklist."LATITUDE" >= :min_lat')
|
|
374
|
+
query_string.append('and checklist."LATITUDE" <= :max_lat')
|
|
375
|
+
d["min_lat"], d["max_lat"] = lat_range
|
|
376
|
+
if lng_range is not None:
|
|
377
|
+
query_string.append('and checklist."LONGITUDE" >= :min_lng')
|
|
378
|
+
query_string.append('and checklist."LONGITUDE" <= :max_lng')
|
|
379
|
+
d["min_lng"], d["max_lng"] = lng_range
|
|
380
|
+
# Submits the query.
|
|
381
|
+
query_string = " ".join(query_string)
|
|
382
|
+
if verbose:
|
|
383
|
+
print("Query:", query_string)
|
|
384
|
+
print("Expanded query:", expand_sqlite_query(query_string, d))
|
|
385
|
+
checklists_df = pd.read_sql_query(query_string, self.conn, params=d)
|
|
386
|
+
return checklists_df
|
|
271
387
|
|
|
272
388
|
def get_square_individual_checklists(self, square, bird,
|
|
273
389
|
breeding=None, date_range=None, min_time=None,
|
|
@@ -288,6 +404,8 @@ class EbirdObservations(Connection):
|
|
|
288
404
|
(any of further distance will be too noisy, and should be disreguarded)
|
|
289
405
|
:returns: list of squares which fall within the query parameters
|
|
290
406
|
"""
|
|
407
|
+
# Adds deprecation warning.
|
|
408
|
+
warnings.warn("This function is deprecated. Use get_square_checklists instead.", DeprecationWarning)
|
|
291
409
|
# First the checklists, with or without the bird.
|
|
292
410
|
query_string=['select DISTINCT("SAMPLING EVENT IDENTIFIER")',
|
|
293
411
|
'FROM checklist where SQUARE = :square']
|
|
@@ -296,6 +414,9 @@ class EbirdObservations(Connection):
|
|
|
296
414
|
query_string.append('and "PROTOCOL TYPE" != "Incidental"')
|
|
297
415
|
query_string.append('and "EFFORT DISTANCE KM" <= :dist')
|
|
298
416
|
d["dist"] = max_dist
|
|
417
|
+
if min_time is not None:
|
|
418
|
+
query_string.append('and "DURATION MINUTES" >= :min_time')
|
|
419
|
+
d["min_time"] = min_time
|
|
299
420
|
# Adds breeding portion
|
|
300
421
|
if breeding is not None:
|
|
301
422
|
query_string.extend([
|
|
@@ -303,9 +424,6 @@ class EbirdObservations(Connection):
|
|
|
303
424
|
'and substr("OBSERVATION DATE", 6, 2) <= :br2',
|
|
304
425
|
])
|
|
305
426
|
d['br1'], d['br2'] = breeding
|
|
306
|
-
if min_time is not None:
|
|
307
|
-
query_string.append('and "DURATION MINUTES" >= :min_time')
|
|
308
|
-
d["min_time"] = min_time
|
|
309
427
|
if date_range is not None:
|
|
310
428
|
query_string.append('and "OBSERVATION DATE" >= :min_date')
|
|
311
429
|
query_string.append('and "OBSERVATION DATE" <= :max_date')
|
{ecoscape_utilities-0.0.40 → ecoscape_utilities-0.0.41}/ecoscape_utilities.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ecoscape-utilities
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.41
|
|
4
4
|
Summary: A collection of EcoScape utilities.
|
|
5
5
|
Author-email: Luca de Alfaro <luca@ucsc.edu>, Coen Adler <ctadler@ucsc.edu>, Artie Nazarov <anazarov@ucsc.edu>, Natalia Ocampo-Peñuela <nocampop@ucsc.edu>, Jasmine Tai <cjtai@ucsc.edu>, Natalie Valett <nvalett@ucsc.edu>
|
|
6
6
|
Project-URL: Homepage, https://github.com/ecoscape-earth/ecoscape-utilities
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ecoscape_utilities-0.0.40 → ecoscape_utilities-0.0.41}/ecoscape_utilities.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{ecoscape_utilities-0.0.40 → ecoscape_utilities-0.0.41}/ecoscape_utilities.egg-info/requires.txt
RENAMED
|
File without changes
|
{ecoscape_utilities-0.0.40 → ecoscape_utilities-0.0.41}/ecoscape_utilities.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|