# Wradlib.util.cross\_section\_ppi - wrong altitude

**URL:** <https://openradar.discourse.group/t/wradlib-util-cross-section-ppi-wrong-altitude/361>\
**Category:** General\
**Created:** [November 30, 2023, 10:51am UTC](https://openradar.discourse.group/t/wradlib-util-cross-section-ppi-wrong-altitude/361 "2023-11-30T10:51:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![lou](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@lou](https://openradar.discourse.group/u/lou)\
**Post date:** [November 30, 2023, 10:51am UTC](https://openradar.discourse.group/t/wradlib-util-cross-section-ppi-wrong-altitude/361/1 "2023-11-30T10:51:47Z")

</div>

Hi all,

I just figured out that my rays are plotted on a different altitude than I’d expect. I am not sure if I did something wrong or if this is a bug in the cross\_section\_ppi function. Here is what I have:

```auto
fname = "/file/to/h5path"

sweeps = []
for sn in np.arange(5):
    # load all sweeps and merge them
    swp = xr.open_dataset(fname, engine="odim", group="sweep_"+str(sn))
    sweeps.append(swp)
    
    # round the azimuths to avoid slight differences in the different sweep rounds
    sweeps[sn].coords["azimuth"] = sweeps[sn].coords["azimuth"].round(0)
    
    nodata_mask = swp.DBZH.values == -327.68
    swp.DBZH.values[nodata_mask] = np.nan

vol = xr.concat(sweeps, dim="sweep_fixed_angle")
vol = vol.set_coords(("sweep_mode", "sweep_number", "prt_mode", "follow_mode"))
vol["elevation"] = vol["elevation"].median("azimuth")
vol["time"] = vol["time"].min("azimuth")

azimuth = 84
rec_rhi = wradlib.util.cross_section_ppi(vol, azimuth)
rec_rhi.DBZH.plot(cmap='viridis', x="gr", y="z", ylim=(0,8000))

```

And if i zoom-in, the rays of the radar start in an altitude higher than given in the coordinate “altitude” in `vol` .

Best,  
Julian

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [November 30, 2023, 12:12pm UTC](https://openradar.discourse.group/t/wradlib-util-cross-section-ppi-wrong-altitude/361/2 "2023-11-30T12:12:45Z")

</div>

@lou How much is the height difference? If it is in the meter-range it could be related to the bin range. The height is sampled at bin center, not at bin start.

HTH,  
Kai

---

<div class="post-metadata">

**Author:** ![lou](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@lou](https://openradar.discourse.group/u/lou)\
**Post date:** [November 30, 2023, 3:48pm UTC](https://openradar.discourse.group/t/wradlib-util-cross-section-ppi-wrong-altitude/361/3 "2023-11-30T15:48:31Z")

</div>

@kmuehlbauer It seems like that it gets doubled. In my meta-data, altitude was at 150m, but the rays started at 300m. If I change altitude to a different value, the radar rays start always at an altitude of 2\*alt.

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [November 30, 2023, 4:45pm UTC](https://openradar.discourse.group/t/wradlib-util-cross-section-ppi-wrong-altitude/361/4 "2023-11-30T16:45:22Z")

</div>

@lou Yes, this looks like a bug. But I’m not sure where the error source actually is. Need to dive into this.

@JulianGiles could you please have a look here?

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [November 30, 2023, 5:41pm UTC](https://openradar.discourse.group/t/wradlib-util-cross-section-ppi-wrong-altitude/361/5 "2023-11-30T17:41:23Z")

</div>

@lou, @JulianGiles

I’ve found the root cause here, and it’s no real bug, but some usage pattern from old ages.

Please add `crs="None"` (note the quotation marks) to the call to `cross_section_ppi`. This should fix the immediate problem.

HTH,  
Kai

---

<div class="post-metadata">

**Author:** ![JulianGiles](https://avatars.discourse-cdn.com/v4/letter/j/7cd45c/32.png) [@JulianGiles](https://openradar.discourse.group/u/JulianGiles)\
**Post date:** [December 1, 2023, 7:19am UTC](https://openradar.discourse.group/t/wradlib-util-cross-section-ppi-wrong-altitude/361/6 "2023-12-01T07:19:23Z")

</div>

Hi @kmuehlbauer , how can this be fixed so the default behavior is the expected one? Should I just delete the crs keyword from the call to georeference?

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [December 1, 2023, 7:22am UTC](https://openradar.discourse.group/t/wradlib-util-cross-section-ppi-wrong-altitude/361/7 "2023-12-01T07:22:24Z")

</div>

@JulianGiles Thanks for looking into this!

No, we should keep it. But inside `cross_section_ppi` we would need to default the extraction of crs to `"None"`.

`crs = kwargs.get("crs", "None")`

Thanks!  
Kai

---

<div class="post-metadata">

**Author:** ![lou](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@lou](https://openradar.discourse.group/u/lou)\
**Post date:** [December 1, 2023, 7:41am UTC](https://openradar.discourse.group/t/wradlib-util-cross-section-ppi-wrong-altitude/361/8 "2023-12-01T07:41:49Z")

</div>

@kmuehlbauer. Thanks! That works 🙂
