Пример #1
0
def create_record(ir_blob_path, griddef, boxdef, forecast_minutes,
                  ltg_validity_minutes, sampling_frac):
  # read IR image
  logging.info('Retrieving lightning for IR blob %s', ir_blob_path)
  ref = goesio.read_ir_data(ir_blob_path, griddef)
  ref = np.ma.filled(ref, 0) # mask -> 0

  # create "current" lightning image
  influence_km = 5
  irdt = goesio.get_timestamp_from_filename(ir_blob_path)
  ltg_blob_paths = goesio.get_ltg_blob_paths(
      irdt, timespan_minutes=ltg_validity_minutes)
  if ltg_blob_paths:
      ltg = goesio.create_ltg_grid(ltg_blob_paths, griddef, influence_km)

      # create "forecast" lightning image
      irdt = irdt + datetime.timedelta(minutes=forecast_minutes)
      ltg_blob_paths = goesio.get_ltg_blob_paths(
          irdt, timespan_minutes=ltg_validity_minutes)
      if ltg_blob_paths:
          ltgfcst = goesio.create_ltg_grid(ltg_blob_paths, griddef, influence_km)

          # create examples
          for example in create_training_examples(ref, ltg, ltgfcst,
                                                  griddef, boxdef,
                                                  sampling_frac):
            yield example
Пример #2
0
def add_time_stamp(ir_blob_path):
  epoch = datetime.utcfromtimestamp(0)
  timestamp = goesio.get_timestamp_from_filename(ir_blob_path)
  yield beam.window.TimestampedValue(ir_blob_path,
                                     (timestamp - epoch).total_seconds())