Skip to content
Snippets Groups Projects
Commit 534e2ac8 authored by Christian Schrader's avatar Christian Schrader
Browse files

Initial commit.

Splitted original collection into this and https://gitlab1.ptb.de/CSchrader/ttlmk
parents
No related branches found
No related tags found
No related merge requests found
# use glob syntax.
syntax: glob
# Compiled python modules.
*.pyc
*~
Thumbs.db
# Setuptools distribution folder.
*doc/build/
/dist
/build
# Python egg metadata, regenerated from source files by setuptools.
/*.egg-info
/*.egg
# switch to regexp syntax.
#syntax: regexp
#^\.pc/
Hilfs-Module
------------
fit_common.py
* Zum Fitten einiger einfacher Regelgeometrien in Punktwolken. War nur mal zum Testen gedacht...
lmk_picture.py moved to own package https://gitlab1.ptb.de/CSchrader/ttlmk
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 24 13:04:53 2015
@author: schrad05
"""
from __future__ import division
# import os
# import sys
# import time
# import gzip, bz2
import numpy as np
# import ConfigParser
from scipy.optimize import leastsq
# from numpy.linalg import norm
# from scipy import ndimage
# import matplotlib.pyplot as plt
# import matplotlib as mpl
# mpl.rcParams['image.interpolation'] = 'none'
# import enthought.mayavi.mlab as mlab
# TODO: Geometrieprimitive definieren und diese zurückgeben, keine einfachen Arrays
# positionsabhängiger Bedeutung
# z.,B.
class Circle:
def __init__(self, x=0., y=0., r=1.):
self.x = x
self.y = y
self.r = r
def __array__(self):
return np.array([self.x, self.y, self.r])
def __repr__(self):
return "Circle(x={:f}, y={:f}, r={:f})".format(self.x, self.y, self.r)
class Sphere:
def __init__(self, *args, **kwargs):
print("ARGS", args)
self.x = args[0]
self.y = args[1]
self.z = args[2]
self.r = args[3]
def __array__(self):
return np.array([self.x, self.y, self.z, self.r])
def __repr__(self):
print("X", repr(self.x))
print("Y", repr(self.y))
print("Z", repr(self.z))
print("R", repr(self.r))
return "Sphere(x={:f}, y={:f}, z={:f}, r={:f})".format(self.x, self.y, self.z, self.r)
class Fit():
def res_circle2D(self, param, x, y):
xm,ym,r = param
return np.sqrt((xm-x)**2 + (ym-y)**2) - r
def res_sphere(self, param, x,y,z):
xm, ym, zm, r = param
return np.sqrt((xm-x)**2 + (ym-y)**2 + (zm-z)**2 ) - r
# evtl. kwargs für fitparameter
def fit_circle2D(self, x,y=None):
x = np.array(x)
if len(x.shape) == 2:
y = x[:,1]
x = x[:,0]
else:
y = np.array(y)
x_m = np.mean(x)
y_m = np.mean(y)
r0 = (np.max(x) - np.min(x) + np.max(y) - np.min(y))/2.0
fitRes = leastsq(self.res_circle2D, (x_m, y_m, r0), args=(x,y), full_output=1, )
return Circle(fitRes[0])
# noch nicht getestet
def fit_sphere(self, x,y=None, z=None):
x = np.array(x)
if len(x.shape) == 3:
z = x[:,2]
y = x[:,1]
x = x[:,0]
else:
y = np.array(y)
z = np.array(z)
x_m = np.mean(x)
y_m = np.mean(y)
z_m = np.mean(z)
r0 = ( np.max(x) - np.min(x) +
np.max(y) - np.min(y) +
np.max(z) - np.min(z) )/3.0
fitRes = leastsq(self.res_sphere, (x_m, y_m, z_m, r0), args=(x, y, z), full_output=1, )
return fitRes[0]
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = "misc_helper"
version = "0.1.1"
authors = [
{ name="Christian Schrader", email="christian.schrader@ptb.de" },
]
description = "Miscellaneous Helper Modules"
readme = "README.md"
requires-python = ">=3.3"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
]
dependencies = [
"numpy",
]
[tool.setuptools]
packages = ["misc_helper"]
# By default, include-package-data is true in pyproject.toml, so you do
# NOT have to specify this line.
# include-package-data = true
# changes in the package data require to delete bts256.egg-info/SOURCES.txt
# because this caches old selections!
# [tool.setuptools.package-data]
# "misc_helper" = ["./foo*/*"]
# [tool.setuptools.exclude-package-data]
# "bts256" = ["secredpassword"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment