Skip to content

Commit

Permalink
Gdal import fix and diffuse minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mauroalberti committed Mar 12, 2021
1 parent 5dc70db commit 2ef7e2c
Show file tree
Hide file tree
Showing 19 changed files with 144 additions and 470 deletions.
4 changes: 2 additions & 2 deletions fault_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

def rake_to_apsg_movsense(rake):

if rake > 0.0 and rake < 180.0: # reverse faults according to Aki & Richards, 1980 convention
if 0.0 < rake < 180.0: # reverse faults according to Aki & Richards, 1980 convention
return 1
elif rake < 0.0 and rake > -180.0: # normal faults according to Aki & Richards, 1980 convention
elif 0.0 > rake > -180.0: # normal faults according to Aki & Richards, 1980 convention
return -1
elif abs(rake) == 0.0 or abs(rake) == 180.0:
raise RakeInputException("Currently transcurrent data (rake = +/-180 or = 0.0) are not handled in plots")
Expand Down
4 changes: 0 additions & 4 deletions gis_utils/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ class OutputException(Exception):
pass


class ConnectionException(object):
pass


class AnaliticSurfaceIOException(Exception):
pass

Expand Down
2 changes: 1 addition & 1 deletion gis_utils/gdal_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def geo_equiv(self, other, tolerance=1.0e-6):
abs(self.pixSizeEW) + abs(other.pixSizeEW)) > tolerance or \
2 * (abs(self.pixSizeNS) - abs(other.pixSizeNS)) / (
abs(self.pixSizeNS) + abs(other.pixSizeNS)) > tolerance or \
self.rows != other.rows or self.cols != other.cols or self.projection != other.projection:
self.rows != other.rows or self.cols != other.cols:
return False
else:
return True
Expand Down
21 changes: 10 additions & 11 deletions gis_utils/intersections.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

import numpy as np

from ..gsf.geometry import Point, GAxis, GVect, Vect
from ..gsf.geometry import *

from .features import Segment, ParamLine3D
from .profile import PlaneAttitude
from .errors import ConnectionException
from .features import *
from .profile import *


