text: from __future__ import print_function
  import h5py
  import time
  
  def load_stdata(fname):
      f = h5py.File(fname, 'r')
      data = f['data'].value
      timestamps = f['date'].value
      f.close()
      return data, timestamps
  
  
  def stat(fname):
      def get_nb_timeslot(f):
          s = f['date'][0]
          e = f['date'][-1]
          year, month, day = map(int, [s[:4], s[4:6], s[6:8]])
          ts = time.strptime("%04i-%02i-%02i" % (year, month, day), "%Y-%m-%d")
          year, month, day = map(int, [e[:4], e[4:6], e[6:8]])
          te = time.strptime("%04i-%02i-%02i" % (year, month, day), "%Y-%m-%d")
          nb_timeslot = (time.mktime(te) - time.mktime(ts)) / (0.5 * 3600) + 48
          ts_str, te_str = time.strftime("%Y-%m-%d", ts), time.strftime("%Y-%m-%d", te)
          return nb_timeslot, ts_str, te_str
  
      with h5py.File(fname) as f:
          nb_timeslot, ts_str, te_str = get_nb_timeslot(f)
          nb_day = int(nb_timeslot / 48)
          mmax = f['data'].value.max()
          mmin = f['data'].value.min()
          stat = '=' * 5 + 'stat' + '=' * 5 + '\n' + \
                 'data shape: %s\n' % str(f['data'].shape) + \
                 '# of days: %i, from %s to %s\n' % (nb_day, ts_str, te_str) + \
                 '# of timeslots: %i\n' % int(nb_timeslot) + \
                 '# of timeslots (available): %i\n' % f['date'].shape[0] + \
                 'missing ratio of timeslots: %.1f%%\n' % ((1. - float(f['date'].shape[0] / nb_timeslot)) * 100) + \
                 'max: %.3f, min: %.3f\n' % (mmax, mmin) + \
                 '=' * 5 + 'stat' + '=' * 5
          print(stat)
  
  """
  def stat(fname):
      def get_nb_timeslot(f):
          s = f['date'][0]
          e = f['date'][-1]
          year, month, day = map(int, [s[:4], s[4:6], s[6:8]])
          ts = time.strptime("%04i-%02i-%02i" % (year, month, day), "%Y-%m-%d")
          year, month, day = map(int, [e[:4], e[4:6], e[6:8]])
          te = time.strptime("%04i-%02i-%02i" % (year, month, day), "%Y-%m-%d")
          nb_timeslot = (time.mktime(te) - time.mktime(ts)) / (0.5 * 3600) + 48
          ts_str, te_str = time.strftime("%Y-%m-%d", ts), time.strftime("%Y-%m-%d", te)
          return nb_timeslot, ts_str, te_str
  
      with h5py.File(fname) as f:
          nb_timeslot, ts_str, te_str = get_nb_timeslot(f)
          nb_day = int(nb_timeslot / 48)
          mmax = f['data'].value.max()
          mmin = f['data'].value.min()
          stat = '=' * 5 + 'stat' + '=' * 5 + '\n' + \
                 'data shape: %s\n' % str(f['data'].shape) + \
                 'date shape: %s\n' % str(f['date'].shape) + \
                 'date range: [%s, %s]\n' % (str(f['date'][0][:8]), str(f['date'][-1][:8])) + \
                 '# of days: %i, from %s to %s\n' % (nb_day, ts_str, te_str) + \
                 '# of timeslots: %i\n' % int(nb_timeslot) + \
                 '# of timeslots (available): %i\n' % f['date'].shape[0] + \
                 'missing ratio of timeslots: %.1f%%\n' % ((1. - float(f['date'].shape[0] / nb_timeslot)) * 100) + \
                 'max: %.3f, min: %.3f\n' % (mmax, mmin) + \
                 '=' * 5 + 'stat' + '=' * 5
          print(stat)
  """