更改netCDF文件的网格大小 [英] Change grid size of a netCDF file

查看:81
本文介绍了更改netCDF文件的网格大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们假设我有2个netCDF数据文件,这些文件具有相同区域(例如,南美,非洲等)的数据,但不同网格的大小分别为0.5度x 0.5度和1.0度x 1.0度.我想将其网格大小增加或减少为其他值,例如0.25 x 0.25或1.0 x 1.0,以便可以轻松地将其用于栅格计算和比较等.

Let's assume I have 2 netCDF data files with data for the same region (like South America, Africa, etc) but the different grid sizes as 0.5 degrees x 0.5 degrees and 1.0 degrees x 1.0 degrees in another. I want to increase or decrease its grid size to a different value such as 0.25 x 0.25 or 1.0 x 1.0 so that I can use this easily for raster calculations and comparison, etc.

是否有一种使用任何bash脚本,CDO等进行此操作的方法.

可以从此处下载示例数据. https://www.dropbox.com/sh/0vdfn20p355st3i/AABKYO4do_raGHC34VnsX>

A sample data can be downloaded from here. https://www.dropbox.com/sh/0vdfn20p355st3i/AABKYO4do_raGHC34VnsXGPqa?dl

是否可以采用其他方法(例如双线性插值或三次插值)?使用ArcGIS和其他软件,这非常容易,但是有一种方法可以对具有大型数据集的大型netCDF文件进行处理.假设这只是数据的一个子集.我以后要转换的是一整套的年度数据.

Can different methods be followed for this like bilinear interpolation or cubic interpolation? This is quite easy with ArcGIS and other software but is there a way to do it for a big netCDF file with large datasets. Assume that this is just a subset of the data. What I will be later converting is a whole set of yearly data.

结果文件应为.nc文件,其网格大小由用户定义.

The resulted file should be a .nc file with the changed grid size as defined by the user.

推荐答案

您可以使用cdo重新映射网格,例如可以使用常规的1度网格:

You can use cdo to remap grids, e.g. to a regular 1 degree grid you can use:

cdo remapcon,r360x180 input.nc output.nc

除了保守的一阶重映射(remapcon)外,其他选项还有:

As well as conservative first order remapping (remapcon), other options are :

remapbil : bilinear interpolation
remapnn  : nearest neighbour interpolation
remapcon2 : 2nd order conservative remapping

如果愿意,也可以将一个文件重新映射到另一个文件中使用的网格:

It is also possible to remap one file to the grid used in another if you prefer:

cdo remapcon,my_target_file.nc in.nc out.nc 

回答下面的评论.通常,如果您要从高分辨率插值到低分辨率(粗网格化"),则不要使用双线性插值,因为它将本质上对场进行二次采样.对于非光滑,高度非均质的领域(例如降水)而言,这尤其成问题.在那些情况下,我总是建议使用保守的方法(remapcon或remapcon2).这些方法要慢得多,所以我经常在测试脚本速度时使用双线性,然后切换到remapcon进行最终运行.

to answer the comment below. In general if you are interpolating from high resolution to low resolution ("coarse gridding") you don't want to use bilinear interpolation as it will essentially subsample the field. This is especially problematic for non-smooth, highly heterogeneous fields such as precipitation. In those cases I would always suggest to use a conservative method (remapcon or remapcon2). These methods are much slower, so I often use bilinear while testing a script for speed, and then switch to remapcon for the final run.

关于速度的另一个提示是,如果要对许多具有相同分辨率的输入文件执行相同的插值过程,则可以使用genbil,gencon等计算一次插值权重,然后使用文件循环中的那些功能执行重新映射功能.这快得多,因为权重的生成是remapcon的缓慢部分

Another tip for speed is that, if you are performing the same interpolation procedure on many input files with the same resolution, then you can calculate the interpolation weights once using genbil, gencon etc, and then do the remapping function using those in the loop over the file. This is much faster, as the generation of the weights is the slow part of remapcon

这篇关于更改netCDF文件的网格大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