def test_normalization(self): p = Particle() dt = datetime(2012, 8, 15, 0, tzinfo=pytz.utc) norms = [dt] last_real_movement = Location4D(latitude=38, longitude=-76, depth=0, time=dt) p.location = Location4D(latitude=100, longitude=-100, depth=0, time=dt) p.location = Location4D(latitude=101, longitude=-101, depth=0, time=dt) p.location = last_real_movement for x in range(1, 10): norm = (dt + timedelta(hours=x)).replace(tzinfo=pytz.utc) norms.append(norm) p.location = Location4D(latitude=38 + x, longitude=-76 + x, depth=x, time=norm) locs = p.normalized_locations(norms) assert locs[0] == last_real_movement
def setUp(self): start_lat = 38 start_lon = -76 start_depth = -5 temp_time = datetime.utcnow() self.start_time = datetime(temp_time.year, temp_time.month, temp_time.day, temp_time.hour) self.loc = Location4D(latitude=start_lat, longitude=start_lon, depth=start_depth, time=self.start_time) # Generate time,u,v,z as randoms # 48 timesteps at an hour each = 2 days of running self.times = list(range(0, 172800, 3600)) # in seconds self.u = [] self.v = [] self.z = [] for w in range(0, 48): self.z.append(random.gauss(0, 0.0001)) # gaussian in m/s self.u.append(abs(AsaRandom.random())) # random function in m/s self.v.append(abs(AsaRandom.random())) # random function in m/s self.particles = [] # Create particles for i in range(0, 3): p = Particle() p.location = self.loc self.particles.append(p) # Create a transport instance with horiz and vert dispersions self.transport_model = Transport(horizDisp=0.05, vertDisp=0.00003)
def setUp(self): start_lat = 38 start_lon = -76 start_depth = -5 temp_time = datetime.utcnow() self.start_time = datetime(temp_time.year, temp_time.month, temp_time.day, temp_time.hour) self.loc = Location4D(latitude=start_lat, longitude=start_lon, depth=start_depth, time=self.start_time) # Generate time,u,v,z as randoms # 48 timesteps at an hour each = 2 days of running self.times = range(0, 172800, 3600) # in seconds self.u = [] self.v = [] self.z = [] for w in xrange(0, 48): self.z.append(random.gauss(0, 0.0001)) # gaussian in m/s self.u.append(abs(AsaRandom.random())) # random function in m/s self.v.append(abs(AsaRandom.random())) # random function in m/s self.particles = [] # Create particles for i in xrange(0, 3): p = Particle() p.location = self.loc self.particles.append(p) # Create a transport instance with horiz and vert dispersions self.transport_model = Transport(horizDisp=0.05, vertDisp=0.00003)
def test_normalization(self): p = Particle() dt = datetime(2012, 8, 15, 0, tzinfo=pytz.utc) norms =[dt] last_real_movement = Location4D(latitude=38, longitude=-76, depth=0, time=dt) p.location = Location4D(latitude=100, longitude=-100, depth=0, time=dt) p.location = Location4D(latitude=101, longitude=-101, depth=0, time=dt) p.location = last_real_movement for x in xrange(1,10): norm = (dt + timedelta(hours=x)).replace(tzinfo=pytz.utc) norms.append(norm) p.location = Location4D(latitude=38 + x, longitude=-76 + x, depth=x, time=norm) locs = p.normalized_locations(norms) assert locs[0] == last_real_movement