Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to write the sample script from NCL to Python

Shulou Source: shulou.com Published: 2022-06-02 02:43:00 10月15日 Update

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!

Tags: Pictures examples scripts commands dimensions more questions two content official method website project help consistency helplessness to this end information function method Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Technology Docker vpn Xiaomi