[ncl-talk] Plotting NDVI from (AVHRR) sensor

Dennis Shea shea at ucar.edu
Sat Jun 18 09:37:20 MDT 2022


re:   "f is undefined"

??  This indicates that the file pointer is not correct

The script loops over one or more files:

do nf=0,nfili-1
  pthi = diri+fili(nf)
  f    = addfile(pthi, "r")

f is a pointer to a file.
======================================

You should go into 'debug mode'

print(diri)               ; data path
print("=====")
print(fili)               ; print names of one or more files
print("=====")
print("nfili="+nfili)     ; number of files
print("=====")

:
:
do nf=0,nfili-1            ; loop over each file
  pthi = diri+fili(nf)

  print(pthi)
  print("=====")

  f    = addfile(pthi, "r")

  print(f)     ; equivalent to 'ncdump -h '


On Sat, Jun 18, 2022 at 4:50 AM Setareh Rahimi <setareh.rahimi at gmail.com>
wrote:

> Dear Dennis,
> So many thanks for your help, but after running the script it said: "f is
> undefined" !!
> Why does this happen, please?
> Best wishes,
>
>
> On Fri, Jun 17, 2022 at 10:49 PM Dennis Shea <shea at ucar.edu> wrote:
>
>> Looks like I 'somehow'  deleted a line
>> ====
>> Note the script has the following at the top:
>>
>> TEST = False
>> =====
>>
>> The published script should be:
>>
>>   if (TEST) then   ; <=======  This was inadvertently deleted by 'someone'    :;-)
>>                                    ;
>>       ndvi  = short2flt(f->NDVI(:,::50,::25))         ; original unpacked values
>>   else
>>       ndvi  = short2flt(f->NDVI)                      ; original unpacked values
>>   end if
>>
>>
>>
>> On Fri, Jun 17, 2022 at 4:03 AM Setareh Rahimi via ncl-talk <
>> ncl-talk at mailman.ucar.edu> wrote:
>>
>>> Dear all,
>>> I would like to use this example "
>>> https://www.ncl.ucar.edu/Applications/Scripts/ndvi_3.ncl",  available
>>> at: https://www.ncl.ucar.edu/Applications/ndvi.shtml
>>> to plot NDVI from Advanced Very High-Resolution Radiometer (AVHRR)
>>> sensor. But, I got the following error:
>>>
>>> fatal:error in statement
>>> fatal:syntax error: line 55 in file ndvi before or near else
>>>   else
>>> -----^
>>>
>>> fatal:error in statement
>>> fatal:syntax error: line 57 in file ndvi before or near if
>>>   end if
>>> -------^
>>> , "IF" statement is not complete. I do not know what condition has been
>>> considered for the "IF" statement. Would you please kindly advise me?
>>> Thanks in advance,
>>> Best wishes,
>>>
>>>
>>>
>>> --
>>> S.Rahimi
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at mailman.ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>
>
> --
> S.Rahimi
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20220618/6adb8009/attachment.htm>


More information about the ncl-talk mailing list