[ncl-talk] addfiles error in ncl
Mary Haley
haley at ucar.edu
Wed Nov 25 13:34:41 MST 2015
Debasish,
Is the error message the same? If so, you should verify that the variable
"MYD08_M3_051_Optical_Depth_Land_And_Ocean_Mean_Mean" exists on all files.
To verify this, try:
vname = "MYD08_M3_051_Optical_Depth_Land_And_Ocean_Mean_Mean"
do n=0,dimsizes(fname)-1
var_exists = isfilevar(m[n],vname)
print("Is variable on file '" + fname(n) + "'? " + var_exists)
end do
If you are getting a different error message, then please include this, and
include the code again.
Thanks,
--Mary
On Wed, Nov 25, 2015 at 12:12 PM, Debasish Hazra <debasish.hazra5 at gmail.com>
wrote:
> Kyle,
>
> Thanks. I tried with your option :
> fname = systemfunc("ls -1 ../../MODIS/Monthly/AOD/*.nc")
> m = addfiles(fname,"r")
> ListSetType (m, "join")
>
> print(m)
> and it printed out all the 144 file names. I have attached a text file of
> the output. But still shows, it cannot read that variable.
>
> Debasish
>
> On Wed, Nov 25, 2015 at 1:38 PM, Kyle Griffin <ksgriffin2 at wisc.edu> wrote:
>
>> Have you considered the input to addfiles? You appear to be passing the
>> filesize value (column 5 when you run ls -l (lower case L) in your
>> directory) to the NCL function. I can't imagine this is intended, as
>> addfiles is looking for the file name itself - but fname ends up as the
>> size, not the name. Even if you were getting them as names, you then run
>> toint(fname), which should fail if you were actually getting the names as
>> strings.
>>
>> Try using 'ls -1 filenames*.nc' (the number one) and this should print
>> out all of your files in that directory with one name on each line, a
>> format that addfiles will read from quite well and you can avoid your use
>> of awk. Your current method could also work, but would require pulling a
>> later column in the awk command (perhaps 9?).
>>
>> Consider what you actually want your 'print(fsz)' statement to
>> output...you do well by looking at it, but that output is showing you the
>> problem of trying to read the variable from a bunch of numbers and not
>> files.
>>
>>
>> Kyle
>>
>> ----------------------------------------
>> Kyle S. Griffin
>> Department of Atmospheric and Oceanic Sciences
>> University of Wisconsin - Madison
>> Room 1407
>> 1225 W Dayton St, Madison, WI 53706
>> Email: ksgriffin2 at wisc.edu
>>
>> On Wed, Nov 25, 2015 at 12:28 PM, Debasish Hazra <
>> debasish.hazra5 at gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I am trying to read bunch of files in ncl and at first it gave " ncl
>>> fatal:incorrect size for list filevar subselection" error. Followed by ncl
>>> examples I tried something like this :
>>>
>>> fname = systemfunc("ls -l ../../MODIS/Monthly/AOD/*.nc | awk '{print
>>> $5}' ")
>>> fsz = toint(fname)
>>> m = addfiles(fsz,"r")
>>> ListSetType (m, "join")
>>>
>>> print(fsz)
>>> printVarSummary(fsz)
>>>
>>> mod_aod =
>>> m[:]->MYD08_M3_051_Optical_Depth_Land_And_Ocean_Mean_Mean
>>>
>>> which print outs and gave error as :
>>>
>>> Variable: fsz
>>> Type: integer
>>> Total Size: 576 bytes
>>> 144 values
>>> Number of Dimensions: 1
>>> Dimensions and sizes: [144]
>>> Coordinates:
>>> (0) 264160
>>> (1) 263836
>>> (2) 263836
>>> (3) 263836
>>> (4) 263836
>>> (5) 263836
>>> (6) 263836
>>> (7) 263836
>>> (8) 263836
>>> (9) 263836
>>> [SNIP]
>>> (133) 522664
>>> (134) 522664
>>> (135) 522664
>>> (136) 522664
>>> (137) 522664
>>> (138) 522668
>>> (139) 522668
>>> (140) 522668
>>> (141) 522668
>>> (142) 522664
>>> (143) 522664
>>>
>>> fatal:No valid instance of variable
>>> MYD08_M3_051_Optical_Depth_Land_And_Ocean_Mean_Mean found in file list
>>>
>>> However, ncl_filedump of this files show :
>>> g4.subsetted.MYD08_M3_051_Optical_Depth_Land_And_Ocean_Mean_Mean.20130701.180W_90S_180E_90N.nc
>>>
>>> shows
>>> title : MYD08_M3_051_Optical_Depth_Land_And_Ocean_Mean_Mean
>>> (180W_90S_180E_90N)
>>> dimensions:
>>> time = 1 // unlimited
>>> lat = 180
>>> lon = 360
>>> variables:
>>> float MYD08_M3_051_Optical_Depth_Land_And_Ocean_Mean_Mean ( time,
>>> lat, lon )
>>>
>>> Any help why this one is not working. Thanks.
>>>
>>> Attached is the one of the many identical files I was trying to work on.
>>>
>>> Debasish.
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>
> _______________________________________________
> 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/20151125/f7d205e6/attachment.html
More information about the ncl-talk
mailing list