apsg 2.0.0__tar.gz → 2.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {apsg-2.0.0/src/apsg.egg-info → apsg-2.0.1}/PKG-INFO +1 -1
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/__init__.py +44 -46
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/config.py +23 -2
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/database/__init__.py +11 -13
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/database/_sdbmodels.py +7 -11
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/database/_sdbsession.py +36 -23
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/database/_websdbsession.py +29 -29
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/feature/__init__.py +34 -35
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/feature/_container.py +17 -15
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/feature/_geodata.py +41 -8
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/feature/_paleomag.py +19 -33
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/feature/_statistics.py +13 -10
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/feature/_tensor2.py +6 -6
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/feature/_tensor3.py +22 -19
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/helpers/__init__.py +15 -17
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/helpers/_helper.py +1 -1
- apsg-2.0.1/src/apsg/math/__init__.py +4 -0
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/math/_matrix.py +5 -5
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/math/_vector.py +16 -22
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/pandas/__init__.py +9 -11
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/pandas/_accessors.py +12 -8
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/pandas/_pandas_api.py +1 -4
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/plotting/__init__.py +11 -13
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/plotting/_fabricplot.py +19 -17
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/plotting/_paleomagplots.py +8 -10
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/plotting/_plot_artists.py +53 -27
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/plotting/_roseplot.py +14 -12
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/plotting/_stereo_engine/_axes.py +60 -22
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/plotting/_stereo_engine/_utils.py +45 -14
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/plotting/_stereogrid.py +4 -4
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/plotting/_stereonet.py +176 -25
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/plotting/_styles.py +61 -28
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/shell.py +1 -5
- {apsg-2.0.0 → apsg-2.0.1/src/apsg.egg-info}/PKG-INFO +1 -1
- {apsg-2.0.0 → apsg-2.0.1}/tests/test_apsg.py +78 -5
- {apsg-2.0.0 → apsg-2.0.1}/tests/test_containers.py +3 -3
- {apsg-2.0.0 → apsg-2.0.1}/tests/test_plotting.py +555 -7
- {apsg-2.0.0 → apsg-2.0.1}/tests/test_tensors.py +2 -2
- {apsg-2.0.0 → apsg-2.0.1}/tests/test_websdb.py +13 -13
- apsg-2.0.0/src/apsg/math/__init__.py +0 -6
- {apsg-2.0.0 → apsg-2.0.1}/LICENSE +0 -0
- {apsg-2.0.0 → apsg-2.0.1}/README.md +0 -0
- {apsg-2.0.0 → apsg-2.0.1}/pyproject.toml +0 -0
- {apsg-2.0.0 → apsg-2.0.1}/setup.cfg +0 -0
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/database/_webtransport.py +0 -0
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/helpers/_math.py +0 -0
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/helpers/_notation.py +0 -0
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/pandas/_gbfunctions.py +0 -0
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/plotting/_stereo_engine/__init__.py +0 -0
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/plotting/_stereo_engine/_stereogrid.py +0 -0
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg/plotting/_stereo_engine/_transforms.py +0 -0
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg.egg-info/SOURCES.txt +0 -0
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg.egg-info/dependency_links.txt +0 -0
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg.egg-info/entry_points.txt +0 -0
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg.egg-info/requires.txt +0 -0
- {apsg-2.0.0 → apsg-2.0.1}/src/apsg.egg-info/top_level.txt +0 -0
- {apsg-2.0.0 → apsg-2.0.1}/tests/test_pandas.py +0 -0
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
from apsg.config import apsg_conf, apsg_conf_context
|
|
4
2
|
from apsg.feature import (
|
|
5
3
|
Arc as arc,
|
|
@@ -141,62 +139,62 @@ from apsg.plotting import (
|
|
|
141
139
|
)
|
|
142
140
|
|
|
143
141
|
__all__ = (
|
|
142
|
+
"FlinnPlot",
|
|
143
|
+
"G",
|
|
144
|
+
"HsuPlot",
|
|
145
|
+
"RamsayPlot",
|
|
146
|
+
"RosePlot",
|
|
147
|
+
"StereoGrid",
|
|
148
|
+
"StereoNet",
|
|
149
|
+
"VollmerPlot",
|
|
144
150
|
"apsg_conf",
|
|
145
151
|
"apsg_conf_context",
|
|
146
|
-
"stereonet_styles",
|
|
147
|
-
"roseplot_styles",
|
|
148
|
-
"fabricplot_styles",
|
|
149
|
-
"vec",
|
|
150
|
-
"vec2",
|
|
151
|
-
"matrix",
|
|
152
|
-
"matrix2",
|
|
153
|
-
"dir2",
|
|
154
|
-
"lin",
|
|
155
|
-
"fol",
|
|
156
|
-
"pair",
|
|
157
|
-
"fault",
|
|
158
|
-
"cone",
|
|
159
152
|
"arc",
|
|
160
|
-
"vecset",
|
|
161
|
-
"vec2set",
|
|
162
|
-
"dir2set",
|
|
163
|
-
"linset",
|
|
164
|
-
"folset",
|
|
165
|
-
"pairset",
|
|
166
|
-
"faultset",
|
|
167
|
-
"coneset",
|
|
168
153
|
"arcset",
|
|
169
|
-
"ellipseset",
|
|
170
|
-
"ellipsoidset",
|
|
171
|
-
"ortensor2set",
|
|
172
|
-
"ortensorset",
|
|
173
|
-
"stressset",
|
|
174
|
-
"stress2set",
|
|
175
154
|
"cluster",
|
|
176
|
-
"
|
|
155
|
+
"cone",
|
|
156
|
+
"coneset",
|
|
177
157
|
"defgrad",
|
|
178
|
-
"rotation",
|
|
179
|
-
"velgrad",
|
|
180
|
-
"stress",
|
|
181
|
-
"ellipsoid",
|
|
182
|
-
"ortensor",
|
|
183
158
|
"defgrad2",
|
|
184
|
-
"
|
|
185
|
-
"
|
|
186
|
-
"stress2",
|
|
159
|
+
"dir2",
|
|
160
|
+
"dir2set",
|
|
187
161
|
"ellipse",
|
|
162
|
+
"ellipseset",
|
|
163
|
+
"ellipsoid",
|
|
164
|
+
"ellipsoidset",
|
|
165
|
+
"fabricplot_styles",
|
|
166
|
+
"fault",
|
|
167
|
+
"faultset",
|
|
168
|
+
"fol",
|
|
169
|
+
"folset",
|
|
170
|
+
"lin",
|
|
171
|
+
"linset",
|
|
172
|
+
"matrix",
|
|
173
|
+
"matrix2",
|
|
174
|
+
"ortensor",
|
|
188
175
|
"ortensor2",
|
|
189
|
-
"
|
|
190
|
-
"
|
|
191
|
-
"
|
|
192
|
-
"
|
|
193
|
-
"RamsayPlot",
|
|
194
|
-
"FlinnPlot",
|
|
195
|
-
"HsuPlot",
|
|
176
|
+
"ortensor2set",
|
|
177
|
+
"ortensorset",
|
|
178
|
+
"pair",
|
|
179
|
+
"pairset",
|
|
196
180
|
"quicknet",
|
|
181
|
+
"roseplot_styles",
|
|
182
|
+
"rotation",
|
|
183
|
+
"rotation2",
|
|
197
184
|
"rotation_from_axis_angle",
|
|
185
|
+
"stereonet_styles",
|
|
186
|
+
"stress",
|
|
187
|
+
"stress2",
|
|
188
|
+
"stress2set",
|
|
189
|
+
"stressset",
|
|
190
|
+
"vec",
|
|
191
|
+
"vec2",
|
|
192
|
+
"vec2set",
|
|
193
|
+
"vecset",
|
|
194
|
+
"velgrad",
|
|
195
|
+
"velgrad2",
|
|
198
196
|
)
|
|
199
197
|
|
|
200
|
-
__version__ = "2.0.
|
|
198
|
+
__version__ = "2.0.1"
|
|
201
199
|
__author__ = "Ondrej Lexa"
|
|
202
200
|
__email__ = "lexa.ondrej@gmail.com"
|
|
@@ -83,8 +83,6 @@ class StereonetConfig(BaseConfig):
|
|
|
83
83
|
class StereonetPointConfig(StereonetMarkerConfig):
|
|
84
84
|
"""Stereonet point marker style configuration."""
|
|
85
85
|
|
|
86
|
-
pass
|
|
87
|
-
|
|
88
86
|
|
|
89
87
|
@dataclass
|
|
90
88
|
class StereonetVectorConfig(StereonetMarkerConfig):
|
|
@@ -108,6 +106,7 @@ class StereonetArcConfig(BaseConfig):
|
|
|
108
106
|
"""Stereonet arc style configuration (line, points or filled)."""
|
|
109
107
|
|
|
110
108
|
kind: str = "line" # "line", "points" or "filled"
|
|
109
|
+
region: str = "inside" # "inside" or "outside" (kind="filled" only)
|
|
111
110
|
alpha: Any = None
|
|
112
111
|
color: Any = None
|
|
113
112
|
ls: str = "-"
|
|
@@ -188,6 +187,22 @@ class StereonetHoeppnerConfig(StereonetMarkerConfig):
|
|
|
188
187
|
pivot: str = "middle"
|
|
189
188
|
|
|
190
189
|
|
|
190
|
+
@dataclass
|
|
191
|
+
class StereonetDihedraConfig(BaseConfig):
|
|
192
|
+
"""Stereonet fault dihedra (filled extensional quadrants) configuration."""
|
|
193
|
+
|
|
194
|
+
color: Any = None
|
|
195
|
+
alpha: Any = None # None: 0.3 for a few faults, lowered as 1.5 / n for larger sets
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
@dataclass
|
|
199
|
+
class StereonetBeachballConfig(BaseConfig):
|
|
200
|
+
"""Stereonet stress beach ball (filled compressive quadrants) configuration."""
|
|
201
|
+
|
|
202
|
+
color: Any = "k"
|
|
203
|
+
alpha: Any = None # None: 1 for one stress, lowered as 1.5 / n for larger sets
|
|
204
|
+
|
|
205
|
+
|
|
191
206
|
@dataclass
|
|
192
207
|
class StereonetArrowConfig(BaseConfig):
|
|
193
208
|
"""Stereonet arrow style configuration."""
|
|
@@ -399,6 +414,12 @@ class AppConfig(BaseConfig):
|
|
|
399
414
|
stereonet_hoeppner: StereonetHoeppnerConfig = field(
|
|
400
415
|
default_factory=StereonetHoeppnerConfig
|
|
401
416
|
)
|
|
417
|
+
stereonet_dihedra: StereonetDihedraConfig = field(
|
|
418
|
+
default_factory=StereonetDihedraConfig
|
|
419
|
+
)
|
|
420
|
+
stereonet_beachball: StereonetBeachballConfig = field(
|
|
421
|
+
default_factory=StereonetBeachballConfig
|
|
422
|
+
)
|
|
402
423
|
stereonet_arrow: StereonetArrowConfig = field(default_factory=StereonetArrowConfig)
|
|
403
424
|
stereonet_tensor: StereonetTensorConfig = field(
|
|
404
425
|
default_factory=StereonetTensorConfig
|
|
@@ -1,41 +1,39 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
from apsg.database._sdbsession import (
|
|
4
|
-
|
|
2
|
+
Attached,
|
|
5
3
|
Meta,
|
|
4
|
+
SDBSession,
|
|
6
5
|
Site,
|
|
7
6
|
Structdata,
|
|
8
7
|
Structype,
|
|
9
|
-
Attached,
|
|
10
8
|
Tag,
|
|
11
9
|
Unit,
|
|
12
10
|
)
|
|
11
|
+
from apsg.database._websdbsession import WebSDBSession
|
|
13
12
|
from apsg.database._webtransport import (
|
|
14
13
|
ProjectResolutionError,
|
|
15
14
|
ReadOnlySessionError,
|
|
16
|
-
WebsdbError,
|
|
17
15
|
WebSDBAuthError,
|
|
18
16
|
WebSDBConflictError,
|
|
17
|
+
WebsdbError,
|
|
19
18
|
WebSDBNotFoundError,
|
|
20
19
|
WebSDBPermissionError,
|
|
21
20
|
)
|
|
22
|
-
from apsg.database._websdbsession import WebSDBSession
|
|
23
21
|
|
|
24
22
|
__all__ = (
|
|
25
|
-
"
|
|
23
|
+
"Attached",
|
|
26
24
|
"Meta",
|
|
25
|
+
"ProjectResolutionError",
|
|
26
|
+
"ReadOnlySessionError",
|
|
27
|
+
"SDBSession",
|
|
27
28
|
"Site",
|
|
28
29
|
"Structdata",
|
|
29
30
|
"Structype",
|
|
30
|
-
"Attached",
|
|
31
31
|
"Tag",
|
|
32
32
|
"Unit",
|
|
33
|
-
"WebSDBSession",
|
|
34
|
-
"WebsdbError",
|
|
35
33
|
"WebSDBAuthError",
|
|
34
|
+
"WebSDBConflictError",
|
|
36
35
|
"WebSDBNotFoundError",
|
|
37
36
|
"WebSDBPermissionError",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"ProjectResolutionError",
|
|
37
|
+
"WebSDBSession",
|
|
38
|
+
"WebsdbError",
|
|
41
39
|
)
|
|
@@ -23,8 +23,6 @@ from sqlalchemy.orm import (
|
|
|
23
23
|
class Base(DeclarativeBase):
|
|
24
24
|
"""SQLAlchemy declarative base for all models."""
|
|
25
25
|
|
|
26
|
-
pass
|
|
27
|
-
|
|
28
26
|
|
|
29
27
|
metadata = Base.metadata
|
|
30
28
|
|
|
@@ -40,7 +38,7 @@ class Meta(Base):
|
|
|
40
38
|
|
|
41
39
|
def __repr__(self):
|
|
42
40
|
"""Return string representation of the meta entry."""
|
|
43
|
-
return "Meta:{}={
|
|
41
|
+
return f"Meta:{self.name}={self.value}"
|
|
44
42
|
|
|
45
43
|
|
|
46
44
|
class Site(Base):
|
|
@@ -65,7 +63,7 @@ class Site(Base):
|
|
|
65
63
|
|
|
66
64
|
def __repr__(self):
|
|
67
65
|
"""Return string representation of the site."""
|
|
68
|
-
return "Site:{} ({
|
|
66
|
+
return f"Site:{self.name} ({self.unit.name})"
|
|
69
67
|
|
|
70
68
|
|
|
71
69
|
tagged = Table(
|
|
@@ -109,7 +107,7 @@ class Attached(Base):
|
|
|
109
107
|
|
|
110
108
|
def __repr__(self):
|
|
111
109
|
"""Return string representation of the attachment."""
|
|
112
|
-
return "{} - {
|
|
110
|
+
return f"{self.planar} - {self.linear}"
|
|
113
111
|
|
|
114
112
|
|
|
115
113
|
class Structdata(Base):
|
|
@@ -156,9 +154,7 @@ class Structdata(Base):
|
|
|
156
154
|
|
|
157
155
|
def __repr__(self):
|
|
158
156
|
"""Return string representation of the measurement."""
|
|
159
|
-
return "{}:{:g}/{:g}"
|
|
160
|
-
self.structype.structure, self.azimuth, self.inclination
|
|
161
|
-
)
|
|
157
|
+
return f"{self.structype.structure}:{self.azimuth:g}/{self.inclination:g}"
|
|
162
158
|
|
|
163
159
|
|
|
164
160
|
class Structype(Base):
|
|
@@ -180,7 +176,7 @@ class Structype(Base):
|
|
|
180
176
|
|
|
181
177
|
def __repr__(self):
|
|
182
178
|
"""Return string representation of the structure type."""
|
|
183
|
-
return "Type:{
|
|
179
|
+
return f"Type:{self.structure}"
|
|
184
180
|
|
|
185
181
|
|
|
186
182
|
class Tag(Base):
|
|
@@ -197,7 +193,7 @@ class Tag(Base):
|
|
|
197
193
|
|
|
198
194
|
def __repr__(self):
|
|
199
195
|
"""Return string representation of the tag."""
|
|
200
|
-
return "Tag:{
|
|
196
|
+
return f"Tag:{self.name}"
|
|
201
197
|
|
|
202
198
|
|
|
203
199
|
class Unit(Base):
|
|
@@ -214,4 +210,4 @@ class Unit(Base):
|
|
|
214
210
|
|
|
215
211
|
def __repr__(self):
|
|
216
212
|
"""Return string representation of the unit."""
|
|
217
|
-
return "Unit:{
|
|
213
|
+
return f"Unit:{self.name}"
|
|
@@ -31,15 +31,18 @@ from apsg.feature._container import FaultSet, FoliationSet, LineationSet, PairSe
|
|
|
31
31
|
from apsg.feature._geodata import Fault, Foliation, Lineation, Pair
|
|
32
32
|
from apsg.pandas import FolArray, LinArray, pd
|
|
33
33
|
|
|
34
|
+
# Note: a `structype` argument of the wrong type raises ValueError (not TypeError)
|
|
35
|
+
# for backward compatibility, hence the ``noqa: TRY004`` below.
|
|
36
|
+
|
|
34
37
|
|
|
35
38
|
def default_meta():
|
|
36
|
-
return
|
|
37
|
-
version
|
|
38
|
-
crs
|
|
39
|
-
created
|
|
40
|
-
updated
|
|
41
|
-
accessed
|
|
42
|
-
|
|
39
|
+
return {
|
|
40
|
+
"version": "3.1.0",
|
|
41
|
+
"crs": "EPSG:4326",
|
|
42
|
+
"created": datetime.now().strftime("%d.%m.%Y %H:%M"), # noqa: DTZ005
|
|
43
|
+
"updated": datetime.now().strftime("%d.%m.%Y %H:%M"), # noqa: DTZ005
|
|
44
|
+
"accessed": datetime.now().strftime("%d.%m.%Y %H:%M"), # noqa: DTZ005
|
|
45
|
+
}
|
|
43
46
|
|
|
44
47
|
|
|
45
48
|
def default_initial_values():
|
|
@@ -66,13 +69,13 @@ def default_initial_values():
|
|
|
66
69
|
|
|
67
70
|
def before_commit_meta_update(session):
|
|
68
71
|
u = session.query(Meta).filter_by(name="updated").first()
|
|
69
|
-
u.value = datetime.now().strftime("%d.%m.%Y %H:%M")
|
|
72
|
+
u.value = datetime.now().strftime("%d.%m.%Y %H:%M") # noqa: DTZ005
|
|
70
73
|
|
|
71
74
|
|
|
72
75
|
def before_insert_pos_update(mapper, connection, target):
|
|
73
76
|
if target.pos is None:
|
|
74
77
|
t = str(mapper.persist_selectable)
|
|
75
|
-
query = "SELECT max({}.pos) FROM {}"
|
|
78
|
+
query = f"SELECT max({t}.pos) FROM {t}"
|
|
76
79
|
maxpos = connection.scalar(text(query))
|
|
77
80
|
if maxpos is None:
|
|
78
81
|
maxpos = 1
|
|
@@ -108,7 +111,7 @@ class SDBSession:
|
|
|
108
111
|
raise FileNotFoundError(
|
|
109
112
|
f"SDB database {sdb_file} does not exists. Use `create` kwarg, if you want to create the new one."
|
|
110
113
|
)
|
|
111
|
-
self.sdb_engine = create_engine("sqlite:///{}"
|
|
114
|
+
self.sdb_engine = create_engine(f"sqlite:///{sdb_file}")
|
|
112
115
|
if kwargs.get("create", False):
|
|
113
116
|
metadata.create_all(self.sdb_engine)
|
|
114
117
|
sdb_Session = sessionmaker(bind=self.sdb_engine)
|
|
@@ -568,7 +571,7 @@ class SDBSession:
|
|
|
568
571
|
if isinstance(structype, Structype):
|
|
569
572
|
return self.session.query(Structdata).filter_by(structype=structype).all()
|
|
570
573
|
else:
|
|
571
|
-
raise ValueError("structype argument must be string or Structype")
|
|
574
|
+
raise ValueError("structype argument must be string or Structype") # noqa: TRY004
|
|
572
575
|
|
|
573
576
|
def df(self, structype, **kwargs):
|
|
574
577
|
"""Method to retrieve data from SDB database as ``pandas.DataFrame``.
|
|
@@ -636,12 +639,12 @@ class SDBSession:
|
|
|
636
639
|
.filter_by(**tag)
|
|
637
640
|
.all()
|
|
638
641
|
):
|
|
639
|
-
item =
|
|
640
|
-
site
|
|
641
|
-
x_coord
|
|
642
|
-
y_coord
|
|
643
|
-
unit
|
|
644
|
-
|
|
642
|
+
item = {
|
|
643
|
+
"site": row.site.name,
|
|
644
|
+
"x_coord": row.site.x_coord,
|
|
645
|
+
"y_coord": row.site.y_coord,
|
|
646
|
+
"unit": row.site.unit.name,
|
|
647
|
+
}
|
|
645
648
|
if apsg:
|
|
646
649
|
item[structype.structure] = None
|
|
647
650
|
sdata.append((row.azimuth, row.inclination))
|
|
@@ -667,7 +670,7 @@ class SDBSession:
|
|
|
667
670
|
)
|
|
668
671
|
return df
|
|
669
672
|
else:
|
|
670
|
-
raise ValueError("structype argument must be string or Structype")
|
|
673
|
+
raise ValueError("structype argument must be string or Structype") # noqa: TRY004
|
|
671
674
|
|
|
672
675
|
def getset(self, structype, **kwargs):
|
|
673
676
|
"""Method to retrieve data from SDB database to ``FeatureSet``.
|
|
@@ -754,9 +757,9 @@ class SDBSession:
|
|
|
754
757
|
)
|
|
755
758
|
return res
|
|
756
759
|
else:
|
|
757
|
-
raise ValueError("structype argument must be string or Structype")
|
|
760
|
+
raise ValueError("structype argument must be string or Structype") # noqa: TRY004
|
|
758
761
|
|
|
759
|
-
def getpairs(self, ptype, ltype, site=
|
|
762
|
+
def getpairs(self, ptype, ltype, site=None, unit=None, ptag=None, ltag=None):
|
|
760
763
|
"""Method to retrieve data from SDB database to ``PairSet``.
|
|
761
764
|
|
|
762
765
|
Args:
|
|
@@ -770,6 +773,10 @@ class SDBSession:
|
|
|
770
773
|
ltag (dict): keyword args passed to filter linear tag.
|
|
771
774
|
|
|
772
775
|
"""
|
|
776
|
+
site = {} if site is None else site
|
|
777
|
+
unit = {} if unit is None else unit
|
|
778
|
+
ptag = {} if ptag is None else ptag
|
|
779
|
+
ltag = {} if ltag is None else ltag
|
|
773
780
|
if isinstance(ptype, str):
|
|
774
781
|
dbstruct = self.session.query(Structype).filter_by(structure=ptype).first()
|
|
775
782
|
assert dbstruct is not None, f"There is no structure {ptype} in db."
|
|
@@ -818,9 +825,11 @@ class SDBSession:
|
|
|
818
825
|
res = PairSet(pairs, name=f"{ptype.structure}-{ltype.structure}")
|
|
819
826
|
return res
|
|
820
827
|
else:
|
|
821
|
-
raise ValueError("structype argument must be string or Structype")
|
|
828
|
+
raise ValueError("structype argument must be string or Structype") # noqa: TRY004
|
|
822
829
|
|
|
823
|
-
def getfaults(
|
|
830
|
+
def getfaults(
|
|
831
|
+
self, ptype, ltype, sense, site=None, unit=None, ptag=None, ltag=None
|
|
832
|
+
):
|
|
824
833
|
"""Method to retrieve data from SDB database to ``FaultSet``.
|
|
825
834
|
|
|
826
835
|
Args:
|
|
@@ -836,6 +845,10 @@ class SDBSession:
|
|
|
836
845
|
ltag (dict): keyword args passed to filter linear tag.
|
|
837
846
|
|
|
838
847
|
"""
|
|
848
|
+
site = {} if site is None else site
|
|
849
|
+
unit = {} if unit is None else unit
|
|
850
|
+
ptag = {} if ptag is None else ptag
|
|
851
|
+
ltag = {} if ltag is None else ltag
|
|
839
852
|
if isinstance(ptype, str):
|
|
840
853
|
dbstruct = self.session.query(Structype).filter_by(structure=ptype).first()
|
|
841
854
|
assert dbstruct is not None, f"There is no structure {ptype} in db."
|
|
@@ -885,4 +898,4 @@ class SDBSession:
|
|
|
885
898
|
res = FaultSet(faults, name=f"{ptype.structure}-{ltype.structure}")
|
|
886
899
|
return res
|
|
887
900
|
else:
|
|
888
|
-
raise ValueError("structype argument must be string or Structype")
|
|
901
|
+
raise ValueError("structype argument must be string or Structype") # noqa: TRY004
|
|
@@ -301,19 +301,19 @@ class WebSDBSession:
|
|
|
301
301
|
site = gd["_site"]
|
|
302
302
|
unit_id = rock.get("unit_id")
|
|
303
303
|
structype_id = gd.get("structype_id")
|
|
304
|
-
return
|
|
305
|
-
id
|
|
306
|
-
rock_id
|
|
307
|
-
site_id
|
|
308
|
-
site
|
|
309
|
-
rock
|
|
310
|
-
unit
|
|
311
|
-
structype
|
|
304
|
+
return {
|
|
305
|
+
"id": gd["id"],
|
|
306
|
+
"rock_id": gd["rock_id"],
|
|
307
|
+
"site_id": rock["site_id"],
|
|
308
|
+
"site": site["name"],
|
|
309
|
+
"rock": rock["name"],
|
|
310
|
+
"unit": unit_names.get(unit_id) if unit_id is not None else None,
|
|
311
|
+
"structype": structype_names.get(structype_id)
|
|
312
312
|
if structype_id is not None
|
|
313
313
|
else None,
|
|
314
|
-
tags
|
|
315
|
-
description
|
|
316
|
-
|
|
314
|
+
"tags": list(gd.get("value", {}).get("kwargs", {}).get("tags", [])),
|
|
315
|
+
"description": gd.get("description"),
|
|
316
|
+
}
|
|
317
317
|
|
|
318
318
|
def _name_lookups(self):
|
|
319
319
|
return (
|
|
@@ -514,15 +514,15 @@ class WebSDBSession:
|
|
|
514
514
|
fazi, finc = fol_gd["value"]["args"]
|
|
515
515
|
lazi, linc = lin_gd["value"]["args"]
|
|
516
516
|
rock_row = fol_gd["_rock"]
|
|
517
|
-
attrs =
|
|
518
|
-
fol_id
|
|
519
|
-
lin_id
|
|
520
|
-
rock_id
|
|
521
|
-
site_id
|
|
522
|
-
site
|
|
523
|
-
rock
|
|
524
|
-
unit
|
|
525
|
-
|
|
517
|
+
attrs = {
|
|
518
|
+
"fol_id": fol_gd["id"],
|
|
519
|
+
"lin_id": lin_gd["id"],
|
|
520
|
+
"rock_id": fol_gd["rock_id"],
|
|
521
|
+
"site_id": rock_row["site_id"],
|
|
522
|
+
"site": fol_gd["_site"]["name"],
|
|
523
|
+
"rock": rock_row["name"],
|
|
524
|
+
"unit": unit_names.get(rock_row.get("unit_id")),
|
|
525
|
+
}
|
|
526
526
|
misfit = False
|
|
527
527
|
with warnings.catch_warnings():
|
|
528
528
|
warnings.simplefilter("error")
|
|
@@ -835,15 +835,15 @@ class WebSDBSession:
|
|
|
835
835
|
self._t.request(
|
|
836
836
|
"POST", "/api/geodata/pair", json_body={"geodata_ids": [fol_id, lin_id]}
|
|
837
837
|
)
|
|
838
|
-
attrs =
|
|
839
|
-
fol_id
|
|
840
|
-
lin_id
|
|
841
|
-
rock_id
|
|
842
|
-
site_id
|
|
843
|
-
site
|
|
844
|
-
rock
|
|
845
|
-
unit
|
|
846
|
-
|
|
838
|
+
attrs = {
|
|
839
|
+
"fol_id": fol_id,
|
|
840
|
+
"lin_id": lin_id,
|
|
841
|
+
"rock_id": fol._attrs["rock_id"],
|
|
842
|
+
"site_id": fol._attrs["site_id"],
|
|
843
|
+
"site": fol._attrs["site"],
|
|
844
|
+
"rock": fol._attrs["rock"],
|
|
845
|
+
"unit": fol._attrs["unit"],
|
|
846
|
+
}
|
|
847
847
|
return Pair(fazi, finc, lazi, linc, **attrs)
|
|
848
848
|
|
|
849
849
|
# --- write: update / delete geodata ---
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
import sys
|
|
3
2
|
|
|
4
3
|
from apsg.feature._container import (
|
|
@@ -51,50 +50,50 @@ from apsg.math._matrix import Matrix2, Matrix3
|
|
|
51
50
|
from apsg.math._vector import Axial2, Axial3, Vector2, Vector3
|
|
52
51
|
|
|
53
52
|
__all__ = (
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"Vector2",
|
|
53
|
+
"Arc",
|
|
54
|
+
"ArcSet",
|
|
57
55
|
"Axial2",
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"Direction",
|
|
61
|
-
"Lineation",
|
|
62
|
-
"Foliation",
|
|
63
|
-
"Pair",
|
|
64
|
-
"Fault",
|
|
56
|
+
"Axial3",
|
|
57
|
+
"ClusterSet",
|
|
65
58
|
"Cone",
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"Rotation3",
|
|
69
|
-
"VelocityGradient3",
|
|
70
|
-
"Stress3",
|
|
71
|
-
"Ellipsoid",
|
|
72
|
-
"OrientationTensor3",
|
|
59
|
+
"ConeSet",
|
|
60
|
+
"Core",
|
|
73
61
|
"DeformationGradient2",
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"Stress2",
|
|
77
|
-
"Ellipse",
|
|
78
|
-
"OrientationTensor2",
|
|
79
|
-
"Vector2Set",
|
|
62
|
+
"DeformationGradient3",
|
|
63
|
+
"Direction",
|
|
80
64
|
"Direction2Set",
|
|
81
|
-
"
|
|
82
|
-
"Vector3Set",
|
|
83
|
-
"LineationSet",
|
|
84
|
-
"FoliationSet",
|
|
85
|
-
"PairSet",
|
|
86
|
-
"FaultSet",
|
|
87
|
-
"ConeSet",
|
|
88
|
-
"ArcSet",
|
|
65
|
+
"Ellipse",
|
|
89
66
|
"EllipseSet",
|
|
67
|
+
"Ellipsoid",
|
|
90
68
|
"EllipsoidSet",
|
|
69
|
+
"Fault",
|
|
70
|
+
"FaultSet",
|
|
71
|
+
"FeatureSet",
|
|
72
|
+
"Foliation",
|
|
73
|
+
"FoliationSet",
|
|
74
|
+
"G",
|
|
75
|
+
"Lineation",
|
|
76
|
+
"LineationSet",
|
|
77
|
+
"Matrix2",
|
|
78
|
+
"Matrix3",
|
|
79
|
+
"OrientationTensor2",
|
|
91
80
|
"OrientationTensor2Set",
|
|
81
|
+
"OrientationTensor3",
|
|
92
82
|
"OrientationTensor3Set",
|
|
83
|
+
"Pair",
|
|
84
|
+
"PairSet",
|
|
85
|
+
"Rotation2",
|
|
86
|
+
"Rotation3",
|
|
87
|
+
"Stress2",
|
|
93
88
|
"Stress2Set",
|
|
89
|
+
"Stress3",
|
|
94
90
|
"Stress3Set",
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
91
|
+
"Vector2",
|
|
92
|
+
"Vector2Set",
|
|
93
|
+
"Vector3",
|
|
94
|
+
"Vector3Set",
|
|
95
|
+
"VelocityGradient2",
|
|
96
|
+
"VelocityGradient3",
|
|
98
97
|
)
|
|
99
98
|
|
|
100
99
|
|