title: Get non-masked values in Numpys Masked arrays
body: <p>I'm trying to extract data from netCDF4 files. These contain "MaskedArrays" which are part of the Numpy library.</p>
  
  <p>My Data contains: <em>latitude</em>, <em>longitude</em>, <em>day</em> and <em>values</em> (separated over different files).
  Additionally a mask which shows, which latitude/longitudes are not valid for various reasons (no measurements, or other reasons).</p>
  
  <p>My data looks like this (for masked data):</p>
  
  <pre><code>masked_array(
      data =
       [[[-- -- -- ..., -- -- --]
          ..., 
         [-- -- -- ..., -- -- --]]],
      mask =
       [[[ True  True  True ...,  True  True  True]
          ...,
         [ True  True  True ...,  True  True  True]]],
      fill_value = 32767)
  </code></pre>
  
  <p>I'm searching for a numpy method (or similar), which can extract only these values which are not masked. Ideally just by cutting all non-valid entries out of the dataset.
  I found <code>.compressed</code>, but it gives a one dimensional array back. From the 3rd dimension this is quite a loss of information as I don't know, where these values are.</p>
  
  <p>Additionally I tried <code>nonzero = the_array['one of the values'][0].nonzero()</code>. 
  This gives me a double array with lat/lon values, but after that I still have to access these - which is slow. Unfortunately after knowing how to access all this date I need to do that on 30*6 files each with ~1500×700×365 datapoints :D.</p>
  
  <pre><code>all_days = [(x, rhstmax['stuff'][x][24][1288]) for x in range(366)]
  # represents just for lat:24,lon:1288 all days. First 20:
  all_days[:20] =
      [(0, 15.799999),
       (1, 16.199999),
       (2, 17.4),
       (3, 13.2),
       (4, 10.8),
       (5, 11.3),
       (6, 15.299999),
       (7, 16.299999),
       (8, 14.099999),
       (9, 10.8),
       (10, 9.5),
       (11, 9.0999994),
       (12, 11.9),
       (13, 9.1999998),
       (14, 31.0),
       (15, 49.0),
       (16, 8.6999998),
       (17, 10.0),
       (18, 44.099998),
       (19, 30.699999)]
  # ... takes forever :(
  </code></pre>