<jupyter_start><jupyter_text>This notebook is part of the $\omega radlib$ documentation: https://docs.wradlib.org.Copyright (c) $\omega radlib$ developers.Distributed under the MIT License. See LICENSE.txt for more info.  Computing cartesian and geographical coordinates for polar data<jupyter_code>import numpy as np
import wradlib.georef as georef
import wradlib.io as io
import wradlib.util as util
import warnings
warnings.filterwarnings('ignore')<jupyter_output><empty_output><jupyter_text>Read the dataHere, we use an OPERA hdf5 dataset.<jupyter_code>filename = 'hdf5/20130429043000.rad.bewid.pvol.dbzh.scan1.hdf'
filename = util.get_wradlib_data_file(filename)
pvol = io.read_opera_hdf5(filename)<jupyter_output><empty_output><jupyter_text>Count the number of datasets<jupyter_code>ntilt = 1
for i in range(100):
    try:
        pvol["dataset%d/what" % ntilt]
        ntilt += 1
    except Exception:
        ntilt -= 1
        break<jupyter_output><empty_output><jupyter_text>Define radar location and scan geometry<jupyter_code>nrays = int(pvol["dataset1/where"]["nrays"])
nbins = int(pvol["dataset1/where"]["nbins"])
rscale = int(pvol["dataset1/where"]["rscale"])
coord = np.empty((ntilt, nrays, nbins, 3))
for t in range(ntilt):
    elangle = pvol["dataset%d/where" % (t + 1)]["elangle"]
    coord[t, ...] = georef.sweep_centroids(nrays, rscale, nbins, elangle)
# ascale = math.pi / nrays
sitecoords = (pvol["where"]["lon"], pvol["where"]["lat"],
              pvol["where"]["height"])
print(coord.shape)<jupyter_output><empty_output><jupyter_text>Retrieve azimuthal equidistant coordinates and projection<jupyter_code>coords, proj_radar = georef.spherical_to_xyz(coord[..., 0],
                                             np.degrees(coord[..., 1]),
                                             coord[..., 2], sitecoords)
test = coords[0, 90, 0:960:60, 0]
print(test)<jupyter_output><empty_output><jupyter_text>Retrieve geographic coordinates (longitude and latitude)  Using convenience function *spherical_to_proj*.<jupyter_code>lonlatalt = georef.spherical_to_proj(coord[..., 0],
                                     np.degrees(coord[..., 1]),
                                     coord[..., 2], sitecoords)
test = lonlatalt[0, 90, 0:960:60, 0]
print(test)<jupyter_output><empty_output><jupyter_text>Using reproject<jupyter_code>lonlatalt1 = georef.reproject(coords, projection_source=proj_radar,
                             projection_target=georef.get_default_projection())

test = lonlatalt1[0, 90, 0:960:60, 0]
print(test)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13102643856920684, 'fraction_numerical': 0.026049766718507, 'mean_word_length': 3.9864341085271318, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '81395', 'license': 'MIT', 'n_tokens_mistral': 932, 'n_tokens_neox': 883, 'n_words': 168, 'path': 'notebooks/georeferencing/wradlib_coords_example.ipynb', 'repo_name': 'egouden/wradlib-notebooks', 'size': '2572'}