Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Flake8](https://img.shields.io/badge/Flake8-passed-brightgreen)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml)
[![Pytest](https://img.shields.io/badge/Pytest-passed-brightgreen)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml)
[![Coverage](https://img.shields.io/badge/Coverage-99%25-brightgreen)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml)
[![Mypy](https://img.shields.io/badge/Mypy-1164%20errors-red)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml)
[![Flake8](https://img.shields.io/badge/Flake8-failed-red)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml)
[![Pytest](https://img.shields.io/badge/Pytest-failed-red)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml)
[![Coverage](https://img.shields.io/badge/Coverage-%25-red)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml)
[![Mypy](https://img.shields.io/badge/Mypy-1165%20errors-red)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml)


# RuFaS: Ruminant Farm Systems
Expand Down
46 changes: 46 additions & 0 deletions RUFAS/biophysical/animal/animal_module_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,28 @@ def report_milk(cls, milk_reports: list[MilkProductionStatistics], simulation_da
),
}

parity_data: dict[str, dict[str, list[int | float]]] = {
"parity_1": {"milk": [], "days_in_milk": []},
"parity_2": {"milk": [], "days_in_milk": []},
"parity_3_and_above": {"milk": [], "days_in_milk": []},
}
fresh_cows: int = 0
cows_at_or_above_50_dim: int = 0

for milk_stats in milk_reports:
if milk_stats.parity == 1:
parity_group = "parity_1"
elif milk_stats.parity == 2:
parity_group = "parity_2"
else:
parity_group = "parity_3_and_above"

parity_data[parity_group]["milk"].append(milk_stats.estimated_daily_milk_produced)
parity_data[parity_group]["days_in_milk"].append(milk_stats.days_in_milk)
if milk_stats.days_in_milk < 50:
fresh_cows += 1
else:
cows_at_or_above_50_dim += 1
updated_milk_data: dict[str, int | float | str] = {
"cow_id": milk_stats.cow_id,
"pen_id": milk_stats.pen_id,
Expand Down Expand Up @@ -143,6 +164,26 @@ def report_milk(cls, milk_reports: list[MilkProductionStatistics], simulation_da

om.add_variable("milk_data_at_milk_update", updated_milk_data, info_map)

om.add_variable("fresh_cow_num", fresh_cows, info_map)
om.add_variable("cows_at_or_above_50_dim", cows_at_or_above_50_dim, info_map)

for parity_group, data in parity_data.items():
average_milk = sum(data["milk"]) / len(data["milk"]) if data["milk"] else 0.0
average_days_in_milk = (
sum(data["days_in_milk"]) / len(data["days_in_milk"]) if data["days_in_milk"] else 0.0
)

om.add_variable(
f"average_estimated_daily_milk_produced_{parity_group}",
average_milk,
info_map,
)
om.add_variable(
f"average_days_in_milk_{parity_group}",
average_days_in_milk,
info_map,
)

@classmethod
def report_average_genetics(
cls, average_genetics: dict[str, float | None], variable_name_prefix: str, simulation_day: int
Expand Down Expand Up @@ -977,6 +1018,11 @@ def report_sold_animal_information(cls, herd_statistics: HerdStatistics) -> None
"class": AnimalModuleReporter.__name__,
"function": AnimalModuleReporter.report_sold_animal_information.__name__,
}
milk_by_parity_group: dict[str, list[float]] = {
animal_constants.HEIFER_REPRO_CULL: 0,
"parity_2": [],
"parity_3_and_above": [],
}
for animal in sold_animals:
om.add_variable("animal_id", animal["id"], dict(info_map, **{"units": MeasurementUnits.UNITLESS}))
om.add_variable(
Expand Down