<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Consecutive values in a set of rasters in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232677#M18028</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm running ArcGIS 10.2.1 Advanced with SA and Python 2.7&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to replicate in Python something done in excel:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="132741" alt="Capture.JPG" class="image-1 jive-image" height="235" src="https://community.esri.com/legacyfs/online/132741_Capture.JPG" style="width: 260px; height: 234.768px;" width="260" /&gt;&lt;/P&gt;&lt;P&gt;I have a set of 12 rasters with values 0 and 1, each raster representing a month of the year. I need to create an output raster that will count the maximum number of consecutive months occurring. In the excel example above the result is &lt;STRONG&gt;4&lt;/STRONG&gt; as it starts in &lt;STRONG&gt;December&lt;/STRONG&gt; and accumulates through until &lt;STRONG&gt;March&lt;/STRONG&gt;. So it is looping through all months.&lt;/P&gt;&lt;P&gt;I have the column called "Rating Count" above sorted. The problem I encounter is with Jan in the "Consec Mo" column as this value is not fixed because it is fed from the December value in the same column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Set monthly values to 0 and 1


jan = Con(IsNull(Rating_jan), 0, 1)
feb = Con(IsNull(Rating_feb), 0, 1)
mar = Con(IsNull(Rating_mar), 0, 1)
apr = Con(IsNull(Rating_apr), 0, 1)
may = Con(IsNull(Rating_may), 0, 1)
jun = Con(IsNull(Rating_jun), 0, 1)
jul = Con(IsNull(Rating_jul), 0, 1)
aug = Con(IsNull(Rating_aug), 0, 1)
sep = Con(IsNull(Rating_sep), 0, 1)
oct = Con(IsNull(Rating_jan), 0, 1)
nov = Con(IsNull(Rating_jan), 0, 1)
dec = Con(IsNull(Rating_jan), 0, 1)




# Calculate consecutive and MAX value


jan1 = jan
feb2 = Con((feb) == 1, (jan1) + 1, 0)
mar3 = Con((mar) == 1, (feb2) + 1, 0)
apr4 = Con((apr) == 1, (mar3) + 1, 0)
may5 = Con((may) == 1, (apr4) + 1, 0)
jun6 = Con((jun) == 1, (may5) + 1, 0)
jul7 = Con((jul) == 1, (jun6) + 1, 0)
aug8 = Con((aug) == 1, (jul7) + 1, 0)
sep9 = Con((sep) == 1, (aug8) + 1, 0)
oct10 = Con((oct) == 1, (sep9) + 1, 0)
nov11 = Con((nov) == 1, (oct10) + 1, 0)
dec12 = Con((dec) == 1, (nov11) + 1, 0)




Final_Output = CellStatistics([(jan1), (feb2), (mar3), (apr4), (may5), (jun6), (jul7), (aug8), (sep9), (oct10), (nov11), (dec12)]
, "MAXIMUM", "NODATA")


Final_Output.save(OUTWorkspace + "\\" + "Final_Output")&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But as I said the "jan" value (row 23) is not fixed as in the script so it is not quite what I'm after.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wonder if someone could give me some hints about how to solve this issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advanced&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tony&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 11:46:01 GMT</pubDate>
    <dc:creator>anTonialcaraz</dc:creator>
    <dc:date>2021-12-11T11:46:01Z</dc:date>
    <item>
      <title>Consecutive values in a set of rasters</title>
      <link>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232677#M18028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm running ArcGIS 10.2.1 Advanced with SA and Python 2.7&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to replicate in Python something done in excel:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="132741" alt="Capture.JPG" class="image-1 jive-image" height="235" src="https://community.esri.com/legacyfs/online/132741_Capture.JPG" style="width: 260px; height: 234.768px;" width="260" /&gt;&lt;/P&gt;&lt;P&gt;I have a set of 12 rasters with values 0 and 1, each raster representing a month of the year. I need to create an output raster that will count the maximum number of consecutive months occurring. In the excel example above the result is &lt;STRONG&gt;4&lt;/STRONG&gt; as it starts in &lt;STRONG&gt;December&lt;/STRONG&gt; and accumulates through until &lt;STRONG&gt;March&lt;/STRONG&gt;. So it is looping through all months.&lt;/P&gt;&lt;P&gt;I have the column called "Rating Count" above sorted. The problem I encounter is with Jan in the "Consec Mo" column as this value is not fixed because it is fed from the December value in the same column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Set monthly values to 0 and 1


