A post-processing method and device for ocean numerical simulation products
Through the post-processing method of marine numerical simulation products, the problem of the difference between the numerical forecast model output and the basic geographical information is solved, the compatibility of regular and irregular grids is realized, the marine forecast product data is generated consistent with the basic geographical information, and the application efficiency is improved. Accuracy and generalizability.
Patent Information
- Application Number
- CN202311682316.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-08
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2043-12-08
AI Technical Summary
There are differences between the output results of marine numerical prediction models and basic geographical information, resulting in the inability to accurately compare the forecast results with the coastline, affecting the application of numerical prediction products.
A post-processing method for marine numerical simulation products is proposed. By reading shapefile format data and numerical forecast product grid information, it determines whether the grid type is a regular or irregular grid, initializes the validity array, calculates the difference part, and processes it through interpolation Generate ocean forecast product data that is consistent with basic geographic information.
Compatible with regular and irregular grids, it improves the universality and accuracy of marine numerical simulation products and ensures the accuracy of mapping output.
Smart Images

Figure CN118153266B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a method and device for post-processing ocean numerical simulation products. Background Art
[0002] At present, ocean forecasting is mainly based on the ocean numerical forecast model. Due to the limitations of the water depth and terrain data used in constructing numerical forecasts, the output results (forecast data) only have simulated prediction values in the forecast product grid (without additional processing). When numerical forecast products are used directly (such as drawing output forecast maps, providing data products to external customers, etc.), the forecast results and coastlines cannot be accurately compared. The root of this problem is the difference between the product grid of the numerical forecast model and the basic geographic information. Basic geographic information data (generally in shapefile format) and numerical forecast product grid data (generally gridded text) are superimposed in space. It can be seen that the differences mainly exist in two aspects:
[0003] 1. The numerical forecast grid point is on land (based on basic geographic information), but the model outputs the ocean forecast results for this location;
[0004] 2. The numerical forecast grid point is located in the ocean (based on basic geographic information), but the model does not have ocean forecast results for this location.
[0005] The reasons for the above differences are as follows: basic geographic information is a coastline generated according to scale, and generally its expression ability is closer to the real coastline. However, the numerical forecasting model is limited by business tasks, supercomputing capabilities, water depth data requirements, etc., and its spatial resolution cannot be expanded infinitely. It can only choose a more "reasonable" spatial resolution in order to obtain more economical and sustainable results.
[0006] The above differences directly affect the application of numerical forecast products, such as the production of numerical forecast maps and the production of products reprocessed based on numerical forecasts. Therefore, targeted post-processing is needed to solve this problem. Summary of the invention
[0007] The purpose of the present invention is to address the problems existing in the background technology and to propose a post-processing method and device for ocean numerical simulation products that can be compatible with regular grids and irregular grids in grid products output by ocean numerical forecast models, thereby improving the universality.
[0008] On the one hand, the present invention proposes a post-processing method for ocean numerical simulation products, comprising the following steps Step 1-Step 6:
[0009] Step 1. Read the data record in shapefile format. If the record type is multi-polygon format, process it into a single polygon set and record the BBox parameters of each polygon.
[0010] Step 2. Read the grid information of the numerical forecast product data, and determine whether the grid type is a regular grid or an irregular grid based on the grid information. The judgment is based on traversing the longitude and latitude variables respectively. If the two are equally spaced and the longitude and latitude interval values are the same, it is a regular grid; otherwise, it is an irregular grid.
[0011] Step 3. Initialize the forecast factor data validity array:
[0012] Initialization of validity array 1: In numerical forecast mode, the non-ocean part of the grid area is set to a fixed value of NaN when outputting the forecast results. First, read the forecast field at any forecast time, copy its array, and set the part with NaN value to 0;
[0013] Validity array 2 initialization: Initialize the data group with dimensions (n, lat, lon), where n is the number of polygons in Step 1, lat is the latitude data in Step 2, and lon is the longitude data in Step 2. During the initialization process, all data are set to 0;
[0014] Step 4, calculate the validity array 2 for regular grids and irregular grids respectively;
[0015] Step 5, calculate the difference between validity array 2 and validity array 1, and perform data processing on the difference;
[0016] Step 6. After interpolation processing, generate ocean forecast product data consistent with the basic geographic information, output it according to the format requirements, and carry out subsequent mapping output.
[0017] Preferably, in Step 4, when calculating the validity array 2 for the regular grid, a set of square grids is pre-generated with 8 times the spatial resolution, and then the square grids are traversed one by one, and the operations in the traversal are steps A1-A6:
[0018] A1, n of validity array 2 is loop control;
[0019] A2. In the loop, determine the relationship between the square and each polygon in the geographic information data. If the polygon contains the square, set the grid point corresponding to the square in the validity array to 1.
[0020] A3. If the polygon has no intersection with the square, skip this loop;
[0021] A4. If the polygon and the square intersect, adjust the square resolution to n / 2, where n is not equal to 1;
[0022] A5. Repeat steps A2-A4, and the termination condition is: if n=1, determine whether the polygon includes the point, and if so, set the value of validity array 2 of the point location to 1;
[0023] A6. After the n cycles are completed, the obtained n (lat, lon) arrays are merged to obtain validity array 2.
[0024] Preferably, in Step 4, when calculating the validity array 2 for the irregular grid, the following steps B1-B6 are performed:
[0025] B1. Randomly sample 3 times, each time selecting 5% of the grid points, and calculate the average distance between the grid points [D1, D2, D3];
[0026] B2. Determine the average distance D avg The corresponding S2 spatial index level, where D avg is the mean of the three distances;
[0027] B3, traverse the irregular grid, calculate the S2 spatial index value of each grid point, and record the grid point record set corresponding to each polygon with the same spatial index value. After the traversal is completed, the spatial index polygon set is obtained;
[0028] B4, n of validity array 2 is loop control;
[0029] B5. In the loop, traverse the spatial index polygon and perform the following steps B51-B53:
[0030] B51, determine the relationship between the spatial index polygon and each polygon in the geographic information data, the polygon contains the spatial index polygon, and set the grid point corresponding to the spatial index polygon in the validity array to 1;
[0031] B52. If the polygon has no intersection with the spatial index polygon, skip this loop;
[0032] B53. If the polygon and the spatial index polygon are in an intersecting relationship, the relationship of each point in the polygon spatial index polygon is judged in turn. If there is a containment relationship, the value of the grid position is set to 1;
[0033] B6. After the n cycles are completed, the obtained n (lat, lon) arrays are merged to obtain validity array 2.
[0034] Preferably, in Step 5:
[0035] A grid point set that satisfies the conditions that validity array 1 is 1 and validity array 2 is 0: the forecast value of each point position in the set is set to empty;
[0036] A set of grid points that meet the conditions that validity array 1 is 0 and validity array 2 is 1: For each point position in the set, select a set of grid points with a neighborhood radius of r and interpolate the forecast value of the point.
[0037] On the other hand, the present invention provides a post-processing device for ocean numerical simulation products, the device comprising:
[0038] Information data preprocessing module: It is used to read data records in shapefile format. If the record type is multi-polygon format, it is processed into a single polygon set and the BBox parameters of each polygon are recorded;
[0039] Grid type judgment module: It is used to read the grid information of numerical forecast product data, and judge whether the grid type is a regular grid or an irregular grid through the grid information. The judgment is based on traversing the longitude and latitude variables respectively. If the two are equally spaced and the longitude and latitude interval values are the same, it is a regular grid; otherwise, it is an irregular grid;
[0040] Validity array initialization module: It is used to initialize the validity array of forecast element data:
[0041] Initialization of validity array 1: In numerical forecast mode, the non-ocean part of the grid area is set to a fixed value of NaN when outputting the forecast results. First, read the forecast field at any forecast time, copy its array, and set the part with NaN value to 0;
[0042] Validity array 2 initialization: Initialize the data group with dimensions (n, lat, lon), where n is the number of polygons in Step 1, lat is the latitude data in Step 2, and lon is the longitude data in Step 2. During the initialization process, all data are set to 0;
[0043] Validity array calculation module: used to calculate validity array 2 for regular grids and irregular grids respectively;
[0044] Array difference calculation module: it is used to calculate the difference between validity array 2 and validity array 1, and perform data processing on the difference;
[0045] Data output module: It is used to generate ocean forecast product data that is consistent with basic geographic information after interpolation processing, output it according to the format requirements, and carry out subsequent mapping output.
[0046] Compared with the prior art, the present invention has the following beneficial technical effects:
[0047] The present invention is compatible with regular grids and irregular grids in grid products output by ocean numerical forecast models, is compatible with two styles of products, generates ocean forecast product data consistent with basic geographic information, improves universality and accuracy, and is facilitating subsequent mapping processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 is a flow chart of a processing method according to an embodiment of the present invention;
[0049] Figure 2 It is the hierarchical lookup table corresponding to the average distance mean. DETAILED DESCRIPTION
[0050] like Figure 1 and Figure 2 As shown, a post-processing method for ocean numerical simulation products proposed in this embodiment includes the following steps Step 1-Step 6:
[0051] Step 1, information data preprocessing: read the data record in shapefile format, if the record type is multi-polygon format, process it into a single polygon set, and record the BBox parameters of each polygon (multi-polygon is to combine multiple polygons into one primitive, the current processing is to decompose it); numerical forecast product data is generally stored in netCDF format or GRIB format, and the various elements in it are stored in array mode (multidimensional); basic geographic information data is generally in shapefile format, and the primitive type is polygon class. The boundary of a country or region is stored in a record, which includes the polygon or multi-polygon of the primitive and the attribute table;
[0052] Step 2, grid type judgment: read the grid information of the numerical forecast product data, and judge whether the grid type is a regular grid or an irregular grid through the grid information. The judgment is based on traversing the longitude and latitude variables (arrays) respectively. If the two are equally spaced and the longitude and latitude interval values are the same, it is a regular grid; otherwise, it is an irregular grid.
[0053] Step 3. Initialize the validity array: Initialize the validity array of forecast element data:
[0054] Initialization of validity array 1: In numerical forecast mode, the non-ocean part of the grid area is set to a fixed value of NaN when outputting the forecast results. First, read the forecast field at any forecast time, copy its array, and set the part with NaN value to 0;
[0055] Validity array 2 initialization: Initialize the data group with dimensions (n, lat, lon), where n is the number of polygons in Step 1, lat is the latitude data in Step 2, and lon is the longitude data in Step 2. During the initialization process, all data are set to 0;
[0056] Step 4. Validity array calculation: Calculate validity array 2 for regular grids and irregular grids respectively:
[0057] ① When calculating the validity array 2 for the regular grid, a set of square grids is pre-generated with 8 times the spatial resolution, and then the square grids are traversed one by one. The operations in the traversal are steps A1-A6:
[0058] A1, n of validity array 2 is loop control;
[0059] A2. In the loop, determine the relationship between the square and each polygon in the geographic information data. If the polygon contains the square, set the grid point corresponding to the square in the validity array to 1.
[0060] A3. If the polygon has no intersection with the square, skip this loop;
[0061] A4. If the polygon and the square intersect, adjust the square resolution to n / 2 (when n is not equal to 1);
[0062] A5. Repeat steps A2-A4, and the termination condition is: if n=1, determine whether the polygon includes the point, and if so, set the value of validity array 2 of the point location to 1;
[0063] A6. After the n cycles are completed, the obtained n (lat, lon) arrays are merged to obtain validity array 2;
[0064] ② When calculating validity array 2 for irregular grids, perform the following steps B1-B6:
[0065] B1. Randomly sample 3 times, each time selecting 5% of the grid points, and calculate the average distance between the grid points [D1, D2, D3];
[0066] B2. Determine the average distance D avg The corresponding S2 spatial index level (see Figure 2 ), where D avg is the mean of the three distances;
[0067] B3, traverse the irregular grid, calculate the S2 spatial index value of each grid point (based on the longitude and latitude and level parameters), and record the grid point record set corresponding to each polygon with the same spatial index value. After the traversal is completed, the spatial index polygon set is obtained;
[0068] B4, n of validity array 2 is loop control;
[0069] B5. In the loop, traverse the spatial index polygon and perform the following steps B51-B53:
[0070] B51, determine the relationship between the spatial index polygon and each polygon in the geographic information data, the polygon contains the spatial index polygon, and set the grid point corresponding to the spatial index polygon in the validity array to 1;
[0071] B52. If the polygon has no intersection with the spatial index polygon, skip this loop;
[0072] B53. If the polygon and the spatial index polygon are in an intersecting relationship, the relationship of each point in the polygon spatial index polygon is judged in turn. If there is a containment relationship, the value of the grid position is set to 1;
[0073] B6. After the n cycles are completed, the obtained n (lat, lon) arrays are merged to obtain validity array 2;
[0074] The generation of the validity array in Step 4 is the most core step.
[0075] Step 5, array difference calculation: calculate the difference between validity array 2 and validity array 1, and perform data processing on the difference;
[0076] ① A grid point set that satisfies the condition that validity array 1 is 1 and validity array 2 is 0: the forecast value of each point position in the set is set to empty;
[0077] ② A set of grid points that meet the conditions that validity array 1 is 0 and validity array 2 is 1: For each point position in the set, select a set of grid points with a neighborhood radius of r and interpolate the forecast value of the point;
[0078] Step 6. Data output: After interpolation processing, generate ocean forecast product data consistent with the basic geographic information, output according to the format requirements, and carry out subsequent mapping output.
[0079] The grids of numerical forecast products can be divided into regular grids and irregular grids. The former can be understood as points with equal intervals in the longitude and latitude dimensions representing the grid position, and the entire grid can be inferred from the starting point position; the latter can be understood as scattered points.
[0080] This embodiment is compatible with regular grids and irregular grids in the grid products output by the ocean numerical forecast model, is compatible with two styles of products, generates ocean forecast product data that is consistent with basic geographic information, improves universality and accuracy, and is facilitating subsequent mapping processing.
[0081] The embodiments of the present invention are described in detail above with reference to the accompanying drawings, but the present invention is not limited thereto, and various changes can be made within the knowledge scope of technicians in the relevant technical field without departing from the purpose of the present invention.
Claims
1. A post-processing method for ocean numerical simulation products, It is characterized in that The process includes the following steps: Step 1-Step 6: Step 1. Read the data record in shapefile format. If the record type is multi-polygon format, process it into a single polygon set and record the BBox parameters of each polygon. Step 2. Read the grid information of the numerical forecast product data, and determine whether the grid type is a regular grid or an irregular grid based on the grid information. The judgment is based on traversing the longitude and latitude variables respectively. If the two are equally spaced and the longitude and latitude interval values are the same, it is a regular grid; otherwise, it is an irregular grid. Step 3. Initialize the forecast factor data validity array: Initialization of validity array 1: In numerical forecast mode, the non-ocean part of the grid area is set to a fixed value of NaN when outputting the forecast results. First, read the forecast field at any forecast time, copy its array, and set the part with NaN value to 0; Validity array 2 initialization: Initialize the data group with dimensions (n, lat, lon), where n is the number of polygons in Step 1, lat is the latitude data in Step 2, and lon is the longitude data in Step 2. During the initialization process, all data are set to 0; Step 4. Calculate the validity array 2 for regular grids and irregular grids respectively. When calculating the validity array 2 for regular grids, pre-generate a set of square grids with 8 times the spatial resolution, and then traverse each square grid. The operations in the traversal are steps A1-A6: A1, n of validity array 2 is loop control; A2. In the loop, determine the relationship between the square and each polygon in the geographic information data. If the polygon contains the square, set the grid point corresponding to the square in the validity array to 1. A3. If the polygon has no intersection with the square, skip this loop; A4. If the polygon and the square intersect, adjust the square resolution to n / 2, where n is not equal to 1; A5. Repeat steps A2-A4, and the termination condition is: if n=1, determine whether the polygon includes the point, and if so, set the value of validity array 2 of the point location to 1; A6. After the n cycles are completed, the obtained n (lat, lon) arrays are merged to obtain validity array 2; When calculating the validity array 2 for a non-regular grid, the following steps B1-B6 are performed: B1. Randomly sample 3 times, each time select 5% of the grid points, and calculate the average distance between the grid points [D 1 , D 2 , D 3 ]; B2. Determine the average distance D avg The corresponding S2 spatial index level, where D avg is the mean of the three distances; B3, traverse the irregular grid, calculate the S2 spatial index value of each grid point, and record the grid point record set corresponding to each polygon with the same spatial index value. After the traversal is completed, the spatial index polygon set is obtained; B4, n of validity array 2 is loop control; B5. In the loop, traverse the spatial index polygon and perform the following steps B51-B53: B51, determine the relationship between the spatial index polygon and each polygon in the geographic information data, the polygon contains the spatial index polygon, and set the grid point corresponding to the spatial index polygon in the validity array to 1; B52. If the polygon has no intersection with the spatial index polygon, skip this loop; B53. If the polygon and the spatial index polygon are in an intersecting relationship, the relationship of each point in the polygon spatial index polygon is judged in turn. If there is a containment relationship, the value of the grid position is set to 1; B6. After the n cycles are completed, the obtained n (lat, lon) arrays are merged to obtain validity array 2; Step 5, calculate the difference between validity array 2 and validity array 1, and perform data processing on the difference; Step 6. After interpolation processing, generate ocean forecast product data consistent with the basic geographic information, output it according to the format requirements, and carry out subsequent mapping output.
2. The ocean numerical simulation product post-processing method according to claim 1, It is characterized in that In Step 5: A grid point set that satisfies the conditions that validity array 1 is 1 and validity array 2 is 0: the forecast value of each point position in the set is set to empty; A set of grid points that meet the conditions that validity array 1 is 0 and validity array 2 is 1: For each point position in the set, select a set of grid points with a neighborhood radius of r and interpolate the forecast value of the point.
3. A post-processing device for ocean numerical simulation products, It is characterized in that include: Information data preprocessing module: It is used to read data records in shapefile format. If the record type is multi-polygon format, it is processed into a single polygon set and the BBox parameters of each polygon are recorded; Grid type judgment module: It is used to read the grid information of numerical forecast product data, and judge whether the grid type is a regular grid or an irregular grid through the grid information. The judgment is based on traversing the longitude and latitude variables respectively. If the two are equally spaced and the longitude and latitude interval values are the same, it is a regular grid; otherwise, it is an irregular grid; Validity array initialization module: It is used to initialize the validity array of forecast element data: Initialization of validity array 1: In numerical forecast mode, the non-ocean part of the grid area is set to a fixed value of NaN when outputting the forecast results. First, read the forecast field at any forecast time, copy its array, and set the part with NaN value to 0; Validity array 2 initialization: Initialize the data group with dimensions (n, lat, lon), where n is the number of polygons in Step 1, lat is the latitude data in Step 2, and lon is the longitude data in Step 2. During the initialization process, all data are set to 0; Validity array calculation module: It is used to calculate the validity array 2 for regular grids and irregular grids respectively. When calculating the validity array 2 for regular grids, a square grid set is pre-generated with 8 times the spatial resolution, and then traversed one square grid at a time. The operations in the traversal are steps A1-A6: A1, n of validity array 2 is loop control; A2. In the loop, determine the relationship between the square and each polygon in the geographic information data. If the polygon contains the square, set the grid point corresponding to the square in the validity array to 1. A3. If the polygon has no intersection with the square, skip this loop; A4. If the polygon and the square intersect, adjust the square resolution to n / 2, where n is not equal to 1; A5. Repeat steps A2-A4, and the termination condition is: if n=1, determine whether the polygon includes the point, and if so, set the value of validity array 2 of the point location to 1; A6. After the n cycles are completed, the obtained n (lat, lon) arrays are merged to obtain validity array 2; When calculating the validity array 2 for a non-regular grid, the following steps B1-B6 are performed: B1. Randomly sample 3 times, each time select 5% of the grid points, and calculate the average distance between the grid points [D 1 , D 2 , D 3 ]; B2. Determine the average distance D avg The corresponding S2 spatial index level, where D avg is the mean of the three distances; B3, traverse the irregular grid, calculate the S2 spatial index value of each grid point, and record the grid point record set corresponding to each polygon with the same spatial index value. After the traversal is completed, the spatial index polygon set is obtained; B4, n of validity array 2 is loop control; B5. In the loop, traverse the spatial index polygon and perform the following steps B51-B53: B51, determine the relationship between the spatial index polygon and each polygon in the geographic information data, the polygon contains the spatial index polygon, and set the grid point corresponding to the spatial index polygon in the validity array to 1; B52. If the polygon has no intersection with the spatial index polygon, skip this loop; B53. If the polygon and the spatial index polygon are in an intersecting relationship, the relationship of each point in the polygon spatial index polygon is judged in turn. If there is a containment relationship, the value of the grid position is set to 1; B6. After the n cycles are completed, the obtained n (lat, lon) arrays are merged to obtain validity array 2; Array difference calculation module: it is used to calculate the difference between validity array 2 and validity array 1, and perform data processing on the difference; Data output module: It is used to generate ocean forecast product data that is consistent with basic geographic information after interpolation processing, output it according to the format requirements, and carry out subsequent mapping output.
