Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Release History

0.8.0 ( ?????????????? )
++++++++++++++++++++++++

0.7.3 (October, 6, 2020)
++++++++++++++++++++++++
* update to python 3.8 and change tests for compatibility
Expand Down
2 changes: 1 addition & 1 deletion pyprom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

PyProm: This library includes tools for surface network analysis.
"""
version_info = (0, 7, 3)
version_info = (0, 8, 0)
__name__ = 'pyProm'
__doc__ = 'A python surface network analysis script'
__author__ = 'Marc Howes'
Expand Down
5 changes: 3 additions & 2 deletions pyprom/dataload.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import os
import numpy
import logging
import gdal
import osr
from osgeo import gdal
from osgeo import osr

from .lib.datamap import ProjectionDataMap

Expand Down Expand Up @@ -88,6 +88,7 @@ def __init__(self, filename, epsg_alias="WGS84"):
# Create target Spatial Reference for converting coordinates.
target = osr.SpatialReference()
target.ImportFromEPSG(epsg_code)
target.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)
transform = osr.CoordinateTransformation(spatialRef, target)
# create a reverse transform for translating back
# into Native GDAL coordinates
Expand Down
4 changes: 3 additions & 1 deletion pyprom/feature_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,9 @@ def edge_feature_analysis(self, x, y, perimeter,
if multipoint:
pts = multipoint.points
# this gets the closest single highPerimeterNeighborhood point to our midpoint
highPerimeterNeighborhoods.append([high_perimeter_neighborhood_shortest_path(mid, pts, highPerimeter, self.datamap)])
highPerimeterNeighborhoods.append(
(high_perimeter_neighborhood_shortest_path(mid, pts, highPerimeter, self.datamap),)
)
else:
# just use the regular highPerimeterNeighborhoods if not a multipoint
highPerimeterNeighborhoods = highPerimeter
Expand Down
11 changes: 11 additions & 0 deletions pyprom/lib/containers/linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,17 @@ def linkers_to_summits_connected_via_saddle(self, excludeSelf=True,
if _linker_ok(linker, skipDisqualified, {}) and
self._help_exclude_self(linker, excludeSelf)]

def linker_other_side_of_saddle(self):
"""
Much faster, but less robust than linkers_to_summits_connected_via_saddle
Uses linker ids.
:return: list of linkers to summits connected to the saddle this
linker links
:rtype: list(:class:`Linker`)
"""

return [x for x in self.saddle.summits if x.id != self.id and not x.disqualified]

def add_to_remote_saddle_and_summit(self, ignoreDuplicates=True):
"""
Safely adds this linker to the remote
Expand Down
9 changes: 8 additions & 1 deletion pyprom/lib/containers/spot_elevation.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ def __init__(self, spotElevationList):
"""
super(SpotElevationContainer, self).__init__()
self.points = spotElevationList
self.fast_lookup = {point.id: point for point in self.points}
self.fast_lookup = self.generate_fast_lookup()

def generate_fast_lookup(self):
"""
Produces a fast lookup dict of this Container.
:return: {id: SpotElevation} fast lookup dict.
"""
return {point.id: point for point in self.points}

@property
def lowest(self):
Expand Down
8 changes: 5 additions & 3 deletions pyprom/lib/locations/saddle.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ def __init__(self, latitude, longitude, elevation, *args, **kwargs):
elevation, *args, **kwargs)
self.multipoint = kwargs.get('multipoint', [])
self.highPerimeterNeighborhoods = kwargs.get('highPerimeterNeighborhoods', [])
self.id = kwargs.get('id', 'sa:' + randomString())
self.id = kwargs.get('id')
if not self.id:
self.id = 'sa:' + randomString()
# List of linkers to summits
self.summits = []
# If this is set, this saddle has spun out another
Expand Down Expand Up @@ -375,11 +377,11 @@ def from_dict(cls, saddleDict, datamap=None):
hsx = []
for hs in hss:
hsx.append(tuple(hs))
highPerimeterNeighborhoods.append(hsx)
highPerimeterNeighborhoods.append(tuple(hsx))

return cls(lat, long, elevation,
multipoint=multipoint,
highPerimeterNeighborhoods=highPerimeterNeighborhoods,
highPerimeterNeighborhoods=tuple(highPerimeterNeighborhoods),
edge=edge,
edgePoints=edgePoints,
id=id,
Expand Down
4 changes: 3 additions & 1 deletion pyprom/lib/locations/spot_elevation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def __init__(self, latitude, longitude, elevation, *args, **kwargs):
self.elevation = elevation
self.edgeEffect = kwargs.get('edge', False)
self.edgePoints = kwargs.get('edgePoints', [])
self.id = kwargs.get('id', 'se:' + randomString())
self.id = kwargs.get('id')
if not self.id:
self.id = 'se:' + randomString()

def to_dict(self):
"""
Expand Down
4 changes: 3 additions & 1 deletion pyprom/lib/locations/summit.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def __init__(self, latitude, longitude, elevation, *args, **kwargs):
super(Summit, self).__init__(latitude, longitude,
elevation, *args, **kwargs)
self.multipoint = kwargs.get('multipoint', [])
self.id = kwargs.get('id', 'su:' + randomString())
self.id = kwargs.get('id')
if not self.id:
self.id = 'su:' + randomString()
# saddles contains a list of linker objects linking this summit to a
# saddle. These are populated by :class:`Walk`
self.saddles = list()
Expand Down
6 changes: 3 additions & 3 deletions pyprom/lib/logic/basin_saddle_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def disqualify_basin_saddles(self):
while features: # loop over features
if root is None:
_, root = features.popitem()
if root.disqualified or root.edgeEffect:
if root.disqualified:
root = None
continue
stack = [root] # stack of features to explore.
Expand All @@ -73,12 +73,12 @@ def disqualify_basin_saddles(self):
cycleMembers = {}
while stack:
z = stack.pop()
if z.disqualified or z.edgeEffect:
if z.disqualified:
features.pop(z.id, None)
continue
zEexploredNbrs = exploredNbrs[z.id]
for nbr in z.feature_neighbors():
if nbr.disqualified or nbr.edgeEffect:
if nbr.disqualified:
features.pop(nbr.id, None)
continue
if nbr.id not in exploredNbrs: # new node
Expand Down
36 changes: 36 additions & 0 deletions pyprom/lib/logic/breadth_first_search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

