Skip to content

Add new transition matrix and optimization workflow - #4101

Merged
mdietze merged 12 commits into
PecanProject:developfrom
ananyak534:matrix-development
Sep 17, 2026
Merged

mdietze merged 12 commits into
PecanProject:developfrom
ananyak534:matrix-development

Conversation

@ananyak534

Copy link
Copy Markdown
Contributor

Submitting a new PR for this new/cleaned branch on transition matrix and matrix optimization development due to multiple changes overtime

PR includes:

  • reusable crop transition functions in modules/data.remote/R/transition_functions.R
  • historical per county crop transition-matrix construction
  • crop transition-matrix optimization based on the scenario acreage targets
  • documentation for the transition and optimization workflow

Main outputs
The workflow produces:

  • crops_full_counties.csv
  • crop_year_states_cleaned.csv
  • county historical crop transition matrices
  • optimized county crop transition matrices

The optimized matrices are used by the downstream parcel crop-prediction workflow.

@mdietze mdietze left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Need to run make document and commit the updated /man and NAMESPACE files


The crop-transition state space is:

```text

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

define values


Each row of the matrix therefore sums to 1.

## 3. Cleaning unknown crop states

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For the future: this should be done on the LandIQ in general, not just for calculating transitions. In that context, the observed CDL data also plays a role. Indeed, is Sarah's code not already gapfilling these values?

A parcel can contain multiple LandIQ observations within the same year because
multiple growing seasons may be recorded.

These observations are reduced to one annual crop state.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
These observations are reduced to one annual crop state.
To simplify the transition modeling, these observations are reduced to predicting changes in the dominant crop.

```

Crop optimization is performed once because the current BAU and NBS scenarios
use the same crop acreage targets.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would be helpful to provide a bit of info about what to do if you have different scenarios or new/additional scenarios. For example, do you run the code more than once, and if so how does that change how you specify inputs and outputs so that you can ensure downstream code uses the correct scenario-specific inputs.

For each county, the starting crop distribution is constructed from each
parcel's latest observed crop state at or before:

```text

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Similar to comments on the phenology workflow, in general you use text blobs too much and there are a lot of places you can simplify to just writing sentences. Also, in cases like this one, you should be clarifying how to set these sort of variables in the config rather than just telling us what the current default value is.

2023
```

Parcel acreage is summed by crop state to create:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Parcel acreage is summed by crop state to create:
Parcel acreage is summed by crop state to create `X0`, the county crop acreage vector used by the optimizer.

Comment thread modules/data.remote/inst/ccmmf/documentation/projections/01-matrix_development.md Outdated
Comment thread modules/data.remote/inst/ccmmf/documentation/projections/01-matrix_development.md Outdated
Comment thread modules/data.remote/inst/ccmmf/documentation/projections/01-matrix_development.md Outdated
Comment thread modules/data.remote/inst/ccmmf/documentation/projections/01-matrix_development.md Outdated
Comment thread modules/data.remote/inst/ccmmf/documentation/projections/01-matrix_development.md Outdated
Comment thread modules/data.remote/inst/ccmmf/documentation/projections/01-matrix_development.md Outdated
Comment thread modules/data.remote/inst/ccmmf/documentation/projections/01-matrix_development.md Outdated
Comment thread modules/data.remote/inst/ccmmf/documentation/projections/01-matrix_development.md Outdated
@@ -0,0 +1,447 @@
# Crop Transition Matrices and Scenario Optimization

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If both this file and the previous are numbered 01, how does the user know which to read/run first?

Ananya Kulkarni and others added 3 commits September 17, 2026 09:18
…ansition-matrix-optimization.md

This is an old documentation version, removing for cleaning. 01-matrix_development.md is the correct tutorial in this file
ananyak534 and others added 4 commits September 17, 2026 10:25
Co-authored-by: Michael Dietze <dietze@bu.edu>
Co-authored-by: Michael Dietze <dietze@bu.edu>
Co-authored-by: Michael Dietze <dietze@bu.edu>
Co-authored-by: Michael Dietze <dietze@bu.edu>
irrigation_max: 150


scc:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Make sure scripts are not hard coded to run with this as the default

Comment thread modules/data.remote/inst/config.yml
@mdietze
mdietze enabled auto-merge September 17, 2026 15:28
@mdietze
mdietze added this pull request to the merge queue Sep 17, 2026
Merged via the queue into PecanProject:develop with commit e56c265 Sep 17, 2026
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants