Skip to content

Commit 64679ce

Browse files
committed
Release 0.7b2 having fixed breakages from mixin re-ordering
1 parent 8202a3a commit 64679ce

9 files changed

Lines changed: 32 additions & 29 deletions

File tree

Stoner/Analysis.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ def action(i,column,row):
15731573
action(i, column, self.data[i])
15741574
return self
15751575

1576-
def peaks(self, ycol=None, width=None, significance=None, xcol=None, peaks=True, troughs=False, poly=2, sort=False,modify=False):
1576+
def peaks(self, ycol=None, width=None, significance=None, xcol=None, peaks=True, troughs=False, poly=2, sort=False,modify=False,full_data=True):
15771577
"""Locates peaks and/or troughs in a column of data by using SG-differentiation.
15781578
15791579
Args:
@@ -1592,6 +1592,8 @@ def peaks(self, ycol=None, width=None, significance=None, xcol=None, peaks=True,
15921592
troughs (bool): select whether to measure troughs in data (default False)
15931593
sort (bool): Sor the results by significance of peak
15941594
modify (book): If true, then the returned object is a copy of self with only the peaks/troughs left in the data.
1595+
full_data (bool): If True (default) then all columns of the data at which peaks in the *ycol* column are found. *modify* true implies
1596+
*full_data* is also true. If *full_data* is False, then only the x-column values of the peaks are returned.
15951597
15961598
Returns:
15971599
If *modify* is true, then returns a the AnalysisMixin with the data set to just the peaks/troughs. If *modify* is false (default),
@@ -1604,7 +1606,9 @@ def peaks(self, ycol=None, width=None, significance=None, xcol=None, peaks=True,
16041606
"""
16051607

