[ncl-talk] read ncdf data from ascii

Mary Haley haley at ucar.edu
Thu Feb 2 13:31:25 MST 2017


Dear Izidine,

First we have to break down this problem to make sure the files are valid.

The error message is admittedly confusing, because you clearly have a ".nc"
extension. BUT, it could be that the file is not named what you think.

What happens if you type the following from the UNIX command line:

ls /home/user/Documents/yr/tasmax/tasmax_NCC-NorESM1-M_
historical_19510101-20051231.nc
ls /home/user/Documents/yr/tasmax/tasmax_CNRM-CERFACS-
CNRM-CM5_historical_19510101-20051231.nc
ncl_filedump /home/user/Documents/yr/tasmax/tasmax_NCC-NorESM1-M_
historical_19510101-20051231.nc
ncl_filedump /home/user/Documents/yr/tasmax/tasmax_CNRM-CERFACS-
CNRM-CM5_historical_19510101-20051231.nc

If the above doesn't produce any errors, then try this in your script:

    files = asciiread("/home/files_path.txt",-1,"string")
    print(files)
    f0 = addfile(files(0),"r")
    f1 = addfile(files(1),"r")
    print(f0)    ; this is like doing an "ncl_filedump" on the file
    print(f1)

I'm thinking that addfiles could be struggling to read them as a set of
files, so I like to try addfile on them individually to be sure they can at
least be opened by NCL.  Of course, if the ncl_filedump works on both
files, then addfile should work on both files.

--Mary






On Thu, Feb 2, 2017 at 9:46 AM, Izidine Pinto <izidinep at gmail.com> wrote:

> Dear NCL users
>
> I'm trying to read a bunch of netcdf files from a list using the script
> below. However I get the following error
>
> fatal:["FileSupport.c":4159]:(/home/user/Documents/yr/
> tasmax/tasmax_NCC-NorESM1-M_historical_19510101-20051231.nc) has no file
> extension, can't determine type of file to open
>
> It has worked before. Am I missing something obvious?
> And I'm using NCAR Command Language Version 6.3.0
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *;***********************************************************************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"load
> "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"begin;************************************************;
> read in netCDF file;************************************************
> files = asciiread("/home/files_path.txt",-1,"string")     print(files)
> f1 = addfiles(files,"r")end*
> The files_path.txt contains the path of the files such as
>
>
> */home/user/Documents/yr/tasmax/tasmax_NCC-NorESM1-M_historical_19510101-20051231.nc
> /home/user/Documents/yr/tasmax/tasmax_CNRM-CERFACS-CNRM-CM5_historical_19510101-20051231.nc
> <http://20051231.nc>*
>
> Thanks in advance
>
> Izidine Pinto
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170202/0d0f662d/attachment.html 


More information about the ncl-talk mailing list