Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NexradLevel2 Bug related to conflicting sizes for dimension #259

Closed
kmuehlbauer opened this issue Jan 30, 2025 · 3 comments · Fixed by #261
Closed

NexradLevel2 Bug related to conflicting sizes for dimension #259

kmuehlbauer opened this issue Jan 30, 2025 · 3 comments · Fixed by #261

Comments

@kmuehlbauer
Copy link
Collaborator

tracked also in #258

Bug related to conflicting sizes for dimension

  • Previously unreported bug.
  • This error does not occur in the pyart reader !
  • In the MCVE below, we first decompress the file.
  • Error: ValueError: conflicting sizes for dimension 'azimuth': length 360 on 'azimuth' and length 358 on {'azimuth': 'DBZH', 'range': 'DBZH'}
import os
import fsspec
import xradar as xd
import subprocess

local_tmp_dir = "/tmp"
fs_args = {}
_ = fs_args.setdefault("anon", True)
fs = fsspec.filesystem("s3", **fs_args)

s3_filepath = "noaa-nexrad-level2/2010/01/01/KABR/KABR20100101_000618_V03.gz"
local_filepath = os.path.join(local_tmp_dir, os.path.basename(s3_filepath))
fs.download(s3_filepath, local_tmp_dir)
subprocess.run(["gzip", "-d", local_filepath], check=True)

dt = xd.io.open_nexradlevel2_datatree(local_filepath.replace(".gz", ""))
@kmuehlbauer
Copy link
Collaborator Author

The reader breaks when trying to access the last sweep:

import xarray as xr
ds = xr.open_dataset(local_filepath.replace(".gz", ""), engine="nexradlevel2", group="sweep_6") 
ds

All sweeps before that will read perfectly fine. Investigating the root cause.

@mgrover1
Copy link
Collaborator

Ohh thanks for raising the issue here!

@kmuehlbauer
Copy link
Collaborator Author

kmuehlbauer commented Feb 3, 2025

So, I've found the root cause of the ValueError:

# get rays and bins
nrays = (
datastore.ds["record_end"]
- datastore.ds["record_number"]
+ 1
- len(datastore.ds["intermediate_records"])
)

In the above code we retrieve the number of rays by calculating

nrays = n_end - n_start + 1 - n_intermed

where n_intermed is the numbers of intermediate records within the data records. In the above case in the final record, those intermediate records are after n_end and should not be subtracted. So the solution is to count the number of intermediate records which fall inside n_start and n_end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants