[ncl-talk] NDVI from Advanced Very High-Resolution Radiometer (AVHRR)

Setareh Rahimi setareh.rahimi at gmail.com
Sun Jun 26 10:12:34 MDT 2022


Dear Dennis,
I put all NDVI files in one folder(like the attached image), and tried to
run the attached script to plot the NDVI anomaly from 1986 to 2021.
However, I faced another issue(attached). May I ask you, please to advise
me why this message appeared? How can I remove this issue, please?
Many thanks for considering my request.
Best wishes,

On Tue, Jun 21, 2022 at 10:09 PM Dennis Shea <shea at ucar.edu> wrote:

> I downloaded 5 files for a test.
>
> %> ncl NDVI_anomaly.ncl
>
> Copyright (C) 1995-2017 - All Rights Reserved
>  University Corporation for Atmospheric Research
>  NCAR Command Language Version 6.5.0
>  The use of this software is governed by a License Agreement.
>  See http://www.ncl.ucar.edu/ for more details.
>
>
> Variable: fils
> Type: string
> Total Size: 40 bytes
>             5 values
> Number of Dimensions: 1
> Dimensions and sizes:   [5]
> Coordinates:
> (0)     AVHRR-Land_v005_AVH13C1_NOAA-09_19860101_c20170612092103.nc
> (1)     AVHRR-Land_v005_AVH13C1_NOAA-09_19860102_c20170612093403.nc
> (2)     AVHRR-Land_v005_AVH13C1_NOAA-09_19861229_c20170612212717.nc
> (3)     AVHRR-Land_v005_AVH13C1_NOAA-09_19861230_c20170612214313.nc
> (4)     AVHRR-Land_v005_AVH13C1_NOAA-09_19861231_c20170612215936.nc
>
> Variable: prc
> Type: float
> Total Size: 518400000 bytes
>             129600000 values
> Number of Dimensions: 3
> Dimensions and sizes:   [time | 5] x [latitude | 3600] x [longitude | 7200]
> Coordinates:
>             time: [1826..2190]
>             latitude: [89.975..-89.97499]
>             longitude: [-179.975..179.975]
> Number Of Attributes: 7
>   long_name :   NOAA Climate Data Record of Normalized Difference
> Vegetation Index
>   units :       1
>   grid_mapping :        crs
>   standard_name :       normalized_difference_vegetation_index
>   _FillValue_original : -9999
>   _FillValue :  -9999
> ========================================================================
> ========================================================================
> ========================================================================
> It seems to me that you have path or file problems.
> I am not sure what else I can do.
>
> Others?
>
>
>
> On Tue, Jun 21, 2022 at 5:49 AM Setareh Rahimi <setareh.rahimi at gmail.com>
> wrote:
>
>> Dear Dennis,
>> So many thanks for your advice. I run the script on a remote server with
>> at least *1 terabyte* of memory. I think this is not the case.
>> I used the below commands to check the files:
>> ===========================================
>> fils = systemfunc("ls [1-2][8-9-0-1]*/*nc")
>>    print(fils)
>>
>>    f   = addfiles (fils, "r")
>>
>>    x   = short2flt(f[:]->NDVI)
>>
>>    printVarSummary(x)
>> ===========================================
>> , and attached the result. Please look at the image, and kindly help me
>> sort the issue out. I do not know what is wrong with the files I downloaded.
>> best regards,
>>
>> On Sat, Jun 18, 2022 at 10:52 PM Dennis Shea <shea at ucar.edu> wrote:
>>
>>> Based on the provided information, I have no idea why you would get
>>> "returned nothing to me"
>>>
>>> I know that NDVI files are 0.1 degree resolution (3600,7200). You have
>>> 36 years (1986-2021) of daily data.
>>> So, 36*365=13140   [+ a few Leap Year days)
>>>
>>>    prc(13140,3600,7200)    => daily data
>>>
>>> A lot of memory is needed. Maybe your computer can not handle this?
>>>
>>> After the
>>>       xM = calculate_monthly_values (prc, "avg", 0,opt)
>>>       printVarSummary(xM)
>>>
>>>    xM(432,3600,7200)
>>>
>>>
>>>
>>> On Sat, Jun 18, 2022 at 5:01 AM Setareh Rahimi via ncl-talk <
>>> ncl-talk at mailman.ucar.edu> wrote:
>>>
>>>> Dear all,
>>>>
>>>> I need to calculate the monthly anomaly of the Normalized Difference
>>>> Vegetation Index (NDVI), from Advanced Very High-Resolution Radiometer
>>>> (AVHRR) sensor. I have downloaded AVHRR data (1986-2021) from the link
>>>> below:
>>>>
>>>> https://www.ncei.noaa.gov/metadata/geoportal/rest/metadata/item/gov.noaa.ncdc:C01558/html
>>>> I first tried to prepare a script to combine all the data, and then
>>>> calculate the monthly average from daily data ( the link provides daily
>>>> data). After having monthly data I tried to figure out anomalies (the
>>>> script has been attached). But NCL stopped and returned nothing to me. I
>>>> just wonder what is wrong. Please kindly advise me on this issue.
>>>> 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
>>
>>

-- 
S.Rahimi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20220626/10b08da1/attachment-0001.htm>
-------------- next part --------------
begin
;************************************************
; Read the file
;************************************************
  ymStrt = 198601                              ; climatology start year/month
  ymLast = 202112                              ;      "      last  year/month  a      = addfile("air.mon.mean.nc","r")
  
;--------------------------------------
  fils = systemfunc("ls *.nc")
   print(fils)

   a   = addfiles (fils, "r")
;-----------------------------------------
  time   = a[:]->time
  yyyymm = cd_calendar(time, -1)
  ntStrt = ind(yyyymm.eq.ymStrt)                ; start time index
  ntLast = ind(yyyymm.eq.ymLast)                ; last  time index
  ndvi    =short2flt(a[:]->NDVI(ntStrt:ntLast,:,:))            ; (time,lat,lon)
  ntim = dimsizes(time)
 printMinMax(ndvi,0)
  months = (/"January", "February", "March", "April" \
            ,"May", "June", "July", "August"         \
            ,"September", "October", "November"      \
            ,"December" /)

;************************************************
; Compute the climatology using a function in contributed.ncl
;************************************************  
  ;prcClm   = clmMonTLL(tmp)     
  ;printVarSummary(prcClm)
  xM = calculate_monthly_values (ndvi, "avg", 0,opt)
  printVarSummary(xM)
  anom = calcMonAnomTLL(ndvi,xM)
;************************************************
; create colors
;*************************************************
  wks = gsn_open_wks("png","NDVI-anomaly_ghcn")             ; send graphics to PNG file

;************************************************
; create panel plots
;*************************************************
  plot   = new (12, graphic)                    ; create graphical array


  res                      = True               ; plot options desired
  res at gsnDraw              = False
  res at gsnFrame             = False
  res at cnFillOn             = True               ; turn on color fill
  res at cnFillPalette        = "amwg256"          ; set color map
  res at cnInfoLabelOn        = False              ; turn off contour info label
  res at cnLinesOn            = False              ; turn off contour lines
  res at cnLineLabelsOn       = False              ; turn off line labels
   

  res at cnLevelSelectionMode = "ManualLevels"     ; set manual contour levels
  res at cnMinLevelValF       = -1       ; set min contour level
  res at cnMaxLevelValF       = 1  ; set max contour level
  res at cnLevelSpacingF      = 0.2           ; set contour spacing

  ;res at mpFillOn             = False              ; turn off gray continents
  res at mpCenterLonF         = 0                  ; Centers the plot at 0
  ;res at lbLabelBarOn         = False              ; No single label bar


 res at mpMaxLatF            = 60        ; choose subregion
 res at mpMinLatF            = 0
 res at mpMaxLonF            = 70
 res at mpMinLonF            = -50
 res at mpDataBaseVersion    = "MediumRes"      ; better map outlines
 res at gsnRightString      = " mm"




  resP                     = True               ; panel options
  resP at gsnPanelMainString  = " NDVI anomaly : "+(ymStrt/100)+"-"+(ymLast/100)
  resP at gsnMaximize         = True               ; maximize image
  resP at gsnPanelLabelBar    = True               ; Add common label bar
   




  do nmo=0,2                                  ; loop over the months
     res at gsnLeftString     = months(nmo)
     plot(nmo) = gsn_csm_contour_map(wks,anom(nmo,:,:), res)  ; create plot
  end do


    do nmo=9,11                                  ; loop over the months
     res at gsnLeftString     = months(nmo)
     plot(nmo) = gsn_csm_contour_map(wks,anom(nmo,:,:), res)  ; create plot
   end do




  ;shapefile_name1 = "clip.basin3.shp"
  shapefile_name2 = "IRN_adm0.shp"
  lnres = True
  lnres at gsLineThicknessF = 5
  lnres at gsLineColor = "Black"

  ;shape1 = gsn_add_shapefile_polylines(wks,plot,shapefile_name1,lnres)
  shape2 = gsn_add_shapefile_polylines(wks,plot,shapefile_name2,lnres)
  
  ;gsn_panel(wks,plot,(/2,3/),resP)
  gsn_panel(wks,(/plot(0),plot(1),plot(2),plot(9),plot(10),plot(11)/),(/2,3/),resP)

end






-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1.png
Type: image/png
Size: 220549 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20220626/10b08da1/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2.png
Type: image/png
Size: 350055 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20220626/10b08da1/attachment-0003.png>


More information about the ncl-talk mailing list