Git Product home page Git Product logo

apsg's Introduction

APSG logo

PyPI - Version Conda Documentation Status DOI

What is APSG?

APSG is the package for structural geologists. It defines several new python classes to easily manage, analyze and visualize orientational structural geology data.

Major changes in class names and API from version 1.0.0

APSG has been significantly refactored from version 1.0 and several changes are breaking backward compatibility. The main APSG namespace provides often-used classes in lowercase names as aliases to PascalCase convention used in modules to provide a simplified interface for users. The PascalCase names of classes use longer and plain English names instead acronyms for better readability.

Check documentation for more details.

Requirements

You need Python 3.8 or later to run APSG. The package requires NumPy and SciPy, and Matplotlib.

Quick start

APSG can be installed using pip:

pip install apsg

If you want to run the latest version of the code, you can install it from git:

pip install git+https://github.com/ondrolexa/apsg.git

Alternatively, you can download the package manually from the GitHub repository https://github.com/ondrolexa/apsg, unzip it, navigate into the package, and use the command:

python setup.py install

or

pip install .

Upgrading via pip

To upgrade an existing version of APSG from PyPI, execute

pip install apsg --upgrade --no-deps

Please note that the dependencies (Matplotlib, NumPy and SciPy) will also be upgraded if you omit the --no-deps flag; use the --no-deps ("no dependencies") flag if you don't want this.

Conda

The APSG package is also available on conda-forge channel.

Current release info

Name Downloads Version Platforms
Conda Recipe Conda Downloads Conda Version Conda Platforms

Installing apsg

Installing apsg from the conda-forge channel can be achieved by adding conda-forge to your channels with:

conda config --add channels conda-forge

Once the conda-forge channel has been enabled, apsg can be installed with:

conda install apsg

It is possible to list all of the versions of apsg available on your platform with:

conda search apsg --channel conda-forge

Documentation

Explore the full features of APSG. You can find detailed documentation here.

Contributing

Most discussion happens on Github. Feel free to open an issue or comment on any open issue or pull request. Check CONTRIBUTING.md for more details.

Donate

APSG is an open-source project, available for you for free. It took a lot of time and resources to build this software. If you find this software useful and want to support its future development please consider donating me.

Donate via PayPal

License

APSG is free software: you can redistribute it and/or modify it under the terms of the MIT License. A copy of this license is provided in LICENSE file.

apsg's People

Contributors

4e1e0603 avatar dependabot[bot] avatar ondrolexa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apsg's Issues

Create a new math/physics abstraction

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.

Question about the poles color

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?

Use the `master` as the main development branch

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.

Help

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()

AttributeError

I have a problem when I use this library. I want to see the stereonet diagram but there is an error when I run the program (the error is seen in the image). Please, can someone help me with this problem?
error 4
thanks!

Wrong plot while using RHR instead of DD

from apsg import *
from apsg.config import apsg_conf
apsg_conf.update(notation='rhr')
s = StereoNet(overlay_step=10, kind='Equal-angle')
f1 = fol(12, 50)
s.great_circle(f1)
s.show()

Wulff_net

Safety Factor

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!

Errors "object has no attribute 'dd'" occur when trying to tabulate data from an rs3 file that omits 'BDec' and 'BInc' values

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.

Rose Diagram with separated Shapes in PDF method.

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
Rose_diagram1

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:
Rose_diagram

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.

test-stereonet-anticline1.csv

Regards
Nima

Focal Mechanism

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 pipenv instead of requirements.txt

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". ?)

Remove support for Python 2

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).

Cluster class error

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

Question about poles/planes in a pandas df column

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?

image

Question about contour plots

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.