Skip to content

[Output][Naming][Units] Updates to variable names and units#3149

Open
ew3361zh wants to merge 19 commits into
devfrom
output-variable-names
Open

[Output][Naming][Units] Updates to variable names and units#3149
ew3361zh wants to merge 19 commits into
devfrom
output-variable-names

Conversation

@ew3361zh

@ew3361zh ew3361zh commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Addresses a handful of units and variable naming issues raised.

Context

Issue(s) closed by this pull request: closes #3057

What

  • Updates Weather.mean_annual_temperature -> Weather.long_term_average_annual_temperature to better represent the calculation made to determine it.
  • Updates units for EnergyEstimator.estimate_all.application_depth_for_(Fertilizer/Manure)_Application from cm to mm.
  • Updates units for EnergyEstimator.estimate_all.diesel_consumption_for_(Fertilizer_Application/Manure_Application/Harvest/Planting from LITERS_PER_TON to LITERS_PER_HA.
  • Updates EnergyEstimator.estimate_all to properly aggregate total_diesel_consumption_tractor_implement as a total amount of diesel consumed across fields and implements and updated the unit to LITERS.
  • Removes the following outputs from the animal module:
    • AnimalModuleReporter.report_manure_excretions.[ANIMAL_COMBINATION][PEN#]_inorganic_phosphorus_fraction
    • AnimalModuleReporter.report_manure_excretions.[ANIMAL_COMBINATION][PEN#]_organic_phosphorus_fraction
    • AnimalModuleReporter.report_manure_excretions.[ANIMAL_COMBINATION][PEN#]_non_water_inorganic_phosphorus_fraction
    • AnimalModuleReporter.report_manure_excretions.[ANIMAL_COMBINATION][PEN#]_non_water_organic_phosphorus_fraction

Why

The updated units and names were either confusing or outright incorrect.
The removed outputs were not passed to the manure module and the SME team opted to remove them for the time being.

How

Updated specific references as outlined in the What section. Additionally updated all related unit testing.

Test plan

Input Changes

Output Changes

  • N/A

Filter

@github-actions

Copy link
Copy Markdown
Contributor

Current Coverage: 99%

Mypy errors on output-variable-names branch: 1136
Mypy errors on dev branch: 1136
No difference in error counts

@github-actions

Copy link
Copy Markdown
Contributor

🚨 Please update the changelog. This PR cannot be merged until changelog_WIP.md is updated.

@github-actions

Copy link
Copy Markdown
Contributor

Current Coverage: 99%

Mypy errors on output-variable-names branch: 1136
Mypy errors on dev branch: 1136
No difference in error counts

@github-actions

Copy link
Copy Markdown
Contributor

Current Coverage: 99%

Mypy errors on output-variable-names branch: 1136
Mypy errors on dev branch: 1136
No difference in error counts

@ew3361zh
ew3361zh marked this pull request as ready for review July 20, 2026 20:09
@github-actions

Copy link
Copy Markdown
Contributor

Current Coverage: 99%

Mypy errors on output-variable-names branch: 1141
Mypy errors on dev branch: 1136
5 more errors on output-variable-names branch

@allisterakun allisterakun left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just one observation regarding if it makes sense to sum L/ha together.

Comment thread RUFAS/EEE/energy.py Outdated
diesel_consumption_tractor_implement_liter_per_ha,
)
total_diesel_consumption_tractor_implement_liter_per_ha = diesel_consumption_tractor_implement_liter_per_ha
total_diesel_consumption_tractor_implement_liter_per_ha += diesel_consumption_tractor_implement_liter_per_ha

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth some review here about the meaning of this variable vs its unit:
it seems like we're iterating all tractor operations potentially across difference field (hence different field size). It looks like we are just recording it as an output at the moment, but if we multiply this consumption rate in L/ha by the field size, then it introduces a potential error here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After discussion with Pooya and Allister, we decided to change this to an aggregated amount of diesel consumed by all implements across all farms instead trying to summarize different rates across different fields and implements. The total diesel consumed seemed like a more meaningful output. The individual diesel consumption rates are still logged to OM as before (and it's now clearer that they are diesel consumption rates).

@matthew7838 matthew7838 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions

Copy link
Copy Markdown
Contributor

Current Coverage: 99%

Mypy errors on output-variable-names branch: 1141
Mypy errors on dev branch: 1136
5 more errors on output-variable-names branch

Comment thread RUFAS/EEE/energy.py
Comment on lines 156 to 198
@@ -173,9 +174,9 @@ def estimate_all(simulate_animals: bool, simulate_feed: bool, simulate_fields: b
harvest_type=harvest_type,
)

diesel_consumption_tractor_implement_liter_per_ha = estimator.calculate_diesel_consumption(
diesel_consumption_tractor_implement_liters_per_ha = estimator.calculate_diesel_consumption(
diesel_consumption_data_item.get("crop_yield", 0),
diesel_consumption_data_item["field_production_size"],
field_production_size,
tractor,
diesel_consumption_data_item.get("clay_percent", 0),
diesel_consumption_data_item.get("mass"),
@@ -185,21 +186,23 @@ def estimate_all(simulate_animals: bool, simulate_feed: bool, simulate_fields: b
diesel_consumption_data_item,
herd_size,
tractor.tractor_size,
diesel_consumption_tractor_implement_liter_per_ha,
diesel_consumption_tractor_implement_liters_per_ha,
)
total_diesel_consumption_tractor_implement_liters += (
diesel_consumption_tractor_implement_liters_per_ha * field_production_size
)
total_diesel_consumption_tractor_implement_liter_per_ha = diesel_consumption_tractor_implement_liter_per_ha
om.add_variable(
"total_diesel_consumption_tractor_implement",
total_diesel_consumption_tractor_implement_liter_per_ha,
{**base_info_map, **{"units": MeasurementUnits.LITERS_PER_HA}},
"total_tractor_implement_diesel_consumption",
total_diesel_consumption_tractor_implement_liters,
{**base_info_map, **{"units": MeasurementUnits.LITERS}},
)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KFosterReed wanted to tag you in here for a discussion/question we weren't able to resolve at our dev team work-together yesterday:

this variable being added at the end (now total_tractor_implement_diesel_consumption) is currently on dev as total_diesel_consumption_tractor_implement. It seems from code-context that it was supposed to be aggregating the individual diesel_consumption_tractor_implement_liter_per_ha (calculated a few lines above from calculate_diesel_consumption()) but the way it was set up it was just resetting every loop and logging the individual calculated value.

I initially made a quick change to aggregate these values and report the total summed amount but as @allisterakun caught in his review, these individual calculated diesel_consumption_tractor_implement_liter_per_ha variables are 1. diesel consumption RATES specific to their tractor implement and a field size and 2. already reported individually by report_diesel_consumption() which is called directly above.

In our discussion, we thought the thing that made sense to calculate was the total diesel consumed across all fields by all implements which meant calculating the rate and multiplying it by the field size and then adding that to the aggregating variable (total_tractor_implement_diesel_consumption).

But we couldn't find the documentation to check if this assumption was correct so we're hoping you can weigh in on this. Let me know if you need more context (or less) or if you have any further clarifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issues and descrepncies in output variables

3 participants