コード例 #1
0
def getDayTSpots(date, network):
  """ Returns a list of sequences of TSpot objects for this day.
  """
  all_traj_fns = list_traj_filenames(date)
  tspots_groups = []
  for fname in all_traj_fns:
    # pylint:disable=W0142
    try:
      tspots = read_trajectory(fname)
    except IOError:
      tic("Could not read trajectory: {0}".format(fname), "getDayTSpots")
      tspots = []
    # tspots is a list of TSpot
    # Make sure we only have data for our sub network.
    for net_tspots in filterOutsideNetwork(tspots, network):
      tspots_groups.append(net_tspots)
  return tspots_groups
コード例 #2
0
def getDayTTOBservations(date, network, print_stats=1000):
  """
  """
  all_trajs = list_traj_filenames(date)
  all_groups = []
  idx = 1
  for traj_index in all_trajs:
    idx += 1
    if print_stats > 0 and idx % print_stats == 0:
      tic("processed {0} observations".format(idx),"getDayTTOBservations")
    # pylint:disable=W0142
    try:
      tspots = read_trajectory(traj_index)
    except IOError:
      tic("ioerror when loading a trajectory {0}".format(traj_index), "getDayTTOBservations")
      tspots = []
    # Make sure we only have data for our sub network.
    for net_tspots in filterOutsideNetwork(tspots, network):
      groups = seqGroupBy(net_tspots, keyf=lambda tsp:tsp.spot.linkId)
      for g in completeGroups(groups, network):
        all_groups.append(g)
  return all_groups