16061608
_=self._col_args(scalar=False,xcol=xcol,ycol=ycol)
1607-
xcol,ycol=_.xcol,_.ycol[0]
1609+
xcol,ycol=_.xcol,_.ycol
1610+
if isinstance(ycol,Iterable):
1611+
ycol=ycol[0]
16081612
if width is None: # Set Width to be length of data/20
16091613
width = len(self) / 20
16101614
assert poly >= 2, "poly must be at least 2nd order in peaks for checking for significance of peak or trough"
@@ -1624,20 +1628,13 @@ def peaks(self, ycol=None, width=None, significance=None, xcol=None, peaks=True,
16241628
elif isinstance(significance, int): # integer significance is inverse to floating
16251629
significance = _np_.max(_np_.abs(d2))/significance # Base an apriori significance on max d2y/dx2 / 20
16261630

1627-
i = _np_.arange(len(self))
16281631
d2_interp = interp1d(_np_.arange(len(d2)), d2,kind='cubic')
16291632
# Ensure we have some X-data
1630-
if xcol == None:
1631-
full_data=True
1632-
xdata = i
1633-
1634-
elif isinstance(xcol,bool) and not xcol:
1635-
full_data=False
1636-
xdata = i
1633+
if xcol is None:
1634+
xdata = _np_.arange(len(self))
16371635
else:
1638-
full_data=False
16391636
xdata = self.column(xcol)
1640-
xdata = interp1d(i, xdata,kind="cubic")
1637+
xdata = interp1d(_np_.arange(len(self)), xdata,kind="cubic")
16411638

16421639

16431640
possible_peaks = _np_.array(_threshold(0, d1, rising=troughs, falling=peaks))
@@ -1657,9 +1654,8 @@ def peaks(self, ycol=None, width=None, significance=None, xcol=None, peaks=True,
16571654
elif full_data:
16581655
ret=self.interpolate(xdat,kind="cubic",xcol=False)
16591656
else:
1660-
ret=xdata(possible_peaks+index_offset)
1657+
ret=xdat
16611658
self.setas=setas
1662-
print(setas)
16631659
# Return - but remembering to add back on the offset that we took off due to differentials not working at start and end
16641660
return ret
16651661

Stoner/Core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,8 @@ def __new__(cls, input_array, *args,**kargs):
10671067
# Finally, we must return the newly created object:
10681068
obj.i=i
10691069
obj.setas._row=_row and len(obj.shape)==1
1070+
#Set shared mask - stops some deprication warnings
1071+
obj._shared_mask=True
10701072
return obj
10711073

10721074
def __array_finalize__(self, obj):
@@ -1401,6 +1403,7 @@ class DataFile(metadataObject):
14011403
already saved to disc. This is the default filename used by the :py:meth:`Stoner.Core.DataFile.load`
14021404
and :py:meth:`Stoner.Core.DataFile.save`.
14031405
mask (array of booleans): Returns the current mask applied to the numerical data equivalent to self.data.mask.
1406+
mime_type (list of str): The possible mime-types of data files represented by each matching filename pattern in :py:attr:`Datafile.pattern`.
14041407
patterns (list): A list of filename extenion glob patterns that matrches the expected filename patterns for a DataFile (*.txt and *.dat")
14051408
priority (int): Used to indicathe order in which subclasses of :py:class:`DataFile` are tried when loading data. A higher number means a lower
14061409
priority (!)
@@ -1413,7 +1416,7 @@ class DataFile(metadataObject):
14131416
dtype (numpoy dtype): Returns the datatype stored in the :py:attr:`DataFile.data` attribute.
14141417
T (:py:class:`DataArray`): Transposed version of the data.
14151418
subclasses (list): Returns a list of all the subclasses of DataFile currently in memory, sorted by
1416-
their py:attr:`Stoner.Core.DataFile.priority. Each entry in the list consists of the
1419+
their py:attr:`Stoner.Core.DataFile.priority`. Each entry in the list consists of the
14171420
string name of the subclass and the class object.
14181421
"""
14191422

Stoner/Image/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def __array_finalize__(self, obj):
161161
more info and examples
162162
"""
163163
if obj is None: return
164-
self.metadata = getattr(obj, 'metadata', None)
164+
self.metadata = getattr(obj, 'metadata', {})
165165
self.filename = getattr(obj, 'filename', None)
166166

167167
def __array_wrap__(self, out_arr, context=None):

Stoner/Util.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,12 @@ def annotate_fit(self,model,x=None,y=None,z=None,prefix=None,text_only=False,**k
140140
y (float): y co-ordinate of the label
141141
z (float): z co-ordinbate of the label if the current axes are 3D
142142
prefix (str): The prefix placed ahead of the model parameters in the metadata.
143-
text_only (bool): If False (default), add the text to the plot and return the current object, otherwise,
144-
return just the text and don't add to a plot.
143+
text_only (bool): If False (default), add the text to the plot and return the current object, otherwise,
144+
return just the text and don't add to a plot.
145145
146146
Returns:
147-
A copy of the current Data instance if text_only is False, otherwise returns the text.
147+
148+
(Datam, str): A copy of the current Data instance if text_only is False, otherwise returns the text.
148149
149150
If *prefix* is not given, then the first prefix in the metadata lmfit.prefix is used if present,
150151
otherwise a prefix is generated from the model.prefix attribute. If *x* and *y* are not specified then they
@@ -271,8 +272,11 @@ def split_up_down(data, col=None, folder=None):
271272
width = len(a) / 10
272273
if width % 2 == 0: # Ensure the window for Satvisky Golay filter is odd
273274
width += 1
274-
peaks = list(a.peaks(col, width,xcol=False, peaks=True, troughs=False))
275-
troughs = list(a.peaks(col, width, xcol=False, peaks=False, troughs=True))
275+
setas=a.setas.clone
276+
a.setas=""
277+
peaks = list(a.peaks(col, width,xcol=None, peaks=True, troughs=False,full_data=False))
278+
troughs = list(a.peaks(col, width, xcol=None, peaks=False, troughs=True,full_data=False))
279+
a.setas=setas
276280
if len(peaks) > 0 and len(troughs) > 0: #Ok more than up down here
277281
order = peaks[0] < troughs[0]
278282
elif len(peaks) > 0: #Rise then fall

Stoner/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
from .Util import Data
1111
from .Folders import DataFolder
1212

13-
__version_info__ = ('0', '7', 'b1')
13+
__version_info__ = ('0', '7', 'b2')
1414
__version__ = '.'.join(__version_info__)

doc/Stoner.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Instrument Formats
9090

9191
BigBlueFile
9292
FmokeFile
93-
QDSquidVSMFile
93+
QDFile
9494
RigakuFile
9595
VSMFile
9696
MokeFile

doc/UserGuide/datafile.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ Base Classes and Generic Formats
5555
but has not been extensively tested.
5656
:py:class:`Stoner.FileFormats.TDMSFile`
5757
Loads a file saved in the National Instruments TDMS format
58-
:py:class:`Stoner.FileFormats.QDSquidVSMFile`
59-
Loads data from a Quantum Design SQUID VSM as used on the I10 Beamline in Diamond and in our labs.
58+
:py:class:`Stoner.FileFormats.QDFile`
59+
Loads data from various Quantum Design instruments, cincluding PPMS, MPMS and SQUID VSM.
6060
:py:class:`Stoner.FileFormats.OVFFile`
6161
OVF files are output by a variety of micomagnetics simulators. The standard was designed for the OOMMF code. This class will handle rectangualr mesh files with text or binary formats, versions 1.0 and 2.0
6262

@@ -144,8 +144,8 @@ from disk::
144144

145145
data=Stoner.Core.DataFile()<<open("File on Disk.txt")
146146

147-
Constructing :py:class:`DataFile`s from Scratch
148-
-----------------------------------------------
147+
Constructing :py:class:`DataFile` s from Scratch
148+
------------------------------------------------------------
149149

150150
The constructor :py:class:`DataFile`, :py:meth:`DataFile.__init__` will try its best to guess what your intention
151151
was in constructing a new instance of a DataFile. First of all a constructor function is called based on the number of positional

doc/UserGuide/plotfile.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ publication ready figures. The :py:class:`PlotMixin` is included as apart of the
1010
Quick Plots
1111
===========
1212

13-
:py:class:`PlotMixin` is intended to help you make plots that look reasonably good with as little hassle as possible.
13+
The :py:class:`PlotMixin` class is intended to help you make plots that look reasonably good with as little hassle as possible.
1414
In common with many graph plotting programmes, it has a concept of declaring columns of data to be used for 'x', 'y' axes and
1515
for containing error bars. This is done with the :py:attr:`DataFile.setas` attribute (see :ref:`setas` for full details). Once this is done, the plotting
1616
methods will use these to try to make a sensible plot.::

tests/Stoner/test_Folders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_Operators(self):
6464
print("Starting....")
6565
self.assertEqual((fl+1)*2,len(fldr2),"Failed + operator with DataFolder on DataFolder")
6666
print("Passed 2")
67-
fldr-="Untitled-0"
67+
fldr-="Untitled"
6868
self.assertEqual(len(fldr),fl,"Failed to remove Untitled-0 from DataFolder by name.")
6969
print("Passed 3")
7070
fldr-="New-XRay-Data.dql"

0 commit comments

Comments
 (0)