[ncl-talk] Wind Swath Calculation using NCL

Dennis Shea shea at ucar.edu
Tue May 12 10:51:32 MDT 2020


Examining satellite swath data was the original reason for developing the *
stat_dispersion
<http://www.ncl.ucar.edu/Document/Functions/Contributed/stat_dispersion.shtml>
*function.

Note: The documentation says to explicitly:  *load /.../contributed.ncl*
That is out-of-date.
The contributed library is automatically loaded so the explicit load is NOT
necessary.
---------------
The golden rule of data processing is *'know your data'*  !!

Examining only the min/max of noisy data can be rather limiting. Try:

  ws_opt_sd = True               ; options for *s*tat_*d*ispersion
  ws_opt_sd at PrintStat = True
  ws_stat = *stat_dispersion*
<http://www.ncl.ucar.edu/Document/Functions/Contributed/stat_dispersion.shtml>(ws,
ws_opt_sd )
-------

See also *nice_mnmxintvl*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/nice_mnmxintvl.shtml>.
You may wish to use this and the output from *stat_dispersion*  to
help set contour levels. EG:
If you decide to use (say) the lower and upper sextiles

 ws_low  =  ws_stat(5)         ; Low Sextile   ; whatever statistic you want
 ws_high = ws_stat(11)       ; High Sextile   ;       "             "
       "      "
 ws_MaxPlotLevel = 16      ; whatever you choose  8 to 16 is common
 ws_mnmxint = *nice_mnmxintvl*( ws_low, ws_high,ws_MaxPlotLevel  ,
False)  ; last argument could be True also

  ws_res = True
  . . .
  ws_res@*cnLevelSelectionMode*
<http://www.ncl.ucar.edu/Document/Graphics/Resources/cn.shtml#cnLevelSelectionMode>
= "ManualLevels"
  ws_res@*cnMinLevelValF*
<http://www.ncl.ucar.edu/Document/Graphics/Resources/cn.shtml#cnMinLevelValF>
      = ws_low
  ws_res@*cnMaxLevelValF*
<http://www.ncl.ucar.edu/Document/Graphics/Resources/cn.shtml#cnMaxLevelValF>
     = ws_high
  ws_res@*cnLevelSpacingF*
<http://www.ncl.ucar.edu/Document/Graphics/Resources/cn.shtml#cnLevelSpacingF>
    = ws_mnmxint(2)       ; use suggested contour interval

             ; could be changed as you see as appropriate
---

To be clear, you could use *any returned statistic *for low and high

ws_low  =  ws_stat(3)    ; Low Decile
ws_high = ws_stat(12)  ; High Octile
==
ws_low  =  ws_stat(2)    ; Min value
ws_high = ws_stat(7)    ; High Tri
==
ws_low  =  ws_stat(24)    ; lower 5%
ws_high = ws_stat(26)    ; Upper 1%
==

If you want to eliminate 'extreme' values, then

     ws = *where*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml>(ws.lt.ws_low
.or.  ws.gt.ws_high , ws at _FillValue, ws)

*Again, as a scientist/researcher [... ALWAYS...] examine your data.*

Good Luck


On Tue, May 12, 2020 at 6:00 AM Sakib Ahmed <nonicknameforever at gmail.com>
wrote:

> Thank you, Dennis, for the suggestion!
>
> On Mon, May 11, 2020 at 9:25 PM Dennis Shea <shea at ucar.edu> wrote:
>
>> Oops:
>>      print(WS)   ; all 287 values
>> should be
>>      print(ws(:,nl,ml))
>>
>> On Mon, May 11, 2020 at 1:52 PM Dennis Shea <shea at ucar.edu> wrote:
>>
>>> Looks correct to me.
>>>
>>> Keep in mind that satellite swath data can be quite noisy.
>>>
>>> You can do a simple test at one lat/lon location.
>>>
>>>   nl  = 600                       ; arbitrary ... your choice
>>>   ml = 700                       ;     "                    "
>>>
>>>   ws_min  = *min*(ws(:,nl,ml))
>>>   ws_max = *max*(ws(:,nl,ml)
>>>
>>>   print(WS)   ; all 287 values
>>>   print("====")                         ; visual separator
>>>   print("ws_min  ="+ws_min )
>>>   print("ws_max ="+ws_max )
>>>   print("swath="+swath(nl,ml))   ; should match 'ws_max'
>>>
>>> On Mon, May 11, 2020 at 1:16 PM Sakib Ahmed via ncl-talk <
>>> ncl-talk at ucar.edu> wrote:
>>>
>>>> Dear NCL Community,
>>>>
>>>> I'm trying to calculate the maximum wind swath(maximum wind speed at
>>>> each grid point for all the time steps) from a model output but after
>>>> plotting, it doesn't look correct. It would be helpful if anyone can point
>>>> me if there's anything wrong with the code that I'm using.
>>>>
>>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>>> begin
>>>>
>>>> f    = addfile("florence_wind.nc" ,"r" )   ; reading file
>>>> ws = f->ws                                          ; reading variable
>>>>
>>>> printVarSummary(ws)
>>>>
>>>> Variable: ws
>>>> Type: float
>>>> Total Size: 1658634992 bytes
>>>>             414658748 values
>>>> Number of Dimensions: 3
>>>> Dimensions and sizes:   [287] x [1202] x [1202]
>>>> Coordinates:
>>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;calculate
>>>> swath;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>>>
>>>> swath = dim_max_n(ws,0)   ; swath(nlat,nlon)
>>>>
>>>> printVarSummary(swath)
>>>>
>>>> Variable: swath
>>>> Type: float
>>>> Total Size: 5779216 bytes
>>>>             1444804 values
>>>> Number of Dimensions: 2
>>>> Dimensions and sizes:   [1202] x [1202]
>>>> Coordinates:
>>>>
>>>> end
>>>>
>>>> Thank you in advance for the help.
>>>> Sakib
>>>>
>>>> Sakib Ahmed
>>>> Connecticut College
>>>> Environmental Studies Major,
>>>> New London, CT 06320
>>>>
>>>>
>>>> _______________________________________________
>>>> 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/20200512/7b1d4782/attachment.html>


More information about the ncl-talk mailing list