如何让细胞指数的纬度和经度WRF模式网格?- 江南体育网页版- - - - -地球科学堆江南电子竞技平台栈交换 最近30从www.hoelymoley.com 2023 - 07 - 07 - t15:11:05z //www.hoelymoley.com/feeds/question/2732 https://creativecommons.org/licenses/by-sa/4.0/rdf //www.hoelymoley.com/q/2732 14 如何让细胞指数的纬度和经度WRF模式网格? gansub //www.hoelymoley.com/users/1066 2014 - 11 - 05 - t07:17:54z 2015 - 02年- 15 - t17:11:02z < p >我用气象研究和预测模型WRF和WRF预处理系统WPS,不能从wrfhelp得到满意的答案。谁能指引我在经度和纬度转换为网格点尤其是嵌套网格?特别是http://www2.mmm.ucar.edu/wrf/OnLineTutorial/Basics/GEOGRID/geogrid_namelist.htm < a href = " http://www2.mmm.ucar.edu/wrf/OnLineTutorial/Basics/GEOGRID/geogrid_namelist.htm " > < / >和< a href = " http://www2.mmm.ucar.edu/wrf/users/docs/user_guide_V3/users_guide_chap3.htm _Description_of_the_1 " > http://www2.mmm.ucar.edu/wrf/users/docs/user_guide_V3/users_guide_chap3.htm _Description_of_the_1 < / > < / p > < p >如何变换纬度和经度<代码> i_parent_start < /代码>和<代码> j_parent_start > < /代码?这是如何与<代码> dx < /代码>和<代码> dy < /代码>和<代码> ref_lat < /代码>和<代码> ref_lon > < /代码?一个简单的例子,一个解释会很有帮助。< / p > //www.hoelymoley.com/questions/2732/-/2740 # 2740 11 答案由f。索普如何让细胞指数的纬度和经度在WRF模式网格? f.thorpe //www.hoelymoley.com/users/543 2014 - 11 - 05 - t23:22:13z 2014 - 11 - 07 - t16:34:35z < p >这个问题可能更适合GIS栈交流……江南电子竞技平台但我会尝试:< / p > < p > dx和dy每网格单元的距离投影网格单元,这是你的网格定义的一部分。ref_lat和ref_lon投影定义的一部分。i_parent_start和j_parent_start水平父网格的网格单元数,你的嵌套网格。我相信WRF网格是面向我,j(0, 0是网格的左下角(例如,一个典型的x - y笛卡儿坐标系统)和第一像素位置定义为1,1协调。< / p > < p >为了创建一个shapefile网格的投影,我将亲自使用空间分配程序工具从UNC (< a href = " https://www.cmascenter.org/sa-tools/ " rel = " noreferrer " > https://www.cmascenter.org/sa-tools/ < / >)。我相信同样的工具将地图指向你的网格。然而,如果你想事情映射到检查结果,您可以使用投影定义构建一个定制的转换在GIS项目,项目你的纬度/多头,然后地图都在一起。< / p > < p > < img src = " https://i.stack.imgur.com/9dqpB.gif " alt = "在这里输入图像描述" > < / p > //www.hoelymoley.com/questions/2732/-/2741 # 2741 16 milancurcic回答的如何让细胞指数的纬度和经度WRF模式网格? milancurcic //www.hoelymoley.com/users/192 2014 - 11 - 06 - t05:32:08z 2014 - 11 - 07 - t13:49:16z < p >我WRF用户已经快5年了,最近的一次公开发布和贡献代码。我不知道WPS (WRF预处理系统)有这样一个工具,需要在网格和点坐标并返回适当的索引。然而,它是非常简单的自己。一些建议使用一个外部的库,我认为这可能是一种过度对于这样一个简单的任务。这是你需要做的是:< / p > < p > 1)运行<代码>土工格栅。exe > < /代码生成网格。因为你还不知道鸟巢的确切位置,设置<代码> max_dom = 1在<代码> < /代码> namelist.wps > < /代码。这将生成一个文件名为<代码> geo_em.d01.nc > < /代码。< / p > < p > 2)看<代码> geo_em.d01。数控代码< / >文件为你的孩子找到合适的指标域。<代码> i_parent_start < /代码>和<代码> j_parent_start > < /代码引用父网格上的x和y指数的西南角落的孩子网格将定位。<代码> XLONG_M < /代码>和<代码> XLAT_M > < /代码的经度和纬度网格质量(压力)点。 Using a programming language of choice, find the grid cell that is closest to your desired location for the child nest corner. This is typically done by looking for the minimum value of distance between desired location and all the points on the grid. For example, in Fortran, you can do something like:

integer :: i_parent_start,j_parent_start integer,dimension(2) :: coords coords = minloc((lon0-xlong_m)**2+(lat0-xlat_m)**2) i_parent_start = coords(1) j_parent_start = coords(2) 

where xlong_m and xlat_m are 2-dimensional arrays that you read from the grid, and lat0 and lon0 are the desired coordinates of the child nest southwest corner. Similarly, if you use Python, you could do:

import numpy as np j_parent_start,i_parent_start = np.unravel_index(\ np.argmin((lon0-xlong_m)**2+(lat0-xlat_m)**2),xlon_m.shape) # Add one because WRF indices start from 1 i_parent_start += 1 j_parent_start += 1 

