Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Developing the complex VNA analysis #492

Merged
merged 10 commits into from
Aug 16, 2018
Merged

Developing the complex VNA analysis #492

merged 10 commits into from
Aug 16, 2018

Conversation

fluthi
Copy link
Contributor

@fluthi fluthi commented Aug 2, 2018

Please use the following template for a pull request.

Changes proposed in this pull request:

  • This is to get the MAv2 working for the standard (non-complex) VNA fitting
  • Changed the timestamp extraction in the options dict of MAv2
  • Additional wisdom will follow

In order for the pull request to be merged, the following conditions must be met:

  • travis test suite passes
  • all reasonable issues raised by codacy must be resolved
  • a positive review is required

Whenever possible the pull request should

  • follow the PEP8 style guide
  • have tests for the code
  • be well documented and contain comments

Tests are not mandatory as this is generally hard to make for instruments that interact with hardware.

Includes:
- Generalization of the base analysis to also run the minimizing method
for fitting
- Complex resonator fit for the VNA analysis, based on an initial guess
using the hanger fitting
- Fitting models updated to match the complex fitting
@coveralls
Copy link

coveralls commented Aug 14, 2018

Pull Request Test Coverage Report for Build 3645

  • 126 of 182 (69.23%) changed or added relevant lines in 4 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.3%) to 38.47%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pycqed/analysis_v2/spectroscopy_analysis.py 25 28 89.29%
pycqed/analysis_v2/base_analysis.py 62 80 77.5%
pycqed/analysis/fitting_models.py 24 59 40.68%
Files with Coverage Reduction New Missed Lines %
pycqed/analysis_v2/base_analysis.py 1 69.42%
Totals Coverage Status
Change from base Build 3541: 0.3%
Covered Lines: 20274
Relevant Lines: 52701

💛 - Coveralls

Copy link
Contributor

@AdriaanRol AdriaanRol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some small comments (see review). Also, please do not commit changes to the hdf5 files that get triggered by the tests. (no blind commit all). After we discuss this we can approve.

@@ -310,33 +312,10 @@ def HangerFuncAmplitude(f, f0, Q, Qe, A, theta):
return abs(A * (1. - Q / Qe * np.exp(1.j * theta) / (1. + 2.j * Q * (f / 1.e9 - f0) / f0)))


def HangerFuncComplex(f, pars):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this is being deleted on purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The standard complex hanger function should, just like the standard for the fitting models, take floats as arguments.
In order no to loose functionality the function taking a list of parameters as been renamed to hanger_func_complex_SI_pars.
I've added a comment to this.

@@ -24,6 +24,8 @@
import h5py
from pycqed.measurement.hdf5_data import write_dict_to_hdf5

from importlib import reload # Useful for reloading while testing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this from base analysis.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -138,11 +140,14 @@ def __init__(self, t_start: str = None, t_stop: str = None,
# These options determine what data to extract #
################################################
scan_label = self.options_dict.get('scan_label', label)
if scan_label is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be much better to instead replace the default argument with '', a hidden if statement that replaces some parameter is quite horrible for debugging.

Copy link
Contributor Author

@fluthi fluthi Aug 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default argument is indeed a str='', see definition of the init of the base_class.

So in principle the if statement could be removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you agree, could you remove this addition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests fail without it.
Cleanup of this should be addressed in a different pull request. So I'm going to change it back.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Culprit is the default label in the spec analysis. This is now changed, and the if statement removed.
So should be all good now.

@@ -224,7 +231,7 @@ def run_analysis(self):
self.plot(key_list='auto') # make the plots

if self.options_dict.get('save_figs', False):
self.save_figures(close_figs=self.options_dict.get('close_figs', False))
self.save_figures(close_figs=self.options_dict.get('close_figs', True))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch 👍

@@ -470,6 +477,7 @@ def prepare_fitting(self):
# initialize everything to an empty dict if not overwritten
self.fit_dicts = OrderedDict()


def run_fitting(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Danger! I think this piece of code is getting awfully complicated to understand (as you have probably experienced when debugging the tests) I am sure the tests are working now but I'm a bit hesitant to approve this change... Let's discuss a bit, I'm not sure what the best solution is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added extensive comments that explain what arguments can be passed to the run_fitting function.
Added some comments to clarify what the requirements for the different fitting methods are.
Added extensive comments how the guessing can be done / how guess parameters can be passed on.

@@ -13,8 +13,11 @@
from pycqed.analysis import fitting_models as fit_mods
import lmfit

from importlib import reload # Useful for reloading while testing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove debugging stuff from here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed all the reload commands, also to reload the base_class and the fitting_mods

@@ -13,8 +13,11 @@
from pycqed.analysis import fitting_models as fit_mods
import lmfit

from importlib import reload # Useful for reloading while testing

import importlib
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Especially if it is imported multiple times.

@@ -210,22 +215,22 @@ def process_data(self):
self.proc_data_dict['amp_label'] = 'Transmission amplitude (V rms)'
self.proc_data_dict['phase_label'] = 'Transmission phase (degrees)'
if len(self.raw_data_dict['timestamps']) == 1:
self.proc_data_dict['plot_phase'] = np.unwrap(np.pi / 180. * self.proc_data_dict['plot_phase']) * 180 / np.pi
self.proc_data_dict['plot_phase'] = np.unwrap(self.proc_data_dict['plot_phase'],discont=3.141592653589793)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not np.pi instead of 3.14159....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

@AdriaanRol
Copy link
Contributor

@fluthi @tstavenga , the test you added is failing because the hdf5 file is not added (these are by default ignored in the gitignore). Come find me and we can fix this

@AdriaanRol AdriaanRol mentioned this pull request Aug 15, 2018
@AdriaanRol
Copy link
Contributor

Hi @fluthi you comment that the changes have been made but there are no new commits. Could you push the changes?

@fluthi fluthi merged commit dd7a451 into master Aug 16, 2018
@fluthi fluthi deleted the VNA_analysis_development branch August 16, 2018 15:09
@fluthi
Copy link
Contributor Author

fluthi commented Aug 16, 2018

Merged and deleted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants