{"id":13686430,"url":"https://github.com/CyanideCN/PyCINRAD","last_synced_at":"2025-05-01T09:31:32.031Z","repository":{"id":43231933,"uuid":"139155365","full_name":"CyanideCN/PyCINRAD","owner":"CyanideCN","description":"Decode CINRAD (China New Generation Weather Radar) data and visualize.","archived":false,"fork":false,"pushed_at":"2024-10-19T07:32:58.000Z","size":41059,"stargazers_count":371,"open_issues_count":10,"forks_count":157,"subscribers_count":26,"default_branch":"master","last_synced_at":"2024-10-30T07:45:01.392Z","etag":null,"topics":["matplotlib","meteorology","python","radar"],"latest_commit_sha":null,"homepage":"https://pycinrad.readthedocs.io/en/latest/index.html","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CyanideCN.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-29T13:52:59.000Z","updated_at":"2024-10-28T07:28:03.000Z","dependencies_parsed_at":"2023-10-16T14:07:58.037Z","dependency_job_id":"2e758575-f5cb-4e0d-91c6-7328dde5e08c","html_url":"https://github.com/CyanideCN/PyCINRAD","commit_stats":{"total_commits":434,"total_committers":11,"mean_commits":39.45454545454545,"dds":"0.14055299539170507","last_synced_commit":"e62a8d2428f78e9a94055d68f48399cf5b3a1895"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyanideCN%2FPyCINRAD","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyanideCN%2FPyCINRAD/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyanideCN%2FPyCINRAD/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyanideCN%2FPyCINRAD/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CyanideCN","download_url":"https://codeload.github.com/CyanideCN/PyCINRAD/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222364238,"owners_count":16972422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["matplotlib","meteorology","python","radar"],"created_at":"2024-08-02T15:00:32.325Z","updated_at":"2025-05-01T09:31:32.024Z","avatar_url":"https://github.com/CyanideCN.png","language":"Python","funding_links":[],"categories":["Radar","Atmosphere"],"sub_categories":["Meteorological Observation and Forecast"],"readme":"# PyCINRAD\n\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Downloads](https://pepy.tech/badge/cinrad)](https://pepy.tech/project/cinrad)\n[![DOI](https://zenodo.org/badge/139155365.svg)](https://zenodo.org/badge/latestdoi/139155365)\n\nDecode CINRAD (China New Generation Weather Radar) data and visualize. \n\nTo check out live examples and docs, visit [pycinrad.cn](https://pycinrad.cn/).\n\n[中文说明](https://github.com/CyanideCN/PyCINRAD/blob/master/README_zh.md)\n\n**`example` folder contains detailed examples!**\n\n## Installation\n\nPyCINRAD supports Python version 3.9 and higher.\n\n```\npip install cinrad\n```\n\nYou can also download from github page and build from source\n\n```\npython setup.py install\n```\n\n## Modules\n\n### cinrad.io\n\nDecode CINRAD radar data.\n\n```python\nfrom cinrad.io import CinradReader, StandardData\nf = CinradReader(your_radar_file) #Old version data\nf = StandardData(your_radar_file) #New standard data (or phased array data)\nf.get_data(tilt, drange, dtype) #Get data\nf.get_raw(tilt, drange, dtype)\n```\n\nThe `get_raw` method returns radar records without other geographic information.\n\nThe `get_data` method returns `xarray.Dataset` with radar records, geographic coordinates, and all extra attributes. So, all benefits of `xarray` can be enjoyed.\n\n```python\n\u003e\u003e\u003e print(data)\n\u003cxarray.Dataset\u003e\nDimensions:    (azimuth: 366, distance: 920)\nCoordinates:\n  * azimuth    (azimuth) float32 0.14084807 0.15812683 ... 0.12601277 0.14381513\n  * distance   (distance) float64 0.25 0.5 0.75 1.0 ... 229.2 229.5 229.8 230.0\nData variables:\n    ZDR        (azimuth, distance) float64 nan nan nan nan ... nan nan nan nan\n    longitude  (azimuth, distance) float64 120.2 120.2 120.2 ... 120.6 120.6\n    latitude   (azimuth, distance) float64 35.99 35.99 36.0 ... 38.04 38.04\n    height     (azimuth, distance) float64 0.1771 0.1792 0.1814 ... 5.218 5.227\nAttributes:\n    elevation:        0.48339844\n    range:            230\n    scan_time:        2020-05-17 11:00:28\n    site_code:        Z9532\n    site_name:        青岛\n    site_longitude:   120.23028\n    site_latitude:    35.98861\n    tangential_reso:  0.25\n    nyquist_vel:      8.37801\n    task:             VCP21D\n```\nFor example, it's very convenient to save data as netcdf format.\n```python\n\u003e\u003e\u003e data.to_netcdf('1.nc')\n```\n\n`xarray` also makes interpolation very convenient.\n```python\n\u003e\u003e\u003e data.interp(azimuth=np.deg2rad(300), distance=180)\n\u003cxarray.Dataset\u003e\nDimensions:    ()\nCoordinates:\n    azimuth    float64 5.236\n    distance   int32 180\nData variables:\n    ZDR        float64 0.3553\n    longitude  float64 118.5\n    latitude   float64 36.8\n    height     float64 3.6\nAttributes:\n    elevation:        0.48339844\n    range:            230\n    scan_time:        2020-05-17 11:00:28\n    site_code:        Z9532\n    site_name:        青岛\n    site_longitude:   120.23028\n    site_latitude:    35.98861\n    tangential_reso:  0.25\n    nyquist_vel:      8.37801\n    task:             VCP21D\n```\n\nFor single-tilt data (i.e. files that contain only one elevation angle), `cinrad.io.StandardData.merge` can merge these files to a file contains full volumetric scan.\n\n#### Export data to `Py-ART` defined class\n\nConvert data structure defined in this module into `pyart.core.Radar` is very simple. `cinrad.io.export` has a function `standard_data_to_pyart`, which can take `cinrad.io.StandardData` as input and return `pyart.core.Radar` as output.\n\n`example` folder contains a simple demo about this.\n\n#### Decode PUP data and SWAN data\n\n`cinrad.io.StandardPUP` provides functions to decode Standard PUP(rose) data. The extracted data can be further used to create PPI.\n\n`cinrad.io.SWAN` provides similar interface to decode SWAN data.\n\n```python\nfrom cinrad.io import StandardPUP\nf = StandardPUP(your_radar_file)\ndata = f.get_data()\n```\n\n#### Decode phased array radar data\n\n`cinrad.io.PhasedArrayData` provides similar interface to decode level 2 data from phased array radar with old format.\n\n```python\nfrom cinrad.io import PhasedArrayData\nf = PhasedArrayData(your_radar_file)\ndata = f.get_data(0, 40, 'REF')\n```\n\n### cinrad.utils\n\nThis submodule provides some useful algorithms in radar meteorology. All functions only accept `numpy.ndarray` as input data. This submodule extends the usage of this program, as these functions can accept customized data rather than only the data decoded by `cinrad.io`.\n\n### cinrad.calc\n\nFor direct computation of decoded data, `cinrad.calc` provides functions that simplify the process of calculation. For functions contained in this submodule, only a list of reflectivity data is required as the argument.\n\nCode to generate the required list:\n\n```python\nr_list = [f.get_data(i, 230, 'REF') for i in f.angleindex_r]\n# or\nr_list = list(f.iter_tilt(230, 'REF'))\n```\n\n#### VCS\n\n`cinrad.calc.VCS` provides calculation of vertical cross-section for **all variables**.\n\n```python\nimport cinrad\nfrom cinrad.visualize import Section\nf = cinrad.io.CinradReader(your_radar_file)\nrl = [f.get_data(i, 230, 'REF') for i in f.angleindex_r]\nvcs = cinrad.calc.VCS(rl)\nsec = vcs.get_section(start_cart=(111, 25.5), end_cart=(112, 26.7)) # pass geographic coordinates (longitude, latitude)\nsec = vcs.get_section(start_polar=(115, 350), end_polar=(130, 30)) # pass polar coordinates (distance, azimuth)\nfig = Section(sec)\nfig('D:\\\\')\n```\n\n#### Radar mosaic\n\n`cinrad.calc.GridMapper` can merge different radar scans into a cartesian grid, also supports CR.\n\n#### Hydrometeor classification\n\n`cinrad.calc.hydro_class` uses algorithm suggested by Dolan to classify hydrometeors into 10 categories. (Requires REF, ZDR, RHO, and KDP)\n\n### cinrad.correct\n\nThis submodule provides algorithms to correct raw radar fields.\n\n#### cinrad.correct.dealias\n\nThis function can unwrap the folded velocity using algorithm originated from `pyart`. (needs C compiler)\n\n```python\nimport cinrad\n#(some codes omitted)\nv = f.get_data(1, 230, 'VEL')\nv_corrected = cinrad.correct.dealias(v)\n```\n\n### cinrad.visualize\n\nVisualize the data stored in acceptable format (`cinrad.datastruct`). It also means that you can using customized data to perform visualization, as long as the data is stored as `xarray.Dataset` and constructed by the same protocol (variables naming conventions, data coordinates and dimensions, etc.) For further information about this method, please see the examples contained in `example` folder.\n\n```python\nfrom cinrad.visualize import PPI\nfig = PPI(R) #Plot PPI\nfig('D:\\\\') #Pass the path to save the fig\nfrom cinrad.visualize import Section\nfig = Section(Slice_) #Plot VCS\nfig('D:\\\\')\n```\n\nThe path passed into the class can either be the folder path or the file path. Also, if no path is passed, the figure will be saved at the folder named `PyCINRAD` in the home folder (e.g. `C:\\Users\\tom`).\n\n#### Customize plot settings\n\nThe summary of args that can be passed into `PPI` are listed as follows.\n\n|arg|function|\n|:-:|:-:|\n|`cmap`|colormaps used for plotting|\n|`norm`|norm used for plotting|\n|`nlabel`|number of labels on the colorbar|\n|`label`|labels on the colorbar|\n|`highlight`|highlight area of input name|\n|`dpi`|dpi of figure|\n|`extent`|area to plot e.g. `extent=[90, 91, 29, 30]`|\n|`section`|cross-section data to ppi plot|\n|`style`|background color:`black`/`white`/`transparent`|\n|`add_city_names`|annotate name of city on the plot|\n\nBeside args, class `PPI` has some other auxiliary plotting functions.\n\n##### PPI.plot_range_rings(self, _range, color='white', linewidth=0.5, **kwargs)\n\nPlot range rings on the PPI plot.\n\n##### PPI.plot_cross_section(self, data, ymax=None)\n\nPlot VCS section under the PPI plot.\n\nThis function is very similar to `vcs` argument of class `PPI`, but the range of y-axis can be adjusted only by this function.\n\n##### PPI.storm_track_info(self, filepath)\n\nPlot PUP STI product on the current PPI map, including past positions, current position, and forecast positions.\n\n## Gallery\n\n#### PPI reflectivity\n\n![PPI reflectivity](https://raw.githubusercontent.com/CyanideCN/PyCINRAD/master/pictures/Z9735_20180304125031_0.6_230_REF.png)\n\n#### Phased array radar reflectivity\n\n![Phased array radar reflectivity](https://raw.githubusercontent.com/CyanideCN/PyCINRAD/master/pictures/ZGZ02_20200826123326_0.9_40_REF.png)\n\n#### PPI reflectivity combined with cross-section\n\n![PPI reflectivity combined with cross-section](https://raw.githubusercontent.com/CyanideCN/PyCINRAD/master/pictures/Z9735_20180304120845_0.6_230_REF.png)\n\n#### Cross-section\n\n![Cross-section](https://raw.githubusercontent.com/CyanideCN/PyCINRAD/master/pictures/Z9735_20180304004209_VCS_25.5N111E_26.5N112E.png)\n\n#### Cross-section other than reflectivity\n\n![ZDR cross-section](https://raw.githubusercontent.com/CyanideCN/PyCINRAD/master/pictures/Z9574_20190321025715_0.5_230_ZDR_29.47N121.44E_29.4N122.04E.png)\n\n#### RHI reflectivity\n\n![RHI reflectivity](https://raw.githubusercontent.com/CyanideCN/PyCINRAD/master/pictures/XXX_XXX_RHI_299_100_REF.png)\n\n## Citation\n\nIf you use PyCINRAD in your paper, please cite PyCINRAD using the DOI below.\n\n[![DOI](https://zenodo.org/badge/139155365.svg)](https://zenodo.org/badge/latestdoi/139155365)\n\n## Papers that use plots generated by `PyCINRAD`\n\n1. Recognition and Analysis of Biological Echo Using WSR-88D Dual-polarization Weather Radar in Nanhui of Shanghai doi: 10.16765/j.cnki.1673-7148.2019.03.015\n\n## Notes\n\nThe hydrometeor classfication algorithm comes from Dolan, B., S. A. Rutledge, S. Lim, V. Chandrasekar, and M. Thurai, 2013: A Robust C-Band Hydrometeor Identification Algorithm and Application to a Long-Term Polarimetric Radar Dataset. J. Appl. Meteor. Climatol., 52, 2162–2186, https://doi.org/10.1175/JAMC-D-12-0275.1.\n\nIf you are interested in this program, you can join the developers of this program. Any contribution is appreciated!\n\nIf you have questions or advise about this program, you can create an issue or email me at 274555447@qq.com.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCyanideCN%2FPyCINRAD","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCyanideCN%2FPyCINRAD","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCyanideCN%2FPyCINRAD/lists"}