有没有一种方法可以裁剪NETCDF文件? [英] Is there a way to crop a NETCDF file?

查看:579
本文介绍了有没有一种方法可以裁剪NETCDF文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设您有一个文件example.nc,其中的风力数据定义在90N,90S,180E,180W区域中.无论如何,在Linux中,我可以使用一个简单的nc-type命令(无需在matlab/python中提取数据来重写),将该文件裁剪为包含一个较小的区域,即上述子集.

Imagine that you have a file example.nc, that has wind data defined in 90N, 90S, 180E, 180W region. Is there anyway I could in linux, with a simple nc-type command (without extracting the data in matlab/python to rewrite), crop this file to include a smaller region, subset of the above.

例如30N,10S,60E和30W.

For example, 30N, 10S, 60E and 30W.

推荐答案

是,使用NCO包中的ncks: http://nco.sourceforge.net/nco.html

如果您知道与所需纬度/经度范围相对应的索引,例如,它们的纬度为30-40,经度为25-50,则可以使用以下方式裁剪netCDF文件

If you know the indices corresponding to the lat/lon range you want, let's say they are 30-40 in latitude and 25-50 for longitude for example, then you could crop the netCDF file with

ncks -d lat,30,40 -d lon,25,50 example.nc -O cropped_example.nc

确保使用整数值指定索引.

make sure you specify the indices with integer values.

否则,您也可以直接指定所需的经度和纬度值的范围,但是在这种情况下,您必须确保使用小数点将范围作为浮点值传递.

Otherwise you can also directly specify the range of the lat and lon values you want, but in this case you must make sure to use decimal points to pass the range as floats.

 ncks -d lat,30.,-10. -d lon,-30.,60. example.nc -O cropped_example.nc

这篇关于有没有一种方法可以裁剪NETCDF文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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