jan = Con(IsNull(Rating_jan), 0, 1)
feb = Con(IsNull(Rating_feb), 0, 1)
mar = Con(IsNull(Rating_mar), 0, 1)
apr = Con(IsNull(Rating_apr), 0, 1)
may = Con(IsNull(Rating_may), 0, 1)
jun = Con(IsNull(Rating_jun), 0, 1)
jul = Con(IsNull(Rating_jul), 0, 1)
aug = Con(IsNull(Rating_aug), 0, 1)
sep = Con(IsNull(Rating_sep), 0, 1)
oct = Con(IsNull(Rating_jan), 0, 1)
nov = Con(IsNull(Rating_jan), 0, 1)
dec = Con(IsNull(Rating_jan), 0, 1)




# Calculate consecutive and MAX value


jan1 = jan
feb2 = Con((feb) == 1, (jan1) + 1, 0)
mar3 = Con((mar) == 1, (feb2) + 1, 0)
apr4 = Con((apr) == 1, (mar3) + 1, 0)
may5 = Con((may) == 1, (apr4) + 1, 0)
jun6 = Con((jun) == 1, (may5) + 1, 0)
jul7 = Con((jul) == 1, (jun6) + 1, 0)
aug8 = Con((aug) == 1, (jul7) + 1, 0)
sep9 = Con((sep) == 1, (aug8) + 1, 0)
oct10 = Con((oct) == 1, (sep9) + 1, 0)
nov11 = Con((nov) == 1, (oct10) + 1, 0)
dec12 = Con((dec) == 1, (nov11) + 1, 0)




Final_Output = CellStatistics([(jan1), (feb2), (mar3), (apr4), (may5), (jun6), (jul7), (aug8), (sep9), (oct10), (nov11), (dec12)]
, "MAXIMUM", "NODATA")


Final_Output.save(OUTWorkspace + "\\" + "Final_Output")&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But as I said the "jan" value (row 23) is not fixed as in the script so it is not quite what I'm after.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wonder if someone could give me some hints about how to solve this issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advanced&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tony&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:46:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232677#M18028</guid>
      <dc:creator>anTonialcaraz</dc:creator>
      <dc:date>2021-12-11T11:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: CONSECUTIVE VALUES IN A SET OF RASTERS</title>
      <link>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232678#M18029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry bit confused here.&lt;/P&gt;&lt;P&gt;I can see that Dec14, Jan15, Feb15, Mar15 are consecutive.&lt;/P&gt;&lt;P&gt;But how do you know that Dec is the previous year and not 8 month later?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2015 13:25:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232678#M18029</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2015-10-22T13:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: CONSECUTIVE VALUES IN A SET OF RASTERS</title>
      <link>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232679#M18030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Neil. Sorry, I probably didn't explain myself properly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not dealing with years here; just months of any year. I need to calculate cumulative number of months that hold data (in this case value 1). The calculation should loop through the 12 months with no fixed starting point.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it is a bit more clear now. Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2015 15:45:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232679#M18030</guid>
      <dc:creator>anTonialcaraz</dc:creator>
      <dc:date>2015-10-22T15:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: CONSECUTIVE VALUES IN A SET OF RASTERS</title>
      <link>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232680#M18031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That any consecutive in a loop of 12 will be quite tricky.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2015 16:56:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232680#M18031</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2015-10-22T16:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: CONSECUTIVE VALUES IN A SET OF RASTERS</title>
      <link>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232681#M18032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understand correctly, rather than hard-coding month names into your variable names, I believe you should try naming based on something like "number of months before now (or given date)". So, if you ran the code now (October) the value for September would be held in the variable "months_ago_1", August in "months_ago_2", etc. When you run the code in November, October would move into "months_ago_1" etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2015 17:33:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232681#M18032</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-10-22T17:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: CONSECUTIVE VALUES IN A SET OF RASTERS</title>
      <link>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232682#M18033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Neil/Darren,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Darren, WHEN running the code it is not relevant here. I'll try to graphically explain again:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.JPG" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/132819_Capture.JPG" style="width: 620px; height: 138px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a stack of 12 cells each one representing presence or absence of data (1/0) for 12 months.&lt;/P&gt;&lt;P&gt;I need to produce an output raster cell that tells me the maximum number of cumulative months with data.&lt;/P&gt;&lt;P&gt;In example 1 above the output is &lt;STRONG&gt;5 &lt;/STRONG&gt;because there is data for sep, oct, nov, dec and jan&lt;/P&gt;&lt;P&gt;In example 2 above the output is &lt;STRONG&gt;3&lt;/STRONG&gt; because there is data for apr, may and jun&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Oct 2015 08:06:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232682#M18033</guid>
      <dc:creator>anTonialcaraz</dc:creator>
      <dc:date>2015-10-23T08:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: CONSECUTIVE VALUES IN A SET OF RASTERS</title>
      <link>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232683#M18034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is something that I have in excel but it seems not that straight forward to code in Python (or maybe it is...)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A function in python that calculates the "last occurrence"; in this case the last occurrence of 0 so it can start counting from there, I guess it would do the job. However, I cannot find in the documentation anything related to that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Oct 2015 08:11:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232683#M18034</guid>
      <dc:creator>anTonialcaraz</dc:creator>
      <dc:date>2015-10-23T08:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: CONSECUTIVE VALUES IN A SET OF RASTERS</title>
      <link>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232684#M18035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Numpy format would be best&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; #----------------------------------------
