Skip to content

Update crop residue biomass calculation and adjust related test cases#207

Merged
SvenVw merged 2 commits into
developmentfrom
FDM203
Jul 30, 2025
Merged

Update crop residue biomass calculation and adjust related test cases#207
SvenVw merged 2 commits into
developmentfrom
FDM203

Conversation

@SvenVw
Copy link
Copy Markdown
Collaborator

@SvenVw SvenVw commented Jul 29, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Corrected the calculation of crop residue biomass in nitrogen balance computations, resulting in updated nitrogen removal and volatilization values.
  • Tests

    • Updated test cases to reflect changes in calculation logic and adjusted expected results accordingly. Input data for tests now includes explicit date ranges for cultivations.

Closes #203

@SvenVw SvenVw self-assigned this Jul 29, 2025
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jul 29, 2025

🦋 Changeset detected

Latest commit: a088e0d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@svenvw/fdm-calculator Patch
@svenvw/fdm-app Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 29, 2025

Walkthrough

The changes update the calculation of crop residue biomass in nitrogen balance and volatilization functions by dividing the yield by the harvest index before applying residue and nitrogen content factors. Corresponding test cases were updated to include explicit cultivation date ranges and adjusted expected values to match the revised calculation.

Changes

Cohort / File(s) Change Summary
Calculation Logic: Nitrogen Residue & Volatilization
fdm-calculator/src/balance/nitrogen/removal/residue.ts, fdm-calculator/src/balance/nitrogen/volatization/residues.ts
Modified formulas to divide yield by harvest index before multiplying by residue and nitrogen content factors in both nitrogen removal and volatilization calculations.
Test Updates: Nitrogen Removal & Residue
fdm-calculator/src/balance/nitrogen/removal/index.test.ts, fdm-calculator/src/balance/nitrogen/removal/residue.test.ts
Added explicit b_lu_start and b_lu_end dates to cultivation objects; updated expected nitrogen removal values to reflect new calculation logic.
Test Updates: Nitrogen Volatilization
fdm-calculator/src/balance/nitrogen/volatization/residues.test.ts
Added explicit cultivation date ranges and updated expected volatilization values to match new calculation.
Documentation/Changelog
.changeset/sour-kings-drive.md
Added a changeset entry summarizing the fix to residue biomass calculation in nitrogen balance.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant NitrogenRemoval
    participant NitrogenVolatilization
    participant CultivationData

    User->>NitrogenRemoval: Request nitrogen removal calculation
    NitrogenRemoval->>CultivationData: Fetch yield, harvest index, residue factors
    NitrogenRemoval->>NitrogenRemoval: Compute (yield / harvest index) * residue * N-content
    NitrogenRemoval-->>User: Return updated nitrogen removal

    User->>NitrogenVolatilization: Request volatilization calculation
    NitrogenVolatilization->>CultivationData: Fetch yield, harvest index, residue factors, emission factor
    NitrogenVolatilization->>NitrogenVolatilization: Compute (yield / harvest index) * residue * N-content * emission
    NitrogenVolatilization-->>User: Return updated volatilization value
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
Fix calculation for residue biomass at nitrogen balance (#203)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Possibly related PRs

Suggested labels

fdm-calculator

Suggested reviewers

  • gerardhros

Poem

In fields of code where residues lie,
A rabbit hopped by with a keen, bright eye.
"Divide by the index!" it thumped in delight,
Now nitrogen counts are finally right.
With harvest and yield in perfect array,
The bunny declares: "It's a balanced day!"
🐇🌾

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 26d1142 and a088e0d.

📒 Files selected for processing (6)
  • .changeset/sour-kings-drive.md (1 hunks)
  • fdm-calculator/src/balance/nitrogen/removal/index.test.ts (3 hunks)
  • fdm-calculator/src/balance/nitrogen/removal/residue.test.ts (8 hunks)
  • fdm-calculator/src/balance/nitrogen/removal/residue.ts (1 hunks)
  • fdm-calculator/src/balance/nitrogen/volatization/residues.test.ts (9 hunks)
  • fdm-calculator/src/balance/nitrogen/volatization/residues.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: SvenVw
PR: SvenVw/fdm#134
File: fdm-calculator/src/balance/nitrogen/index.ts:236-238
Timestamp: 2025-05-26T10:32:15.538Z
Learning: In nitrogen balance calculations for agricultural systems, removal and volatilization are calculated as negative values by definition since they represent nitrogen losses from the system. The balance calculation uses addition (.add()) for all components because removal and volatilization are already negative, so adding them effectively subtracts the losses from the supply.
Learnt from: SvenVw
PR: SvenVw/fdm#156
File: fdm-calculator/src/norms/nl/2025/stikstofgebruiksnorm.ts:295-303
Timestamp: 2025-07-21T12:06:07.070Z
Learning: Functions in the fdm-calculator with "NL2025" in their names are specifically designed for Netherlands 2025 agricultural norms calculation and hardcoded 2025 dates are appropriate in this context, as different years would have separate calculation modules.
Learnt from: SvenVw
PR: SvenVw/fdm#134
File: fdm-calculator/src/balance/nitrogen/index.ts:162-168
Timestamp: 2025-05-26T10:32:00.674Z
Learning: In the nitrogen balance calculation system (fdm-calculator), removal and volatilization values are negative by definition. This means the balance calculation using supply.total.add(removal.total).add(volatilization.total) is correct, as it effectively computes supply - |removal| - |volatilization|.
fdm-calculator/src/balance/nitrogen/volatization/residues.test.ts (8)

Learnt from: SvenVw
PR: #134
File: fdm-calculator/src/balance/nitrogen/index.ts:236-238
Timestamp: 2025-05-26T10:32:15.538Z
Learning: In nitrogen balance calculations for agricultural systems, removal and volatilization are calculated as negative values by definition since they represent nitrogen losses from the system. The balance calculation uses addition (.add()) for all components because removal and volatilization are already negative, so adding them effectively subtracts the losses from the supply.

Learnt from: SvenVw
PR: #9
File: fdm-data/src/cultivations/index.test.ts:57-59
Timestamp: 2024-11-27T12:15:36.425Z
Learning: In fdm-data/src/cultivations/index.test.ts, the fdm object created by drizzle does not have an .end() method. Cleanup code should not attempt to call fdm.end();.

Learnt from: SvenVw
PR: #134
File: fdm-calculator/src/balance/nitrogen/index.ts:162-168
Timestamp: 2025-05-26T10:32:00.674Z
Learning: In the nitrogen balance calculation system (fdm-calculator), removal and volatilization values are negative by definition. This means the balance calculation using supply.total.add(removal.total).add(volatilization.total) is correct, as it effectively computes supply - |removal| - |volatilization|.

Learnt from: SvenVw
PR: #9
File: fdm-data/src/cultivations/index.test.ts:57-59
Timestamp: 2024-11-27T11:27:27.797Z
Learning: When cleaning up test data in afterAll hooks in fdm-data/src/cultivations/index.test.ts, use fdm.delete(schema.tableName).execute(); to delete rows from a table without dropping the table itself.

Learnt from: SvenVw
PR: #156
File: fdm-calculator/src/norms/nl/2025/stikstofgebruiksnorm.ts:295-303
Timestamp: 2025-07-21T12:06:07.070Z
Learning: Functions in the fdm-calculator with "NL2025" in their names are specifically designed for Netherlands 2025 agricultural norms calculation and hardcoded 2025 dates are appropriate in this context, as different years would have separate calculation modules.

Learnt from: SvenVw
PR: #49
File: fdm-core/src/db/schema.ts:407-426
Timestamp: 2025-01-23T15:18:57.212Z
Learning: In the farm data model, each cultivation (b_lu) can have only one termination date but can have multiple harvest dates. This is enforced through the database schema where cultivationTerminating uses b_lu as primary key while cultivationHarvesting uses a composite primary key of b_id_harvestable and b_lu.

Learnt from: SvenVw
PR: #71
File: fdm-app/app/routes/farm.$b_id_farm.field.$b_id.cultivation.$b_lu.harvest.$b_id_harvesting.tsx:114-124
Timestamp: 2025-02-13T08:35:59.306Z
Learning: The HarvestForm component in fdm-app expects undefined (not 0) for b_lu_yield when no yield information is available, as 0 would incorrectly imply that yield data exists.

Learnt from: SvenVw
PR: #49
File: fdm-core/src/cultivation.ts:625-671
Timestamp: 2025-01-24T11:39:57.805Z
Learning: Every cultivation has an associated cultivationTerminating record created by addCultivation, with b_terminate_date initially set to null. Therefore, updateCultivation can safely assume the record exists and only needs to handle updates.

fdm-calculator/src/balance/nitrogen/volatization/residues.ts (4)

Learnt from: SvenVw
PR: #134
File: fdm-calculator/src/balance/nitrogen/index.ts:236-238
Timestamp: 2025-05-26T10:32:15.538Z
Learning: In nitrogen balance calculations for agricultural systems, removal and volatilization are calculated as negative values by definition since they represent nitrogen losses from the system. The balance calculation uses addition (.add()) for all components because removal and volatilization are already negative, so adding them effectively subtracts the losses from the supply.

Learnt from: SvenVw
PR: #134
File: fdm-calculator/src/balance/nitrogen/index.ts:162-168
Timestamp: 2025-05-26T10:32:00.674Z
Learning: In the nitrogen balance calculation system (fdm-calculator), removal and volatilization values are negative by definition. This means the balance calculation using supply.total.add(removal.total).add(volatilization.total) is correct, as it effectively computes supply - |removal| - |volatilization|.

Learnt from: SvenVw
PR: #71
File: fdm-app/app/routes/farm.$b_id_farm.field.$b_id.cultivation.$b_lu.harvest.$b_id_harvesting.tsx:114-124
Timestamp: 2025-02-13T08:35:59.306Z
Learning: The HarvestForm component in fdm-app expects undefined (not 0) for b_lu_yield when no yield information is available, as 0 would incorrectly imply that yield data exists.

Learnt from: SvenVw
PR: #49
File: fdm-core/src/db/schema.ts:407-426
Timestamp: 2025-01-23T15:18:57.212Z
Learning: In the farm data model, each cultivation (b_lu) can have only one termination date but can have multiple harvest dates. This is enforced through the database schema where cultivationTerminating uses b_lu as primary key while cultivationHarvesting uses a composite primary key of b_id_harvestable and b_lu.

.changeset/sour-kings-drive.md (7)

Learnt from: SvenVw
PR: #156
File: fdm-calculator/src/norms/nl/2025/stikstofgebruiksnorm.ts:295-303
Timestamp: 2025-07-21T12:06:07.070Z
Learning: Functions in the fdm-calculator with "NL2025" in their names are specifically designed for Netherlands 2025 agricultural norms calculation and hardcoded 2025 dates are appropriate in this context, as different years would have separate calculation modules.

Learnt from: SvenVw
PR: #6
File: fdm-app/vite.config.ts:5-9
Timestamp: 2024-11-25T12:42:32.783Z
Learning: In the fdm-app project, SvenVw is preparing for migration to Remix v3 and may include type declarations or configurations for v3 features in advance, such as in vite.config.ts.

Learnt from: SvenVw
PR: #75
File: fdm-app/app/routes/farm.$b_id_farm.field.$b_id.fertilizer.tsx:68-71
Timestamp: 2025-02-14T09:56:37.606Z
Learning: The calculateDose function in @svenvw/fdm-calculator is a synchronous function that includes built-in validation for negative application amounts and nutrient rates.

Learnt from: SvenVw
PR: #134
File: fdm-calculator/src/balance/nitrogen/index.ts:162-168
Timestamp: 2025-05-26T10:32:00.674Z
Learning: In the nitrogen balance calculation system (fdm-calculator), removal and volatilization values are negative by definition. This means the balance calculation using supply.total.add(removal.total).add(volatilization.total) is correct, as it effectively computes supply - |removal| - |volatilization|.

Learnt from: SvenVw
PR: #134
File: fdm-calculator/src/balance/nitrogen/index.ts:236-238
Timestamp: 2025-05-26T10:32:15.538Z
Learning: In nitrogen balance calculations for agricultural systems, removal and volatilization are calculated as negative values by definition since they represent nitrogen losses from the system. The balance calculation uses addition (.add()) for all components because removal and volatilization are already negative, so adding them effectively subtracts the losses from the supply.

Learnt from: SvenVw
PR: #88
File: fdm-calculator/src/doses/calculate-dose.ts:18-18
Timestamp: 2025-03-04T10:56:35.540Z
Learning: In the FDM calculator, fertilizer nutrient rates (p_n_rt, p_p_rt, p_k_rt) are measured in g/kg, and are converted to fractions by dividing by 10 during dose calculations.

Learnt from: SvenVw
PR: #71
File: fdm-app/app/routes/farm.$b_id_farm.field.$b_id.cultivation.$b_lu.harvest.$b_id_harvesting.tsx:114-124
Timestamp: 2025-02-13T08:35:59.306Z
Learning: The HarvestForm component in fdm-app expects undefined (not 0) for b_lu_yield when no yield information is available, as 0 would incorrectly imply that yield data exists.

fdm-calculator/src/balance/nitrogen/removal/residue.ts (4)

Learnt from: SvenVw
PR: #134
File: fdm-calculator/src/balance/nitrogen/index.ts:236-238
Timestamp: 2025-05-26T10:32:15.538Z
Learning: In nitrogen balance calculations for agricultural systems, removal and volatilization are calculated as negative values by definition since they represent nitrogen losses from the system. The balance calculation uses addition (.add()) for all components because removal and volatilization are already negative, so adding them effectively subtracts the losses from the supply.

Learnt from: SvenVw
PR: #134
File: fdm-calculator/src/balance/nitrogen/index.ts:162-168
Timestamp: 2025-05-26T10:32:00.674Z
Learning: In the nitrogen balance calculation system (fdm-calculator), removal and volatilization values are negative by definition. This means the balance calculation using supply.total.add(removal.total).add(volatilization.total) is correct, as it effectively computes supply - |removal| - |volatilization|.

Learnt from: SvenVw
PR: #71
File: fdm-app/app/routes/farm.$b_id_farm.field.$b_id.cultivation.$b_lu.harvest.$b_id_harvesting.tsx:114-124
Timestamp: 2025-02-13T08:35:59.306Z
Learning: The HarvestForm component in fdm-app expects undefined (not 0) for b_lu_yield when no yield information is available, as 0 would incorrectly imply that yield data exists.

Learnt from: SvenVw
PR: #49
File: fdm-core/src/db/schema.ts:407-426
Timestamp: 2025-01-23T15:18:57.212Z
Learning: In the farm data model, each cultivation (b_lu) can have only one termination date but can have multiple harvest dates. This is enforced through the database schema where cultivationTerminating uses b_lu as primary key while cultivationHarvesting uses a composite primary key of b_id_harvestable and b_lu.

fdm-calculator/src/balance/nitrogen/removal/residue.test.ts (9)

Learnt from: SvenVw
PR: #9
File: fdm-data/src/cultivations/index.test.ts:57-59
Timestamp: 2024-11-27T12:15:36.425Z
Learning: In fdm-data/src/cultivations/index.test.ts, the fdm object created by drizzle does not have an .end() method. Cleanup code should not attempt to call fdm.end();.

Learnt from: SvenVw
PR: #134
File: fdm-calculator/src/balance/nitrogen/index.ts:236-238
Timestamp: 2025-05-26T10:32:15.538Z
Learning: In nitrogen balance calculations for agricultural systems, removal and volatilization are calculated as negative values by definition since they represent nitrogen losses from the system. The balance calculation uses addition (.add()) for all components because removal and volatilization are already negative, so adding them effectively subtracts the losses from the supply.

Learnt from: SvenVw
PR: #9
File: fdm-data/src/cultivations/index.test.ts:57-59
Timestamp: 2024-11-27T11:27:27.797Z
Learning: When cleaning up test data in afterAll hooks in fdm-data/src/cultivations/index.test.ts, use fdm.delete(schema.tableName).execute(); to delete rows from a table without dropping the table itself.

Learnt from: SvenVw
PR: #134
File: fdm-calculator/src/balance/nitrogen/index.ts:162-168
Timestamp: 2025-05-26T10:32:00.674Z
Learning: In the nitrogen balance calculation system (fdm-calculator), removal and volatilization values are negative by definition. This means the balance calculation using supply.total.add(removal.total).add(volatilization.total) is correct, as it effectively computes supply - |removal| - |volatilization|.

Learnt from: SvenVw
PR: #156
File: fdm-calculator/src/norms/nl/2025/stikstofgebruiksnorm.ts:295-303
Timestamp: 2025-07-21T12:06:07.070Z
Learning: Functions in the fdm-calculator with "NL2025" in their names are specifically designed for Netherlands 2025 agricultural norms calculation and hardcoded 2025 dates are appropriate in this context, as different years would have separate calculation modules.

Learnt from: SvenVw
PR: #71
File: fdm-app/app/routes/farm.create.$b_id_farm.cultivations.$b_lu_catalogue.crop.harvest._index.tsx:111-135
Timestamp: 2025-02-13T09:03:11.890Z
Learning: When adding multiple harvests in fdm-app, use Promise.all instead of Promise.allSettled to ensure atomic behavior - if one harvest addition fails, all should fail and rollback to maintain data consistency.

Learnt from: SvenVw
PR: #49
File: fdm-core/src/db/schema.ts:407-426
Timestamp: 2025-01-23T15:18:57.212Z
Learning: In the farm data model, each cultivation (b_lu) can have only one termination date but can have multiple harvest dates. This is enforced through the database schema where cultivationTerminating uses b_lu as primary key while cultivationHarvesting uses a composite primary key of b_id_harvestable and b_lu.

Learnt from: SvenVw
PR: #71
File: fdm-app/app/routes/farm.$b_id_farm.field.$b_id.cultivation.$b_lu.harvest.$b_id_harvesting.tsx:114-124
Timestamp: 2025-02-13T08:35:59.306Z
Learning: The HarvestForm component in fdm-app expects undefined (not 0) for b_lu_yield when no yield information is available, as 0 would incorrectly imply that yield data exists.

Learnt from: SvenVw
PR: #49
File: fdm-core/src/cultivation.ts:625-671
Timestamp: 2025-01-24T11:39:57.805Z
Learning: Every cultivation has an associated cultivationTerminating record created by addCultivation, with b_terminate_date initially set to null. Therefore, updateCultivation can safely assume the record exists and only needs to handle updates.

fdm-calculator/src/balance/nitrogen/removal/index.test.ts (8)

Learnt from: SvenVw
PR: #9
File: fdm-data/src/cultivations/index.test.ts:57-59
Timestamp: 2024-11-27T12:15:36.425Z
Learning: In fdm-data/src/cultivations/index.test.ts, the fdm object created by drizzle does not have an .end() method. Cleanup code should not attempt to call fdm.end();.

Learnt from: SvenVw
PR: #134
File: fdm-calculator/src/balance/nitrogen/index.ts:236-238
Timestamp: 2025-05-26T10:32:15.538Z
Learning: In nitrogen balance calculations for agricultural systems, removal and volatilization are calculated as negative values by definition since they represent nitrogen losses from the system. The balance calculation uses addition (.add()) for all components because removal and volatilization are already negative, so adding them effectively subtracts the losses from the supply.

Learnt from: SvenVw
PR: #134
File: fdm-calculator/src/balance/nitrogen/index.ts:162-168
Timestamp: 2025-05-26T10:32:00.674Z
Learning: In the nitrogen balance calculation system (fdm-calculator), removal and volatilization values are negative by definition. This means the balance calculation using supply.total.add(removal.total).add(volatilization.total) is correct, as it effectively computes supply - |removal| - |volatilization|.

Learnt from: SvenVw
PR: #9
File: fdm-data/src/cultivations/index.test.ts:57-59
Timestamp: 2024-11-27T11:27:27.797Z
Learning: When cleaning up test data in afterAll hooks in fdm-data/src/cultivations/index.test.ts, use fdm.delete(schema.tableName).execute(); to delete rows from a table without dropping the table itself.

Learnt from: SvenVw
PR: #156
File: fdm-calculator/src/norms/nl/2025/stikstofgebruiksnorm.ts:295-303
Timestamp: 2025-07-21T12:06:07.070Z
Learning: Functions in the fdm-calculator with "NL2025" in their names are specifically designed for Netherlands 2025 agricultural norms calculation and hardcoded 2025 dates are appropriate in this context, as different years would have separate calculation modules.

Learnt from: SvenVw
PR: #49
File: fdm-core/src/db/schema.ts:407-426
Timestamp: 2025-01-23T15:18:57.212Z
Learning: In the farm data model, each cultivation (b_lu) can have only one termination date but can have multiple harvest dates. This is enforced through the database schema where cultivationTerminating uses b_lu as primary key while cultivationHarvesting uses a composite primary key of b_id_harvestable and b_lu.

Learnt from: SvenVw
PR: #71
File: fdm-app/app/routes/farm.$b_id_farm.field.$b_id.cultivation.$b_lu.harvest.$b_id_harvesting.tsx:114-124
Timestamp: 2025-02-13T08:35:59.306Z
Learning: The HarvestForm component in fdm-app expects undefined (not 0) for b_lu_yield when no yield information is available, as 0 would incorrectly imply that yield data exists.

Learnt from: SvenVw
PR: #71
File: fdm-app/app/routes/farm.create.$b_id_farm.cultivations.$b_lu_catalogue.crop.harvest._index.tsx:111-135
Timestamp: 2025-02-13T09:03:11.890Z
Learning: When adding multiple harvests in fdm-app, use Promise.all instead of Promise.allSettled to ensure atomic behavior - if one harvest addition fails, all should fail and rollback to maintain data consistency.

🔇 Additional comments (8)
fdm-calculator/src/balance/nitrogen/removal/residue.ts (1)

105-106: Formula fix correctly implemented.

The addition of .dividedBy(b_lu_hi) correctly implements the required formula from issue #203. This converts the yield to total biomass basis before applying the residue fraction (1 - b_lu_hi) and nitrogen content, matching the expected calculation: (b_lu_yield / b_lu_hi) * (1 - b_lu_hi) * b_lu_n_residue.

.changeset/sour-kings-drive.md (1)

1-6: Changeset documentation is appropriate.

The changeset correctly categorizes this as a patch release and provides a clear description that matches the PR objectives. The format follows standard changeset conventions.

fdm-calculator/src/balance/nitrogen/removal/residue.test.ts (2)

27-28: Test date properties correctly added.

Adding explicit b_lu_start and b_lu_end date properties to cultivation objects ensures test data completeness and consistency across the nitrogen balance module.

Also applies to: 51-52, 88-89, 123-124, 145-146, 169-170, 193-194


79-80: Expected values correctly updated for formula change.

The adjustment from approximately -1.2 to -3 correctly reflects the 2.5x increase expected from dividing by the harvest index (b_lu_hi = 0.4). This validates that the biomass calculation fix is working as intended.

Also applies to: 114-115, 136-137, 216-217

fdm-calculator/src/balance/nitrogen/removal/index.test.ts (2)

12-13: Date properties appropriately added.

Adding b_lu_start and b_lu_end properties ensures consistent test data structure across the nitrogen balance module.

Also applies to: 61-62


50-50: Integration test values correctly updated.

The total nitrogen removal correctly reflects the residue calculation change (-21.2 to -23), while harvest removal remains unchanged at -20. This confirms the fix specifically targets residue biomass calculation without affecting other components.

Also applies to: 52-52

fdm-calculator/src/balance/nitrogen/volatization/residues.test.ts (2)

27-28: Date properties consistently added.

The addition of cultivation date properties maintains consistency across all nitrogen balance test files.

Also applies to: 66-67, 120-121, 144-145, 181-182, 219-220


55-55: Harvest index division confirmed in volatilization residues calculation

Verification shows that in fdm-calculator/src/balance/nitrogen/volatization/residues.ts (line 114) the biomass value is correctly scaled by .dividedBy(b_lu_hi). The 2.5× increase in the test (from –2.688 to –6.72) matches this fix, so no further changes are needed.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch FDM203

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.04%. Comparing base (26d1142) to head (a088e0d).
⚠️ Report is 3 commits behind head on development.

Additional details and impacted files
@@             Coverage Diff              @@
##           development     #207   +/-   ##
============================================
  Coverage        94.04%   94.04%           
============================================
  Files               85       85           
  Lines            12632    12634    +2     
  Branches          1291     1291           
============================================
+ Hits             11880    11882    +2     
  Misses             750      750           
  Partials             2        2           
Flag Coverage Δ
fdm-calculator 94.96% <100.00%> (+<0.01%) ⬆️
fdm-core 93.38% <ø> (ø)
fdm-data 94.21% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot changed the title @coderabbitai Update crop residue biomass calculation and adjust related test cases Jul 29, 2025
@SvenVw SvenVw requested a review from gerardhros July 29, 2025 13:44
Copy link
Copy Markdown
Collaborator

@gerardhros gerardhros left a comment

Choose a reason for hiding this comment

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

Thanks. LGTM.

@SvenVw SvenVw merged commit 2716a8c into development Jul 30, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix calculation for residue biomass at nitrogen balance

2 participants