Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write the sample script from NCL to Python

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

NCL to Python sample script how to write, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

In order to help you migrate from NCL to Python, developers have also tried their best. Recently, they have launched a new project-GeoCAT Examples [1], which provides a lot of Python scripts corresponding to the sample scripts of NCL websites, which are designed to help you gradually migrate from NCL to Python.

In addition, another project, geocat-viz [2], has been created, which provides a number of tool functions for drawing.

Among the many sample Python drawing scripts provided, the current deficiency is the drawing of curly vector diagrams in NCL. As shown in the following figure:

The left is drawn by Python and the right is drawn by NCL. The picture on the left is a screenshot.

It can be seen that the vector arrows in the quiver diagram drawn by matplotlib do not have the streamline of NCL, but this problem may be solved later by the upstream contribution of matplotlib.

The rest of the figure python can be easily implemented. For more examples, let's go to the official website. I won't say much here.

Or create a sample script environment by using the following command to get started:

Conda create-c conda-forge-c ncar-n geocat-examples python=3 geocat-comp geocat-datafiles geocat-viz=2020.2.18.1 netcdf4 matplotlib cartopy jupyter

Python on the left and NCL on the right

Attached:

The official images are of different sizes. In order to stitch the images of Python and NCL, this article uses two commands of ImageMagic:

Identify: get the size information of the picture convert: change the size of the picture, and splice the picture

Use the following command to get the picture size of the drawing drawn by Python and NCL, respectively

Identify xy_18_lg.pngxy_18_lg.png PNG 700x472 826x827+66+66 8-bit sRGB 163813B 0.000u 0:00.000

Then zoom out the large image, using the following command:

Convert-resize 826x827+66+66 sphx_glr_NCL_xy_18_001.png pyxy.png

Finally, the two pictures are spliced horizontally:

Convert + append pyxy.png xy_18_lg.png pyncl_xy.png

All right, call it a day.

After reading the above, have you mastered how to write the sample script from NCL to Python? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report