mirror of https://gitlab.com/pamhyr/pamhyr2
Results: Minor results reading optimisation with async computation.
parent
32cbc6bc3e
commit
565a7530fb
|
|
@ -858,11 +858,11 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||
|
||||
return start, list(reversed(end))
|
||||
|
||||
@timer
|
||||
def get_water_limits(self, z):
|
||||
"""
|
||||
Determine left and right limits of water elevation.
|
||||
"""
|
||||
|
||||
# Get the index of first point with elevation lesser than water
|
||||
# elevation (for the right and left river side)
|
||||
i_left = -1
|
||||
|
|
@ -908,7 +908,8 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||
else:
|
||||
pt_right = self.point(self.number_points - 1)
|
||||
|
||||
return pt_left, pt_right
|
||||
# Create a generator to improve results data reading speed
|
||||
yield pt_left, pt_right
|
||||
|
||||
def compute_tabulation(self):
|
||||
sorted_points = sorted(self._points, key=lambda p: p.z)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import types
|
||||
import struct
|
||||
import logging
|
||||
import itertools
|
||||
|
|
@ -74,7 +75,14 @@ class Profile(SQLSubModel):
|
|||
def get_ts_key(self, timestamp, key):
|
||||
if timestamp in self._data:
|
||||
if key in self._data[timestamp]:
|
||||
return self._data[timestamp][key]
|
||||
v = self._data[timestamp][key]
|
||||
|
||||
# If is a generator, compute value(s)
|
||||
if isinstance(v, types.GeneratorType):
|
||||
v = self._data[timestamp][key] = next(v)
|
||||
|
||||
return v
|
||||
|
||||
return None
|
||||
|
||||
def has_sediment_layers(self):
|
||||
|
|
|
|||
Loading…
Reference in New Issue