ecoscape-utilities 0.0.3__py3-none-any.whl → 0.0.25__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/bird_runs.py +39 -33
- {ecoscape_utilities-0.0.3.dist-info → ecoscape_utilities-0.0.25.dist-info}/METADATA +1 -1
- ecoscape_utilities-0.0.25.dist-info/RECORD +7 -0
- {ecoscape_utilities-0.0.3.dist-info → ecoscape_utilities-0.0.25.dist-info}/WHEEL +1 -1
- ecoscape_utilities-0.0.3.dist-info/RECORD +0 -7
- {ecoscape_utilities-0.0.3.dist-info → ecoscape_utilities-0.0.25.dist-info}/LICENSE.md +0 -0
- {ecoscape_utilities-0.0.3.dist-info → ecoscape_utilities-0.0.25.dist-info}/top_level.txt +0 -0
ecoscape_utilities/bird_runs.py
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import os
|
|
2
2
|
from collections import namedtuple
|
|
3
|
+
import shutil
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
BirdRunInfo = namedtuple('BirdRunInfo', [
|
|
5
6
|
'nickname', # 6-letter ebird name.
|
|
6
7
|
'name', # official name.
|
|
8
|
+
'state', # State for the analysis.
|
|
9
|
+
'run_name', # Name of the run.
|
|
7
10
|
'terrain_fn', # File for the terrain
|
|
8
11
|
'habitat_fn', # File for the habitat.
|
|
9
12
|
'transmission_fn', # Terrain transmission.
|
|
@@ -14,50 +17,46 @@ BirdRunDef = namedtuple('BirdRun', [
|
|
|
14
17
|
'validation_fn',
|
|
15
18
|
'obs_path',
|
|
16
19
|
'obs_csv_path',
|
|
17
|
-
|
|
18
|
-
'hop_distance', 'num_spreads', 'num_simulations'])
|
|
20
|
+
])
|
|
19
21
|
|
|
22
|
+
def delete_run(base_path, nickname, state, run_name="Standard"):
|
|
23
|
+
"""Deletes the files for the given run."""
|
|
24
|
+
p = os.path.join(base_path, f"{nickname}/{state}/Output/{run_name}")
|
|
25
|
+
print("Deleting", p)
|
|
26
|
+
shutil.rmtree(p, ignore_errors=True)
|
|
20
27
|
|
|
21
28
|
class BirdRun(object):
|
|
22
29
|
|
|
23
30
|
def __init__(self, data_path):
|
|
24
31
|
"""Initializes a bird run, given a data path"""
|
|
25
32
|
self.files_path = data_path
|
|
26
|
-
|
|
27
|
-
def get_bird_run(self, nickname, bird_name, run_name=None,
|
|
28
|
-
hop_distance=4, num_spreads=5, num_simulations=2, transmission_exponent=1):
|
|
33
|
+
|
|
34
|
+
def get_bird_run(self, nickname, bird_name, run_name=None, state="US-CA"):
|
|
29
35
|
"""Given a bird name in 6-letter ebird format, returns the BirdRun object for the bird."""
|
|
30
36
|
d = {"bird": nickname,
|
|
31
37
|
"run_name": run_name or "Standard",
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"transmission_exponent": transmission_exponent}
|
|
36
|
-
self.createdir(os.path.join(self.files_path, "{bird}/Output/{run_name}".format(**d)))
|
|
37
|
-
return BirdRunDef(
|
|
38
|
+
"state": state}
|
|
39
|
+
self.createdir(os.path.join(self.files_path, "{bird}/{state}/Output/{run_name}".format(**d)))
|
|
40
|
+
return BirdRunInfo(
|
|
38
41
|
nickname = nickname,
|
|
39
42
|
name = bird_name,
|
|
43
|
+
state = state,
|
|
44
|
+
run_name = run_name or "Standard",
|
|
40
45
|
# Input ,
|
|
41
|
-
terrain_fn = os.path.join(self.files_path, "
|
|
42
|
-
habitat_fn = os.path.join(self.files_path, "{bird}/habitat.tif".format(**d)),
|
|
43
|
-
transmission_fn = os.path.join(self.files_path, "{bird}/
|
|
46
|
+
terrain_fn = os.path.join(self.files_path, "{bird}/{state}/terrain.tif".format(**d)),
|
|
47
|
+
habitat_fn = os.path.join(self.files_path, "{bird}/{state}/habitat.tif".format(**d)),
|
|
48
|
+
transmission_fn = os.path.join(self.files_path, "{bird}/{state}/transmission_refined_1.csv".format(**d)),
|
|
44
49
|
resistance_original_fn = os.path.join(self.files_path, "{bird}/resistance.csv".format(**d)),
|
|
45
|
-
terrain_histogram_json_fn = os.path.join(self.files_path, "{bird}/terrain_hist.json".format(**d)),
|
|
46
|
-
terrain_histogram_csv_fn = os.path.join(self.files_path, "{bird}/terrain_hist.csv".format(**d)),
|
|
50
|
+
terrain_histogram_json_fn = os.path.join(self.files_path, "{bird}/{state}/terrain_hist.json".format(**d)),
|
|
51
|
+
terrain_histogram_csv_fn = os.path.join(self.files_path, "{bird}/{state}/terrain_hist.csv".format(**d)),
|
|
47
52
|
# Validation files.
|
|
48
|
-
validation_fn = os.path.join(self.files_path, "{bird}/Ratios".format(**d)),
|
|
53
|
+
validation_fn = os.path.join(self.files_path, "{bird}/{state}/Ratios".format(**d)),
|
|
49
54
|
# Output files
|
|
50
|
-
repopulation_fn = os.path.join(self.files_path, "{bird}/Output/{run_name}/
|
|
51
|
-
gradient_fn = os.path.join(self.files_path, "{bird}/Output/{run_name}/
|
|
52
|
-
log_fn = os.path.join(self.files_path, "{bird}/Output/{run_name}/
|
|
53
|
-
obs_path = os.path.join(self.files_path, "{bird}/Observations".format(**d)),
|
|
54
|
-
obs_csv_path = os.path.join(self.files_path, "{bird}/Output/{run_name}/
|
|
55
|
-
# Run parameters
|
|
56
|
-
do_gradient=do_gradient,
|
|
57
|
-
do_validation = do_validation,
|
|
58
|
-
hop_distance = hop_distance,
|
|
59
|
-
num_spreads = num_spreads,
|
|
60
|
-
num_simulations = num_simulations
|
|
55
|
+
repopulation_fn = os.path.join(self.files_path, "{bird}/{state}/Output/{run_name}/repopulation.tif".format(**d)),
|
|
56
|
+
gradient_fn = os.path.join(self.files_path, "{bird}/{state}/Output/{run_name}/gradient.tif".format(**d)),
|
|
57
|
+
log_fn = os.path.join(self.files_path, "{bird}/{state}/Output/{run_name}/log.json".format(**d)),
|
|
58
|
+
obs_path = os.path.join(self.files_path, "{bird}/{state}/Observations".format(**d)),
|
|
59
|
+
obs_csv_path = os.path.join(self.files_path, "{bird}/{state}/Output/{run_name}/observations.csv".format(**d)),
|
|
61
60
|
)
|
|
62
61
|
|
|
63
62
|
def get_observations_fn(self, obs_path, bigsquare=False, **kwargs):
|
|
@@ -66,7 +65,7 @@ class BirdRun(object):
|
|
|
66
65
|
"""
|
|
67
66
|
d = dict(**kwargs)
|
|
68
67
|
d["isbig"] = "_big" if bigsquare else ""
|
|
69
|
-
return os.path.join(obs_path, "
|
|
68
|
+
return os.path.join(obs_path, "OBS_min_{min_checklists}_len_{max_distance}{isbig}.json".format(**d))
|
|
70
69
|
|
|
71
70
|
def get_observations_display_fn(self, obs_path, bigsquare=False, **kwargs):
|
|
72
71
|
"""Completes the name of an observation ratio tif file, adding the information on minimum number of observations,
|
|
@@ -74,21 +73,28 @@ class BirdRun(object):
|
|
|
74
73
|
"""
|
|
75
74
|
d = dict(**kwargs)
|
|
76
75
|
d["isbig"] = "_big" if bigsquare else ""
|
|
77
|
-
return os.path.join(obs_path, "
|
|
76
|
+
return os.path.join(obs_path, "OBS_min_{min_checklists}_len_{max_distance}{isbig}.tif".format(**d))
|
|
78
77
|
|
|
79
78
|
def get_observations_all_fn(self, obs_path, **kwargs):
|
|
80
79
|
"""Completes the name of an observation ratio file, adding the information on minimum number of observations,
|
|
81
80
|
and maximum length walked.
|
|
82
81
|
"""
|
|
83
82
|
d = dict(**kwargs)
|
|
84
|
-
return os.path.join(obs_path, "
|
|
83
|
+
return os.path.join(obs_path, "OBS_all_len_{max_distance}_{date_range}_{num_squares}.csv".format(**d))
|
|
84
|
+
|
|
85
|
+
def get_terrain_occurrences_fn(self, obs_path, **kwargs):
|
|
86
|
+
"""Completes the name of an observation ratio file, adding the information on minimum number of observations,
|
|
87
|
+
and maximum length walked.
|
|
88
|
+
"""
|
|
89
|
+
d = dict(**kwargs)
|
|
90
|
+
return os.path.join(obs_path, "TEROBS_all_len_{max_distance}_{date_range}_{num_squares}.csv".format(**d))
|
|
85
91
|
|
|
86
92
|
def get_observations_all_display_fn(self, obs_path, **kwargs):
|
|
87
93
|
"""Completes the name of an observation ratio tif file, adding the information on minimum number of observations,
|
|
88
94
|
and maximum length walked.
|
|
89
95
|
"""
|
|
90
96
|
d = dict(**kwargs)
|
|
91
|
-
return os.path.join(obs_path, "
|
|
97
|
+
return os.path.join(obs_path, "OBS_all_len_{max_distance}_{date_range}_{num_squares}.tif".format(**d))
|
|
92
98
|
|
|
93
99
|
def createdir_for_file(self, fn):
|
|
94
100
|
"""Ensures that the path to a file exists."""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ecoscape-utilities
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.25
|
|
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,7 @@
|
|
|
1
|
+
ecoscape_utilities/__init__.py,sha256=Zk3uTyqbLTdAUiTEutTKG9vI82XD-DQ7SvEB-6h4pcM,26
|
|
2
|
+
ecoscape_utilities/bird_runs.py,sha256=v43PfH_4ojpkTE-EFOJxr0oOW3M9suNm_1zMjZ9P-eI,5409
|
|
3
|
+
ecoscape_utilities-0.0.25.dist-info/LICENSE.md,sha256=3vh2mpA_XIR3FJot6a5F9DqktAoq45sEGIRkYjvAEeU,1304
|
|
4
|
+
ecoscape_utilities-0.0.25.dist-info/METADATA,sha256=8ilvkRRwtKfmhQgmVmpGf-9v4ALdjEQesZkMLig-ycs,1246
|
|
5
|
+
ecoscape_utilities-0.0.25.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
6
|
+
ecoscape_utilities-0.0.25.dist-info/top_level.txt,sha256=jLf7iMlySaJg0Vh8z4lbAaqOc5W5ruMgKFvp797CryQ,19
|
|
7
|
+
ecoscape_utilities-0.0.25.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
ecoscape_utilities/__init__.py,sha256=Zk3uTyqbLTdAUiTEutTKG9vI82XD-DQ7SvEB-6h4pcM,26
|
|
2
|
-
ecoscape_utilities/bird_runs.py,sha256=bkgm0H2dRcKP_9PzzSoIwWx4QMRHrpY9M_mLjzI-Oe0,5514
|
|
3
|
-
ecoscape_utilities-0.0.3.dist-info/LICENSE.md,sha256=3vh2mpA_XIR3FJot6a5F9DqktAoq45sEGIRkYjvAEeU,1304
|
|
4
|
-
ecoscape_utilities-0.0.3.dist-info/METADATA,sha256=3g7VHV9-usoDQkDgBOmop8BKPOEOnkLEdn3W-ECp8Sw,1245
|
|
5
|
-
ecoscape_utilities-0.0.3.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
6
|
-
ecoscape_utilities-0.0.3.dist-info/top_level.txt,sha256=jLf7iMlySaJg0Vh8z4lbAaqOc5W5ruMgKFvp797CryQ,19
|
|
7
|
-
ecoscape_utilities-0.0.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|