使用 ncks 从 netCDF 文件中的变量中提取文本

Extract text from variable in netCDF file using ncks

我正在尝试使用 ncks 从文件中提取变量 "flash_lon" 并以纯文本形式输出到文本文件。

当我使用以下命令时,它会在屏幕上显示我需要的变量并输出到文件。

ncks -v flash_lon -x file.nc output.txt

但是,该文件不是可读文本。在 ncks 的文档中,它说 "ncks will print netCDF data in ASCII format ".

我需要做什么才能简单地将变量提取到文本中?它只是文本。我在下面附上了一张图片,显示了命令行中工作的数据,肯定有办法让它输出。我在 Windows 10.

如果你有 ncdump 和 sed 你可以像这样只输出数据

 ncdump -v flash_lon file.nc | sed -e '1,/data:/d' -e '$d' > output.txt

我经常使用并在此处找到的解决方案:

https://www.unidata.ucar.edu/mailing_lists/archives/netcdfgroup/2011/msg00317.html

如果你连变量名的第一行都不想要,你可以用尾巴剪掉那些:

 ncdump -v flash_lon file.nc | sed -e '1,/data:/d' -e '$d' | tail -n +3 > output.txt