&amp;gt;&amp;gt;&amp;gt; data = [0,0,1,1,1,1,0,0,0,1,1,1,1,1,0,0,1,1,1,1]
&amp;gt;&amp;gt;&amp;gt; a = np.array(data,dtype=bool)&amp;nbsp; # boolean data
&amp;gt;&amp;gt;&amp;gt; chg = (a[:-1] ^ a[1:])&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # change
&amp;gt;&amp;gt;&amp;gt; pos = np.arange(len(chg))[chg] # positions
&amp;gt;&amp;gt;&amp;gt; diff = np.diff(pos)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # differences
&amp;gt;&amp;gt;&amp;gt; max_seq = np.max(diff)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # max in sequences
&amp;gt;&amp;gt;&amp;gt;
&amp;gt;&amp;gt;&amp;gt; chg
array([False,&amp;nbsp; True, False, False, False,&amp;nbsp; True, False, False,&amp;nbsp; True,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; False, False, False, False,&amp;nbsp; True, False,&amp;nbsp; True, False, False, False], dtype=bool)
&amp;gt;&amp;gt;&amp;gt; pos
array([ 1,&amp;nbsp; 5,&amp;nbsp; 8, 13, 15])
&amp;gt;&amp;gt;&amp;gt; diff
array([4, 3, 5, 2])
&amp;gt;&amp;gt;&amp;gt; max_seq
5&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am sure it can also be done with cursors and other stuff, if you can't get your data into a numpy array using numpyarraytotable or similar&lt;/P&gt;&lt;P&gt;EDIT&lt;/P&gt;&lt;P&gt;to prevent wraparound you need to pad the array at the beginning and the end.&amp;nbsp; It can be done int this fashion, in this example yielding the same result&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; # to prevent wrap around sequence starts at zero
&amp;gt;&amp;gt;&amp;gt; an = np.hstack(([0],a,[0]))&amp;nbsp; # a is from above
&amp;gt;&amp;gt;&amp;gt; diff2 = np.diff(an)
&amp;gt;&amp;gt;&amp;gt; begin = np.where(diff2 &amp;gt; 0)
&amp;gt;&amp;gt;&amp;gt; end = np.where(diff2 &amp;lt; 0)
&amp;gt;&amp;gt;&amp;gt; # tuples are returned to get the 0th result
&amp;gt;&amp;gt;&amp;gt; end[0] - begin[0]
array([4, 5, 4], dtype=int64)
&amp;gt;&amp;gt;&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Arrays are powerful tools&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:46:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232684#M18035</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T11:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: CONSECUTIVE VALUES IN A SET OF RASTERS</title>
      <link>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232685#M18036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I posted a numpy arcpy example on sequences on &lt;A _jive_internal="true" href="https://community.esri.com/blogs/dan_patterson/2015/10/23/numpy-lesson-7-sequential-datanumpy-and-arcpy-play-nice"&gt;my blog &lt;/A&gt;​&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the data can be brought out into tabular form then this example may help.&amp;nbsp; You can use RasterToNumpyArray to get rasters to arrays or TableToNumPyArray to get tabular data into array format.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Oct 2015 19:52:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232685#M18036</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-10-23T19:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: CONSECUTIVE VALUES IN A SET OF RASTERS</title>
      <link>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232686#M18037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;I see. I think you can basically use your existing code, wrapping around the year one more time to pick up the dec-&amp;gt;jan connection. Then, use the second "year" of rasters to get the max.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;jan1 = jan&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;feb2 = Con((feb) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (jan1) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;)&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;mar3 = Con((mar) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (feb2) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;)&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;apr4 = Con((apr) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (mar3) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;)&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;may5 = Con((may) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (apr4) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;)&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;jun6 = Con((jun) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (may5) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;)&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;jul7 = Con((jul) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (jun6) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;)&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;aug8 = Con((aug) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (jul7) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;)&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;sep9 = Con((sep) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (aug8) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;)&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;oct10 = Con((oct) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (sep9) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;)&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;nov11 = Con((nov) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (oct10) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;)&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;dec12 = Con((dec) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (nov11) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;) &lt;/SPAN&gt;&lt;/SPAN&gt;

