Data processing method
Through a data processing method, including obtaining dimensional data and variable data, making color scales and drawing images, the problems of insufficient memory and low performance during the processing of CESM model output files under ultra-high resolution grids are solved, and efficient image processing and post-processing tasks are achieved.
Patent Information
- Application Number
- CN202411692270.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-03-14
AI Technical Summary
When processing NetCDF files output by CESM models under ultra-high resolution mesh, existing tools are prone to problems of insufficient memory or extremely poor performance, making it difficult to complete post-processing tasks efficiently.
Provide a data processing method, including obtaining dimensional data and variable data output by CESM, making color scales and drawing basic images, synthesizing dynamic images, generating vector images, and coloring the earth projection block diagram based on color scales to obtain the earth projection diagram.
This method can improve image processing efficiency and reduce the computing power burden, solving the problems of insufficient memory and low performance of existing tools when processing high-resolution NC files.
Smart Images

Figure CN119625119A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of meteorological data processing, and in particular, relates to a data processing method. Background Art
[0002] The Community Earth System Model (CESM) is a fully coupled global climate model that provides users with the most advanced computer simulations of the Earth's past, present and future climate states. It is an advanced technology for Earth system simulation. CESM combines new numerical algorithms and adds modules such as carbon and nitrogen cycles, global vegetation dynamics and land use changes caused by human activities, marine biogeochemistry modules, ice sheet dynamics modules, and chemical and physical processes indirectly and directly affected by aerosols.
[0003] NC / NetCDF stands for Network Common Data Format, which is translated into Chinese as "Network Common Data Format". It was developed by scientists from the Unidata project of the Association of Universities for Atmospheric Research in the United States based on the characteristics of scientific data. It is an array-oriented data description and encoding standard suitable for network sharing.
[0004] CESM uses NetCDF (usually with .nc as the file extension) as one of the main data storage formats. Specifically, the CESM model generates and processes a large amount of scientific data during operation, which is usually stored and exchanged in the NetCDF format. One of the advantages of the NetCDF format is its cross-platform compatibility and self-descriptiveness, which allows the data output by the CESM model to be easily shared, transmitted and reused in different scientific research institutions and computing platforms.
[0005] After the CESM simulation is completed, a large amount of model output data will be generated, covering the simulation results of multiple components such as atmosphere, ocean, land and ice layer. These output data are usually stored in NetCDF format, including multiple dimensions (such as time, longitude, latitude, etc.) and variables (such as temperature, humidity, wind speed, etc.).
[0006] Normally, researchers use specialized data analysis tools, such as matplot, NCL, MATLAB, etc. under Python, to read and process NetCDF files generated by CESM. At conventional resolutions, these tools can perform data post-processing duties well, but at ultra-high resolution grids, such as ne480pg3 (5km atmospheric grid) or ts003v1 (3km ocean grid), these tools often encounter serious memory shortages or extremely poor performance. Therefore, developing a post-processing tool for high-resolution nc files is an urgent problem to be solved.
[0007] Application Contents
[0008] In order to solve the problems in the related art, the present application provides a data processing method capable of efficiently processing nc files of high-resolution examples.
[0009] The present application provides a data processing method, which includes: obtaining dimensional data and variable data output by CESM in nc format; making a color code and drawing a basic image according to the dimensional data and the variable data; synthesizing a dynamic image through the basic image; determining the vector type of drawing a vector map, collecting vector density and vector standard length and generating a vector map; obtaining the drawn basic image and earth projection frame diagram, and coloring the earth projection frame diagram according to the color code to obtain an earth projection map.
[0010] The beneficial effect of this technical solution is that a basic image can be drawn according to meteorological data, and the basic image can be used to obtain the image information required for other post-processing. While completing the post-processing of high-resolution NC files, the image processing efficiency is improved and the problem of low computing power encountered by other tools during processing is solved.
[0011] In some optional embodiments, drawing of the basic image includes drawing an image title, an image frame line, and longitude and latitude scales, wherein: the image title, the image frame line, and the longitude and latitude scales are drawn by computer vision library functions.
[0012] The beneficial effect of this technical solution is that the image title, image frame line and longitude and latitude scale parts in the basic image are processed by an external computer vision library, which can reduce the computing power burden and improve processing efficiency.
[0013] In some optional embodiments, the drawing of the basic image also includes drawing the coastline, and the drawing of the coastline includes the following steps: S101: select an adaptive ocean grid and obtain its mask data, and use a drawing tool to draw a mask image, wherein the mask value of the land pixel points in the mask image is 0, and the mask value of the ocean pixel points is 1; S102: find any land pixel point that meets the coastline, collect the pixels within the set range of the land pixel point itself and the surrounding pixels, traverse all the pixels in the mask image, and extract the pixels with a mask value of 0; S103: map the coordinates of the qualified pixel points to longitude and latitude to obtain a high-precision longitude and latitude set of coastline points.
[0014] The beneficial effect of this technical solution is that by grouping all pixel points, information is screened within each group, land pixel points are extracted, and finally a high-precision longitude and latitude set of coastline points can be obtained through combination.
[0015] In some optional embodiments, the land pixels are filled with blue, and the ocean pixels are filled with red; any land pixel that matches the coastline is set as A ij , where: i value is set to A ij The horizontal axis value of j is set as the vertical axis value of pixel A; get A ij A total of 9 pixels within the range of itself and its surrounding 1 pixel: A i-1j-1 , A i-1j , A i-1j+1 , A ij-1 , A ij , A ij+1 , A i+1j-1 , A i+1j , A i+1j+1 ; Get the colors of the above pixels, count the number of pixels filled with blue, and record it as n1, where n1 meets the following conditions:
[0016]
[0017] All the pixels in the mask image are traversed by the above formula, and the coordinates of the pixels that meet the first formula are extracted and mapped to longitude and latitude to obtain the longitude and latitude set of the coastline points.
[0018] In some optional embodiments, the drawing of the basic image further includes making a color label, and the making of the color label includes the following steps: S201: selecting a color configuration scheme of the color label, marking the color label as C; S202: obtaining the minimum value and maximum value of the variable to be drawn, respectively marked as V min With V max , for V min To V max The numerical range is divided into four parts according to V min With V max Calculate the five color scale four-point values in sequence, namely C a0 , C a1 , C a2 , C a3 and C a4 The corresponding variable size is recorded as V a0 、V a1 、V a2 、V a3 and V a4 , where V a0 =V min , V a4 =V max , the calculation formula of the color scale four-point value is as follows:
[0019] V a2 =(V a0 +Va4 )÷2
[0020] V a1 =(V a0 +V a2 )÷2
[0021] V a3 =(V a2 +V a4 )÷2
[0022] S203: 5 color mark quarter values are obtained by calculation, and the color of the color mark is linearly gradiented according to the two quarter values of the interval, so as to obtain a complete color mark.
[0023] In some optional embodiments, when the color scale is made in the contour line mode, the following steps are also included: S301: setting the number of contour line layers to L, combining V min With V max Calculate the median V of the value range corresponding to each contour layer br , r is any positive integer between 0 and L-1, and is calculated as follows:
[0024] interval=(V max -V min ) / L
[0025] V br =V min +(r+1-0.5)×interval
[0026] Where interval represents the interval length of each contour layer;
[0027] S302: The V calculated in S202 is a0 、V a1 、V a2 、V a3 and V a4 Represented as V aw , C a0 , C a1 , C a2 , C a3 and C a4 Represented as C aw , w is any integer between 0 and 4;
[0028] According to V br与 V aw The relationship between the calculation of the contour color scale C br , the calculation formula is as follows:
[0029]
[0030] S303: After confirming the color scale of each contour layer, a complete contour color scale can be obtained by stacking them in the color scale frame.
[0031] In some optional embodiments, the drawing of the basic image further includes coloring, and the coloring includes the following steps: S401: obtaining any longitude and latitude point, calculating the coordinates of the longitude and latitude point by image ratio, and coloring the grid where the longitude and latitude point is located and its surroundings according to the maximum density of the grid; S402: after confirming the color of the variable value of the longitude and latitude point in the color code, setting the pointSize parameter to n2; S403: when n2≤1, coloring the pixel point where the coordinates of the longitude and latitude point are located; when n2>1, coloring the (2n2+1) pixel point around the pixel point where the coordinates are located. 2 Paint within a pixel range.
[0032] In some optional embodiments, the drawing of the dynamic image includes the following steps: S501: counting the numerical range of any variable to be drawn at all times, and limiting the range of the color code produced by the minimum and maximum values of the numerical range; S502: forming a picture group from the basic image obtained by drawing the variables to be drawn at all times, and then inserting the pictures in the picture group into the corresponding frame sequence in timeline order; S503: compressing the frame sequence at a set time interval to obtain the dynamic image.
[0033] In some optional embodiments, the vector type includes a first mode and a second mode, wherein: the first mode is configured to display the instantaneous vector direction size; and the second mode is configured to display the change trend of the vector.
[0034] In some optional embodiments, the drawing of the first mode includes the following steps: S601: confirming the coordinates of the coordinate point to be drawn, and reading two vector components in the orthogonal direction of the coordinate point from the nc file; S602: calculating the direction and modulus of the vector through the two vector components, and calculating the starting point and end point of the vector in the figure according to the coordinates, the standard length of the vector, and the direction and modulus of the vector, so as to draw a direction arrow; S603: when the direction of the vector is used to indicate the wind direction, u and v are set to indicate the vector components of the wind direction in the horizontal and vertical directions respectively, then u and v meet the second formula, which is:
[0035] Modulus
[0036] Auxiliary arc value
[0037] Direction (radians)
[0038] The specific values of the direction and the modulus can be calculated according to the second formula.
[0039] In some optional embodiments, the drawing of the second mode includes the following steps: S701: confirm the coordinate point to be drawn, and assign a transparency value of o to the coordinate point; S702: calculate the position of the next landing point according to the coordinates of the coordinate point and the corresponding vector direction and modulus value; S703: assign a transparency value of o+step to the next landing point, where step is set to a fixed value, and repeat this process until the transparency value is p1; S704: calculate the previous landing point in the opposite direction, and assign a transparency value of o-step to the previous landing point, and repeat this process until the transparency value is p2, thereby completing the drawing of the transparent line.
[0040] In some optional embodiments, the drawing of the earth projection map includes the following steps: S801: obtain the earth projection frame map, and align the set point of the earth projection frame map with the center of the drawn field of view; S802: take any point on the earth projection frame map, take the longitude value of the polar coordinates of the point as φ, and the latitude value as 90°-θ, calculate the values of φ and θ, and then get the longitude and latitude corresponding to the point; S803: color the point with the color corresponding to the variable value on the color scale with reference to the point.
[0041] It should be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0043] Figure 1 A flowchart of a data processing method provided in this application;
[0044] Figure 2 Schematic diagram of the coastline algorithm provided for this application;
[0045] Figure 3 Colored schematic provided for this application;
[0046] Figure 4 A schematic diagram of the first mode in coloring provided by the present application;
[0047] Figure 5 A schematic diagram of the second mode in coloring provided by this application;
[0048] Figure 6 Schematic diagram of the Earth projection provided for this application. DETAILED DESCRIPTION
[0049] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0050] In order to solve the problem of insufficient performance of drawing tools under ultra-high resolution grids, the present application provides a data processing method that can efficiently process nc files of high-resolution examples.
[0051] like Figure 1 As shown:
[0052] The present application provides a data processing method, the method comprising S1-S5:
[0053] S1: Obtain dimension data and variable data;
[0054] S2: drawing a basic image according to the dimension data and the variable data, and obtaining a color scale according to the basic image;
[0055] S3: synthesizing the basic image into a dynamic image according to the variable data and the color code;
[0056] S4: collect vector type, vector density and vector standard length, and generate vector map;
[0057] S5: Obtain the completed basic image and the earth projection frame diagram, and color the earth projection frame diagram according to the color code to obtain the earth projection map.
[0058] Steps S1-S5 can draw a basic image based on meteorological data, and use the basic image to obtain image information required for other post-processing. While completing the post-processing of high-resolution nc files, the overall calculation amount of the example is reduced, the image processing efficiency is improved, and the problem of low computing power encountered by other tools during processing is solved. In the above steps, CESM outputs dimension data and variable data in nc format; draws a basic image based on the dimension data and the variable data, and obtains a color scale based on the basic image; limits the range of the color scale by the variable data, and synthesizes the basic image within the range of the color scale into a dynamic image; determines the vector type of the vector map, collects the vector density and the vector standard length, and generates a vector map; obtains the basic image and the earth projection frame diagram, and colors the earth projection frame diagram according to the color scale to obtain the earth projection map. The reading of dimension data and variable data uses netcdf4-python as support, and the drawing of the image uses OpenCV. Since OpenCV uses numpy to store the pixel RGBA information of the image, the data read by netcdf4-python can meet the interface standard of OpenCV after simple processing.
[0059] In some optional embodiments, the drawing of the basic image includes drawing an image title, an image frame line, and a latitude and longitude scale, wherein: the image title, the image frame line, and the latitude and longitude scale are drawn by computer vision library functions. The image title, image frame line, and latitude and longitude scale parts in the basic image are processed by an external computer vision library, which can reduce the computing power burden and improve processing efficiency.
[0060] In some optional embodiments, the drawing of the basic image also includes drawing the coastline, and the drawing of the coastline includes the following steps: S101: select an adapted ocean grid and obtain its mask data, and use a drawing tool to draw a mask image, wherein the mask value of the land pixel in the mask image is 0, and the mask value of the ocean pixel is 1; S102: find any land pixel that meets the coastline, collect the pixels within the set range of the land pixel itself and the surrounding pixels, traverse all the pixels in the mask image, and extract the pixels with a mask value of 0; S103: map the coordinates of the pixels that meet the conditions to longitude and latitude, and obtain a high-precision longitude and latitude set of coastline points. The premise of drawing the coastline is to obtain the information of the coastline, and because it involves the drawing of high-resolution meteorological data, the location information of the coastline also requires high precision. The highest resolution ocean grid currently used is ts003 (3km), and the mask data of the ts003 grid is taken to use the existing drawing tools to draw a high-precision image. According to the above steps, the specific location information of the coastline can be obtained by designing an algorithm to obtain the boundary line between the land and sea parts. By grouping all the pixels, filtering the information within each group, extracting the land pixels, and finally combining them, we can get a high-precision longitude and latitude set of coastline points.
[0061] In some optional embodiments, the land pixels are filled with blue and the ocean pixels are filled with red; any land pixel that matches the coastline is set as A ij , where: i value is set to A ij The horizontal axis value of j is set as the vertical axis value of pixel A; get A ij A total of 9 pixels within the range of itself and its surrounding 1 pixel: A i-1j-1 , A i-1j , A i-1j+1 , A ij-1 , A ij , A ij+1 , A i+1j-1 , A i+1j , A i+1j+1 ; Get the colors of the above pixels, count the number of pixels filled with blue, and record it as n1, where n1 meets the following conditions:
[0062]
[0063] All the pixels in the mask image are traversed by the above formula, and the coordinates of the pixels that meet the first formula are extracted and mapped to longitude and latitude to obtain the longitude and latitude set of the coastline points.
[0064] Draw the coastline as follows Figure 2As shown in the figure, each grid is a pixel point, the blue grid value is set to 0, the red grid value is set to 1, for any land point A that meets the coastline ij For example, A22 in the figure should satisfy the surrounding 9 pixels including itself. Considering the data compression efficiency and interface consistency, the coastline data is stored in the same nc format file as the meteorological data for drawing tools to call.
[0065] In some optional embodiments, the basic image also includes the drawing of the color scale. Regarding the color configuration scheme, the commonly used color schemes of NCL and matplot can be used, including rainbow (rainbow seven colors), b2r (blue-red gradient), b2y (blue-yellow gradient), g2r (green-red gradient), and classic (255 blue-red gradient). These configurations can be selected in the interface, and the default value is generally rainbow; the drawing of the color scale also depends on the coloring mode of the variable drawing, that is, the normal mode and the contour mode. On the one hand, in the normal mode, the production of the color scale includes the following steps:
[0066] S201: Select the color scheme of the color code, and mark the color as C; S202: Get the minimum and maximum values of the variable to be plotted, and record them as V respectively min With V max , for V min To V max The numerical range is divided into four parts according to V min With V max Calculate the five color scale four-point values in sequence, namely C a0 , C a1 , C a2 , C a3 and C a4 The corresponding variable size is recorded as V a0 、V a1 、V a2 、V a3 and V a4 , where V a0 =V min , V a4 =V max , the calculation formula of the color scale four-point value is as follows:
[0067] V a2 =(V a0 +V a4 )÷2
[0068] V a1 =(V a0 +V a2 )÷2
[0069] V a3 =(V a2 +Va4 )÷2
[0070] S203: Get 5 color scale quartiles by calculation, and make linear gradients on the color scale colors according to the 2 quartiles in the interval, and you can get a complete color scale. The above steps adopt the quartile method. First, get the minimum and maximum values of the variable to be drawn. Taking the classic color scale as an example, the minimum value is set to (0,0,255), the maximum value is set to (255,0,0), the median value is set to (0,255,0), and the remaining two quartiles are set to (0,255,255) and (255,255,0). After confirming all the quartiles, make linear gradients on the remaining colors according to the color scales of the two quartiles in the interval, and you can get a complete color scale.
[0071] On the other hand, in the contour mode, the preparation of the color scale further includes the following steps:
[0072] S301: Set the number of contour layers to L, combined with V min With V max Calculate the median V of the value range corresponding to each contour layer br , r is any positive integer between 0 and L-1, and is calculated as follows:
[0073] interval=(V max -V min ) / L
[0074] V br =V min +(r+1-0.5)×interval
[0075] Where interval represents the interval length of each contour layer;
[0076] S302: The V calculated in S202 is a0 、V a1 、V a2 、V a3 and V a4 Represented as V aw , C a0 , C a1 , C a2 , C a3 and C a4 Represented as C aw , w is any integer between 0 and 4;
[0077] According to V br与 V aw The relationship between the calculation of the contour color scale C br , the calculation formula is as follows:
[0078]
[0079] S303: After confirming the color scale of each contour layer, a complete contour color scale can be obtained by stacking them in the color scale frame.
[0080] In some optional embodiments, the basic image also includes coloring, and the coloring includes the following steps: S401: obtain any longitude and latitude point, calculate the coordinates of the longitude and latitude point by image ratio, and color the grid where the longitude and latitude point is located and its surroundings according to the maximum density of the grid; S402: after confirming the color of the variable value of the longitude and latitude point in the color code, set the pointSize parameter to n2; S403: when n2≤1, color the pixel point where the coordinates of the longitude and latitude point are located; when n2>1, color the (2n2+1) pixel point around the pixel point where the coordinates are located. 2 Coloring is performed within the pixel range. In ultra-high-resolution images, the meteorological data grid is too sparse, which will result in the inability to fill in the color. Therefore, the above steps are set to first determine the grid density. When the grid density meets the conditions, the grid where the selected longitude and latitude point is located and its surroundings are colored according to the preset pointSize parameter, effectively avoiding the situation where the grid is not fully filled.
[0081] Coloring is mainly done using the FloodFill method. The specific process is as follows: Figure 3 As shown: for a certain longitude and latitude point G (latitude is expressed as lat, longitude is expressed as lon), the pixel coordinates are calculated as (e, f) through the image ratio. Assuming that the variable value of the longitude and latitude point corresponds to green in the color scale, several points around it are filled with green to prevent the situation in which the meteorological data grid is too sparse in the ultra-high resolution image and the color cannot be filled in.
[0082] In some optional embodiments, the dynamic image is drawn using Python's imageio library, and the drawing of the dynamic image includes the following steps: S501: Count the numerical range of any variable to be drawn at all times, and limit the range of the color scale produced by the minimum and maximum values of the numerical range; S502: The basic image obtained by drawing the variables to be drawn at all times is formed into a picture group, and then the pictures in the picture group are inserted into the corresponding frame sequence in time axis order; S503: The frame sequence is compressed at a set time interval to obtain the dynamic image. In the above step S503, the frame sequence needs to be compressed into a gif format file, and the time interval is set to no more than 0.04s to ensure that the number of frames of the dynamic image is above 24fps.
[0083] In some optional embodiments, the vector type includes a first mode and a second mode, wherein: the first mode is configured to display the instantaneous vector direction size; the second mode is configured to display the change trend of the vector. The setting of vector density supports block (region division mode) and all (full drawing mode). When implementing this embodiment, the operator can choose according to technical requirements. Block is suitable for use when it is necessary to fully observe the vectors of a larger area or observe the vectors of a higher resolution grid, so as to avoid the vector drawing being too dense and difficult to distinguish; the all mode is suitable for use when observing the vectors of a smaller area or a low-resolution grid, and is used to observe the vector information of each grid point in detail. The vector standard length is set as a standard for vector drawing. When the vector length is set to be positively correlated with the vector size, the vector standard length guides the drawing length of each vector.
[0084] In some optional embodiments, the drawing of the first mode includes the following steps: S601: confirming the coordinates of the coordinate point to be drawn, and reading two vector components in the orthogonal direction of the coordinate point from the nc file; S602: calculating the direction and modulus of the vector through the two vector components, and calculating the starting point and end point of the vector in the figure according to the coordinates, the standard length of the vector, and the direction and modulus of the vector, so as to draw a direction arrow; S603: when the direction of the vector is used to indicate the wind direction, u and v are set to indicate the vector components of the wind direction in the horizontal and vertical directions respectively, then u and v meet the second formula, which is:
[0085] Modulus
[0086] Auxiliary arc value
[0087] Direction (radians)
[0088] According to the above formula, the specific values of direction and modulus can be calculated; according to the coordinates, direction, modulus and standard length of the vector, the starting point and end point of the vector in the figure can be calculated. Figure 4 As shown, Figure 4 The green arrow and red arrow in the middle represent the two vector components of the coordinate point read from the nc file. The direction and modulus of the vector can be calculated through the two components. Then, based on the coordinates, direction, modulus and standard length of the vector, the starting point and end point of the vector can be calculated to draw the blue arrow.
[0089] In some optional embodiments, the drawing of the second mode includes the following steps: S701: confirm the coordinate point to be drawn, and assign the transparency of the coordinate point to be o; S702: calculate the position of the next landing point according to the coordinates of the coordinate point and the corresponding vector direction and modulus; S703: assign the transparency of the next landing point to be o+step, and step is set to a fixed value, and repeat this process until the transparency value is p1; S704: calculate the previous landing point in the reverse direction, and assign the previous landing point to be o-step, and repeat this process until the transparency value is p2, and the drawing of the transparent line is completed. The drawing effect of the second mode is as follows: Figure 5 shown.
[0090] In some optional embodiments, referring to Figure 6 The drawing of the earth projection map includes the following steps: S801: obtaining the earth projection frame map, aligning the set point of the earth projection frame map with the center of the drawn field of view; S802: taking any point H on the earth projection frame map, taking the longitude value of the polar coordinates of point H as φ, and the latitude value as 90°-θ, and calculating the values of φ and θ to obtain the longitude and latitude corresponding to the point; S803: coloring with the color corresponding to the variable value of the point on the color scale.
[0091] In step S801, the set point can be the center point of the equator, the North Pole, the South Pole, or four points on the Arctic and Antarctic Circles, the Tropic of Cancer and the Tropic of Capricorn with longitudes of 0°, 90°, 180°, and 270°, respectively aligned to the center of the field of view, and finally 7*4 earth projection images with different viewing angles are generated, in which the latitudes of the center of the field of view correspond to -90°, -66.5°, -23.5°, 0°, 23.5°, 66.5°, and 90°, and the longitudes correspond to 0°, 90°, 180°, and 270°, respectively.
[0092] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the present application. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that the present application does not apply for. The specification and embodiments are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the appended claims.
[0093] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A data processing method, characterized in that: The method comprises: Get the dimension data and variable data output by CESM in nc format; Create a color scale and draw a basic image based on the dimension data and the variable data; Synthesize the basic image into a dynamic image; Determine the vector type for drawing vector graphs, collect vector density and vector standard length, and generate vector graphs; The drawn basic image and the earth projection frame diagram are obtained, and the earth projection frame diagram is colored according to the color code to obtain the earth projection map.
2. The method according to claim 1, characterized in that The drawing of the basic image includes drawing the image title, image frame line and latitude and longitude scales, wherein: The image title, the image frame line and the latitude and longitude scales are drawn by computer vision library functions.
3. The method according to claim 2, characterized in that The drawing of the basic image also includes drawing a coastline, and the drawing of the coastline includes the following steps: S101: Select an adapted ocean grid and obtain its mask data, and draw a mask image using a drawing tool, wherein the mask value of the land pixel point in the mask image is 0, and the mask value of the ocean pixel point is 1; S102: Find any land pixel point that matches the coastline, collect the land pixel point itself and the pixels within a set range around it, traverse all the pixels in the mask image, and extract the pixels whose mask value is 0; S103: Mapping the coordinates of the pixel points that meet the conditions to longitude and latitude, so as to obtain a high-precision longitude and latitude set of coastline points.
4. The method according to claim 3, characterized in that The step S103 is specifically as follows: setting the land pixel points to be filled in blue, setting the ocean pixel points to be filled in red; setting any land pixel point that matches the coastline to be A ij ,in: The i value is set to the horizontal axis value of pixel A, and the j value is set to A ij The vertical axis value of Get A ij A total of 9 pixels within the range of itself and its surrounding 1 pixel: A i-1j-1 , A i-1j , A i-1j+1 , A ij-1 , A ij , A ij+1 , A i+1j-1 , A i+1j , A i+1j+1 The colors of the above pixels are obtained, and the number of pixels filled with blue is counted and recorded as n1, where n1 conforms to the first formula, which is specifically: In the first formula, x is the horizontal coordinate value of pixel point A, and y is the vertical coordinate value of pixel point A; the first formula is used to traverse all pixel points in the mask image, and the coordinates of the pixel points that meet the first formula are extracted and mapped to longitude and latitude to obtain the longitude and latitude set of coastline points.
5. The method according to claim 2, characterized in that: The drawing of the basic image also includes making a color scale, and the making of the color scale includes the following steps: S201: Select a color configuration scheme of the color mark and mark the color as C; S202: Get the minimum and maximum values of the variable to be plotted, denoted as V min With V max , for V min To V max The numerical range is divided into four parts according to V min With V max Calculate the five color scale four-point values in sequence, namely C a0 , C a1 , C a2 , C a3 and C a4 The corresponding variable size is recorded as V a0 、V a1 、V a2 、V a3 and V a4 , where V a0 =V min , V a4 =V max , the calculation formula of the color scale four-point value is as follows: V a2 =(V a0 +V a4 )÷2 V a1 =(V a0 +V a2 )÷2 V a3 =(V a2 +V a4 )÷2 S203: 5 color mark quarter values are obtained by calculation, and the color of the color mark is linearly gradiented according to the two quarter values of the interval, so as to obtain a complete color mark.
6. The method according to claim 5, characterized in that When the color scale is made in isoline mode, the following steps are also included: S301: Set the number of contour layers to L, combined with V min With V max Calculate the median V of the value range corresponding to each contour layer br , r is any positive integer between 0 and L-1, and is calculated as follows: interval=(V max -V min ) / L V br =V min +(r+1-0.5)×interval Where interval represents the interval length of each contour layer; S302: The V calculated in S202 is a0 、V a1 、V a2 、V a3 and V a4 Represented as V aw , C a0 , C a1 , C a2 , C a3 and C a4 Represented as C aw , w is any integer between 0 and 4; According to V br与 V aw The relationship between the calculation of the contour color scale C br , the calculation formula is as follows: S303: After confirming the color scale of each contour layer, a complete contour color scale can be obtained by stacking in each color scale frame.
7. The method according to claim 2, characterized in that The drawing of the basic image also includes coloring, and the coloring includes the following steps: S401: Obtain any longitude and latitude point, calculate the coordinates of the longitude and latitude point by using the image ratio, and color the grid where the longitude and latitude point is located and its surroundings according to the maximum density of the grid; S402: after confirming the color of the variable value of the latitude and longitude point in the color scale, set the pointSize parameter to n2; S403: When n2≤1, color the pixel where the coordinates of the longitude and latitude point are located; when n2>1, color the (2n2+1) pixels around the pixel where the coordinates are located. 2 Paint within a pixel range.
8. The method according to claim 5 or 6, characterized in that: The drawing of the dynamic image comprises the following steps: S501: Counting the value range of any variable to be plotted at all times, and limiting the range of the color scale produced by the minimum and maximum values of the value range; S502: The basic image is obtained by drawing the variables to be drawn at all times, forming a picture group, and then inserting the pictures in the picture group into a corresponding frame sequence according to the time axis sequence; S503: compressing the frame sequence at a set time interval to obtain the dynamic image.
9. The method according to claim 1, characterized in that: The vector type includes a first mode and a second mode, wherein: The first mode is configured to display instantaneous vector direction magnitude; The second mode is configured to display a change trend of a vector.
10. The method according to claim 9, characterized in that The drawing of the first mode comprises the following steps: S601: confirm the coordinates of the coordinate point to be drawn, and read two vector components in the orthogonal direction of the coordinate point from the nc file; S602: Calculate the direction and modulus of the vector through two vector components, calculate the starting point and end point of the vector in the figure according to the coordinates, the standard length of the vector, and the direction and modulus of the vector, and thus draw a direction arrow; S603: When the direction of the vector is used to represent the wind direction, u and v are set to represent the vector components of the wind direction in the horizontal axis direction and the vertical axis direction respectively, and u and v conform to the second formula, which is: The specific values of the direction and the modulus can be calculated according to the second formula.
11. The method according to claim 9, characterized in that The drawing of the second mode comprises the following steps: S701: confirm the coordinate point to be drawn, and assign the transparency value of the coordinate point to be o; S702: Calculate the position of the next landing point according to the coordinates of the coordinate point and the corresponding vector direction and modulus value; S703: assigning a transparency value of o+step to the next landing point, where step is set to a fixed value, and repeating this process until the transparency value is p1; S704: Calculate the last landing point in the reverse direction, assign o-step to the last landing point, and repeat this process until the transparency value reaches p2, thereby completing the drawing of the transparent line.
12. The method according to claim 1, characterized in that The drawing of the earth projection map comprises the following steps: S801: Obtaining a globe projection frame diagram, and aligning a set point of the globe projection frame diagram with the center of the drawn field of view; S802: Take any point on the Earth projection frame diagram, take the longitude of the polar coordinates of the point as φ, and take the latitude as 90°-θ, calculate the values of φ and θ, and then obtain the longitude and latitude corresponding to the point; S803: Coloring the point with reference to the color corresponding to the variable value of the point on the color scale.