def calculate_distance_with_sign(projected_point, section_init_pt, section_vector):
Expand Down Expand Up @@ -60,7 +59,7 @@ def calculate_nearest_intersection(intersection_versor_3d, section_cartes_plane,

def calculate_axis_intersection(map_axis, section_cartes_plane, structural_pt):

axis_versor = map_axis.as_vect().versor
axis_versor = map_axis.as_gvect().versor()
l, m, n = axis_versor.x, axis_versor.y, axis_versor.z
axis_param_line = ParamLine3D(structural_pt, l, m, n)
return axis_param_line.intersect_cartes_plane(section_cartes_plane)
Expand Down Expand Up @@ -178,12 +177,12 @@ def get_intersections(self):
len(list(self.ycoords_y[np.logical_not(np.isnan(self.ycoords_y))]))

# creation and initialization of structured array of valid intersections in the x-direction
links = np.zeros((num_intersections), dtype=dt)
links = np.zeros(num_intersections, dtype=dt)

# filling array with values

curr_ndx = 0
for i in range((self.xcoords_x.shape)[0]):
for i in range(self.xcoords_x.shape[0]):
for j in range(self.xcoords_x.shape[1]):
if not isnan(self.xcoords_x[i, j]):
links[curr_ndx] = (curr_ndx + 1, i, j, 'x', 0, 0, False)
Expand Down Expand Up @@ -345,21 +344,21 @@ def follow_path(self, start_id):
conns = self.neighbours[from_id]
num_conn = len(conns)
if num_conn == 0:
raise ConnectionException('no connected intersection')
raise Exception('no connected intersection')
elif num_conn == 1:
if self.links[conns[0] - 1]['conn_from'] == 0 and self.links[conns[0] - 1]['conn_to'] != from_id:
to_id = conns[0]
else:
raise ConnectionException('no free connection')
raise Exception('no free connection')
elif num_conn == 2:
if self.links[conns[0] - 1]['conn_from'] == 0 and self.links[conns[0] - 1]['conn_to'] != from_id:
to_id = conns[0]
elif self.links[conns[1] - 1]['conn_from'] == 0 and self.links[conns[1] - 1]['conn_to'] != from_id:
to_id = conns[1]
else:
raise ConnectionException('no free connection')
raise Exception('no free connection')
else:
raise ConnectionException('multiple connection')
raise Exception('multiple connection')

# set connection
self.links[to_id - 1]['conn_from'] = from_id
Expand Down
6 changes: 3 additions & 3 deletions gis_utils/meshes.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def __init__(self, apex_pt3d, vector_1, vector_2):
"""

self._apex = apex_pt3d
self._versor_1 = vector_1.versor_full()
self._versor_2 = vector_2.versor_full()
self._versor_1 = vector_1.versor()
self._versor_2 = vector_2.versor()

def fangle_degr(self):
"""
Expand Down Expand Up @@ -91,7 +91,7 @@ def is_pt_within(self, pt_3d):

def versor3d(pt_1, pt_2):

return Segment(pt_1, pt_2).vector().versor_full()
return Segment(pt_1, pt_2).vector().versor()

def is_pt_in_fascio(pt_1, pt_2, pt_3):

Expand Down
4 changes: 2 additions & 2 deletions gis_utils/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def remove(self, ndx):
_ = self._geoprofiles.pop(ndx)


class GeoProfile(object):
class GeoProfile:
"""
Class representing the topographic and geological elements
embodying a single geological profile.
Expand Down Expand Up @@ -180,7 +180,7 @@ def add_curves(self, lMultilines, lIds):
self.geosurfaces_ids.append(lIds)


class ProfileElevations(object):
class ProfileElevations:

def __init__(self):

Expand Down
20 changes: 10 additions & 10 deletions gis_utils/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

def get_statistics(topo_array):

min = np.nanmin(topo_array)
max = np.nanmax(topo_array)
mean = np.nanmean(topo_array)
var = np.nanvar(topo_array)
std = np.nanstd(topo_array)
stat_min = np.nanmin(topo_array)
stat_max = np.nanmax(topo_array)
stat_mean = np.nanmean(topo_array)
stat_var = np.nanvar(topo_array)
stat_std = np.nanstd(topo_array)

stats = dict(min=min,
max=max,
mean=mean,
var=var,
std=std)
stats = dict(min=stat_min,
max=stat_max,
mean=stat_mean,
var=stat_var,
std=stat_std)

return stats
4 changes: 2 additions & 2 deletions gsf/array_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ def is_number(s):
return True


def to_float(iterable):
def to_float(curr_iterable):

return [float(item) for item in iterable]
return [float(item) for item in curr_iterable]


def almost_zero(val):
Expand Down
11 changes: 5 additions & 6 deletions gsf/faults.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-


from builtins import object
from .geometry import *
from .errors import SlickelineTypeException, SlickelineSenseException
from .math_utils import isclose


class Slickenline(object):
"""
Slickeline.
Expand Down Expand Up @@ -81,7 +79,7 @@ def set_known_sense(self):
if self.has_known_sense():
raise SlickelineSenseException("Slickenline must have unknown movement sense")

return Slickenline(self.lin.as_vect())
return Slickenline(self.lin.as_gvect())

def set_unknown_sense(self):
"""
Expand Down Expand Up @@ -289,8 +287,8 @@ def PTaxes(self):
PTBAxes(P: GAxis(000.00, -90.00), T: GAxis(090.00, +00.00), True)
"""

s_versor = self.sl.lin.versor_full
f_versor = self.fp.normal.versor_full
s_versor = self.sl.lin.versor()
f_versor = self.fp.normal.versor()
T_axis = (f_versor + s_versor).gaxis
P_axis = (f_versor - s_versor).gaxis
known = self.known_sense
Expand Down Expand Up @@ -396,6 +394,7 @@ def Mplane(self):

return self.Paxis.common_plane(self.Taxis)


if __name__ == "__main__":

import doctest
Expand Down
Loading

0 comments on commit 2ef7e2c

Please sign in to comment.