&lt;SPAN style="background-color: inherit; color: black; font-weight: inherit; font-size: 9pt !important; font-style: inherit;"&gt;# wrap back around&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;jan1_2 = &lt;SPAN style="color: #000000; font-size: 12px;"&gt;Con((jan) == &lt;/SPAN&gt;&lt;SPAN class="number" style="font-style: inherit; font-weight: inherit; color: green; font-size: 9pt !important;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-style: inherit; font-weight: inherit; font-size: 9pt !important;"&gt;, (dec12) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-style: inherit; font-weight: inherit; color: green; font-size: 9pt !important;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-style: inherit; font-weight: inherit; font-size: 9pt !important;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-style: inherit; font-weight: inherit; color: green; font-size: 9pt !important;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-style: inherit; font-weight: inherit; font-size: 9pt !important;"&gt;) &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;feb2_2 = Con((feb) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (jan1_2) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;) &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;mar3_2 = Con((mar) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (feb2_2) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;) &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;apr4_2 = Con((apr) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (mar3_2) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;) &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;may5_2 = Con((may) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (apr4_2) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;) &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;jun6_2 = Con((jun) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (may5_2) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;) &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;jul7_2 = Con((jul) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (jun6_2) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;) &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;aug8_2 = Con((aug) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (jul7_2) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;) &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;sep9_2 = Con((sep) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (aug8_2) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;) &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;oct10_2 = Con((oct) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (sep9_2) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;) &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;nov11_2 = Con((nov) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (oct10_2) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;) &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;dec12_2 = Con((dec) == &lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, (nov11_2) + &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;Final_Output = CellStatistics([(jan1_2), (feb2_2), (mar3_2), (apr4_2), (may5_2), (jun6_2), (jul7_2), (aug8_2), (sep9_2), (oct10_2), (nov11_2), (dec12_2)]&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;SPAN class="string" style="font-weight: inherit; font-style: inherit; color: blue; font-size: 9pt !important; background-color: inherit;"&gt;"MAXIMUM"&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;, &lt;/SPAN&gt;&lt;SPAN class="string" style="font-weight: inherit; font-style: inherit; color: blue; font-size: 9pt !important; background-color: inherit;"&gt;"NODATA"&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;)&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:46:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232686#M18037</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-11T11:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: CONSECUTIVE VALUES IN A SET OF RASTERS</title>
      <link>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232687#M18038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Darren,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That works nicely.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only thing is that the Max value you get is 24 so that needs to be set back to 12 in the final output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Other than that, that's good.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tony&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Oct 2015 10:25:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232687#M18038</guid>
      <dc:creator>anTonialcaraz</dc:creator>
      <dc:date>2015-10-26T10:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: CONSECUTIVE VALUES IN A SET OF RASTERS</title>
      <link>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232688#M18039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Darren,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That seems a very elegant way of doing it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to adapt your script to my set of 12 rasters using the RasterToNumpyArray.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Oct 2015 10:28:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232688#M18039</guid>
      <dc:creator>anTonialcaraz</dc:creator>
      <dc:date>2015-10-26T10:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: CONSECUTIVE VALUES IN A SET OF RASTERS</title>
      <link>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232689#M18040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I will post a 3d example sometime this week.&amp;nbsp; The only issue I have seen so far is array size vs memory.&amp;nbsp; You may need to use an generator to pass your arrays in, instead of holding them in all at once.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Oct 2015 11:48:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232689#M18040</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-10-26T11:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: CONSECUTIVE VALUES IN A SET OF RASTERS</title>
      <link>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232690#M18041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;(I meant "Thanks Dan" on my previous reply)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll keep an eye on your 3rd example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Oct 2015 12:32:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232690#M18041</guid>
      <dc:creator>anTonialcaraz</dc:creator>
      <dc:date>2015-10-26T12:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: CONSECUTIVE VALUES IN A SET OF RASTERS</title>
      <link>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232691#M18042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Busy now, will finish later... consider these huge binary arrays (aka 3x3) forming a time stack for a location.&amp;nbsp; Just an idea, I will let you play with the other axes should you be interested in other differences.&amp;nbsp; As indicated, it may be too much to load a large sequence in memory, but the whole process could be parsed.&amp;nbsp; I took out some of the extra print lines between the tiles&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a
