ecoscape-utilities 0.0.32__py3-none-any.whl → 0.0.33__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.
Potentially problematic release.
This version of ecoscape-utilities might be problematic. Click here for more details.
- ecoscape_utilities/ebird_db.py +14 -39
- {ecoscape_utilities-0.0.32.dist-info → ecoscape_utilities-0.0.33.dist-info}/METADATA +1 -1
- ecoscape_utilities-0.0.33.dist-info/RECORD +8 -0
- ecoscape_utilities-0.0.32.dist-info/RECORD +0 -8
- {ecoscape_utilities-0.0.32.dist-info → ecoscape_utilities-0.0.33.dist-info}/WHEEL +0 -0
- {ecoscape_utilities-0.0.32.dist-info → ecoscape_utilities-0.0.33.dist-info}/licenses/LICENSE.md +0 -0
- {ecoscape_utilities-0.0.32.dist-info → ecoscape_utilities-0.0.33.dist-info}/top_level.txt +0 -0
ecoscape_utilities/ebird_db.py
CHANGED
|
@@ -486,42 +486,12 @@ A module for common functionality in the validaiton process using ebird data
|
|
|
486
486
|
"""
|
|
487
487
|
class Validation(object):
|
|
488
488
|
|
|
489
|
-
def __init__(self, obs_fn
|
|
489
|
+
def __init__(self, obs_fn):
|
|
490
490
|
"""
|
|
491
491
|
Generates a class for validation.
|
|
492
|
-
It first tries to read the cached version of obs_fn for the specified geotiff_fn.
|
|
493
|
-
If the cached version is not found, it is created.
|
|
494
|
-
The cached version contains pre-translated coordinates to pixel values.
|
|
495
492
|
:param obs_fn: Observations filename.
|
|
496
|
-
:param geotiff_fn: name of a geotiff (repopulation is preferred) used
|
|
497
|
-
for translating coordinates to pixel coordinates.
|
|
498
493
|
"""
|
|
499
494
|
self.obs_fn = obs_fn
|
|
500
|
-
self.geotiff_fn = geotiff_fn
|
|
501
|
-
h = hashlib.sha1(obs_fn.encode('utf-8'))
|
|
502
|
-
h.update(geotiff_fn.encode('utf-8'))
|
|
503
|
-
cached_fn = obs_fn + "." + h.hexdigest() + ".csv"
|
|
504
|
-
if not os.path.exists(cached_fn):
|
|
505
|
-
self._create_cached_observations(cached_fn)
|
|
506
|
-
self.observations = pd.read_csv(cached_fn)
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
def _create_cached_observations(self, cached_fn):
|
|
510
|
-
"""Creates a cached version of the observations that also contains
|
|
511
|
-
pixel coordinates."""
|
|
512
|
-
geotiff = GeoTiff.from_file(self.geotiff_fn)
|
|
513
|
-
def f(row):
|
|
514
|
-
square = row["Square"]
|
|
515
|
-
if (isinstance(square, str)):
|
|
516
|
-
coords = format_coords(square)
|
|
517
|
-
else:
|
|
518
|
-
coords = square
|
|
519
|
-
lat, lng = coords
|
|
520
|
-
pix_x, pix_y = transform_coords(geotiff, coords)
|
|
521
|
-
return lat, lng, pix_x, pix_y
|
|
522
|
-
df = pd.read_csv(self.obs_fn)
|
|
523
|
-
df["lat"], df["lng"], df["pix_x"], df["pix_y"] = zip(*df.apply(f, axis=1))
|
|
524
|
-
df.to_csv(cached_fn)
|
|
525
495
|
|
|
526
496
|
|
|
527
497
|
def filter_CA_rectangle(self, observation_ratios, bigsquare=False):
|
|
@@ -594,8 +564,6 @@ class Validation(object):
|
|
|
594
564
|
:param weighted_tile_size: size of the tile to attribute grouped weights to
|
|
595
565
|
:returns: a dataframe with columns repopulation, observation ratio, and weights
|
|
596
566
|
'''
|
|
597
|
-
assert repop_tif.crs == hab.crs, "Repopulation and habitat geotiffs must have the same CRS"
|
|
598
|
-
assert repop_tif.size == hab.size, "Repopulation and habitat geotiffs must have the same size"
|
|
599
567
|
df = pd.DataFrame(columns=['repop', 'hab', 'max_repop', 'max_hab', 'obs_ratio', 'lat', 'lng', 'x', 'y', ])
|
|
600
568
|
count = defaultdict(int)
|
|
601
569
|
for (square, ratio) in observation_ratios:
|
|
@@ -604,9 +572,10 @@ class Validation(object):
|
|
|
604
572
|
else:
|
|
605
573
|
coords = square
|
|
606
574
|
lat, lng = coords
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
575
|
+
repop_pix_coords = transform_coords(repop_tif, coords)
|
|
576
|
+
hab_pix_coords = transform_coords(hab, coords)
|
|
577
|
+
repop_tile = repop_tif.get_tile_from_coord(repop_pix_coords, tile_scale=tile_scale)
|
|
578
|
+
hab_tile = hab.get_tile_from_coord(hab_pix_coords, tile_scale=tile_scale)
|
|
610
579
|
if repop_tile is None or hab_tile is None:
|
|
611
580
|
continue
|
|
612
581
|
x, y = repop_tif.get_pixel_from_coord(coords)
|
|
@@ -640,9 +609,15 @@ class Validation(object):
|
|
|
640
609
|
"""
|
|
641
610
|
df = self.observations.copy()
|
|
642
611
|
def f(row):
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
612
|
+
square = row["Square"]
|
|
613
|
+
if (isinstance(square, str)):
|
|
614
|
+
coords = format_coords(square)
|
|
615
|
+
else:
|
|
616
|
+
coords = square
|
|
617
|
+
repop_pix_coords = transform_coords(repop_tif, coords)
|
|
618
|
+
hab_pix_coords = transform_coords(hab_tif, coords)
|
|
619
|
+
repop_tile = repop_tif.get_tile_from_coord(repop_pix_coords, tile_scale=tile_scale)
|
|
620
|
+
hab_tile = hab_tif.get_tile_from_coord(hab_pix_coords, tile_scale=tile_scale)
|
|
646
621
|
if repop_tile is None or hab_tile is None:
|
|
647
622
|
return pd.NA, pd.NA, pd.NA, pd.NA
|
|
648
623
|
avg_repop = np.average(repop_tile.m)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ecoscape-utilities
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.33
|
|
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
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
ecoscape_utilities/__init__.py,sha256=LXt1rL9JVsjnCmsNZwZ2aoElphIK-koaEDdW6ffZsMQ,50
|
|
2
|
+
ecoscape_utilities/bird_runs.py,sha256=v43PfH_4ojpkTE-EFOJxr0oOW3M9suNm_1zMjZ9P-eI,5409
|
|
3
|
+
ecoscape_utilities/ebird_db.py,sha256=qtnAjc4mid7bcwVTrg0h30UyuyydWbfh2Ogaei4_WuA,30062
|
|
4
|
+
ecoscape_utilities-0.0.33.dist-info/licenses/LICENSE.md,sha256=3vh2mpA_XIR3FJot6a5F9DqktAoq45sEGIRkYjvAEeU,1304
|
|
5
|
+
ecoscape_utilities-0.0.33.dist-info/METADATA,sha256=_IF2EBqPc-R9FvnaDnuR5SRut2JSi5J7d5PanptTz4E,1382
|
|
6
|
+
ecoscape_utilities-0.0.33.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
7
|
+
ecoscape_utilities-0.0.33.dist-info/top_level.txt,sha256=jLf7iMlySaJg0Vh8z4lbAaqOc5W5ruMgKFvp797CryQ,19
|
|
8
|
+
ecoscape_utilities-0.0.33.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
ecoscape_utilities/__init__.py,sha256=LXt1rL9JVsjnCmsNZwZ2aoElphIK-koaEDdW6ffZsMQ,50
|
|
2
|
-
ecoscape_utilities/bird_runs.py,sha256=v43PfH_4ojpkTE-EFOJxr0oOW3M9suNm_1zMjZ9P-eI,5409
|
|
3
|
-
ecoscape_utilities/ebird_db.py,sha256=A3xoeymVIZbnxhYwlS9Ex22NJdeUVJDI_PATT0BGL3k,31321
|
|
4
|
-
ecoscape_utilities-0.0.32.dist-info/licenses/LICENSE.md,sha256=3vh2mpA_XIR3FJot6a5F9DqktAoq45sEGIRkYjvAEeU,1304
|
|
5
|
-
ecoscape_utilities-0.0.32.dist-info/METADATA,sha256=7o3bGeSdY49LAM57i-Cknxwt3hHBGMdAHZNTfszgMw0,1382
|
|
6
|
-
ecoscape_utilities-0.0.32.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
7
|
-
ecoscape_utilities-0.0.32.dist-info/top_level.txt,sha256=jLf7iMlySaJg0Vh8z4lbAaqOc5W5ruMgKFvp797CryQ,19
|
|
8
|
-
ecoscape_utilities-0.0.32.dist-info/RECORD,,
|
|
File without changes
|
{ecoscape_utilities-0.0.32.dist-info → ecoscape_utilities-0.0.33.dist-info}/licenses/LICENSE.md
RENAMED
|
File without changes
|
|
File without changes
|