population-trend 0.1.0__py3-none-any.whl → 2.0.0__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.
@@ -1,4 +1,6 @@
1
1
  """A template Python module"""
2
2
 
3
- __version__ = "0.1.0"
3
+ __version__ = "2.0.0"
4
+ from .cli import * # noqa
5
+ from .filter_data import * # noqa
4
6
  from .population_growth_model import * # noqa
@@ -0,0 +1,51 @@
1
+ from population_trend.filter_data import filter_by_species_and_island
2
+ from population_trend.population_growth_model import (
3
+ Population_Trend_Model,
4
+ Plotter_Population_Trend_Model,
5
+ )
6
+ import pandas as pd
7
+ import typer
8
+ import json
9
+
10
+ app = typer.Typer(help="Write filtered burrows data by species and island")
11
+
12
+
13
+ @app.command(help="Write csv with ouput-path")
14
+ def write_burrows_by_species_and_island(
15
+ data_path: str = "data/processed/subset_burrows_data.csv",
16
+ species: str = "Guadalupe Murrelet",
17
+ island: str = "Guadalupe",
18
+ output_path: str = "data/processed/gumu_guadalupe_burrows.csv",
19
+ ):
20
+ data = pd.read_csv(data_path)
21
+ filtered = filter_by_species_and_island(data, species, island)
22
+ filtered.to_csv(output_path, index=False)
23
+
24
+
25
+ @app.command(help="Plot population trend")
26
+ def plot_population_trend(
27
+ data_path: str = "",
28
+ intervals_path: str = "",
29
+ island: str = "Guadalupe",
30
+ variable_of_interest: str = "Maxima_cantidad_nidos",
31
+ output_path=None,
32
+ ):
33
+ fit_data = pd.read_csv(data_path)
34
+ with open(intervals_path, "r") as read_file:
35
+ intervals_json = json.load(read_file)
36
+ intervals = intervals_json["intervals"]
37
+ lambda_latex = intervals_json["lambda_latex_interval"]
38
+
39
+ Modelo_Tendencia_Poblacional = Population_Trend_Model(fit_data, intervals, variable_of_interest)
40
+ Graficador = Plotter_Population_Trend_Model()
41
+ Graficador.plot_smooth(Modelo_Tendencia_Poblacional)
42
+ Graficador.plot_model(Modelo_Tendencia_Poblacional)
43
+ Graficador.plot_data(Modelo_Tendencia_Poblacional, fit_data[variable_of_interest])
44
+ legend_mpl_object = Graficador.set_legend_location(island)
45
+ Graficador.set_x_lim(Modelo_Tendencia_Poblacional)
46
+ Graficador.set_y_lim(fit_data[variable_of_interest])
47
+ Graficador.set_labels()
48
+ Graficador.set_ticks(Modelo_Tendencia_Poblacional)
49
+ Graficador.draw()
50
+ Graficador.plot_growth_rate_interval(legend_mpl_object, lambda_latex)
51
+ Graficador.savefig(island, output_path)
@@ -0,0 +1,14 @@
1
+ import pandas as pd
2
+
3
+
4
+ def filter_by_species_and_island(data: pd.DataFrame, species: str, island: str):
5
+ filtered_by_species = filter_by_species(data, species)
6
+ return filter_data_by_islet(filtered_by_species, island)
7
+
8
+
9
+ def filter_by_species(data: pd.DataFrame, species: str):
10
+ return data[data.Nombre_en_ingles == species]
11
+
12
+
13
+ def filter_data_by_islet(df, islet):
14
+ return df[df.Isla == islet]
@@ -1,13 +1,9 @@
1
1
  import numpy as np
2
2
  from geci_plots import geci_plot, roundup, ticks_positions_array, order_magnitude
3
- from bootstrapping_tools import lambda_calculator, power_law
3
+ from bootstrapping_tools import power_law
4
4
  import matplotlib.pyplot as plt
5
5
 
6
6
 
7
- def filter_data_by_islet(df, islet):
8
- return df[df.Isla == islet]
9
-
10
-
11
7
  def resample_seasons(df):
12
8
  first_season = int(df.Temporada.min())
13
9
  last_season = int(df.Temporada.max())
@@ -31,19 +27,19 @@ class Population_Trend_Model:
31
27
  self.time_to_model = np.linspace(
32
28
  self.ticks_positions.min(), self.ticks_positions.max(), 100
33
29
  )