array([[0, 1, 0],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [1, 1, 1],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [0, 1, 0]])
&amp;gt;&amp;gt;&amp;gt; b
array([[1, 0, 1],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [0, 0, 0],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [1, 0, 1]])
&amp;gt;&amp;gt;&amp;gt; c
array([[&amp;nbsp; 1,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&amp;nbsp; 10],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 0,&amp;nbsp; 100,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [1000,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; 1]])&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; stack
array([[[&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; 1,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 1,&amp;nbsp;&amp;nbsp;&amp;nbsp; 1,&amp;nbsp;&amp;nbsp;&amp;nbsp; 1],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; 1,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0]],

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [[&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; 1,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 1,&amp;nbsp;&amp;nbsp;&amp;nbsp; 1,&amp;nbsp;&amp;nbsp;&amp;nbsp; 1],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; 1,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0]],

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [[&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; 1,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 1,&amp;nbsp;&amp;nbsp;&amp;nbsp; 1,&amp;nbsp;&amp;nbsp;&amp;nbsp; 1],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; 1,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0]],

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [[&amp;nbsp; 1,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; 1],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 1,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; 1]],

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [[&amp;nbsp; 1,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; 1],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 1,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; 1]],

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [[&amp;nbsp; 1,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&amp;nbsp; 10],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 0,&amp;nbsp; 100,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [1000,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; 1]]])
&amp;gt;&amp;gt;&amp;gt; # stack = np.array((a,a,a,b,b,c))&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;... np.diff(stack,axis=0)
...
array([[[&amp;nbsp; 0,&amp;nbsp; 0,&amp;nbsp; 0],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 0,&amp;nbsp; 0,&amp;nbsp; 0],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 0,&amp;nbsp; 0,&amp;nbsp; 0]],

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [[&amp;nbsp; 0,&amp;nbsp; 0,&amp;nbsp; 0],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 0,&amp;nbsp; 0,&amp;nbsp; 0],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 0,&amp;nbsp; 0,&amp;nbsp; 0]],

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [[&amp;nbsp; 1,&amp;nbsp; -1,&amp;nbsp; 1],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ -1,&amp;nbsp; -1,&amp;nbsp; -1],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 1,&amp;nbsp; -1,&amp;nbsp; 1]],

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [[&amp;nbsp; 0,&amp;nbsp; 0,&amp;nbsp; 0],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 0,&amp;nbsp; 0,&amp;nbsp; 0],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 0,&amp;nbsp; 0,&amp;nbsp; 0]],

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [[&amp;nbsp; 0,&amp;nbsp; 0,&amp;nbsp; 9],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 0, 100,&amp;nbsp; 0],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [999,&amp;nbsp; 0,&amp;nbsp; 0]]])&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;later&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:46:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232691#M18042</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T11:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: CONSECUTIVE VALUES IN A SET OF RASTERS</title>
      <link>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232692#M18043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Speaking of elegant, Darren, we can do better than that. 0 is false and anything else is true so:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;jan1 = jan
feb2 = Con(feb, jan1 + 1, 0)&amp;nbsp;&amp;nbsp; 
mar3 = Con(mar, feb2 + 1, 0)&amp;nbsp;&amp;nbsp; 
apr4 = Con(apr, mar3 + 1, 0)&amp;nbsp;&amp;nbsp; 
may5 = Con(may, apr4 + 1, 0)&amp;nbsp;&amp;nbsp; 
jun6 = Con(jun, may5 + 1, 0)&amp;nbsp;&amp;nbsp; 
jul7 = Con(jul, jun6 + 1, 0)&amp;nbsp;&amp;nbsp; 
aug8 = Con(aug, jul7 + 1, 0)&amp;nbsp;&amp;nbsp; 
sep9 = Con(sep, aug8 + 1, 0)&amp;nbsp;&amp;nbsp; 
oct10 = Con(oct, sep9 + 1, 0)&amp;nbsp;&amp;nbsp; 
nov11 = Con(nov, oct10 + 1, 0)&amp;nbsp;&amp;nbsp; 
dec12 = Con(dec, nov11 + 1, 0) 

