population-trend 1.0.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,5 +1,6 @@
1
1
  """A template Python module"""
2
2
 
3
- __version__ = "1.0.0"
3
+ __version__ = "2.0.0"
4
+ from .cli import * # noqa
4
5
  from .filter_data import * # noqa
5
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)
@@ -1,19 +1,4 @@
1
1
  import pandas as pd
2
- import typer
3
-
4
- app = typer.Typer(help="Write filtered burrows data by species and island")
5
-
6
-
7
- @app.command(help="Write csv with ouput-path")
8
- def write_burrows_by_species_and_island(
9
- data_path: str = "data/processed/subset_burrows_data.csv",
10
- species: str = "Guadalupe Murrelet",
11
- island: str = "Guadalupe",
12
- output_path: str = "data/processed/gumu_guadalupe_burrows.csv",
13
- ):
14
- data = pd.read_csv(data_path)
15
- filtered = filter_by_species_and_island(data, species, island)
16
- filtered.to_csv(output_path, index=False)
17
2
 
18
3
 
19
4
  def filter_by_species_and_island(data: pd.DataFrame, species: str, island: str):
@@ -1,6 +1,6 @@
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
 
@@ -27,19 +27,19 @@ class Population_Trend_Model:
27
27
  self.time_to_model = np.linspace(
28
28
  self.ticks_positions.min(), self.ticks_positions.max(), 100
29
29
  )
30
- self.parameters = lambda_calculator(fit_data["Temporada"], fit_data[interest_variable])[1]
30
+ self.initial_population = fit_data[interest_variable].iloc[0]
31
31
 
32
32
  @property
33
33
  def model_min(self):
34
- 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)
35
35
 
36
36
  @property
37
37
  def model_med(self):
38
- 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)
39
39
 
40
40
  @property
41
41
  def model_max(self):
42
- 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)
43
43
 
44
44
 
45
45
  class Plotter_Population_Trend_Model:
@@ -113,11 +113,19 @@ class Plotter_Population_Trend_Model:
113
113
  plt.gcf().subplots_adjust(bottom=0.2)
114
114
  plt.draw()
115
115
 
116
- def savefig(self, islet):
117
- plt.savefig(
118
- "reports/figures/cormorant_population_trend_{}".format(islet.replace(" ", "_").lower()),
119
- dpi=300,
120
- )
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
+ )
121
129
 
122
130
  def set_legend_location(self, islet):
123
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: 1.0.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
@@ -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,7 +0,0 @@
1
- population_trend/__init__.py,sha256=a3S2oxTV02NtRy7qgj8tOJajdyO_PDvCbemYlH9vtVA,136
2
- population_trend/filter_data.py,sha256=aTJ4PpARilJ3eGT_twdMAb8wtbnQ0BZ3Jbe4YA3Ob30,936
3
- population_trend/population_growth_model.py,sha256=iOlStcgMWO2C76lV95yfzCtE9Lcl4agzlZFYDHuhI-g,4051
4
- population_trend-1.0.0.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
5
- population_trend-1.0.0.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
6
- population_trend-1.0.0.dist-info/METADATA,sha256=-OC9MTb3aQFX6Pbw6PZAwQTYQaclEd1t1mCt6DoHrN8,1504
7
- population_trend-1.0.0.dist-info/RECORD,,