Commit bd5e218e authored by Rama Vasudevan's avatar Rama Vasudevan
Browse files

Merge branch 'master' of https://github.com/pycroscopy/pycroscopy

parents ed5ef0e5 ed33194d
......@@ -8,7 +8,7 @@ Created on Mon Sep 28 11:35:57 2015
from __future__ import division, print_function, absolute_import, unicode_literals
import numpy as np
from numpy import exp, abs, sqrt, sum, real, imag, arctan2, append
from scipy.optimize import minimize
def SHOfunc(parms, w_vec):
"""
......@@ -25,6 +25,26 @@ def SHOfunc(parms, w_vec):
(w_vec ** 2 - 1j * w_vec * parms[1] / parms[2] - parms[1] ** 2)
def SHOfit(parms, w_vec, resp_vec):
"""
Cost function minimization of SHO fitting
Parameters
-----------
parms : list or tuple
SHO parameters=(A,w0,Q,phi)
w_vec : 1D numpy array
Vector of frequency values
resp_vec : 1D complex numpy array or list
Cantilever response vector as a function of frequency
"""
# Cost function to minimize.
cost = lambda p: np.sum((SHOfunc(parms, w_vec) - resp_vec) ** 2)
popt = minimize(cost, parms, method='TNC', options={'disp':False})
return popt.x
def SHOestimateGuess(resp_vec, w_vec, num_points=5):
"""
Generates good initial guesses for fitting
......
......@@ -15,7 +15,8 @@ from time import time, sleep
from warnings import warn
import h5py
from pyUSID.io.hdf_utils import assign_group_index, write_simple_attrs, attempt_reg_ref_build, write_region_references
from pyUSID.io.hdf_utils import assign_group_index, write_simple_attrs
from pyUSID.io.reg_ref import attempt_reg_ref_build, write_region_references
from .virtual_data import VirtualGroup, VirtualDataset, VirtualData
from ..__version__ import version
......
......@@ -16,8 +16,9 @@ from sklearn.utils.extmath import randomized_svd
from pyUSID.processing.process import Process
from .proc_utils import get_component_slice
from pyUSID.io.hdf_utils import find_results_groups, get_indices_for_region_ref, \
create_region_reference, copy_attributes, reshape_to_n_dims, get_attr, write_main_dataset, \
from pyUSID.io.reg_ref import get_indices_for_region_ref, create_region_reference
from pyUSID.io.hdf_utils import find_results_groups, \
copy_attributes, reshape_to_n_dims, get_attr, write_main_dataset, \
create_results_group, write_simple_attrs, create_indexed_group
from pyUSID.processing.comp_utils import get_available_memory
from pyUSID.io.io_utils import format_time
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment