[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
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:
>
> 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
> 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:
>
>
> --