【问题标题】:Extract text from variable in netCDF file using ncks使用 ncks 从 netCDF 文件中的变量中提取文本
【发布时间】:2019-06-25 15:18:58
【问题描述】:

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

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

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

但是,该文件不是可读文本。在 ncks 的文档中,它说“ncks 将以 ASCII 格式打印 netCDF 数据”。

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

【问题讨论】:

    标签: netcdf ncks


    【解决方案1】:

    如果你有 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
    

    【讨论】:

      猜你喜欢
      • 2018-09-02
      • 2019-07-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-13
      • 1970-01-01
      • 2021-11-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多