Python Forum
Identifying consecutive masked values in a 3D data array
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Identifying consecutive masked values in a 3D data array
#1
I have a large 3 dimensional (time, longitude, latitude) input array of daily tmax values. I have masked the values which exceed a certain threshold. I need to find those entries where the mask is True for longer than a specific number of (3) consecutive time steps. The result should be a data array with 0s for the non-consecutive days and numbers corresponding to the length (duration of event) of consecutive elements.

Below is some pseudo-code to make myself clearer:

events = find_consecutive(input_array, duration=3)

input_array = [1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1]

events = [0, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0, 0, 5, 5, 5, 5, 5, 0, 0, 0]

I've had a look at scipy nd image but haven't been able to completely figure out how to use it.

Any help is appreciated :)
Reply


Messages In This Thread
Identifying consecutive masked values in a 3D data array - by chai0404 - Jan-12-2020, 10:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  replace sets of values in an array without using loops paul18fr 7 1,721 Jun-20-2022, 08:15 PM
Last Post: paul18fr
  Keep inner Values of 2D array timste 0 1,566 Jul-26-2021, 09:04 AM
Last Post: timste
  [machine learning] identifying a number 0-9 from a 28x28 picture, not working SheeppOSU 0 1,846 Apr-09-2021, 12:38 AM
Last Post: SheeppOSU
  Calculating consecutive days in a 3D array chai0404 0 1,902 Aug-27-2020, 10:28 PM
Last Post: chai0404
  Adding data in 3D array from 2D numpy array asmasattar 0 2,220 Jul-23-2020, 10:55 AM
Last Post: asmasattar
  Comparing and Identifying ID with Percentage jonatasflausino 1 2,443 Jun-23-2020, 06:44 PM
Last Post: hussainmujtaba
  Read json array data by pandas vipinct 0 1,947 Apr-13-2020, 02:24 PM
Last Post: vipinct
  Creating look up table/matrix from 3d data array chai0404 3 2,874 Apr-09-2020, 04:53 AM
Last Post: buran
  Replacing values for specific columns in Panda data structure Padowan 1 14,670 Nov-27-2017, 08:21 PM
Last Post: Padowan
  Match two data sets based on item values klllmmm 7 6,457 Mar-29-2017, 02:33 PM
Last Post: zivoni

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020