[ncl-talk] Assessing the length of above and below average streaks in de-trended datasets

Toni Klemm toni-klemm at tamu.edu
Fri May 10 09:20:05 MDT 2019


Thanks a lot, Adam!

It took me a while to understand what I’m getting by dim_numrun_n, but it saves me a lot of coding and is exactly what I needed!

For future reference, to better understand the data you get from dim_numrun_n and opt=1, it helps looking at example 2. opt=1 gives you the data in column “r1”, which refers to column “run length”. “r1” tells you how many consecutive runs of 1s of different lengths the dummy data in example 2 has, e.g., 3 runs with a single 1, 1 run with two 1s, 3 runs with three 1s, and so on.

To calculate the average length of consecutive 1s, multiply "run length” and “r1”, take the sum of the product, and divide it by the sum of “r1”. Essentially:

Average length = sum(“run length” * “r1”) / sum(“r1”)


I hope that helps future users. It’s a great function!

Toni


Toni Klemm, Ph.D.
Postdoctoral Research Associate
Department of Ecosystem Science and Management
College of Agriculture and Life Sciences
Texas A&M University, College Station, TX
www.toni-klemm.de <http://www.toni-klemm.de/> | @toniklemm <http://twitter.com/toniklemm>
Editorial Board member, Early Career Climate Forum <http://www.eccforum.org/>







> On May 9, 2019, at 11:27 AM, Adam Phillips <asphilli at ucar.edu> wrote:
> 
> Hi Toni,
> See example #3 in the dim_numrun_n documentation:
> http://www.ncl.ucar.edu/Document/Functions/Built-in/dim_numrun_n.shtml <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.ncl.ucar.edu_Document_Functions_Built-2Din_dim-5Fnumrun-5Fn.shtml&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=VvzoKtIseDjtyUD8VWUMhpyE4jPU5aD352WZdT2aQ3g&s=uiPO4Wrb4KOva8OyRbBKNbb4nXl6qNPxJcnkwT7yMk0&e=>
> Adam
> 
> On Thu, May 9, 2019 at 10:22 AM Toni Klemm <toni-klemm at tamu.edu <mailto:toni-klemm at tamu.edu>> wrote:
> Hello NCL community,
> 
> I have a dataset of de-trended precipitation and temperature projections from 2020 to 2099, and I’m trying to count the number of consecutive years with above and below zero data, in other words the length of wet/dry or warm/cool periods, for 20-year periods (2020-2039, 2040-2059, …) on a grid cell basis (241 latitudes, 457 longitudes = 110,137 grid cells). Is there a function in NCL that can do that somehow? It seems really cumbersome trying to do this through if and do loops.
> 
> Thank you very much for your help!
> 
> Toni
> 
> 
> Toni Klemm, Ph.D.
> Postdoctoral Research Associate
> Department of Ecosystem Science and Management
> College of Agriculture and Life Sciences
> Texas A&M University, College Station, TX
> www.toni-klemm.de <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.toni-2Dklemm.de_&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=VvzoKtIseDjtyUD8VWUMhpyE4jPU5aD352WZdT2aQ3g&s=U4jmAacOAbmZmM6fgIchVP7dSP2S11b0ANC77goLcWI&e=> | @toniklemm <https://urldefense.proofpoint.com/v2/url?u=http-3A__twitter.com_toniklemm&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=VvzoKtIseDjtyUD8VWUMhpyE4jPU5aD352WZdT2aQ3g&s=OHEdgxMYoVqcbCfRA-cHwpHEgqRG6zkaMXEdE_R-7v0&e=>
> Editorial Board member, Early Career Climate Forum <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.eccforum.org_&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=VvzoKtIseDjtyUD8VWUMhpyE4jPU5aD352WZdT2aQ3g&s=UAnIz2x1G6sy2zogLEV1N4oPuLWd0QWgpTP1yXXYqSs&e=>
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk <https://urldefense.proofpoint.com/v2/url?u=http-3A__mailman.ucar.edu_mailman_listinfo_ncl-2Dtalk&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=VvzoKtIseDjtyUD8VWUMhpyE4jPU5aD352WZdT2aQ3g&s=CbpcNj_HeBVc3fHl1R8cdPFz9djuKgKAbbp51GJeUkY&e=>
> 
> 
> -- 
> Adam Phillips 
> Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
> www.cgd.ucar.edu/staff/asphilli/ <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.cgd.ucar.edu_staff_asphilli_&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=VvzoKtIseDjtyUD8VWUMhpyE4jPU5aD352WZdT2aQ3g&s=p6fI6x2nQFNh6jsTRpVAaKufOPKYmEnMhATPL--vQF0&e=>   303-497-1726
> 
>  <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.cgd.ucar.edu_staff_asphilli&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=VvzoKtIseDjtyUD8VWUMhpyE4jPU5aD352WZdT2aQ3g&s=DxMw6W0EDFtDQM8oXFqwCZWrroUpXa4oOSsUjn56r0c&e=>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190510/2b279b91/attachment.html>


More information about the ncl-talk mailing list