Differences

This shows you the differences between two versions of the page.

Link to this comparison view

spdlib:developers:python:h5py [2012/11/24 08:12]
John Armston Initial h5py doco added
spdlib:developers:python:h5py [2012/11/24 09:13] (current)
John Armston
Line 51: Line 51:
      
      
-  def readSPDPointsRow(f,row,XYZ=False):+  def readSPDPointsRow(f,row,fieldName=None):
       """       """
       Read a row of point data       Read a row of point data
Line 61: Line 61:
           start = pData['PTS_START_IDX'][0]           start = pData['PTS_START_IDX'][0]
           finish = pData['PTS_START_IDX'][-1] + pData['NUMBER_OF_RETURNS'][-1]           finish = pData['PTS_START_IDX'][-1] + pData['NUMBER_OF_RETURNS'][-1]
-          if XYZ: +          if fieldName is None:
-              points = f['DATA']['POINTS'][start:finish,'X','Y','Z'] +
-          else:+
               points = f['DATA']['POINTS'][start:finish]               points = f['DATA']['POINTS'][start:finish]
 +          else:
 +              points = f['DATA']['POINTS'][start:finish,fieldName]
 +          return points.view(np.recarray)
 +      else:
 +          return None
 +  
 +  
 +  def readSPDXYZRow(f,row,returnType=None):
 +      """
 +      Read a row of XYZ point data
 +      ReturnType:
 +          1 = first returns
 +          2 = middle returns
 +          3 = last returns
 +          otherwise all returns
 +      """
 +      cnt = f['INDEX']['PLS_PER_BIN'][row]
 +      if cnt.any():
 +          idx = f['INDEX']['BIN_OFFSETS'][row]       
 +          pData = f['DATA']['PULSES'][idx[0]:idx[-1]+cnt[-1],'PTS_START_IDX','NUMBER_OF_RETURNS']
 +          start = pData['PTS_START_IDX'][0]
 +          finish = pData['PTS_START_IDX'][-1] + pData['NUMBER_OF_RETURNS'][-1]
 +          points = f['DATA']['POINTS'][start:finish,'X','Y','Z']
 +          if returnType == 1:
 +              idx = pData['PTS_START_IDX'] - pData['PTS_START_IDX'][0]
 +              mask = pData['NUMBER_OF_RETURNS'] > 0
 +              points = points[idx[mask]]
 +          elif returnType == 2:
 +              idx = np.ones(points.size)
 +              mask = pData['NUMBER_OF_RETURNS'] > 0
 +              idx[pData['PTS_START_IDX'][mask] - pData['PTS_START_IDX'][mask][0]] = 0
 +              idx[pData['PTS_START_IDX'][mask] - pData['PTS_START_IDX'][mask][0] + pData['NUMBER_OF_RETURNS'] - 1] = 0
 +              points = points[idx > 0]
 +          elif returnType == 3:
 +              idx = pData['PTS_START_IDX'] - pData['PTS_START_IDX'][0] + pData['NUMBER_OF_RETURNS'] - 1
 +              mask = pData['NUMBER_OF_RETURNS'] > 0
 +              points = points[idx[mask]]
           return points.view(np.recarray)           return points.view(np.recarray)
       else:       else:
           return None           return None
  

Navigation