# wrap back around 
jan1_2 = Con(jan, dec12 + 1, 0)
feb2_2 = Con(feb, jan1_2 + 1, 0) 
mar3_2 = Con(mar, feb2_2 + 1, 0) 
apr4_2 = Con(apr, mar3_2 + 1, 0) 
may5_2 = Con(may, apr4_2 + 1, 0) 
jun6_2 = Con(jun, may5_2 + 1, 0) 
jul7_2 = Con(jul, jun6_2 + 1, 0) 
aug8_2 = Con(aug, jul7_2 + 1, 0) 
sep9_2 = Con(sep, aug8_2 + 1, 0) 
oct10_2 = Con(oct, sep9_2 + 1, 0) 
nov11_2 = Con(nov, oct10_2 + 1, 0) 
dec12_2 = Con(dec, nov11_2 + 1, 0) 
counts = CellStatistics(
&amp;nbsp;&amp;nbsp;&amp;nbsp; [jan1_2, feb2_2, mar3_2, apr4_2, may5_2, jun6_2,
&amp;nbsp;&amp;nbsp;&amp;nbsp; jul7_2, aug8_2, sep9_2, oct10_2, nov11_2, dec12_2],
&amp;nbsp; "MAXIMUM", "NODATA")&amp;nbsp;&amp;nbsp; 
# "wraps" may give us more than 12 (actually 24 if no gaps)
final_raster = Con(counts &amp;gt; 12, 12, counts)&lt;/PRE&gt;&lt;P&gt;Note these are all local operators so with deferred raster calculations this may be extremely efficient, and you don't have to load all the rasters into numpy&amp;nbsp; arrays - so this approach is more likely to be successful with large rasters.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:46:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232692#M18043</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T11:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: CONSECUTIVE VALUES IN A SET OF RASTERS</title>
      <link>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232693#M18044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think &lt;A href="https://community.esri.com/migrated-users/3116" target="_blank"&gt;Dan Patterson&lt;/A&gt;​ had it 95% right the first time (the chg and pos arrays are great), and then bypassed the problem and took it to the moon. Really, you just need to append the first array (12 items) to itself (24 items) to capture the wraparound.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; import numpy as np
... year1 = np.array([1,0,0,1,1,1,1,0,1,1,1,1],dtype=bool) # year data
... print year1
... doubleYear1 = np.append(year1,year1) # append year data to itself
... print doubleYear1
... chg = (doubleYear1[:-1] ^ doubleYear1[1:]) # change array. Ingenious, really.
... print chg
... pos = np.arange(len(chg))[chg] # indices of change
... print pos
... diff = np.diff(pos) # difference between n+1 and n
... print diff
... max_seq = np.max(diff) # max
... print max_seq
... if max_seq &amp;gt; 12:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; max_seq = 12

[ True False False&amp;nbsp; True&amp;nbsp; True&amp;nbsp; True&amp;nbsp; True False&amp;nbsp; True&amp;nbsp; True&amp;nbsp; True&amp;nbsp; True]

[ True False False&amp;nbsp; True&amp;nbsp; True&amp;nbsp; True&amp;nbsp; True False&amp;nbsp; True&amp;nbsp; True&amp;nbsp; True&amp;nbsp; True
&amp;nbsp; True False False&amp;nbsp; True&amp;nbsp; True&amp;nbsp; True&amp;nbsp; True False&amp;nbsp; True&amp;nbsp; True&amp;nbsp; True&amp;nbsp; True]
[ True False&amp;nbsp; True False False False&amp;nbsp; True&amp;nbsp; True False False False False
&amp;nbsp; True False&amp;nbsp; True False False False&amp;nbsp; True&amp;nbsp; True False False False]
[ 0&amp;nbsp; 2&amp;nbsp; 6&amp;nbsp; 7 12 14 18 19]

[2 4 1 5 2 4 1]

