ondrolexa / apsg Goto Github PK
View Code? Open in Web Editor NEWStructural geology package for Python
Home Page: https://apsg.readthedocs.io
License: Other
Structural geology package for Python
Home Page: https://apsg.readthedocs.io
License: Other
It's possible to, somehow, get the resulting parameters/centroids/density values from a density contour analysis/plot for a set of poles?
I'm guessing it uses Kamb.
this is my code that plots normal Rose Diagram using PDF method:
import pandas as pd
from apsg import *
from apsg.feature import Vector2Set as vec2set
from apsg.helpers._notation import *
from apsg.plotting._roseplot import *
##### ROSE DIAGRAM ######
# read data from CSV file
df = pd.read_csv('../test-stereonet-anticline1.csv')
# create a list of 2D vectors from the data
vectors2 = [vec2((sind(x - 90) * cosd(y)), (cosd(x + 90) * cosd(y))) for x, y in zip(df['DipD'], df['Dip'])]
# create a Vector2Set object from the list of vectors
vs1 = vec2set(vectors2)
p = RosePlot(grid=True, title='Test Rose Diagram',
bins=36, axial=True,
density=True, kappa=250,
scaled=False, ticks=True,
arrowness=0.95, rwidth=1,
pdf_res=1000, cmap="jet")
p.pdf(vs1, fc='White', ec='Blue', ls="-", lw=1, legend=True)
p.show()
the output is like the first photo that is drawn in Blue
and a second code that does plot each shape individually using this code:
import pandas as pd
from apsg import *
from apsg.feature import Vector2Set as vec2set
from apsg.helpers._notation import *
from apsg.plotting._roseplot import *
from sklearn.cluster import KMeans
##### ROSE DIAGRAM ######
# read data from CSV file
df = pd.read_csv('../test-stereonet-anticline1.csv')
# Add k-means clustering
clust = 5
kmeans = KMeans(n_clusters=clust, n_init="auto", random_state=0)
kmeans.fit(df)
centers = kmeans.cluster_centers_
SD = [(centers[i][0], centers[i][1]) for i in range(clust)]
colors = ['red', 'green', 'blue', 'orange', 'purple']
p = RosePlot(grid=True, title='Test Rose Diagram',
bins=36, axial=True,
density=True, kappa=250,
scaled=False, ticks=False,
arrowness=0, rwidth=1,
pdf_res=1000)
for i, center in enumerate(SD):
vectors = []
vector2 = [vec2((sind(center[0] - 90) * cosd(center[1])), (cosd(center[0] + 90) * cosd(center[1])))]
vectors.extend(vector2)
vs = vec2set(vectors)
p.pdf(vs, fc='White', ec=colors[i], ls="-", lw=1, label=f'Cluster {i+1}')
p.show()
and the output is the second photo that has different colors:
Here is the Issuse
I want those shapes completely separated so that i can set each one a new color meanwhile i want them to be scaled just like the first one.
and Idea on how to integrate this?
My input data is some folded beddings in righ hand rule format (ignore the header please) and it's it attached as well.
Regards
Nima
Structural geology package for Python
Hi @ondrolexa
I am currently trying to split the Structure Name into it's separated groups but have no success. Would you be able to suggest a solution?
Depth | Structure Name | Dip | Dip Direction (TN) | Comments |
---|---|---|---|---|
562.67 | Magnetite Vein | 77.88 | 290.55 | NaN |
614.34 | Magnetite Vein | 52.68 | 67.55 | NaN |
743.80 | Magnetite Vein | 59.10 | 18.98 | NaN |
s=StereoNet()
test_list=[]
for i in vein_names:
for index in range(len(vein_names)):
vein_df = []
test =sg_data.loc[sg_data['Structure Name'] == i]
test
sg_vein = Group.from_array(azis = test['Dip Direction (TN)'],
incs = test['Dip'],
typ=Fol ,
name=i)
s.pole(sg_vein,label= i)
s.pole(sg_vein,label= i)
s.contourf(sg_vein, 20, legend=True, sigma=2)
s.show()
Hi!
I sought to pull data from an rs3 file to perform further computations by using the from_rs3 class method. In this rs3 file, values for 'BDec' and 'BInc' are not specified.
Here's the code I used:
from apsg.feature import Core
rs3path = '/content/drive/MyDrive/paleomagnetism/2-1.rs3'
rs3core = Core.from_rs3(rs3path)
rs3core.datatable()
Upon running my code, an AttributeError pops up, stating that "AttributeError: 'NoneType' object has no attribute 'dd' ".
And the full error message can be seen below:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-53bbc95bbeba> in <cell line: 4>()
2 rs3path = '/content/drive/MyDrive/paleomagnetism/2-1.rs3'
3 rs3core = Core.from_rs3(rs3path)
----> 4 rs3core.datatable()
1 frames
/usr/local/lib/python3.10/dist-packages/apsg/feature/_paleomag.py in tilt(self)
400 """Returns ``Vector3Set`` of vectors in tilt‐corrected coordinates system"""
401 return self.geo.rotate(
--> 402 Lineation(self.bedding.dd[0] - 90, 0), -self.bedding.dd[1]
403 )
404
AttributeError: 'NoneType' object has no attribute 'dd'
Hence, I modified the code as follows:
from apsg import fol
from apsg.feature import Core
rs3path = '/content/drive/MyDrive/paleomagnetism/2-1.rs3'
rs3core = Core.from_rs3(rs3path)
rs3core.bedding = fol(0,0)
rs3core.datatable()
However, this time, an AttributeError arises again, stating that "AttributeError: 'Foliation' object has no attribute 'dd' ".
And here is the full error message produced by running the modified code as follows:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-4-2849371bd677> in <cell line: 6>()
4 rs3core = Core.from_rs3(rs3path)
5 rs3core.bedding = fol(0,0)
----> 6 rs3core.datatable()
1 frames
/usr/local/lib/python3.10/dist-packages/apsg/feature/_paleomag.py in tilt(self)
400 """Returns ``Vector3Set`` of vectors in tilt‐corrected coordinates system"""
401 return self.geo.rotate(
--> 402 Lineation(self.bedding.dd[0] - 90, 0), -self.bedding.dd[1]
403 )
404
AttributeError: 'Foliation' object has no attribute 'dd'
Could you provide some advice on how to solve this? Your assistance would be greatly appreciated.
Hello Again,
I wonder if there is any way to plot focal mechanism using APSG lib, It can simply be done by OBSPY by giving Strike, Dip, Rake but have focal mechanism meanwhile PTB Axis and other statistical methods wil be great.
If not i would be happy to help implementing that,
Regards
Use the master
branch as the main development branch. Using a develop
branch complicates the development process. When you use the develop
branch all the hot-fixes have to be merged back from master
to develop
. There is also no project activity visible to the repository visitors (potential contributors) unless we merge the develop
back to master
, which happens not so often. At least merging to the master
force us to be more critical when we write or review a new code.
Hi, Ondrej
I can't run following example from the tutorial:
g1 = Group.randn_lin(mean=Lin(45, 30))
g2 = Group.randn_lin(mean=Lin(320, 56))
g3 = Group.randn_lin(mean=Lin(150, 40))
g = g1 + g2 + g3
cl = Cluster(g) # <==== error
cl.dendrogram(no_labels=True)
traceback:
AttributeError Traceback (most recent call last)
<ipython-input-14-90e135d9136a> in <module>()
----> 1 import codecs, os;__pyfile = codecs.open('''/tmp/py32407pTR''', encoding='''utf-8''');__code = __pyfile.read().encode('''utf-8''');__pyfile.close();os.remove('''/tmp/py32407pTR''');exec(compile(__code, '''/home/jw/work/apsg_tutorial.py''', 'exec'));
/home/jw/work/apsg_tutorial.py in <module>()
----> 1 # APSG defines several new python classes to easily manage, analyze and
2 # visualize orientation structural geology data.Base class Vec3 is derived from
3 # numpy.array class and offers several new method which will be explained in
4 # following examples
5
/home/jw/.virtualenvs/scienv/lib/python2.7/site-packages/apsg/core.pyc in __init__(self, d, **kwargs)
2069 def __init__(self, d, **kwargs):
2070 assert isinstance(d, Group), 'Only group could be clustered'
-> 2071 self.data = Group(d.copy())
2072 self.maxclust = kwargs.get('maxclust', 2)
2073 self.angle = kwargs.get('angle', None)
/home/jw/.virtualenvs/scienv/lib/python2.7/site-packages/apsg/core.pyc in copy(self)
856
857 def copy(self):
--> 858 return Group(super(Group, self).copy(), self.name)
859
860 @property
AttributeError: 'super' object has no attribute 'copy'
System
Linux Mint 18.3
Python 2.7.12
scipy==1.0.1
numpy==1.14.2
matplotlib==2.2.2
apsg==0.5.1
Will there be Polar plotting of stereonets added in the near future?
Doctest or Pytest module can check examples in comments as they are valid Python code.
We can keep examples up to date with tutorial.
Write tests for IPython notebooks to be sure that they are always evaluated and synchronized with the code base.
We can use this plugin: https://github.com/computationalmodelling/nbval
Hello Ondrej,
Is it possible to add right hand rule notation to the StereoNet class? I plotted some data and now I can't change the notation displayed in the legend.
Hi!
I'm trying to plot a large number of poles from a list where each one has a different color, all of them in another list, however, i'm getting an error that the list of colors "is not a valid value for color". The code i'm trying is:
color_list = [list_of_colors]
g = [list_of_poles]
s.pole(g,color=color_list,ms=7)
And i get the error color_list is not a valid value for color
I can do, alternatively:
s.pole(g[i],color=color_list[i],ms=7) for i in range(len(g))
And works perfect, but it takes waaay longer. I'm guessing i'm missing something in the color input format to make it take a list. Any advice?
Hello!
Sorry if this is not the proper section for questions, but i wanted to ask.. it's possible to calculate the safety factor of a wedge failure planes and the corresponding slope using apsg?
Thanks in advance!
Create a new math/physics abstractions with the following classes:
Vector
Matrix
Tensor
The goal is to clean up and speed up the implementation of these basic mathematical objects.
Numpy and Pandas will drop the support for Python 2.
Pandas: Starting January 1, 2019, pandas feature releases will support Python 3 only. See Plan for dropping Python 2.7 for more.
Numpy: Starting on January 1, 2019, any new feature releases will support only Python3.
If we will remove the Python 2 support wen can use more Python 3 features as typing annotations and dataclasses (new in 3.7).
Hi!
When i add a column of points/planes to a pandas dataframe, they are not shown when printing the dataframe in the "compact" format they usually have when you single print them but rather as an array of points (example in the picture below).
Is there any way to "force" pandas to show the lines/planes in that compact 'dipdir/dip' format in the dataframes?
It would be nice to manage dependencies via pipenv instead of requirements.txt files. The reason is that you have automatic virtualenv management, deterministic install/uninstall of dependencies and so on.
https://docs.pipenv.org/
(... I thing this is a package or library: "Structural geology module
for Python". ?)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.