NCAS-CMS / NCAS-CMS/cf-python

Unexpected behaviour comparing two views of the same data: pp and netcdf

Open
#775 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug um/pp
Dominant language
Python
Stars
150
Forks
23
Avg merge
1d 11h
Merged PRs (30d)
2

Description

Usecase: I read some pp data, and look at what I have. I then write the same data out to netcdf, and read it back in. I expect the list of cf-fields to be identical. But they are not.

ff=cf.read('myfile.pp`)
ff
[<CF Field: geopotential_height(time(40), air_pressure(9), latitude(1921), longitude(2560)) m>,
 <CF Field: id%UM_m01s30i301_vn1106(time(40), air_pressure(6), latitude(1921), longitude(2560))>,
 <CF Field: id%UM_m01s30i407_vn1106(time(40), latitude(1920), longitude(2560))>,
 <CF Field: id%UM_m01s30i408_vn1106(time(40), latitude(1920), longitude(2560))>]

compare with the same operation aftrer writing that list of fields out to a netcdf file

ff=cf.read('myfile.nc')
ff
[<CF Field: geopotential_height(time(40), air_pressure(9), latitude(1921), longitude(2560)) m>,
 <CF Field: long_name=HEAVYSIDE FN ON P LEV/UV GRID(time(40), air_pressure(6), latitude(1921), longitude(2560))>,
 <CF Field: long_name=TOTAL MOISTURE FLUX U  RHO GRID(time(40), latitude(1920), longitude(2560))>,
 <CF Field: long_name=TOTAL MOISTURE FLUX V  RHO GRID(time(40), latitude(1920), longitude(2560))>]

This is cf.__version__ = 3.16.2

From my point of view the file format should not affect the logical view of the contents. I understand there may be some historical reasons for this behaviour, but maybe they should be reviewed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the PP-to-NetCDF round trip described in the issue with cf-python 3.16.2, then compare the field identities returned by the two reads. Investigate whether the differing long_name and UM identifiers should round-trip consistently; done when the behavior is resolved or its expected semantics are clearly established.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.