Skip to content

Draft: Make fof compare work with radar fof files#103

Open
muellch wants to merge 4 commits into
MeteoSwiss:mainfrom
muellch:radar_fof_fixes
Open

Draft: Make fof compare work with radar fof files#103
muellch wants to merge 4 commits into
MeteoSwiss:mainfrom
muellch:radar_fof_fixes

Conversation

@muellch

@muellch muellch commented May 21, 2026

Copy link
Copy Markdown

Make fof comparison work for radar fof files

  • Strip the over-allocated padding by the real n_hdr/n_body counts (radar
    files allocate d_* larger than the real data), replacing the previous
    zero-append hack with an isel slice
  • Sort radar observations by the per-observation position dlat/dlon instead
    of the radar-station lat/lon, so the row order is deterministic
  • Size the fof_compare consistency gate and tolerance vector by n_body (real
    count) rather than the padded d_body
  • Flag veri_data cells that are NaN in one file but real in the other as
    differences instead of silently passing them
  • Guard against non-front-packed padding (via the dlat discriminator) and
    against multiple verification runs (d_veri > 1), failing loudly
  • Skip empty data frames in fof_compare's detailed log via log_dataframe
  • Add a realistic radar fixture (2-D veri_data, float fields, NaN padding) and
    unit/integration tests: padding strip, sort determinism, scattered-padding
    guard, and fof_compare consistent / not-consistent / different-padding /
    NaN-vs-real cases

Co-authored-by: Alina Yapparova alina.yapparova@meteoswiss.ch

Comment thread util/fof_utils.py Outdated
muellch added 2 commits June 4, 2026 11:42
- Strip the over-allocated padding by the real n_hdr/n_body counts (radar
files allocate d_* larger than the real data), replacing the previous
zero-append hack with an isel slice
- Sort radar observations by the per-observation position dlat/dlon instead
of the radar-station lat/lon, so the row order is deterministic
- Size the fof_compare consistency gate and tolerance vector by n_body (real
count) rather than the padded d_body
- Flag veri_data cells that are NaN in one file but real in the other as
differences instead of silently passing them
- Guard against non-front-packed padding (via the dlat discriminator) and
against multiple verification runs (d_veri > 1), failing loudly
- Skip empty data frames in fof_compare's detailed log via log_dataframe
- Add a realistic radar fixture (2-D veri_data, float fields, NaN padding) and
unit/integration tests: padding strip, sort determinism, scattered-padding
guard, and fof_compare consistent / not-consistent / different-padding /
NaN-vs-real cases

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

Thanks a lot for this new feature. It is minimal invasive, what I like very much.
I only have some minor comments. Final verdict should come from an expert and should be checked if it is compatible with the letkf pipeline.

Comment thread util/dataframe_ops.py
Comment on lines +391 to +396
# A value present (non-NaN) in one file but missing (NaN) in the other is a
# real difference -- an observation appeared or disappeared. The relative
# diff is NaN there and check_variable would treat NaN as within tolerance,
# silently passing it; force those cells to fail. Both-NaN stays NaN (and
# passes), since both being missing means they are equal.
only_one_nan = df_ref.isna() ^ df_cur.isna()

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.

Wouldn't this be useful for every compute_rel_diff_dataframe and coud be used there?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, should we move this out of the fof file only code path and into the general dataframe code path?

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.

I can't see any reason why not. Do you see any drawbacks?

Comment thread engine/fof_compare.py
Comment on lines +56 to +57
n_rows_file1 = xr.open_dataset(file1_path).attrs["n_body"]
n_rows_file2 = xr.open_dataset(file2_path).attrs["n_body"]

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.

I guess that needs to be discussed with an expert.

Comment thread engine/fof_compare.py Outdated
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.

2 participants