openradar / xradar

A tool to work in weather radar data in xarray
https://docs.openradarscience.org/projects/xradar
MIT License
98 stars 17 forks source link

Option to use fixed angle step in Rainbow reader #75

Open egouden opened 1 year ago

egouden commented 1 year ago

In Rainbow, the radar measurements can be sampled for a given fixed angle step (fixselect>Anglestep)

It would be nice to have the option to use this as regular nominal coordinates instead of the actual azimuth angles.

kmuehlbauer commented 1 year ago

Thanks @egouden for raising this.

Since xradar 0.0.9 we have angle reindexing implemented. Please have a look here for details here https://docs.openradarscience.org/projects/xradar/en/latest/notebooks/angle_reindexing.html

If you know the layout of your scans, you can read the data like this:

reindex_angle=dict(tolerance=1.0, start_angle=0, stop_angle=360, angle_res=1.0, direction=1)
ds = xr.open_dataset(rainbow_file, group="sweep_0", engine="rainbow", reindex_angle=reindex_angle)

So for ray at 0.5deg center-beam the algorithm would take the nearest ray which has a maximum distance of 1.0deg.

Update: python example code, minor fixes

egouden commented 1 year ago

Thank you @kmuehlbauer for the suggestion.

I am wondering if an automatic option based on the file metadata would be interesting.

kmuehlbauer commented 1 year ago

That would be specific to that backend, but we might have the chance to use reindex_angle for that. I'll let this sink in a bit.

egouden commented 1 year ago

I think reading the nominal angles should be the default for all readers for several reasons:

What do you think?

kmuehlbauer commented 1 year ago

@egouden I fully agree to present the dataset in nominal angles.

That's exactly whats angle_reindexing is aimed for. It can actually repair many more issues (missing angles, missing sectors etc). We might retrieve some reasonable default values from metadata to run this without user interaction.

I'd make this either nominal or accurate angles, not both. If a user really want to have both they can retrieve it using reindex_angle itself.

mgrover1 commented 1 year ago

Yeah - I agree that setting some reasonable defaults/adding a bit more logic on attempting to calculate some of the fields required would be great!

This is a similar practice to reading in terabytes of climate model output where the exact latitude/longitude can vary a bit. When using open_mfdataset, the file uses the first or last file to use as the coords and aligns everything to that. This is not necessarily what we need to do/follow here, but a similar practice.