Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions src/Basic_Path/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# author: Axel Fischer
# created at: 07.05.2019
# company/institute: sweep-me.net

import os

class Main():

# please define variables and units as returned by the function 'main'
variables = ["Folder", "File name", "File extension", "File exists"]
units = ["", "", "", ""]

# the function 'main' will be loaded as the function that can be seen inside the module
# the arguments of the function tell SweepMe! which kind of data you expect and what are the default values
# SweepMe! will generate the input of the graphical user interface accordingly
def main(
self,
# must the first argument and should not be removed

Path_to_evaluate = (),
# a tuple let you choose from all available SweepMe! values from a ComboBox


): # angry? If you find a bug or need support, please write to [email protected]


'''
<h2>Path evaluation</h2>
returns folder, file name, file extension and whether files exists<br>
'''

existing = os.path.exists(Path_to_evaluate[0])

if existing:

file_name, ext = os.path.splitext(Path_to_evaluate[0])

file_name = os.path.basename(file_name)

folder = os.path.dirname(Path_to_evaluate[0])


else:

folder, file_name, ext = False, False, False


# ... and return your result according to 'variables' and 'units' defined at the beginning of this file
return folder, file_name, ext, existing

15 changes: 15 additions & 0 deletions src/Basic_Print/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# author: Axel Fischer
# created at: 27.04.2019
# company/institute: sweep-me.net


class Main():

def main(self, Data = ()):

'''
<h2>Print</h2>
print the selected data to the Debug console (F2)<br>
'''

print("Print:", Data[0])
72 changes: 72 additions & 0 deletions src/Basic_RegEx/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# author: Axel Fischer
# created at: 27.04.2019
# company/institute: sweep-me.net

import re

class Main():

# please define variables and units as returned by the function 'main'
variables = ["Match"]
units = [""]

# the function 'main' will be loaded as the function that can be seen inside the module
# the arguments of the function tell SweepMe! which kind of data you expect and what are the default values
# SweepMe! will generate the input of the graphical user interface accordingly
def main(
self,
# must the first argument and should not be removed

String_to_evaluate = (),
# a tuple let you choose from all available SweepMe! values from a ComboBox

Search_pattern = "",
# an integer let you insert an integer

#Return_type = ["String", "Integer", "Float"],
# A list of strings let you choose one of the items in a ComboBox

): # angry? If you find a bug or need support, please write to [email protected]


'''
<h2>Regular expression</h2>
Search for a sequence of characters in a string using regular expressions<br>

<h4>Usage:</h4>
Use as 'String_to_evaluate' a variable that contains a string.<br>
Use as 'Search_pattern' a regular expression pattern.<br>
The function returns the first match, otherwise not-a-number (nan).<br>
If possible the result is automatically converted to an integer or a float.<br>
The function is based on the re module of python.
<br>
<h4>Examples:</h4>
The pattern 'W=([-+]?\d+.d+)nm_' finds a positive or negative float in the string "...W=340.12nm_..." and will return '340.0' as float.<br>
The pattern 'W=([-+]?\[0-9]+.[0-9]+)nm_' does the same than the previous example.<br>
The pattern 'W=(\d+)nm_' finds a positive integer in the string "...W=340nm_..." and will return '340' as int.<br>
The pattern '([A-Z])=' finds a capital letter in the string "...W=340nm_..." and will return 'W' as string.<br>
<br>
Further help about regular expressions can be found here:<br>
<a href="https://docs.python.org/3.6/library/re.html">https://docs.python.org/3.6/library/re.html</a>
'''

match = re.search(Search_pattern, str(String_to_evaluate[0]))

try:
result = match.group(1)

try:
result = int(result)
except:
try:
result = float(result)
except:
pass

except:
result = float('nan')


# ... and return your result according to 'variables' and 'units' defined at the beginning of this file
return result

24 changes: 24 additions & 0 deletions src/CreateAnimation/libs/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (c) 2014-2018, imageio developers
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Binary file added src/CreateAnimation/libs/library.zip
Binary file not shown.
46 changes: 46 additions & 0 deletions src/CreateAnimation/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# author: Axel Fischer (sweep-me.net)
# started: 23.01.19

import numpy as np
import os
import pathlib

import FolderManager
FoMa = FolderManager.FolderManager()
FolderManager.addFolderToPATH()

import imageio


# please defines variables and units as returned by the function 'main'
variables = ["Path animation"]
units = [""]

# the function 'main' will be loaded as function
def main(
Pictures = (), # a tuple let you choose SweepMe! values from a ComboBox
Duration = 0.1,
#Format = ["gif", "avi"],

):

# just right at the start of the function, you set the help text which will be displayed as description in the GUI
'''
<h2>Animation</h2>
<br>
create an animation based on a list of files<br>
select a variable that stores paths to image files<br>
'''

tempfolder = FoMa.get_path("TEMP")

images = []
for filename in Pictures:
images.append(imageio.imread(filename))

animation_path = tempfolder + os.sep + "temp_Animation.gif"

imageio.mimsave(animation_path, images, duration = Duration)

return [animation_path]

30 changes: 30 additions & 0 deletions src/Evaluation_Rectification/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# author: Axel Fischer (sweep-me.net)
# started: 29.08.18

import numpy as np
import os
import pathlib
import math

# please defines variables and units as returned by the function 'main'
variables = ["Rectification", ""]
units = ["", ""]

# the function 'main' will be loaded as function
def main(
current = (), # a tuple let you choose SweepMe! values from a ComboBox
voltage = (),
): # angry? If you find a bug or need support for another type, please contact us

# just right at the start of the function, you set the help text which will be displayed as description in the GUI
'''
<h2>Rectification</h2>
'''

# do whatever you want
print("Output of Evaluation example function:")
print("data:", current)

# return values according to 'variables' and 'units' defined at the beginning of this file
return [abs(current.max()/current.min()), ""]

72 changes: 72 additions & 0 deletions src/Evaluation_Statistics/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# author: Axel Fischer ([email protected])
# company/institution: SweepMe! GmbH
# started: 04.10.18
# revised: 25.01.23

import numpy as np


class Main():

"""
<h2>Simple statistics</h2>

calculates
<ul>
<li>mean</li>
<li>standard deviation</li>
<li>median</li>
<li>minimum</li>
<li>maximum</li>
</ul>

of a list of values.

</h3>Parameters</h3>
<ul>
<li>Data: a list or array of values, or single values, e.g int or float
<li>Append: concatenate new values to previous values.</li>
<li>Last points: Only keep the given number of points. If empty, all points are used.</li>
</ul>
"""

variables = ["Mean", "Standard deviation", "Median", "Min", "Max"]
units = ["", "", "", "", ""]
arguments = {
"Data": (),
"Append": False,
"Last points": "",
}

def configure(self):
self.data_all = np.array([])

def main(self, **kwargs):

# Handing over arguments
new_data = kwargs["Data"]
new_data = new_data[np.isfinite(np.array(new_data).flatten())]
use_append = kwargs["Append"]
last_points = kwargs["Last points"].strip()

# Preprocessing data
if last_points == "":
last_points_index = 0 # all points
else:
last_points_index = -int(last_points)

if use_append:
self.data_all = np.concatenate((self.data_all, new_data))
data = self.data_all[last_points_index:]
else:
data = new_data[last_points_index:]

# Statistical evaluation
average = np.mean(data)
std = np.std(data)
median = np.median(data)
minimum = min(data)
maximum = max(data)

return [average, std, median, minimum, maximum]

Loading