示例#1
0
def filter_v_updates(points, v_max=50 / 3.6, zone=cnt.zone, UTM=True):
    """ Splits trace into sets of points according to sconsecutive updates with impossible velocity jumps
        Given N updates, computes de N-1 inst. velocity updates V_n=(X_n+1-X_n)/(T_n+1-T_n), 
        then if V_n>V_max then the dataset gets separated 
        input: Points (3-col numpy array lat,lon,time)
               v_max (maximum velocity permitted)
               zone UTM zone definition
               mode: If UTM, then no conversion
        output: list of sets of points valids
    """
    if not UTM:
        # Convert points
        utm = cnt.utm()
        xy = np.array(utm(points.T[0],
                          points.T[1])).T  # transformacio geo (lon-lat)
        xy = xy - xy[0]  # refer to arbitrary origin (to ease calculations)
    else:
        xy = points.T[:-1].T
    #deltar=np.array(map(np.linalg.norm,np.diff(xy.T).T),dtype=float)
    #deltat=np.array(np.diff(points.T[-1]),dtype=int) # time diff
    #v=(deltar)/(deltat+1) # avoid problems
    #group_points=[e for e in np.split(points,np.where(v>v_max)[0]) if len(e)>1] # only sets of points bigger than one (if not, means isolated bad point)
    lastp = points[0]
    gpoints = []
    for p in points[1:]:
        deltar = np.linalg.norm(p[:-1] - lastp[:-1])
        deltat = p[-1] - lastp[-1]  # time diff
        if deltat > 0:
            v = deltar / deltat
            if v > v_max:
                #print "Warning, bad point! v=%f" % (v)
                pass
            else:
                lastp = p
                gpoints.append(p)
        else:
            #print "Warning, repeated time! deltat = %f \t deltar = %f" %(deltat,deltar)
            pass
    return [np.array(gpoints)]
示例#2
0
def filter_v_updates(points,v_max=50/3.6,zone=cnt.zone,UTM=True):
    """ Splits trace into sets of points according to sconsecutive updates with impossible velocity jumps
        Given N updates, computes de N-1 inst. velocity updates V_n=(X_n+1-X_n)/(T_n+1-T_n), 
        then if V_n>V_max then the dataset gets separated 
        input: Points (3-col numpy array lat,lon,time)
               v_max (maximum velocity permitted)
               zone UTM zone definition
               mode: If UTM, then no conversion
        output: list of sets of points valids
    """
    if not UTM:
    # Convert points
        utm=cnt.utm()
        xy=np.array(utm(points.T[0],points.T[1])).T # transformacio geo (lon-lat)
        xy=xy-xy[0] # refer to arbitrary origin (to ease calculations)
    else:
        xy=points.T[:-1].T
    #deltar=np.array(map(np.linalg.norm,np.diff(xy.T).T),dtype=float)
    #deltat=np.array(np.diff(points.T[-1]),dtype=int) # time diff
    #v=(deltar)/(deltat+1) # avoid problems
    #group_points=[e for e in np.split(points,np.where(v>v_max)[0]) if len(e)>1] # only sets of points bigger than one (if not, means isolated bad point)
    lastp=points[0]
    gpoints=[]
    for p in points[1:]:
        deltar=np.linalg.norm(p[:-1]-lastp[:-1])
        deltat=p[-1]-lastp[-1] # time diff
        if deltat >0:
            v=deltar/deltat
            if v>v_max:
                #print "Warning, bad point! v=%f" % (v)
                pass
            else:
                lastp=p
                gpoints.append(p)
        else:
            #print "Warning, repeated time! deltat = %f \t deltar = %f" %(deltat,deltar)
            pass
    return [np.array(gpoints)]
示例#3
0
"""
Created on Thu Dec  5 09:59:43 2013

@author: Oleguer Sagarra <*****@*****.**>

This module takes care of geodesic transforms and projections, mainly uses UTM projection (2-D)
"""

# External modules
import pyproj as pr
import numpy as np

# Internal modules
import constants as cnt

utm = cnt.utm()

##### Geodesic functions ######


def UTM_2_latlon(points, origin, zone):
    """ Converts (x-y) input to lat-lon files on given UTM zone with given origin
    input:
        - origin must be a 2 index tupple (x,y)
        - np.array with at least 2 columns x-y
        - Scalar UTM zone
    output:
        - array with lat,lon
    """
    points = np.array(points)
    coords = utm(points.T[0] + origin[0], points.T[1] + origin[1], inverse=True)
示例#4
0
import geodesics as geod
import stats as st
import misc
import geometrics as geom
# External #
import numpy as np
#from scipy import stats as sts
#import pyproj as pr


### General variables definition ###

zone=cnt.zone # zone utm 31T
origin=cnt.origin # map origin #Coordenades geodèsiqueS: N41º23.312 E02º11.034
eps=cnt.eps # very small value (to avoid problems)
utm = cnt.utm() # Define ellipsoid and UMT zone



### Classes ###

class Trace(object):
    """ This is a GPS trace object container of Flights and Stops
    type Trace.func_list for a list of available functions
    """
        
    
    ## Basic funcs of the class ##

    def __init__(self,flights=None):
        self.__setattr__('N_flights',0) #atts[self.att_dic['N_flights']]=0
示例#5
0
"""
Created on Thu Dec  5 09:59:43 2013

@author: Oleguer Sagarra <*****@*****.**>

This module takes care of geodesic transforms and projections, mainly uses UTM projection (2-D)
"""

# External modules
import pyproj as pr
import numpy as np

# Internal modules
import constants as cnt

utm=cnt.utm()

##### Geodesic functions ######

def UTM_2_latlon(points,origin,zone):
    """ Converts (x-y) input to lat-lon files on given UTM zone with given origin
    input:
        - origin must be a 2 index tupple (x,y)
        - np.array with at least 2 columns x-y
        - Scalar UTM zone
    output:
        - array with lat,lon
    """
    points=np.array(points)
    coords=utm(points.T[0]+origin[0],points.T[1]+origin[1],inverse=True)
    return np.array(coords)[::-1].T # transformacio geo (lat-lon)