Skip to content

Make NCC compost timing crop specific and align both event workflows on the latest version monitoring - #4079

Merged
mdietze merged 14 commits into
PecanProject:developfrom
divine7022:n_ncc_tweaks
Aug 24, 2026
Merged

Make NCC compost timing crop specific and align both event workflows on the latest version monitoring#4079
mdietze merged 14 commits into
PecanProject:developfrom
divine7022:n_ncc_tweaks

Conversation

@divine7022

Copy link
Copy Markdown
Member

Description

NCC timed compost by a binary annual/perennial split, with the offset always subtracted from a single green-up anchor. This makes the rule per PFT and allows an event to fall after its anchor.

Both workflows now read the gap-filled LandIQ to MSLSP match, which carries every phenology transition keyed (parcel_id, year, season). Crop cycles join on the season key instead of by rank.

Fertilization changes are included for input consistency, on adopting latest version of monitoring. Its timing is unchanged, date is still anchor itself, and mslsp_50PCGI is transition leafonday was derived from.

Changes

  • Per PFT anchor, signed offset window and rate structure, set in config.yml. Row and rice on mslsp_OGI, woody on mslsp_50PCGI, hay on mslsp_OGD
  • Crop code to PFT now comes from LandIQ_cropCode_lookup_table.csv, the table the monitoring products use. Alfalfa and pasture move from row to hay, G6/G7 from hay to row
  • check-result.R asserts each event falls inside its PFT's window. The year bound now allows a year on each side, since signed offsets can leave the anchor's year in either direction
  • Output paths versioned to v2.0
  • Few doc fixes

Motivation and Context

Review Time Estimate

  • Immediately
  • Within one week
  • When possible

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • My name is in the list of CITATION.cff
  • I agree that PEcAn Project may distribute my contribution under any or all of
    • the same license as the existing code,
    • and/or the BSD 3-clause license.
  • I have updated the CHANGELOG.md.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@divine7022
divine7022 requested a review from sarahkanee August 23, 2026 22:08
Comment on lines +14 to +15
phen_dir: !expr path.expand(Sys.getenv("CCMMF_PHEN_DIR", "/projectnb/dietzelab/ccmmf/management/phenology/matched_landiq_mslsp_v4.1.2/gapfill_dates"))
phen_glob: !expr Sys.getenv("CCMMF_PHEN_GLOB", "assigned_year=*_gapfilled.parquet")

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.

@hdpriest-ui these defaults are handy for development, but should we move toward a workflow where we always explicitly set these environment variables? And if so, is now the time to do so?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would definitely encourage us to move away from using absolute hardcoded paths in these configurations.

If i were to pull this, I definitely won't have these paths available to these R scripts. In addition, I would caution against using !expr in yaml files, as R is not the only language we are using for this project, and not the only language that may need to parse this yaml file.

for example, when i use one of those lines as a input to the linux yq tool, i get something like:
path.expand(Sys.getenv("CCMMF_PHEN_DIR", "testPath"))

as the value returned from the yaml read on that key.

the same will happen if a person reads this using the python implementation of yaml parsing from posit, and if they use the standard python yaml library, it will throw a ConstructorError.

the lines above are documented in the readme as config entries which have "overrides", but for anyone not on the BU server, these are actually required input configuration entries. Because they are interpreted within the config itself, there is also no way to reconstruct the actual run-time configuration passed to an execution of these scripts, because the critical variables are in the calling environment rather than on disk.

@sarahkanee

Copy link
Copy Markdown
Contributor

The points above are valid and apply across CCMMF as we move toward more mature code. For this PR's scope though, I think it looks good. I'd like to merge this now and tackle the broader items in follow-up work.

@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.

FWIW I agree with @hdpriest-ui point, which I think applies across a lot of MAGIC scripts

Because they are interpreted within the config itself, there is also no way to reconstruct the actual run-time configuration passed to an execution of these scripts, because the critical variables are in the calling environment rather than on disk.

That said, I also agree with @sarahkanee to pull this now and refine in a future PR

@mdietze
mdietze added this pull request to the merge queue Aug 24, 2026
Merged via the queue into PecanProject:develop with commit d38bea7 Aug 24, 2026
20 of 22 checks passed
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.

5 participants