コード例 #1
0
 def __full_traj_default(self):
     step = int(1  / (self.step_freq * self.dt))
     tstep = N.arange(0, self.T + self.dt*step, self.dt*step)
     v_sigma = self.v_bar * self.dt * step
     X = N.empty((tstep.shape[0], 2), 'd')
     X[0] = self.Map.x0
     
     def random_step(x0, x1):
         _angle_ = 2*S.pi * N.random.random_sample()
         _x = x0 + (v_sigma * N.cos(_angle_), v_sigma * N.sin(_angle_))
         while not self.Map.inbounds(_x[0], _x[1]):
             _angle_ = 2*S.pi * N.random.random_sample()
             _x = x0 + (v_sigma * N.cos(_angle_), v_sigma * N.sin(_angle_))
         x1[:] = _x
     
     for t in xrange(1, tstep.shape[0]):
         random_step(X[t-1], X[t])
     
     return N.c_[
         _i1d(tstep, X[:,0], kind='cubic', bounds_error=False, fill_value=X[-1,0])(self._time),
         _i1d(tstep, X[:,1], kind='cubic', bounds_error=False, fill_value=X[-1,1])(self._time)]
コード例 #2
0
 def __full_traj_default(self):
     """
     A (2, ntimesteps)-shaped matrix containing the full temporal trajectory
     """
     # Down sample the stage raster according to sample index
     X = self._full_raster[:, N.repeat(self._get_sample_index(), 2)]
     
     # Dwell vector and full-series time vector
     _init = self._init_factor*self.dwell
     _dwell_t = N.linspace(0, self._req_time - _init, int(self._nsteps/2))
     t = N.repeat(_dwell_t, 2)
     t[1::2] += self.dwell - self._transit
     
     # Insert initial dwell time for transients
     t[1:] += _init
     
     return N.c_[
         _i1d(t, X[0], kind='linear', bounds_error=False, 
             fill_value=X[0,-1])(self._time),
         _i1d(t, X[1], kind='linear', bounds_error=False, 
             fill_value=X[1,-1])(self._time)]