code: def dimNamesFromDataset(h5Dataset):
      
      dimNames = [] # TODO: cache?
      for dimNr, dimScales in enumerate(h5Dataset.dims):
          if len(dimScales) == 0:
              dimNames.append('Dim{}'.format(dimNr))
          elif len(dimScales) == 1:
              dimScaleLabel, dimScaleDataset = dimScales.items()[0]
              path = dimScaleDataset.name
              if path:
                  dimNames.append(os.path.basename(path))
              elif dimScaleLabel: # This could potentially be long so it's our second choice
                  dimNames.append(dimScaleLabel)
              else:
                  dimNames.append('Dim{}'.format(dimNr))
          else:
              # TODO: multiple scales for this dimension. What to do?
              logger.warn("More than one dimension scale found: {!r}".format(dimScales))
              dimNames.append('Dim{}'.format(dimNr)) # For now, just number them
  
      return dimNames
docs: Constructs the dimension names given a h5py dataset.
  
          First looks in the dataset's dimension scales to see if it refers to another
          dataset. In that case the referred dataset's name is used. If not, the label of the
          dimension scale is used. Finally, if this is empty, the dimension is numbered.