3) Now edit namelist.wps again, set the i_parent_start and j_parent_start to the values that you calculated in step 3, set max_dom = 2, and re-run geogrid.exe. The child domain file geo_em.d02.nc should be created.

4) Look at the geo_em.d02.nc file. Repeat the procedure until happy with the domain location.

About the parent_grid_ratio parameter. This is an integer factor of child grid refinement relative to the parent grid. For example, if set to 3, and parent grid resolution is 12 km, the child grid resolution will be 4 km. Odd values for parent_grid_ratio (3, 5, etc.) are recommended because for even values, interpolation errors arise due to the nature of Arakawa C-grid staggering. parent_grid_ratio = 3 is the most commonly used value, and recommended by myself.

//www.hoelymoley.com/questions/2732/-/2748 # 2748 9 gansub回答的如何让细胞指数的纬度和经度WRF模式网格? gansub //www.hoelymoley.com/users/1066 2014 - 11 - 08 - t06:30:13z 2014 - 12 - 16 - t06:01:56z < p >我发布的代码计算<代码> i_parent_start < /代码>和<代码> j_parent_start > < /代码。在Java中,当人们意识到Java没有的功能,比如<代码> minloc > < /代码或Python的<代码> unravel_index > < /代码。所以我把我的程序分为三个步骤。< / p >
  1. Read in the xlat_m and xlong_m arrays using java netcdf.

  2. Subtracting desired lat and desired lon from each value of the 2-dimensional xlat_m and xlong_m arrays and squaring the difference.

  3. Then finding the indices i and j of the smallest element of the 2-dimensional array (not as a flattened 1-d array).

There is a tool that comes with WRF called the WRF Domain Wizard that creates the parent and child grids but the issue with this is that you can't see the topography and land use that is so essential for high resolution simulations. In order to view the topography I have another tool that converts the NetCDF file into a KML file and project that on Google Earth. The enclosed image of the child grid is also presented. As explained above for coarse grids this is not so much an issue as it is for nested grids where in the size of the grid itself may not be more than a few hundred meters.

Location of child grid as superimposed on Google Earth

double desiredLatitude = 27; double desiredLongitude = 77; double[][] xlatMArray = getXLatMArray(dataFile); double[][] xlongMArray = getXLongMArray(dataFile); int a = xlatMArray.length; double[][] array = new double[a][a]; for (int i =0 ; i < a;i++) { for (int j =0;j < a ;j++) { double latitudeDiff = desiredLatitude - xlatMArray[i][j]; double longitudeDiff = desiredLongitude - xlongMArray[i][j]; array[i][j]= Math.pow(latitudeDiff,2) + Math.pow(longitudeDiff,2); } } double min = array[0][0]; double max = array[0][0]; int[] minIndex = {0,0}; int[] maxIndex = {0,0}; for (int i =0; i < array.length ; i++) { for (int j =0 ; j < array.length ; j++) { if (array[i][j] < min) { min = array[i][j]; minIndex[0] = i; minIndex[1] = j; } if (array[i][j] > max) { max = array[i][j]; maxIndex[0] = i; maxIndex[1] = j; } } } 
//www.hoelymoley.com/questions/2732/-/4414 # 4414 8 sunt05回答的如何让细胞指数的纬度和经度WRF模式网格? sunt05 //www.hoelymoley.com/users/1376 2015 - 02 - 14 - t23:32:46z 2015 - 02年- 15 - t17:11:02z < p > NCL试试。包WRF-related函数,包括双向的坐标转换例程。< / p > < p >转换坐标对网格指标,按照文档:< a href = " https://www.ncl.ucar.edu/Document/Functions/WRF_arw/wrf_user_ll_to_ij.shtml " rel = " noreferrer " > wrf_user_ll_to_ij < / >。向后(即准备协调)例程可以在这里找到:< A href = " https://www.ncl.ucar.edu/Document/Functions/WRF_arw/wrf_user_ij_to_ll.shtml " rel = " noreferrer " > wrf_user_ij_to_ll < / >。它们非常方便。< / p > < p >为你的场景中,您可以加载父域文件(<代码> geo_em < /代码>或<代码> wrfout < /代码> NetCDF文件),然后指定子域坐标开始,你会得到结果。< / p > < p >这里有一些来自官方文档的例子:< / p > < p >从坐标转换到网格索引:< / p > < pre > <代码>加载“NCARG_ROOT美元/ lib / ncarg / nclscripts / csm / gsn_code。ncl“负载”NCARG_ROOT美元/ lib / ncarg / nclscripts / wrf / WRFUserARW。ncl”= addfile (“wrfout_d01_2000-01-24_12:00:00.nc”、“r”) loc = wrf_user_ij_to_ll (10。,30岁。,真正的)打印(“经度位置是:“+ loc(0))打印(“纬度位置是:”+ loc(1) < /代码> < / pre > < p >从网格指数坐标转换:< / p > < pre > <代码>加载“NCARG_ROOT美元/ lib / ncarg / nclscripts / csm / gsn_code。ncl“负载”NCARG_ROOT美元/ lib / ncarg / nclscripts / wrf / WRFUserARW。ncl“= addfile (“wrfout_d01_2000-01-24_12:00:00.nc”、“r”) res = True res@returnInt = False;返回实际值loc = wrf_user_ll_to_ij (-100.0, 40.0, res)打印(“X / Y位置是:”+ loc) < /代码> < / pre >
Baidu
map