34
- self.parameters = lambda_calculator(fit_data["Temporada"], fit_data[interest_variable])[1]
30
+ self.initial_population = fit_data[interest_variable].iloc[0]
35
31
 
36
32
  @property
37
33
  def model_min(self):
38
- return power_law(self.time_to_model, self.intervals[0], self.parameters)
34
+ return power_law(self.time_to_model, self.intervals[0], self.initial_population)
39
35
 
40
36
  @property
41
37
  def model_med(self):
42
- return power_law(self.time_to_model, self.intervals[1], self.parameters)
38
+ return power_law(self.time_to_model, self.intervals[1], self.initial_population)
43
39
 
44
40
  @property
45
41
  def model_max(self):
46
- return power_law(self.time_to_model, self.intervals[2], self.parameters)
42
+ return power_law(self.time_to_model, self.intervals[2], self.initial_population)
47
43
 
48
44
 
49
45
  class Plotter_Population_Trend_Model:
@@ -117,11 +113,19 @@ class Plotter_Population_Trend_Model:
117
113
  plt.gcf().subplots_adjust(bottom=0.2)
118
114
  plt.draw()
119
115
 
120
- def savefig(self, islet):
121
- plt.savefig(
122
- "reports/figures/cormorant_population_trend_{}".format(islet.replace(" ", "_").lower()),
123
- dpi=300,
124
- )
116
+ def savefig(self, islet, output_path=None):
117
+ if output_path is None:
118
+ plt.savefig(
119
+ "reports/figures/cormorant_population_trend_{}".format(
120
+ islet.replace(" ", "_").lower()
121
+ ),
122
+ dpi=300,
123
+ )
124
+ else:
125
+ plt.savefig(
126
+ output_path,
127
+ dpi=300,
128
+ )
125
129
 
126
130
  def set_legend_location(self, islet):
127
131
  legend_mpl_object = plt.legend(loc="best")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: population_trend
3
- Version: 0.1.0
3
+ Version: 2.0.0
4
4
  Summary: A template Python module
5
5
  Home-page: https://github.com/IslasGECI/population_trend
6
6
  Author: Ciencia de Datos • GECI
@@ -10,6 +10,7 @@ Description-Content-Type: text/markdown
10
10
  Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
11
11
  Requires-Dist: bootstrapping-tools==0.5.7
12
12
  Requires-Dist: geci-plots
13
+ Requires-Dist: typer
13
14
 
14
15
  <a href="https://www.islas.org.mx/"><img src="https://www.islas.org.mx/img/logo.svg" align="right" width="256" /></a>
15
16
  # Dummy Transformations
@@ -0,0 +1,8 @@
1
+ population_trend/__init__.py,sha256=6rhCXlely23zShU26Ujo3WBjM3rSwXX5bQQhSECEtn8,163
2
+ population_trend/cli.py,sha256=8QdnQqvozFZDXHumyaib1KC0GhAzO1n71Zwl70v9MFw,1982
3
+ population_trend/filter_data.py,sha256=D0Y1vztcbbo98af9q7wRhlHfH__bNFI8tnVOdJY6hu0,403
4
+ population_trend/population_growth_model.py,sha256=fNniRWuWtznAMglfKu2Yo6cpUG9lBmVhpx4RK4S0k2k,4238
5
+ population_trend-2.0.0.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
6
+ population_trend-2.0.0.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
7
+ population_trend-2.0.0.dist-info/METADATA,sha256=7gc6DZwPN1lip3IECUIRiSUyw_b71EZ0nGjf3D-T9H0,1504
8
+ population_trend-2.0.0.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- population_trend/__init__.py,sha256=ZYSrjN0CEDVKrqHNVXUEiIR47N6st8otSCpe5ZkOv74,101
2
- population_trend/population_growth_model.py,sha256=u3aZus5w5xwjYBn0vRFIOTJ_P7hNJuskfUfQNt-JNOg,4122
3
- population_trend-0.1.0.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
4
- population_trend-0.1.0.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
5
- population_trend-0.1.0.dist-info/METADATA,sha256=PNhfZC8zmAYzIx8OjVbXhLA9HukZuFnmupErXWkfNJE,1483
6
- population_trend-0.1.0.dist-info/RECORD,,