Skip to content

Commit

Permalink
Merge pull request #129 from paulmueller/develop
Browse files Browse the repository at this point in the history
Develop -> 0.8.9
  • Loading branch information
Paul Müller committed Aug 29, 2015
2 parents fdc99e0 + dfef800 commit a01b57f
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 58 deletions.
12 changes: 8 additions & 4 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
0.8.8-beta2
0.8.9
- Improved support for "ALV-7004" files (#104)
- Increase resolution for image export
- Load weights from PyCorrFit csv files
- Tool 'Overlay Curves': show cropped correlation curves
- Tool 'Trace view': increase size of window (#93)
- Tool 'Global fitting': remove forced, joint weights
- Session comment dialog: more intuitive behavior (#116)
- Improve plot export (#95)
- Bugfixes:
- fitting algorithms did not work (#94)
- creating averages did not work (#123)
- ascii errors in statistics tool (#112)
- Weighted fits at borders of fit interval were
computed incorrectly due to integer division
- Fitting algorithms did not work (#94)
- Creating averages did not work (#123)
- ASCII errors in statistics tool (#112)
- Under the hood:
- Introduce new classes: Correlation, Fit, Trace
- Code cleanup and rewrite to support planned features
Expand Down
3 changes: 1 addition & 2 deletions pycorrfit/fcs_data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ def compute_weights(correlation, verbose=0, uselatex=False):

## Calculation of variance
# In some cases, the actual cropping interval from ival[0]
# ro ival[1] is chosen, such that the dataweights must be
# to ival[1] is chosen, such that the dataweights must be
# calculated from unknown datapoints.
# (e.g. points+endcrop > len(correlation)
# We deal with this by multiplying dataweights with a factor
Expand Down Expand Up @@ -1045,7 +1045,6 @@ def compute_weights(correlation, verbose=0, uselatex=False):
else:
raise ValueError, \
"`weights` must have length of full or cropped array."


return dataweights

Expand Down
38 changes: 12 additions & 26 deletions pycorrfit/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,6 @@ def savePlotCorrelation(parent, dirname, Page, uselatex=False,
labelweights = ur"Weights of fit"
labels, parms = mdls.GetHumanReadableParms(Page.modelid,
corr.fit_parameters)
## According to issue #54, we remove fitting errors from plots
## Error parameters with nice look
#errparmsblank = Page.parmoptim_error
#if errparmsblank is None:
# errparms = None
#else:
# errparms = dict()
# for key in errparmsblank.keys():
# newkey, newparm = mdls.GetHumanReadableParameterDict(Page.modelid,
# key, errparmsblank[key])
# errparms[newkey] = newparm
#parmids = np.where(Page.active_parms[2])[0]
#labels = np.array(labels)[parmids]
#parms = np.array(parms)[parmids]
if dataexp is None:
if tabtitle.strip() == "":
fitlabel = Page.corr.fit_model.name
Expand Down Expand Up @@ -199,18 +185,15 @@ def savePlotCorrelation(parent, dirname, Page, uselatex=False,
ax = plt.subplot(111)
# ax = plt.axes()
ax.semilogx()
# plot fit first
plt.plot(fit[:,0], fit[:,1], '-', label=fitlabel, lw=1.5,
color="blue")
if dataexp is not None:
plt.plot(dataexp[:,0], dataexp[:,1], '-', color="darkgrey",
label=tabtitle)
plt.plot(dataexp[:,0], dataexp[:,1], '-', color="black",
alpha=.7, label=tabtitle, lw=1)
else:
plt.xlabel(ur'lag time $\tau$ [ms]')
# Plotting with error bars is very ugly if you have a lot of
# data points.
# We will use fill_between instead.
#plt.errorbar(fit[:,0], fit[:,1], yerr=weights, fmt='-',
# label = fitlabel, lw=2.5, color="blue")
plt.plot(fit[:,0], fit[:,1], '-', label = fitlabel, lw=2.5,
color="blue")

if weights is not None and show_weights is True:
plt.fill_between(weights[0][:,0],weights[0][:,1],weights[1][:,1],
color='cyan')
Expand Down Expand Up @@ -278,13 +261,16 @@ def savePlotCorrelation(parent, dirname, Page, uselatex=False,
yLabelRes = "weighted "+ lb +"residuals"
else:
yLabelRes = "residuals"
plt.plot(resid[:,0], resid[:,1], '-', color="darkgrey", label=yLabelRes)
plt.xlabel(r'lag time $\tau$ [ms]')
plt.ylabel(yLabelRes, multialignment='center')
minx = np.min(resid[:,0])
maxx = np.max(resid[:,0])
miny = np.min(resid[:,1])
maxy = np.max(resid[:,1])
plt.hlines(0, minx, maxx, colors="orange")
plt.plot(resid[:,0], resid[:,1], '-', color="black",
alpha=.85, label=yLabelRes, lw=1)
plt.xlabel(r'lag time $\tau$ [ms]')
plt.ylabel(yLabelRes, multialignment='center')

ax2.set_xlim(minx, maxx)
maxy = max(abs(maxy), abs(miny))
ax2.set_ylim(-maxy, maxy)
Expand Down
8 changes: 4 additions & 4 deletions pycorrfit/readfiles/read_ASC_ALV.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,10 @@ def openASC_ALV_7004_USB(path):
0.35156 129.67148 74.58858 129.67148 74.58858
0.46875 134.57133 79.53957 134.57133 79.53957
[...]
29.29688 143.78307 79.06236 143.78307 79.06236
29.41406 154.80135 82.87147 154.80135 82.87147
29.53125 187.43013 89.61197 187.43013 89.61197
29.64844 137.82655 77.71597 137.82655 77.71597
29.29688 143.78307 79.06236 143.78307 79.06236
29.41406 154.80135 82.87147 154.80135 82.87147
29.53125 187.43013 89.61197 187.43013 89.61197
29.64844 137.82655 77.71597 137.82655 77.71597
[...]
Expand Down
32 changes: 20 additions & 12 deletions pycorrfit/tools/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
Module tools - comment
Edit the sessions' comment.
"""


from __future__ import print_function
import wx


Expand All @@ -29,28 +28,25 @@ def __init__(self, parent):
self.panel = wx.Panel(self)
self.control = wx.TextCtrl(self.panel, style=wx.TE_MULTILINE,
size=initial_sizec, value=self.parent.SessionComment)
self.Bind(wx.EVT_TEXT, self.OnTextChanged, self.control)
text = wx.StaticText(self.panel,
label="Session comments will be saved in the session file.")
# buttons
btnclose = wx.Button(self.panel, wx.ID_ANY, 'Close')
btnokay = wx.Button(self.panel, wx.ID_ANY, 'OK')
self.Bind(wx.EVT_BUTTON, self.OnClose, btnclose)
self.Bind(wx.EVT_BUTTON, self.OnOkay, btnokay)
btnsave = wx.Button(self.panel, wx.ID_SAVE, 'Save Comment')
self.Bind(wx.EVT_BUTTON, self.OnSave, btnsave)
#sizers
self.topSizer = wx.BoxSizer(wx.VERTICAL)
buttonsizer = wx.BoxSizer(wx.HORIZONTAL)
buttonsizer.Add(btnclose, 1)
buttonsizer.Add(btnokay, 1)
self.topSizer.Add(text)
self.topSizer.Add(buttonsizer)
self.topSizer.Add(self.control)
self.topSizer.Add(btnsave, 1, wx.RIGHT | wx.EXPAND)
self.panel.SetSizer(self.topSizer)
self.topSizer.Fit(self)
#Icon
if parent.MainIcon is not None:
wx.Frame.SetIcon(self, parent.MainIcon)
self.Show(True)
wx.EVT_SIZE(self, self.OnSize)
self.text_changed = False


def OnSize(self, event):
Expand All @@ -60,12 +56,24 @@ def OnSize(self, event):
self.control.SetSize(sizec)


def OnClose(self, event=None):
def OnClose(self, e=None):
self.parent.filemenu.Check(self.parent.menuComm.GetId(), False)
if self.text_changed:
# ask the user to save or discard.
dlg = wx.MessageDialog(self, "Save comment?",
"Do you want to save the current changes?",
style=wx.YES_NO)
if dlg.ShowModal() == wx.ID_YES:
self.OnSave()
self.Destroy()

def OnTextChanged(self, e=None):
""" When the user changes the text
"""
self.text_changed = True

def OnOkay(self, event):
def OnSave(self, e=None):
self.parent.SessionComment = self.control.GetValue()
self.text_changed = False
self.OnClose()

21 changes: 11 additions & 10 deletions pycorrfit/tools/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def GetPageInfo(self, Page):
corr = Page.corr

# Get model information
model = [corr.fit_model.description_short, Page.tabtitle.GetValue(), corr.fit_model.id]
model = corr.fit_model
parms = corr.fit_parameters
fct = corr.fit_model.function.__name__
InfoDict["version"] = [Page.parent.version]
Expand All @@ -117,29 +117,30 @@ def GetPageInfo(self, Page):
if len(model[1]) == 0:
# Prevent saving no title
model[1] = "NoName"
Title.append(["filename/title", model[1] ])
Title.append(["Model ID", str(model[2]) ])
Title.append(["Model name", model[0] ])
Title.append(["Model function", fct ])
Title.append(["Page number", Page.counter[1:-2] ])
Title.append(["filename/title", Page.title])
Title.append(["Model species", model.components])
Title.append(["Model name", model.name])
Title.append(["Model ID", str(model.id)])
Title.append(["Model function", fct])
Title.append(["Page number", Page.counter[1:-2]])
## Parameters
Parameters = list()
# Use this function to determine human readable parameters, if possible
Units, Newparameters = mdls.GetHumanReadableParms(model[2], parms)
Units, Newparameters = mdls.GetHumanReadableParms(model.id, parms)
# Add Parameters
for i in np.arange(len(parms)):
Parameters.append([ Units[i], Newparameters[i] ])
InfoDict["parameters"] = Parameters
# Add some more information if available
# Info is a dictionary or None
MoreInfo = mdls.GetMoreInfo(model[2], Page)
MoreInfo = mdls.GetMoreInfo(model.id, Page)
if MoreInfo is not None:
InfoDict["supplement"] = MoreInfo
# Try to get the dictionary entry of a model
try:
# This function should return all important information
# that can be calculated from the given parameters.
func_info = mdls.supplement[model[2]]
func_info = mdls.supplement[model.id]
except KeyError:
# No information available
pass
Expand Down Expand Up @@ -198,7 +199,7 @@ def GetPageInfo(self, Page):
errors = corr.fit_results["fit error estimation"]
for err, par in zip(errors, fitparms):
nam, val = mdls.GetHumanReadableParameterDict(
model[2], [par], [err])
model.id, [par], [err])
Fitting.append(["Err "+nam[0], val[0]])

InfoDict["fitting"] = Fitting
Expand Down

0 comments on commit a01b57f

Please sign in to comment.