PySDM.products.condensation.peak_supersaturation
highest supersaturation encountered while solving for condensation/evaporation (takes into account
substeps thus values might differ from ambient saturation reported via
PySDM.products.ambient_thermodynamics.ambient_relative_humidity.AmbientRelativeHumidity
;
fetching a value resets the maximum value)
1""" 2highest supersaturation encountered while solving for condensation/evaporation (takes into account 3 substeps thus values might differ from ambient saturation reported via 4 `PySDM.products.ambient_thermodynamics.ambient_relative_humidity.AmbientRelativeHumidity`; 5 fetching a value resets the maximum value) 6""" 7 8import numpy as np 9 10from PySDM.products.impl import Product, register_product 11 12 13@register_product() 14class PeakSupersaturation(Product): 15 def __init__(self, unit="dimensionless", name=None): 16 super().__init__(unit=unit, name=name) 17 self.condensation = None 18 self.RH_max = None 19 20 def register(self, builder): 21 super().register(builder) 22 self.particulator.observers.append(self) 23 24 assert ( 25 "Condensation" in self.particulator.dynamics 26 ), "It seems the Condensation dynamic was not added when building particulator" 27 self.condensation = self.particulator.dynamics["Condensation"] 28 self.RH_max = np.full_like(self.buffer, np.nan) 29 30 def _impl(self, **kwargs): 31 self.buffer[:] = self.RH_max[:] - 1 32 self.RH_max[:] = -1 33 return self.buffer 34 35 def notify(self): 36 self._download_to_buffer(self.condensation.rh_max) 37 self.RH_max[:] = np.maximum(self.buffer[:], self.RH_max[:])
14@register_product() 15class PeakSupersaturation(Product): 16 def __init__(self, unit="dimensionless", name=None): 17 super().__init__(unit=unit, name=name) 18 self.condensation = None 19 self.RH_max = None 20 21 def register(self, builder): 22 super().register(builder) 23 self.particulator.observers.append(self) 24 25 assert ( 26 "Condensation" in self.particulator.dynamics 27 ), "It seems the Condensation dynamic was not added when building particulator" 28 self.condensation = self.particulator.dynamics["Condensation"] 29 self.RH_max = np.full_like(self.buffer, np.nan) 30 31 def _impl(self, **kwargs): 32 self.buffer[:] = self.RH_max[:] - 1 33 self.RH_max[:] = -1 34 return self.buffer 35 36 def notify(self): 37 self._download_to_buffer(self.condensation.rh_max) 38 self.RH_max[:] = np.maximum(self.buffer[:], self.RH_max[:])
def
register(self, builder):
21 def register(self, builder): 22 super().register(builder) 23 self.particulator.observers.append(self) 24 25 assert ( 26 "Condensation" in self.particulator.dynamics 27 ), "It seems the Condensation dynamic was not added when building particulator" 28 self.condensation = self.particulator.dynamics["Condensation"] 29 self.RH_max = np.full_like(self.buffer, np.nan)