5&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:46:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232693#M18044</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-11T11:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: CONSECUTIVE VALUES IN A SET OF RASTERS</title>
      <link>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232694#M18045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/19932" target="_blank"&gt;Darren Wiens&lt;/A&gt;&amp;nbsp; yes, definitely, but it sometimes depends on perspective...lets try rolling/padding by 1 position/year.&lt;/P&gt;&lt;P&gt;In this example the first year and the last year are the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = np.array([1,0,0,1,1,1,1,0,1,1,1,1],dtype=bool) # with first and last month the same
&amp;gt;&amp;gt;&amp;gt; b = np.roll(a,-1)
&amp;gt;&amp;gt;&amp;gt; chg = (b ^ a)
&amp;gt;&amp;gt;&amp;gt; pos = np.arange(len(chg))[chg]
&amp;gt;&amp;gt;&amp;gt; diff = np.diff(pos)
&amp;gt;&amp;gt;&amp;gt; max_seq = np.max(diff)
&amp;gt;&amp;gt;&amp;gt; max_seq
4
&amp;gt;&amp;gt;&amp;gt; a.astype(int)
array([1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1])
&amp;gt;&amp;gt;&amp;gt; b.astype(int)
array([0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1])
&amp;gt;&amp;gt;&amp;gt; chg.astype(int)
array([1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0])
&amp;gt;&amp;gt;&amp;gt; pos
array([0, 2, 6, 7])
&amp;gt;&amp;gt;&amp;gt; diff
array([2, 4, 1])
&amp;gt;&amp;gt;&amp;gt;&lt;/PRE&gt;&lt;P&gt;So the question becomes how far do you roll (12 years as in your case)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But what if the, first year and the last year are different?&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = np.array([1,0,0,1,1,1,1,0,1,1,1,0],dtype=bool) # with last month different than first
&amp;gt;&amp;gt;&amp;gt; b = np.roll(a,-1)
&amp;gt;&amp;gt;&amp;gt; chg = (b ^ a)
&amp;gt;&amp;gt;&amp;gt; pos = np.arange(len(chg))[chg]
&amp;gt;&amp;gt;&amp;gt; diff = np.diff(pos)
&amp;gt;&amp;gt;&amp;gt; max_seq = np.max(diff)
&amp;gt;&amp;gt;&amp;gt; # results........
&amp;gt;&amp;gt;&amp;gt; a.astype(int)
array([1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0])
&amp;gt;&amp;gt;&amp;gt; b.astype(int)
array([0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1])
&amp;gt;&amp;gt;&amp;gt; chg.astype(int)
array([1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1])
&amp;gt;&amp;gt;&amp;gt; pos
array([ 0,&amp;nbsp; 2,&amp;nbsp; 6,&amp;nbsp; 7, 10, 11])
&amp;gt;&amp;gt;&amp;gt; diff
array([2, 4, 1, 3, 1])
&amp;gt;&amp;gt;&amp;gt; max_seq
4&lt;/PRE&gt;&lt;P&gt;The same results are yielded, largely by coincidence since the first and last year are different&lt;/P&gt;&lt;P&gt;It is interesting that you can roll forward or backward as long as you keep track of your positions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also use padding with different pad widths and types AND direction.&amp;nbsp; In this example the edges were padded with their neighbor.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = np.array([1,0,0,1,1,1,1,0,1,1,1,1],dtype=bool) # with first and last month the same
&amp;gt;&amp;gt;&amp;gt; b = np.pad(a,1,mode="edge")
&amp;gt;&amp;gt;&amp;gt; b.astype(int)
array([1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1])
&amp;gt;&amp;gt;&amp;gt; chg = (b[:-1] ^ b[1:]) 
&amp;gt;&amp;gt;&amp;gt; pos = np.arange(len(chg))[chg]
&amp;gt;&amp;gt;&amp;gt; diff = np.diff(pos)
&amp;gt;&amp;gt;&amp;gt; max_seq = np.max(diff)
&amp;gt;&amp;gt;&amp;gt; max_seq
4&lt;/PRE&gt;&lt;P&gt;It just becomes more interesting when you are trying to shift, difference and pad sequences of 2D+ arrays with or without padding or replication.&amp;nbsp; As I indicated, I will try to summarize in an upcoming blog because raster size can play a role.&amp;nbsp; Also, if you are only interested in limited positions within the raster, reducing the input raster to a sparse array will reduce memory needs and speed up processing time. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:46:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/consecutive-values-in-a-set-of-rasters/m-p/232694#M18045</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T11:46:18Z</dc:date>
    </item>
  </channel>
</rss>

