-
Notifications
You must be signed in to change notification settings - Fork 41
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
Conversation
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
Pull Request Test Coverage Report for Build 3645
💛 - Coveralls |
There was a problem hiding this 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): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
pycqed/analysis_v2/base_analysis.py
Outdated
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
pycqed/analysis_v2/base_analysis.py
Outdated
@@ -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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
@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 |
Hi @fluthi you comment that the changes have been made but there are no new commits. Could you push the changes? |
Merged and deleted |
Please use the following template for a pull request.
Changes proposed in this pull request:
In order for the pull request to be merged, the following conditions must be met:
Whenever possible the pull request should
Tests are not mandatory as this is generally hard to make for instruments that interact with hardware.