将站点数据插值到格点上

利用NCL将站点txt数据插值到格点上

  • 观测数据是分散且不规则分布的,不在网格点上,而给定的低分辨率数据为均匀网格。NCL中有多个插值函数,如双线性插值等,本次插值使用了使用Cressman插值方法,即能保留元数据的obj_anal_ic_Wrap函数,影响半径选择为rscan = (/10,5,3/),剔除距离远处站点数值的影响,只考虑区域附近站点气象要素值,保证插值效果。
;首先读入站点数据和被插值的网格数据
  dem_lo_res  = addfile("./station_to_lowgrid/DemLoRes.nc", "r")
    lon_lr = dem_lo_res->lon ;dlon = 0.5
    lat_lr = dem_lo_res->lat ;dlat = 0.5
   
  tem_origin = asciiread("./station_to_lowgrid/20200808tem.txt", (/699,8/),"float")
    lon_tem = tem_origin(:,2)
    lat_tem = tem_origin(:,1)
    tem = tem_origin(:,7)
   
  ;搞清楚想要的格点经纬度信息
   olon = fspan(88.25, 111.75, 48)
   olat = fspan(20.25, 35.75, 32)
   grid_tem = new((/32,48/),float) ;creat a frame to store the interpolated variables
   
     olon!0 = "lon"
     olon@long_name = "lon"
     olon@units = "degrees-east"
     olon&lon = olon
     olat!0 = "lat"
     olat@long_name = "lat"
     olat@units = "degrees_north"
     olat&lat = olat
     
     ;最重要的一步是插值,rscan选择影响半径
      tem@_FillValue = 9.96921e+36  
      rscan = (/10,5,3/)  ;A one-dimensional array of length K specifying the successive radii of influence.
                          ;rscam must be expressed in degrees of latitude and should be monotonically decreasing
      grid_tem = obj_anal_ic_Wrap(lon_tem,lat_tem,tem,olon,olat,rscan, False) ;Creanm
       grid_tem@units = "degC"
       grid_tem@long_name = "Daily Mean Temperature"
       grid_tem@_FillValue   = 9.96921e+36
       grid_tem@missing_value = 9.96921e+36
       grid_tem@time = time

   system("rm -f ./station_to_lowgrid/LiKeXin_LoRes.nc")
    fout = addfile("./station_to_lowgrid/LiKeXin_LoRes.nc","c")
    fout@title = "NetCDF of Daily Mean Temperature in 2020.08.08"
    fout->temperature = grid_tem
end

附:NCL官网上关于Cressman插值函数的介绍

  • 10
    点赞
  • 51
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
MATLAB可以使用插值方法将格点数据插值站点上。插值是通过已知数据点来预测新位置上未知数据点的一种方法。在MATLAB中,有多种插值方法可供选择,如线性插值、三次样条插值、最近邻插值等。 以线性插值为例,假设我们有一组格点数据,包含经度、纬度和对应的数值。我们想要将这些数据插值站点上,即给定目标站点的经度和纬度,预测该站点上的数值。 首先,我们需要将格点数据生成为格点网格。可以使用MATLAB中的meshgrid函数生成经度格点矩阵和纬度格点矩阵。 然后,我们可以使用MATLAB中的interp2函数进行插值。interp2函数可以接受格点数据的经度、纬度和数值作为输入,并给定目标站点的经度和纬度,预测该站点上的数值。 下面是一个简单的示例代码: ```matlab % 假设已知的格点数据 lon = [100, 101, 102, 103]; lat = [20, 21, 22, 23]; value = [1, 2, 3, 4]; % 生成格点网格 [lon_grid, lat_grid] = meshgrid(lon, lat); % 目标站点的经度和纬度 target_lon = 101.5; target_lat = 21.5; % 线性插值 interp_value = interp2(lon_grid, lat_grid, value, target_lon, target_lat); disp(interp_value); ``` 运行以上代码,将输出目标站点上的插值结果。 通过使用不同的插值方法和调整参数,我们可以根据具体数据和需求来选择最合适的插值方法,将格点数据插值站点上,以获得更准确的结果。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值