def move(self, particle, u, v, w, modelTimestep, **kwargs): """ I'm dead, so no behaviors should act on me """ # Kill the particle if it isn't settled and isn't already dead. if not particle.settled and not particle.dead: particle.die() # Still save the temperature and salinity for the model output temp = kwargs.get('temperature', None) if temp is not None and math.isnan(temp): temp = None particle.temp = temp salt = kwargs.get('salinity', None) if salt is not None and math.isnan(salt): salt = None particle.salt = salt u = 0 v = 0 w = 0 # Do the calculation to determine the new location result = AsaTransport.distance_from_location_using_u_v_w(u=u, v=v, w=w, timestep=modelTimestep, location=particle.location) result['u'] = u result['v'] = v result['w'] = w return result
def move(self, particle, u, v, w, modelTimestep, **kwargs): """ I'm dead, so no behaviors should act on me """ # Kill the particle if it isn't settled and isn't already dead. if not particle.settled and not particle.dead: particle.die() # Still save the temperature and salinity for the model output temp = kwargs.get('temperature', None) if temp is not None and math.isnan(temp): temp = None particle.temp = temp salt = kwargs.get('salinity', None) if salt is not None and math.isnan(salt): salt = None particle.salt = salt u = 0 v = 0 w = 0 # Do the calculation to determine the new location result = AsaTransport.distance_from_location_using_u_v_w( u=u, v=v, w=w, timestep=modelTimestep, location=particle.location) result['u'] = u result['v'] = v result['w'] = w return result
def move(self, particle, u, v, w, modelTimestep, **kwargs): """ Returns the lat, lon, H, and velocity of a projected point given a starting lat and lon (dec deg), a depth (m) below sea surface (positive up), u, v, and w velocity components (m/s), a horizontal and vertical displacement coefficient (m^2/s) H (m), and a model timestep (s). GreatCircle calculations are done based on the Vincenty Direct method. Returns a dict like: { 'latitude': x, 'azimuth': x, 'reverse_azimuth': x, 'longitude': x, 'depth': x, 'u': x 'v': x, 'w': x, 'distance': x, 'angle': x, 'vertical_distance': x, 'vertical_angle': x } """ logger.debug("U: %s, V: %s, W: %s" % (str(u), str(v), str(w))) # IMPORTANT: # If we got no data from the model, we are using the last available value stored in the particles! if (u is None) or (u is not None and math.isnan(u)): u = particle.last_u() if (v is None) or (v is not None and math.isnan(v)): v = particle.last_v() if (w is None) or (w is not None and math.isnan(w)): w = particle.last_w() particle.u_vector = u particle.v_vector = v particle.w_vector = w if particle.halted: u, v, w = 0, 0, 0 else: u += AsaRandom.random() * ((2 * self._horizDisp / modelTimestep)** 0.5) # u transformation calcualtions v += AsaRandom.random() * ((2 * self._horizDisp / modelTimestep)** 0.5) # v transformation calcualtions w += AsaRandom.random() * ((2 * self._vertDisp / modelTimestep)** 0.5) # w transformation calculations result = AsaTransport.distance_from_location_using_u_v_w( u=u, v=v, w=w, timestep=modelTimestep, location=particle.location) result['u'] = u result['v'] = v result['w'] = w return result
def move(self, particle, u, v, w, modelTimestep, **kwargs): """ Returns the lat, lon, H, and velocity of a projected point given a starting lat and lon (dec deg), a depth (m) below sea surface (positive up), u, v, and w velocity components (m/s), a horizontal and vertical displacement coefficient (m^2/s) H (m), and a model timestep (s). GreatCircle calculations are done based on the Vincenty Direct method. Returns a dict like: { 'latitude': x, 'azimuth': x, 'reverse_azimuth': x, 'longitude': x, 'depth': x, 'u': x 'v': x, 'w': x, 'distance': x, 'angle': x, 'vertical_distance': x, 'vertical_angle': x } """ logger.debug("U: %s, V: %s, W: %s" % (str(u),str(v),str(w))) # IMPORTANT: # If we got no data from the model, we are using the last available value stored in the particles! if (u is None) or (u is not None and math.isnan(u)): u = particle.last_u() if (v is None) or (v is not None and math.isnan(v)): v = particle.last_v() if (w is None) or (w is not None and math.isnan(w)): w = particle.last_w() particle.u_vector = u particle.v_vector = v particle.w_vector = w if particle.halted: u,v,w = 0,0,0 else: u += AsaRandom.random() * ((2 * self._horizDisp / modelTimestep) ** 0.5) # u transformation calcualtions v += AsaRandom.random() * ((2 * self._horizDisp / modelTimestep) ** 0.5) # v transformation calcualtions w += AsaRandom.random() * ((2 * self._vertDisp / modelTimestep) ** 0.5) # w transformation calculations result = AsaTransport.distance_from_location_using_u_v_w(u=u, v=v, w=w, timestep=modelTimestep, location=particle.location) result['u'] = u result['v'] = v result['w'] = w return result
def move(self, particle, u, v, w, modelTimestep, **kwargs): temp = kwargs.get('temperature', None) salt = kwargs.get('salinity', None) logger.debug("Temp: %.4f, Salt: %.4f" % (temp, salt)) # IMPORTANT: # If we got no data from the model, we are using the last available value stored in the particles! if (temp is None) or (temp is not None and math.isnan(temp)): temp = particle.last_temp() if (salt is None) or (salt is not None and math.isnan(salt)): salt = particle.last_salt() particle.temp = temp particle.salt = salt # Grow the particle. Growth affects which lifestage the particle is in. growth = 0. do_duration_growth = True modelTimestepDays = modelTimestep / 60. / 60. / 24. if self.linear_a is not None and self.linear_b is not None: if particle.temp is not None and not math.isnan(particle.temp): # linear growth, compute q = t / (Ax+B) # Where timestep t (days), at temperature x (deg C), proportion of stage completed (q) growth = modelTimestepDays / (self.linear_a * particle.temp + self.linear_b) particle.grow(growth) do_duration_growth = False else: logger.debug("No temperature found for Particle %s at this location and timestep, skipping linear temperature growth and using duration growth" % particle.uid) pass if do_duration_growth is True: growth = modelTimestepDays / self.duration particle.grow(growth) active_diel = self.get_active_diel(particle.location) # Run the active diel behavior and all of the taxis behaviors # u, v, and w store the continuous results from all of the behavior models. u = 0 v = 0 w = 0 behaviors_to_run = [_f for _f in [self.settlement] + [active_diel] + self.taxis if _f] # Sort these in the order you want them to be run. try: vss = self.capability.calculated_vss except AttributeError: logger.debug("No VSS found, vertical behaviors will not act upon particle") vss = 0 for behave in behaviors_to_run: behave_results = behave.move(particle, 0, 0, vss, modelTimestep, **kwargs) u += behave_results['u'] v += behave_results['v'] w += behave_results['w'] # Do the calculation to determine the new location after running the behaviors result = AsaTransport.distance_from_location_using_u_v_w(u=u, v=v, w=w, timestep=modelTimestep, location=particle.location) result['u'] = u result['v'] = v result['w'] = w return result
def move(self, particle, u, v, w, modelTimestep, **kwargs): temp = kwargs.get('temperature', None) salt = kwargs.get('salinity', None) logger.debug("Temp: %.4f, Salt: %.4f" % (temp, salt)) # IMPORTANT: # If we got no data from the model, we are using the last available value stored in the particles! if (temp is None) or (temp is not None and math.isnan(temp)): temp = particle.last_temp() if (salt is None) or (salt is not None and math.isnan(salt)): salt = particle.last_salt() particle.temp = temp particle.salt = salt # Grow the particle. Growth affects which lifestage the particle is in. growth = 0. do_duration_growth = True modelTimestepDays = modelTimestep / 60. / 60. / 24. if self.linear_a is not None and self.linear_b is not None: if particle.temp is not None and not math.isnan(particle.temp): # linear growth, compute q = t / (Ax+B) # Where timestep t (days), at temperature x (deg C), proportion of stage completed (q) growth = modelTimestepDays / (self.linear_a * particle.temp + self.linear_b) particle.grow(growth) do_duration_growth = False else: logger.debug( "No temperature found for Particle %s at this location and timestep, skipping linear temperature growth and using duration growth" % particle.uid) pass if do_duration_growth is True: growth = modelTimestepDays / self.duration particle.grow(growth) active_diel = self.get_active_diel(particle.location) # Run the active diel behavior and all of the taxis behaviors # u, v, and w store the continuous results from all of the behavior models. u = 0 v = 0 w = 0 behaviors_to_run = [ _f for _f in [self.settlement] + [active_diel] + self.taxis if _f ] # Sort these in the order you want them to be run. try: vss = self.capability.calculated_vss except AttributeError: logger.debug( "No VSS found, vertical behaviors will not act upon particle") vss = 0 for behave in behaviors_to_run: behave_results = behave.move(particle, 0, 0, vss, modelTimestep, **kwargs) u += behave_results['u'] v += behave_results['v'] w += behave_results['w'] # Do the calculation to determine the new location after running the behaviors result = AsaTransport.distance_from_location_using_u_v_w( u=u, v=v, w=w, timestep=modelTimestep, location=particle.location) result['u'] = u result['v'] = v result['w'] = w return result