population-trend 5.9.0__py3-none-any.whl → 5.9.1__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.
- population_trend/__init__.py +1 -2
- population_trend/calculate_growth_rates.py +18 -72
- population_trend/cli.py +6 -5
- population_trend/plotter_growth_rate.py +1 -1
- population_trend/regional_lambdas.py +17 -10
- {population_trend-5.9.0.dist-info → population_trend-5.9.1.dist-info}/METADATA +2 -2
- population_trend-5.9.1.dist-info/RECORD +13 -0
- population_trend-5.9.0.dist-info/RECORD +0 -13
- {population_trend-5.9.0.dist-info → population_trend-5.9.1.dist-info}/LICENSE +0 -0
- {population_trend-5.9.0.dist-info → population_trend-5.9.1.dist-info}/WHEEL +0 -0
- {population_trend-5.9.0.dist-info → population_trend-5.9.1.dist-info}/entry_points.txt +0 -0
population_trend/__init__.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"""A population growth model package"""
|
|
2
2
|
|
|
3
|
-
__version__ = "5.9.
|
|
3
|
+
__version__ = "5.9.1"
|
|
4
4
|
from .calculate_growth_rates import * # noqa
|
|
5
5
|
from .cli import * # noqa
|
|
6
6
|
from .filter_data import * # noqa
|
|
7
|
-
from .plotter_growth_rate import * # noqa
|
|
8
7
|
from .plotter_population_trend_from_cpue import * # noqa
|
|
9
8
|
from .population_growth_model import * # noqa
|
|
10
9
|
from .regional_lambdas import * # noqa
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
from bootstrapping_tools import (
|
|
2
2
|
bootstrap_from_time_series,
|
|
3
|
-
calculate_intervals_from_p_values_and_alpha,
|
|
4
3
|
calculate_p_values,
|
|
5
|
-
generate_latex_interval_string,
|
|
6
4
|
get_bootstrap_deltas,
|
|
7
5
|
lambda_calculator,
|
|
8
6
|
power_law,
|
|
7
|
+
AbstractSeriesBootstrapper,
|
|
8
|
+
Bootstrap_from_time_series_parametrizer,
|
|
9
9
|
)
|
|
10
10
|
from matplotlib.ticker import MaxNLocator
|
|
11
11
|
|
|
@@ -67,27 +67,6 @@ def calculate_percent_diff_in_seasons(cantidad_nidos, model):
|
|
|
67
67
|
return porcentaje_cambio
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
class Bootstrap_from_time_series_parametrizer:
|
|
71
|
-
def __init__(self, blocks_length=3, N=2000, column_name="Maxima_cantidad_nidos", alpha=0.05):
|
|
72
|
-
self.parameters = dict(
|
|
73
|
-
dataframe=None,
|
|
74
|
-
column_name=column_name,
|
|
75
|
-
N=N,
|
|
76
|
-
return_distribution=True,
|
|
77
|
-
blocks_length=blocks_length,
|
|
78
|
-
alpha=alpha,
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
def set_data(self, data):
|
|
82
|
-
self.parameters["dataframe"] = data
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
Bootstrap = dict(
|
|
86
|
-
default=Bootstrap_from_time_series_parametrizer(),
|
|
87
|
-
testing=Bootstrap_from_time_series_parametrizer(blocks_length=2, N=100),
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
|
|
91
70
|
def fit_population_model(seasons_series, data_series):
|
|
92
71
|
parameters = lambda_calculator(seasons_series, data_series)
|
|
93
72
|
model = power_law(
|
|
@@ -98,35 +77,19 @@ def fit_population_model(seasons_series, data_series):
|
|
|
98
77
|
return model
|
|
99
78
|
|
|
100
79
|
|
|
101
|
-
class
|
|
80
|
+
class LambdasBootstrapper(AbstractSeriesBootstrapper):
|
|
102
81
|
def __init__(self, bootstrap_parametrizer):
|
|
103
|
-
self.
|
|
104
|
-
self.
|
|
105
|
-
self.season_series = self.
|
|
106
|
-
self.
|
|
107
|
-
self.lambdas = [lambdas_n0[0] for lambdas_n0 in self.lambdas_n0_distribution]
|
|
108
|
-
self.p_values = self.get_p_values()
|
|
109
|
-
self.intervals = self.intervals_from_p_values_and_alpha()
|
|
110
|
-
self.interval_lambdas = [interval[0] for interval in self.intervals]
|
|
111
|
-
self.lambda_latex_interval = self.get_lambda_interval_latex_string()
|
|
112
|
-
|
|
113
|
-
def intervals_from_p_values_and_alpha(self):
|
|
114
|
-
intervals = calculate_intervals_from_p_values_and_alpha(
|
|
115
|
-
self.lambdas_n0_distribution, self.p_values, self.parameters["alpha"]
|
|
116
|
-
)
|
|
117
|
-
return intervals
|
|
82
|
+
self.bootstrap_config = bootstrap_parametrizer.parameters
|
|
83
|
+
self.data_series = self.bootstrap_config["dataframe"][self.bootstrap_config["column_name"]]
|
|
84
|
+
self.season_series = self.bootstrap_config["dataframe"]["Temporada"]
|
|
85
|
+
self.parameters_distribution, _ = self.get_parameters_distribution()
|
|
118
86
|
|
|
119
|
-
def
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return p_values
|
|
87
|
+
def get_parameters_distribution(self):
|
|
88
|
+
lambdas_n0_distribution, intervals = bootstrap_from_time_series(**self.bootstrap_config)
|
|
89
|
+
return lambdas_n0_distribution, intervals
|
|
123
90
|
|
|
124
91
|
def get_distribution(self):
|
|
125
|
-
return self.
|
|
126
|
-
|
|
127
|
-
def _calculate_distribution_and_interval(self):
|
|
128
|
-
lambdas_n0_distribution, intervals = bootstrap_from_time_series(**self.parameters)
|
|
129
|
-
return lambdas_n0_distribution, intervals
|
|
92
|
+
return self.parameters_distribution
|
|
130
93
|
|
|
131
94
|
def get_inferior_central_and_superior_limit(self):
|
|
132
95
|
inferior_limit, central, superior_limit = get_bootstrap_deltas(
|
|
@@ -134,11 +97,9 @@ class Bootstrap_from_time_series:
|
|
|
134
97
|
)
|
|
135
98
|
return inferior_limit, central, superior_limit
|
|
136
99
|
|
|
137
|
-
def
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
)
|
|
141
|
-
return lambda_latex_string
|
|
100
|
+
def fit_population_model(self):
|
|
101
|
+
model = fit_population_model(self.season_series, self.data_series)
|
|
102
|
+
return model
|
|
142
103
|
|
|
143
104
|
def generate_season_interval(self):
|
|
144
105
|
return "({}-{})".format(
|
|
@@ -154,34 +115,19 @@ class Bootstrap_from_time_series:
|
|
|
154
115
|
seasons_intervals = calculate_seasons_intervals(monitored_seasons)
|
|
155
116
|
return ",".join(seasons_intervals)
|
|
156
117
|
|
|
157
|
-
def fit_population_model(self):
|
|
158
|
-
model = fit_population_model(self.season_series, self.data_series)
|
|
159
|
-
return model
|
|
160
|
-
|
|
161
|
-
def get_intermediate_lambdas(self):
|
|
162
|
-
return [
|
|
163
|
-
lambda_n0
|
|
164
|
-
for lambda_n0 in self.lambdas_n0_distribution
|
|
165
|
-
if (lambda_n0[0] > self.intervals[0][0]) and (lambda_n0[0] < self.intervals[2][0])
|
|
166
|
-
]
|
|
167
|
-
|
|
168
118
|
def save_intervals(self, output_path):
|
|
169
|
-
json_dict =
|
|
170
|
-
|
|
171
|
-
"lambda_latex_interval": self.lambda_latex_interval,
|
|
172
|
-
"p-values": self.p_values,
|
|
173
|
-
"bootstrap_intermediate_distribution": self.get_intermediate_lambdas(),
|
|
174
|
-
}
|
|
119
|
+
json_dict = self.get_parameters_dictionary()
|
|
120
|
+
json_dict["lambda_latex_interval"] = json_dict.pop("main_parameter_latex_interval")
|
|
175
121
|
with open(output_path, "w") as file:
|
|
176
122
|
json.dump(json_dict, file)
|
|
177
123
|
|
|
178
124
|
|
|
179
125
|
def calculate_growth_rates_table(bootstrap: Bootstrap_from_time_series_parametrizer):
|
|
180
|
-
bootstraper =
|
|
126
|
+
bootstraper = LambdasBootstrapper(bootstrap)
|
|
181
127
|
df = bootstrap.parameters["dataframe"]
|
|
182
128
|
model = bootstraper.fit_population_model()
|
|
183
129
|
inferior_limit, central, superior_limit = bootstraper.get_inferior_central_and_superior_limit()
|
|
184
|
-
lambda_latex_string = bootstraper.
|
|
130
|
+
lambda_latex_string = bootstraper.lambda_latex_interval
|
|
185
131
|
bootstrap_distribution = bootstraper.get_distribution()
|
|
186
132
|
lambdas_distribution = [interval[0] for interval in bootstrap_distribution]
|
|
187
133
|
p_value_mayor, p_value_menor = calculate_p_values(lambdas_distribution)
|
population_trend/cli.py
CHANGED
|
@@ -7,15 +7,16 @@ from population_trend.plotter_population_trend_from_cpue import (
|
|
|
7
7
|
Plotter_Population_Trend_Model_From_CPUE,
|
|
8
8
|
)
|
|
9
9
|
from population_trend.calculate_growth_rates import (
|
|
10
|
-
|
|
11
|
-
Bootstrap_from_time_series,
|
|
10
|
+
LambdasBootstrapper,
|
|
12
11
|
)
|
|
13
12
|
from population_trend.regional_lambdas import (
|
|
14
13
|
Island_Bootstrap_Distribution_Concatenator,
|
|
15
14
|
Calculator_Regional_Lambdas_Intervals,
|
|
16
15
|
)
|
|
17
16
|
|
|
18
|
-
from population_trend.plotter_growth_rate import
|
|
17
|
+
from population_trend.plotter_growth_rate import _Plotter_Growth_Rate
|
|
18
|
+
from bootstrapping_tools import Bootstrap_from_time_series_parametrizer
|
|
19
|
+
|
|
19
20
|
|
|
20
21
|
import pandas as pd
|
|
21
22
|
from typing_extensions import Annotated
|
|
@@ -45,7 +46,7 @@ def write_bootstrap_intervals_json(
|
|
|
45
46
|
alpha=alpha,
|
|
46
47
|
)
|
|
47
48
|
parametrizer.set_data(data)
|
|
48
|
-
bootstrap =
|
|
49
|
+
bootstrap = LambdasBootstrapper(parametrizer)
|
|
49
50
|
bootstrap.save_intervals(output_path)
|
|
50
51
|
|
|
51
52
|
|
|
@@ -130,7 +131,7 @@ def plot_growth_rate(
|
|
|
130
131
|
lambdas_intervals_california = read_json(intervals_california)
|
|
131
132
|
lambdas_intervals_pacific = read_json(intervals_pacific)
|
|
132
133
|
|
|
133
|
-
plotter =
|
|
134
|
+
plotter = _Plotter_Growth_Rate(lambdas_intervals_california, lambdas_intervals_pacific)
|
|
134
135
|
plotter.plot_error_bars()
|
|
135
136
|
plt.savefig(output_path, transparent=True)
|
|
136
137
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
import json
|
|
3
3
|
|
|
4
|
-
from bootstrapping_tools import calculate_intervals_from_p_values_and_alpha
|
|
4
|
+
from bootstrapping_tools import calculate_intervals_from_p_values_and_alpha, calculate_p_values
|
|
5
5
|
|
|
6
|
-
from population_trend.calculate_growth_rates import
|
|
6
|
+
from population_trend.calculate_growth_rates import LambdasBootstrapper
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class Island_Bootstrap_Distribution_Concatenator:
|
|
@@ -54,24 +54,31 @@ class Island_Bootstrap_Distribution_Concatenator:
|
|
|
54
54
|
return lambdas_distribution
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
class Calculator_Regional_Lambdas_Intervals(
|
|
57
|
+
class Calculator_Regional_Lambdas_Intervals(LambdasBootstrapper):
|
|
58
58
|
def __init__(self, regional_lambdas, alpha):
|
|
59
59
|
self.lambdas = regional_lambdas
|
|
60
|
-
self.p_values = self.get_p_values()
|
|
61
60
|
self.alpha = alpha
|
|
62
|
-
self.intervals = self.intervals_from_p_values_and_alpha()
|
|
63
|
-
self.interval_lambdas = [interval for interval in self.intervals]
|
|
64
|
-
self.lambda_latex_interval = self.get_lambda_interval_latex_string()
|
|
65
61
|
self.hypothesis_test_statement_latex = self.get_hypotesis_statement()
|
|
66
62
|
self.hypothesis_test_statement_latex_en = self.get_hypotesis_statement_en()
|
|
67
63
|
|
|
68
|
-
|
|
64
|
+
@property
|
|
65
|
+
def p_values(self):
|
|
66
|
+
p_value_mayor, p_value_menor = calculate_p_values(self.lambdas)
|
|
67
|
+
p_values = (p_value_mayor, p_value_menor)
|
|
68
|
+
return p_values
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def intervals(self):
|
|
69
72
|
intervals = calculate_intervals_from_p_values_and_alpha(
|
|
70
73
|
self.lambdas, self.p_values, self.alpha
|
|
71
74
|
)
|
|
72
75
|
return intervals
|
|
73
76
|
|
|
74
|
-
|
|
77
|
+
@property
|
|
78
|
+
def interval_lambdas(self):
|
|
79
|
+
return [interval for interval in self.intervals]
|
|
80
|
+
|
|
81
|
+
def get_lambdas_inside_confidence_interval(self):
|
|
75
82
|
return [
|
|
76
83
|
lambdas
|
|
77
84
|
for lambdas in self.lambdas
|
|
@@ -106,7 +113,7 @@ class Calculator_Regional_Lambdas_Intervals(Bootstrap_from_time_series):
|
|
|
106
113
|
"intervals": list(self.intervals),
|
|
107
114
|
"lambda_latex_interval": self.lambda_latex_interval,
|
|
108
115
|
"p-values": self.p_values,
|
|
109
|
-
"bootstrap_intermediate_distribution": self.
|
|
116
|
+
"bootstrap_intermediate_distribution": self.get_lambdas_inside_confidence_interval(),
|
|
110
117
|
"hypothesis_test_statement_latex_sp": self.hypothesis_test_statement_latex,
|
|
111
118
|
"hypothesis_test_statement_latex_en": self.hypothesis_test_statement_latex_en,
|
|
112
119
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: population_trend
|
|
3
|
-
Version: 5.9.
|
|
3
|
+
Version: 5.9.1
|
|
4
4
|
Summary: A population growth model package
|
|
5
5
|
Home-page: https://github.com/IslasGECI/population_trend
|
|
6
6
|
Author: Ciencia de Datos • GECI
|
|
@@ -8,7 +8,7 @@ Author-email: ciencia.datos@islas.org.mx
|
|
|
8
8
|
Requires-Python: >=3.9
|
|
9
9
|
Description-Content-Type: text/markdown
|
|
10
10
|
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
|
11
|
-
Requires-Dist: bootstrapping-tools==3
|
|
11
|
+
Requires-Dist: bootstrapping-tools==3.*
|
|
12
12
|
Requires-Dist: geci-plots
|
|
13
13
|
Requires-Dist: typer[all]
|
|
14
14
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
population_trend/__init__.py,sha256=IKO9fZhfnavlCZgtkAkXVvIOV4zIie7auj4Ec9IjSNk,316
|
|
2
|
+
population_trend/calculate_growth_rates.py,sha256=qD-a6O17CEhgKo0KmGzVGRpGuKpDQnno16MD3DgjVrk,6003
|
|
3
|
+
population_trend/cli.py,sha256=wsAYBTBpegnvom_UCQqTyDgdE6OqraZ68EjcfXO3lJg,5435
|
|
4
|
+
population_trend/filter_data.py,sha256=D0Y1vztcbbo98af9q7wRhlHfH__bNFI8tnVOdJY6hu0,403
|
|
5
|
+
population_trend/plotter_growth_rate.py,sha256=jWMETGAahYNedyGJmxEzvjJdSNSPDsrpGlXrGIgDLQQ,1175
|
|
6
|
+
population_trend/plotter_population_trend_from_cpue.py,sha256=US8h948Mtb9AQpDYfvt1c-35i2if9HxqcOp1q_R-rio,1351
|
|
7
|
+
population_trend/population_growth_model.py,sha256=LWgMyEJqHY9M5Xuv9nVFSfX5_X61tXCBS2n-kvY8pNk,6002
|
|
8
|
+
population_trend/regional_lambdas.py,sha256=5eCRXf9RWS0c6BG5F-Exico0GNMuUNyexZ0ZJKgOmp4,5274
|
|
9
|
+
population_trend-5.9.1.dist-info/entry_points.txt,sha256=qVw9tnlMx7q2AnksVC2H4oK4ufQrdrbBzSODLH-bcac,61
|
|
10
|
+
population_trend-5.9.1.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
|
11
|
+
population_trend-5.9.1.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
|
|
12
|
+
population_trend-5.9.1.dist-info/METADATA,sha256=vs5I3SAYU6Kvv3PS8_otOxkwFKTCMiBJtm7WhDWA6u0,1330
|
|
13
|
+
population_trend-5.9.1.dist-info/RECORD,,
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
population_trend/__init__.py,sha256=8PILFcMhthYOWPSs7LL974J3weCz9FMXRRVUCiea2vo,359
|
|
2
|
-
population_trend/calculate_growth_rates.py,sha256=FzgAFt2NWc7jZW-v9qG8UCeqfMjyXzp_FT8b5mByNUw,7947
|
|
3
|
-
population_trend/cli.py,sha256=KfIeLpr4uHHIeFMAfyjV_iKAdAVwXzVK4EglVQz8HcY,5419
|
|
4
|
-
population_trend/filter_data.py,sha256=D0Y1vztcbbo98af9q7wRhlHfH__bNFI8tnVOdJY6hu0,403
|
|
5
|
-
population_trend/plotter_growth_rate.py,sha256=4QWuCB_cKF4yWBzuNvtv1jadrT1GNstQ7cjgWXDL8ag,1174
|
|
6
|
-
population_trend/plotter_population_trend_from_cpue.py,sha256=US8h948Mtb9AQpDYfvt1c-35i2if9HxqcOp1q_R-rio,1351
|
|
7
|
-
population_trend/population_growth_model.py,sha256=LWgMyEJqHY9M5Xuv9nVFSfX5_X61tXCBS2n-kvY8pNk,6002
|
|
8
|
-
population_trend/regional_lambdas.py,sha256=Hk1BWWqHjqf9zYarjt1Y7VNebeFmlX3xFpUFaMVdeoI,5222
|
|
9
|
-
population_trend-5.9.0.dist-info/entry_points.txt,sha256=qVw9tnlMx7q2AnksVC2H4oK4ufQrdrbBzSODLH-bcac,61
|
|
10
|
-
population_trend-5.9.0.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
|
11
|
-
population_trend-5.9.0.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
|
|
12
|
-
population_trend-5.9.0.dist-info/METADATA,sha256=EnUbDSSifnPzSAF_PPJn33ZCqMVUsAkE_4Pwcnv59A8,1332
|
|
13
|
-
population_trend-5.9.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|