【问题标题】:Why does ncl not find netcdf files?为什么 ncl 找不到 netcdf 文件?
【发布时间】:2016-10-20 15:45:27
【问题描述】:

我在 Ubuntu 14.04 下使用来自 Trusty 的 ncl-ncarg 6.1.2-7。我创建了一个从usr/share/ncargusr/lib 的软链接,并通过以下方式设置环境和路径:

export NCARG_ROOT="/usr"
export PATH=$NCARG_ROOT/bin:$PATH

我有一个 simple_plot_pr.ncl,它从 3 个 netCDF 文件创建面板图。

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

begin
   ;-- read data and set variable references
       f1 = addfile ("home/robert/Dokumenty/climatological monthly mean pr_1971-2000.nc","r")
       f2 = addfile ("home/robert/Dokumenty/climatological monthly mean pr_2021-2050.nc","r")
       f3 = addfile ("home/robert/Dokumenty/climatological monthly mean pr_2071-2100.nc","r")

       pr1 = f1->pr
       pr2 = f2->pr
       pr3 = f3->pr
;-- open a PNG file
    wks = gsn_open_wks("png","panel_plot")
;-- create plot array
    plot = new(3,graphic)
;-- set resources for contour plots
    res = True
    res@gsnMaximize = True
    res@cnFillOn = True
    res@tiMainString = "Climatological mean monthly precipitation amount"
    gsn_define_colormap(wks,"rainbow")
    plot(0) = gsn_csm_colormap(wks,pr1(:,:),res)
    res@tiMainString = ""
    plot(1) = gsn_csm_colormap(wks,pr2(:,:),res)
    res@tiMainString = ""
    plot(3) = gsn_csm_colormap(wks,pr3(:,:),res)
    ;-- create panel plot
    gsn_panel(wks,plot,(/3,1/),False)
end

当我运行这个 .ncl 文件时,我收到以下错误消息:

Copyright (C) 1995-2013 - All Rights Reserved
 University Corporation for Atmospheric Research
 NCAR Command Language Version 6.1.2
 The use of this software is governed by a License Agreement.
 See http://www.ncl.ucar.edu/ for more details.
fatal:["FileSupport.c":2761]:_NclFindFileExt: Requested file <home/Dokumenty/climatological monthly mean pr_1971-2000.nc> or <home/Dokumenty/climatological monthly mean pr_1971-2000> does not exist

fatal:["FileSupport.c":3106]:(home/Dokumenty/climatological monthly mean pr_1971-2000.nc) has no file extension, can't determine type of file to open
fatal:["FileSupport.c":2761]:_NclFindFileExt: Requested file <home/robert/Dokumenty/climatological monthly mean pr_2021-2050.nc> or <home/robert/Dokumenty/climatological monthly mean pr_2021-2050> does not exist

fatal:["FileSupport.c":3106]:(home/robert/Dokumenty/climatological monthly mean pr_2021-2050.nc) has no file extension, can't determine type of file to open
fatal:["FileSupport.c":2761]:_NclFindFileExt: Requested file <home/robert/Dokumenty/climatological monthly mean pr_2071-2100.nc> or <home/robert/Dokumenty/climatological monthly mean pr_2071-2100> does not exist

fatal:["FileSupport.c":3106]:(home/robert/Dokumenty/climatological monthly mean pr_2071-2100.nc) has no file extension, can't determine type of file to open
fatal:file (f1) isn't defined
fatal:["Execute.c":8128]:Execute: Error occurred at or near line 11 in file simple_plot_pr.ncl

我检查了这些文件并且它们存在。我不明白为什么ncl找不到他们?有人可以给我一个解决这个问题的建议吗?

【问题讨论】:

  • 是否需要在home前加一个/,即/home/robert/../
  • 不,我不需要。我试着按照你的建议运行它,但我得到了同样的错误。但是ncl_filedump 找到了我的 .nc 文件并给出了正确的值。我不明白为什么ncl找不到他们?
  • 文件名中的空格也可能导致问题,请尝试使用下划线重命名文件,例如climatological_monthly_mean_pr_1971-2000.nc

标签: ubuntu-14.04 netcdf ncl


【解决方案1】:

该错误肯定是由于文件名中的空格引起的。请重命名文件名,不带空格。

【讨论】:

    【解决方案2】:

    您也可以在文件名中的空格前使用正斜杠。例如。而不是写“气候月平均pr_1971-2000.nc”;您可以按以下格式编写文件名。 "climatological\monthly\mean\pr_1971-2000.nc"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-14
      • 2010-10-12
      • 1970-01-01
      • 1970-01-01
      • 2022-11-29
      • 2017-10-14
      • 2023-03-31
      • 2021-12-09
      相关资源
      最近更新 更多