cat-data-tools 1.0.2__tar.gz → 1.1.0__tar.gz
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.
- {cat_data_tools-1.0.2 → cat_data_tools-1.1.0}/PKG-INFO +1 -1
- {cat_data_tools-1.0.2 → cat_data_tools-1.1.0}/cat_data_tools/__init__.py +1 -1
- {cat_data_tools-1.0.2 → cat_data_tools-1.1.0}/cat_data_tools/cli.py +21 -0
- cat_data_tools-1.1.0/cat_data_tools/detect_status_change.py +30 -0
- cat_data_tools-1.0.2/cat_data_tools/detect_status_change.py +0 -8
- {cat_data_tools-1.0.2 → cat_data_tools-1.1.0}/LICENSE +0 -0
- {cat_data_tools-1.0.2 → cat_data_tools-1.1.0}/README.md +0 -0
- {cat_data_tools-1.0.2 → cat_data_tools-1.1.0}/cat_data_tools/build_trap_daily_status.py +0 -0
- {cat_data_tools-1.0.2 → cat_data_tools-1.1.0}/cat_data_tools/calculate_effort_and_captures.py +0 -0
- {cat_data_tools-1.0.2 → cat_data_tools-1.1.0}/cat_data_tools/filter_data_between_years.py +0 -0
- {cat_data_tools-1.0.2 → cat_data_tools-1.1.0}/cat_data_tools/filter_data_by_month.py +0 -0
- {cat_data_tools-1.0.2 → cat_data_tools-1.1.0}/cat_data_tools/transform_effort_captures.py +0 -0
- {cat_data_tools-1.0.2 → cat_data_tools-1.1.0}/cat_data_tools/trap_status_list.py +0 -0
- {cat_data_tools-1.0.2 → cat_data_tools-1.1.0}/cat_data_tools/update_status_traps.py +0 -0
- {cat_data_tools-1.0.2 → cat_data_tools-1.1.0}/pyproject.toml +0 -0
|
@@ -7,6 +7,9 @@ from cat_data_tools.build_trap_daily_status import (
|
|
|
7
7
|
_build_trap_daily_status_for_duplicated_positions,
|
|
8
8
|
)
|
|
9
9
|
from cat_data_tools.calculate_effort_and_captures import calculate_effort_and_captures
|
|
10
|
+
from cat_data_tools.detect_status_change import (
|
|
11
|
+
compute_trap_check_log,
|
|
12
|
+
)
|
|
10
13
|
from cat_data_tools.filter_data_between_years import filter_data_between_years
|
|
11
14
|
from cat_data_tools.update_status_traps import _update_status_traps
|
|
12
15
|
from cat_data_tools.transform_effort_captures import transform_effort_captures_to_dict
|
|
@@ -18,6 +21,24 @@ import typer
|
|
|
18
21
|
app = typer.Typer()
|
|
19
22
|
|
|
20
23
|
|
|
24
|
+
@app.command()
|
|
25
|
+
def write_trap_check_log(
|
|
26
|
+
trap_daily_status_path: str = typer.Option(),
|
|
27
|
+
output_path: str = typer.Option(),
|
|
28
|
+
):
|
|
29
|
+
daily_status_df = pd.read_csv(trap_daily_status_path)
|
|
30
|
+
daily_status_df_renamed = daily_status_df.rename(
|
|
31
|
+
columns={
|
|
32
|
+
"Fecha": "Date",
|
|
33
|
+
"Tipo": "Type",
|
|
34
|
+
"Estado_trampa": "Trap_status",
|
|
35
|
+
"Atrayente": "Bait",
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
check_log = compute_trap_check_log(daily_status_df_renamed)
|
|
39
|
+
check_log.to_csv(output_path, index=False, na_rep="NA")
|
|
40
|
+
|
|
41
|
+
|
|
21
42
|
@app.command()
|
|
22
43
|
def write_daily_effort_and_captures_summary_by_zone(
|
|
23
44
|
trap_daily_status_path: str = typer.Option(),
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
def get_status_change(daily_status_df):
|
|
2
|
+
daily_status_df_copy = daily_status_df.copy().dropna(subset="Trap_status")
|
|
3
|
+
df = daily_status_df_copy.sort_values(by=["ID", "Date"])
|
|
4
|
+
is_status_changed = df["Trap_status"] != df.groupby("ID")["Trap_status"].shift()
|
|
5
|
+
is_trapper_changed = df["Trapper"] != df.groupby("ID")["Trapper"].shift()
|
|
6
|
+
is_type_changed = df["Type"] != df.groupby("ID")["Type"].shift()
|
|
7
|
+
filtered_df = df.loc[is_status_changed | is_trapper_changed | is_type_changed]
|
|
8
|
+
return filtered_df.reset_index(drop=True)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def compute_trap_check_log(daily_status_df):
|
|
12
|
+
daily_status_with_next_status = add_next_status_column(daily_status_df)
|
|
13
|
+
check_log = subsitute_check_traps_status(daily_status_with_next_status)
|
|
14
|
+
return check_log.drop(columns=["next_status"])
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def add_next_status_column(daily_status_df):
|
|
18
|
+
sorted_daily = daily_status_df.sort_values(["ID", "Type", "Trapper", "Date"])
|
|
19
|
+
sorted_daily["next_status"] = sorted_daily.groupby(["ID", "Type", "Trapper"])[
|
|
20
|
+
"Trap_status"
|
|
21
|
+
].shift(-1)
|
|
22
|
+
is_capture = sorted_daily["Trap_status"] == "RX"
|
|
23
|
+
sorted_daily.loc[is_capture, "next_status"] = "X"
|
|
24
|
+
return sorted_daily
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def subsitute_check_traps_status(df):
|
|
28
|
+
checked_traps = df[df.Trap_status.str.startswith("R")]
|
|
29
|
+
checked_traps.Trap_status = checked_traps.next_status
|
|
30
|
+
return checked_traps
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
def get_status_change(daily_status_df):
|
|
2
|
-
daily_status_df_copy = daily_status_df.copy().dropna(subset="Trap_status")
|
|
3
|
-
df = daily_status_df_copy.sort_values(by=["ID", "Date"])
|
|
4
|
-
is_status_changed = df["Trap_status"] != df.groupby("ID")["Trap_status"].shift()
|
|
5
|
-
is_trapper_changed = df["Trapper"] != df.groupby("ID")["Trapper"].shift()
|
|
6
|
-
is_type_changed = df["Type"] != df.groupby("ID")["Type"].shift()
|
|
7
|
-
filtered_df = df.loc[is_status_changed | is_trapper_changed | is_type_changed]
|
|
8
|
-
return filtered_df.reset_index(drop=True)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cat_data_tools-1.0.2 → cat_data_tools-1.1.0}/cat_data_tools/calculate_effort_and_captures.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|