"""
pyProm: Copyright 2020.
This software is distributed under a license that is described in
the LICENSE file that accompanies it.
This library contains logic for performing breadth first search on
contiguous point sets on a cartesian grid.
"""
from collections import defaultdict

class BreadthFirstSearch:
def __init__(self,
pointList=None,
pointIndex=None,
datamap=None)
"""
:param list pointList: list(tuple(x,y,z))
"""
self.datamap = datamap
self.points = []

if pointList and pointIndex:
self.points = pointList
self.pointIndex = pointIndex
return

if pointIndex:
self.pointIndex = pointIndex
self.points = [p for x, _y in self.pointIndex.items()
for y, p in _y.items()]

if pointList:
self.points = pointList
self.pointIndex = defaultdict(dict)
for point in self.points:
self.pointIndex[point[0]][point[1]] = point
2 changes: 1 addition & 1 deletion pyprom/lib/logic/contiguous_neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def contiguous_neighbors(points):
stack = [points.pop()]
lookup[stack[0][0]][stack[0][1]] = None
neighbors = list([stack[0]])
neighborsList.append(neighbors)
neighborsList.append(tuple(neighbors))
while stack:
# Grab a point from the stack.
point = stack.pop()
Expand Down
4 changes: 2 additions & 2 deletions pyprom/lib/logic/internal_saddle_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ def generate_child_saddles(self):
self.saddle.longitude,
self.saddle.elevation)

newSaddle.highPerimeterNeighborhoods = [[link.local],
[link.remote]]
newSaddle.highPerimeterNeighborhoods = [(link.local,),
(link.remote,)]

if self.saddle.edgeEffect:
newSaddle.parent = self.saddle
Expand Down
Loading