-
Nick Draper authored
Update copyright headers in all files Squashed commit of the following: * First version of a script to manage copyright statements re #23468 * Neatened up script, added comments re #23488 * move script to tools directory re #23488 * small script changes and a couple of manual file changes re #23488 * Minor chnage to whitespace detection in regex re #23488 * Add an excluded directory re #23488 * remove a repeasted copyright statement in a file re #23488 * Don't comsume the comment end if it is on the same line re #23488 * fix error in new copright parsing re #23488 * remove double copyrifght entry re #23488 * Improve handling of old copyrights at the start of comments re #23488 * remove empty comments re #23488 * exclude gsoapgenerated directories re #23488 * Sort out greedy line matching re #23488 * improve empty comment removal re #23488 * improve false positives re #23488 * impressive speedup by limiting regex matching length re #23488 * remove evil invisible non ascii character Also upadte the copyright at the same time re #23488 * resolve multiple copyrights in a single file re #23488 * resolve an issue with new statement detection re #23488 * another unprintable unicode character re #23488 * pep updates and cmake the new copyright fit clang format re #23488 * update already done new format headers re #23488 * wrong type of bracket re #23488 * Update class_maker and friends re #23488 * Update all copyright statements re #23488 * clang format re #23488 * flake8 warnings re #23488 * Flake8 warnings re #23488 * Exclude .cmake.in and rb.in files re #23488 * replace missing line re #23488 * exclude .py.in files as they are flasely recognized as C++ re #23488 * another setp.py.in re #23488 * another .py.in correction re #23488 * Hopefully the last of the .py.in files re #23488 * resolve utf-8 encoding of python files and changed ABINS checksum re #23488 * updates to unit tests that reference line numbers re #23488 * remaining unit test files and other fixes re #23488
Nick Draper authoredUpdate copyright headers in all files Squashed commit of the following: * First version of a script to manage copyright statements re #23468 * Neatened up script, added comments re #23488 * move script to tools directory re #23488 * small script changes and a couple of manual file changes re #23488 * Minor chnage to whitespace detection in regex re #23488 * Add an excluded directory re #23488 * remove a repeasted copyright statement in a file re #23488 * Don't comsume the comment end if it is on the same line re #23488 * fix error in new copright parsing re #23488 * remove double copyrifght entry re #23488 * Improve handling of old copyrights at the start of comments re #23488 * remove empty comments re #23488 * exclude gsoapgenerated directories re #23488 * Sort out greedy line matching re #23488 * improve empty comment removal re #23488 * improve false positives re #23488 * impressive speedup by limiting regex matching length re #23488 * remove evil invisible non ascii character Also upadte the copyright at the same time re #23488 * resolve multiple copyrights in a single file re #23488 * resolve an issue with new statement detection re #23488 * another unprintable unicode character re #23488 * pep updates and cmake the new copyright fit clang format re #23488 * update already done new format headers re #23488 * wrong type of bracket re #23488 * Update class_maker and friends re #23488 * Update all copyright statements re #23488 * clang format re #23488 * flake8 warnings re #23488 * Flake8 warnings re #23488 * Exclude .cmake.in and rb.in files re #23488 * replace missing line re #23488 * exclude .py.in files as they are flasely recognized as C++ re #23488 * another setp.py.in re #23488 * another .py.in correction re #23488 * Hopefully the last of the .py.in files re #23488 * resolve utf-8 encoding of python files and changed ABINS checksum re #23488 * updates to unit tests that reference line numbers re #23488 * remaining unit test files and other fixes re #23488
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
SliceViewAnimator.py 2.85 KiB
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source
# & Institut Laue - Langevin
# SPDX - License - Identifier: GPL - 3.0 +
#pylint: disable=too-many-arguments
from __future__ import (absolute_import, division, print_function)
import numpy
from wand.image import Image
from wand.drawing import Drawing
from wand.color import Color
from PyQt4.QtCore import QByteArray, QBuffer
def animate_slice(sliceviewer, name, start, end, filename, num_frames=10, font_size=24):
"""Generate an animated gif of a 2D slice moving through a third dimension.
Args:
sliceviewer (SliceViewer): A sliceviewer instance.
name (str): The name of the third dimension to use.
start (float): The starting value of the third dimension.
end (float): The end value of the third dimension.
filename (str): The file to save the gif to.
Kwargs:
num_frames (int): The number of frames the gif should contain.
font_size: (int): The size of the caption.
Example:
ws = CreateMDWorkspace(3, Extents=[-10,10,-10,10,-10,10], Names=["X","Y","Z"], Units=["u","u","u"])
FakeMDEventData(ws, PeakParams=[10000,0,0,0,1])
sv = plotSlice(ws)
#Resize and configure the slice viewer how you want the output to look
sv.setNormalization(1) # We need to normalize by volume in this case, or the data won't show up
#This will create a gif iterating from Z = -1 to Z = 1
animate_slice(sv, "Z", -1, 1, "output.gif")
"""
#Generate all the individual frames
images = []
for slice_point in numpy.linspace(start, end, num_frames):
sliceviewer.setSlicePoint(name, slice_point)
sliceviewer.refreshRebin()
qimg = sliceviewer.getImage().toImage()
data = QByteArray()
buf = QBuffer(data)
qimg.save(buf, "PNG")
image = Image(blob=str(data))
captionstrip_size = font_size + 10
#To add whitespace to the top, we add a vertical border,
#then crop out the bottom border
image.border(Color("#fff"), 0, captionstrip_size)
image.crop(0, 0, image.width, image.height - captionstrip_size)
#Write the caption into the whitespace
draw = Drawing()
draw.font_size = font_size
draw.text(5, font_size,"%s = %g" % (name,slice_point))
draw(image)
images.append(image)
#Create a new image with the right dimensions
animation = Image(width=images[0].width, height=images[0].height)
#Copy in the frames from all the generated images
for image in images:
animation.sequence.append(image.sequence[0])
#Drop the initial blank frame
del animation.sequence[0]
#Write the animation to disk
animation.save(filename=filename)