-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from cslotboom/customFuncs
Custom funcs
- Loading branch information
Showing
48 changed files
with
219 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
from .defaultDataFuncs import (defaultAreaFunction, defaultSlopeFunction, | ||
defaultSampleFunction, defaultCombineDiff) | ||
|
||
from .defaultPlotFuncs import initializeFig, defaultPlotFunction, defaultShowCycles | ||
|
||
|
||
|
||
# ============================================================================= | ||
# Curve objects | ||
# ============================================================================= | ||
|
||
|
||
|
||
class HYSTERESIS_ENVIRONMENT: | ||
|
||
def __init__(self): | ||
""" | ||
Contains the standard functions needed by the hysteresis analysis. | ||
""" | ||
|
||
self.fslope = defaultSlopeFunction | ||
self.fArea = defaultAreaFunction | ||
|
||
self.finit = initializeFig | ||
self.fplot = defaultPlotFunction | ||
self.fcycles = defaultShowCycles | ||
|
||
self.fSample = defaultSampleFunction | ||
self.fCombineDiff = defaultCombineDiff | ||
|
||
|
||
def restart(self): | ||
self.__init__() | ||
|
||
|
||
environment = HYSTERESIS_ENVIRONMENT() | ||
# environment.restart() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
""" | ||
An example of very basic usage of the hysteresis package. | ||
""" | ||
|
||
|
||
import numpy as np | ||
import hysteresis as hys | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
An example of very basic usage of the hysteresis package. | ||
|
||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1 align = "Left">Damper 'Clean' Data Example.</h1> | ||
|
||
An example of analyzing data from a siesmic damper. | ||
The data from this study is very clean, and little manual effort is needed to accurately find the propreties of the dampers. | ||
|
||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1 align = "Left">Wall 'Messy' Data Example.</h1> | ||
|
||
An more complex example analyzing data from a shear wall. | ||
The data from this study is very messy, and manual effort is needed to accurately find the propreties of the dampers. | ||
|
||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<h1 align = "Left">Curve fitting example.</h1> | ||
|
||
An example of finding the backbone curve for data from a siesmic damper. | ||
OpenSees is used to generate input data for the damper. | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1 align = "Left">Custom Functions.</h1> | ||
|
||
An example of how to overwrite the default hysteresis functions with custom functions. | ||
In this example the slope function is changed so that it always returns one. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Many of the Hysteresis default functions can be overwritten by assigning | ||
a new function to the environment object, located at | ||
hys.env.environment | ||
In this example, this feature is showcased by implementing a custom slope | ||
function. | ||
""" | ||
import hysteresis as hys | ||
import numpy as np | ||
|
||
# ============================================================================= | ||
# Input Data | ||
# ============================================================================= | ||
# We create a set of input xy data using numpy, create a hysteresis, then | ||
# plot a figure of our object. | ||
|
||
x = np.linspace(0,3,301) | ||
y = x**3 + x**2 + 2 | ||
xy = np.column_stack((x,y)) | ||
myHys = hys.Hysteresis(xy) | ||
|
||
fig, ax = myHys.initFig() | ||
myHys.plot() | ||
myHys.plotSlope() | ||
ax.set_title('Default slope Function') | ||
|
||
# ============================================================================= | ||
# Define a custom function | ||
# ============================================================================= | ||
|
||
|
||
# define a custom slope function - it makes the slope always 1. | ||
def fslope(xy): | ||
slope = np.ones_like(xy[:,0]) | ||
return slope | ||
|
||
# Overwrite the slope function in the environment. | ||
hys.env.environment.fslope = fslope | ||
|
||
# Plot to show it's worked | ||
myHys = hys.Hysteresis(xy) | ||
fig, ax = myHys.initFig() | ||
myHys.plot() | ||
myHys.plotSlope() | ||
|
||
|
||
# If we want the behaviour to return to normal, restart the environment. | ||
hys.env.environment.restart() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<h1 align = "Left">Examples.</h1> | ||
|
||
|
||
In the following is a list of examples showing how the hysteresis package can be used. | ||
The examples include: | ||
|
||
* 01 Demo: a basic demonstration of creating a hysteresis object. | ||
* 02 Damper: an example working with 'clean' input data from a siesmic damper. | ||
* 03 Wall: an example working with 'messy' data from a shear wall damper. | ||
* 04 Envelope: an example fitting a backbone to a cyclic hysteresis. | ||
* 05 CustomFunctions: an example of how to overwrite the default hysteresis functions. | ||
|
||
|
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
from .defaultDataFuncs import (defaultAreaFunction, defaultSlopeFunction, | ||
defaultSampleFunction, defaultCombineDiff) | ||
|
||
from .defaultPlotFuncs import initializeFig, defaultPlotFunction, defaultShowCycles | ||
|
||
|
||
|
||
# ============================================================================= | ||
# Curve objects | ||
# ============================================================================= | ||
|
||
|
||
|
||
class HYSTERESIS_ENVIRONMENT: | ||
|
||
def __init__(self): | ||
""" | ||
Contains the standard functions needed by the hysteresis analysis. | ||
""" | ||
|
||
self.fslope = defaultSlopeFunction | ||
self.fArea = defaultAreaFunction | ||
|
||
self.finit = initializeFig | ||
self.fplot = defaultPlotFunction | ||
self.fcycles = defaultShowCycles | ||
|
||
self.fSample = defaultSampleFunction | ||
self.fCombineDiff = defaultCombineDiff | ||
|
||
|
||
def restart(self): | ||
self.__init__() | ||
|
||
|
||
environment = HYSTERESIS_ENVIRONMENT() | ||
# environment.restart() |