def flatten_across_time(self):
     mask = None
     current = {}
     tmp_stack = None
     for index in xrange(len(self.acq_stack)):
         mask = None
         tmp_stack = {}
         for band in self.stack:
             tmp_stack[band] = self.stack[band][index]
         tmp_shape = self.shape_stack[index]
         tmp_pqa = self.pqa_stack[index]
         mask = get_mask_pqa(tmp_pqa, [PqaMask.PQ_MASK_CLEAR], mask=mask)
         for band in tmp_stack:
             tmp_stack[band] = tmp_stack[band].reshape(tmp_shape)
             tmp_stack[band] = apply_mask(tmp_stack[band], mask=mask)
             if band in current:
                 swap = np.in1d(current[band].ravel(), -999).reshape(current[band].shape)
                 current[band][swap] = tmp_stack[band][swap]
             else:
                 current[band] = np.array(tmp_stack[band])
         del tmp_stack
         del tmp_shape
         del mask
         del tmp_pqa
     return current
 def apply_mask(self, MASK):
     mask = None
     tmp_stack = None
     for index in xrange(len(self.acq_stack)):
         mask = None
         tmp_stack = {}
         for band in self.stack:
             tmp_stack[band] = self.stack[band][index]
         tmp_shape = self.shape_stack[index]
         tmp_pqa = self.pqa_stack[index]
         mask = get_mask_pqa(tmp_pqa, [MASK], mask=mask)
         for band in tmp_stack:
             tmp_stack[band] = tmp_stack[band].reshape(tmp_shape)
             tmp_stack[band] = apply_mask(tmp_stack[band], mask=mask).ravel()
             self.stack[band][index] = tmp_stack[band]
         del tmp_stack
         del mask
         del tmp_pqa
         del tmp_shape