Skip to content

Preserve DATE-BEG, DATE-END when creating level2 files#963

Merged
jmbhughes merged 14 commits into
mainfrom
fix-identical-timestamps
Jun 14, 2026
Merged

Preserve DATE-BEG, DATE-END when creating level2 files#963
jmbhughes merged 14 commits into
mainfrom
fix-identical-timestamps

Conversation

@d-lamb

@d-lamb d-lamb commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

PR summary

When creating observatory-specific L2 files from L1 files, make sure the beginning and ending dates (DATE-BEG and DATE-END) are preserved in the L2 files. Also, when creating mosaic files, use the earliest input DATE-BEG and the latest input DATE-END in the mosaic.

This is one possible approach. We could adopt a different approach in which the earliest and latest DATE-OBS is what goes into the DATE-BEG and DATE-END of the mosaic.

Todos

Please list tasks to complete this PR.

  • Verify that the new behavior is what is actually wanted
  • Make sure that it also works for L3 PTM where 3 L1 polarized files go into the L2 XP files
  • Verify new tests pass
  • Verify that changes make it all the way to L3 CTM and L3 PTM (This can be done when running a full deployment test.)
  • Address the file provenance issue in comment to L3_CTM files have all date fields set the same #948. (Upon further reflection, I think this can be skipped since the L3_CTM files don't directly inherit from the L2_CTM files, but rather from the L2_X files.)

Test plan

Added many tests to auto/level2

Breaking changes

None known

Related Issues

Closes #948

@codecov

codecov Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.58974% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.24%. Comparing base (280159b) to head (ce41dec).
⚠️ Report is 44 commits behind head on main.

Files with missing lines Patch % Lines
punchbowl/data/meta.py 77.77% 4 Missing ⚠️
punchbowl/auto/flows/level3.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #963      +/-   ##
==========================================
+ Coverage   58.04%   58.24%   +0.19%     
==========================================
  Files         127      127              
  Lines       13833    13952     +119     
==========================================
+ Hits         8030     8126      +96     
- Misses       5803     5826      +23     

☔ View full report in Codecov by Harness.
📢 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.

d-lamb added 5 commits June 3, 2026 10:13
Previously L3_CIM files were getting date_beg and date_end from the min and max of the date_obs values of the inputs (which are all the same). Now they come from date_beg and date_end of the inputs (which are homogenized but different than date_obs).

Also we can skip two loops over input files when setting the outlier and bad packet flags because these are also homogenized in L2_X files.
@d-lamb d-lamb marked this pull request as ready for review June 4, 2026 03:12
@d-lamb d-lamb requested review from jmbhughes and svank June 4, 2026 03:12
@d-lamb

d-lamb commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

This is close, but not quite there. Currently it is doing a good job of settting the database fields from auto/flows, but needs to set the same info in the file header in level2/merge.py.

@d-lamb d-lamb marked this pull request as draft June 4, 2026 16:32
d-lamb added 2 commits June 5, 2026 14:44
Adds metadata properties "datebeg" and "dateend". Sorts through those properties when merging data. Adds tests.
@d-lamb d-lamb marked this pull request as ready for review June 5, 2026 22:32
@d-lamb d-lamb requested a review from lowderchris June 5, 2026 22:32
@d-lamb

d-lamb commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

OK, @jmbhughes, @svank, @lowderchris this is ready for review.

Comment thread punchbowl/auto/flows/tests/test_level2.py Outdated
Comment thread punchbowl/auto/flows/tests/test_level2.py Outdated
date_created=datetime(2026, 4, 9, 1, 0, 0, tzinfo=UTC),
date_beg=datetime(2026, 4, 8, 23, 52, 17, 143000, tzinfo=UTC),
date_obs=datetime(2026, 4, 8, 23, 52, 29, 143000, tzinfo=UTC),
date_end=datetime(2026, 4, 8, 23, 52, 41, 143000, tzinfo=UTC),

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.

I wonder if it would help testing to make one of the WFIs late, or something - to check how that will change things downstream in a predictable way.

@d-lamb d-lamb Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@lowderchris The commit ce41dec makes the two banks of tests the same, replaces the chained equality (which was cumbersome for 4 CTM files) with the len(set()) idiom, and actually checks the values of the returned date_beg, date_obs, and date_end, which is what I think you were going for here.

Comment thread punchbowl/auto/flows/tests/test_level2.py
Comment thread punchbowl/auto/flows/level3.py

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

This is looking great! Time at last... I just left a suggestion or two and a question.

Co-authored-by: Chris Lowder <chris.lowder@swri.org>
@jmbhughes jmbhughes merged commit 8fcda5b into main Jun 14, 2026
8 of 10 checks passed
@jmbhughes jmbhughes deleted the fix-identical-timestamps branch June 14, 2026 03:00
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.

L3_CTM files have all date fields set the same

4 participants