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

Add support for Hewlett Packard 8753E VNA #1004

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

Sionwage
Copy link

@Sionwage Sionwage commented Dec 19, 2023

I would like to add a basic HP8753E VNA support to pymeasure.

The functionality is not ready but I would like feedback as I go and there are some specifics for coding I would like assistance with finding documentation on how to handle these.

  1. How do I handle default Prologix GPIB-USB adapter parameters to work with this device?

    I found these pages that address how to handle read/write terminations and other parameters for the various adapters but I am unsure how to apply this to the prologix gpib-usb adapter I utilize.

    I am not sure if I should be using asrl or gpib for pyvisa.constants.InterfaceType since its a serial device connecting to GPIB.

    Unfortunately, it seems like if I am not defining the Prologix settings and commanding them when using the VNA, there will be unexpected behavior or it will timeout/error out.

    It looks like it is addressed here but not implemented here Handle Prologix USB to GPIB pyvisa/pyvisa#112

  2. If I utilize default Prologix GPIB-USB adapter parameters for one instrument, is the functionality to change these parameters on the fly for other instruments in place? IE, if I need '++auto 1' for one instrument but not another, with pymeasure send the command to the adapter if I communicate to alternating instruments and remember when it needs to change it?

    The Update graphical.rst #112 issue makes it look like different parameters needed with the Prologix adapter for multiple instruments are not handled yet with pymeasure or pyvisa.

  3. Are we allowed to utilize cached properties to save time on communicating?

My to-do list of actions still needed to polish this for others to use is:

  • Need unit tests for this class that don't rely on having the instrument. Currently my unit tests rely on having the instrument on the bench and connected. I know there is some functionality at Adding Instruments->Writing tests->Protocol tests->Test generator to create tests that don't demand the instrument be attached to the computer.
  • Remove adapter specific commands like my workarounds using the Prologix adapter from the class or be able to toggle the Prologix specific functions on/off when initializing the class.
  • Write comments for each of the functions clarifying them
  • Start the comments for properties with ['Get', 'Measure', 'Set', or 'Control']
  • May need to move the __init__ block to __new__?
  • Exceptions may need to use more specific exceptions from the pymeasure library
  • Probably need to remove the __version and if __name__=="__main__": blocks
  • Address other code style issues I am undoubtedly not adhering to.

Copy link
Member

@BenediktBurger BenediktBurger left a comment

Choose a reason for hiding this comment

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

Thank you very much for your contribution. I commented on your code.

A few general points to consider:

Answers to your questions:

  • "How do I handle default Prologix parameters": You have to define them in your personal code, not in pymeasure, as pymeasure defines the parameters for the instrument communication, such that anyone might use the device independent of the adapter, see the init part.
  • "I am not sure if I should be using asrl or gpib for pyvisa.constants.InterfaceType since its a serial device connecting to GPIB.": gpib as that is the device connection.
  • "Unfortunately, it seems like if I am not defining the Prologix settings and commanding them when using the VNA, there will be unexpected behavior or it will timeout/error out.": You have to create your PrologixAdapter with the correct settings beforehand.
  • "If I utilize default Prologix GPIB-USB adapter parameters for one instrument, is the functionality to change these parameters on the fly for other instruments in place? IE, if I need '++auto 1' for one instrument but not another, with pymeasure send the command to the adapter if I communicate to alternating instruments and remember when it needs to change it?": You have to manage your PrologixAdapter yourself.
  • "Are we allowed to utilize cached properties to save time on communicating?" Right now we do not use them. In case they might be good, we could discuss it. I've seen you cache the id/serial_number, but I don't see the point of caching, as you read these data rarely.

If you have more questions, don't hesitate to ask.

pymeasure/instruments/hp/hp8753e.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp8753e.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp8753e.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp8753e.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp8753e.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp8753e.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp8753e.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp8753e.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp8753e.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp8753e.py Outdated Show resolved Hide resolved
Sionwage pushed a commit to Sionwage/pymeasure that referenced this pull request Dec 21, 2023
@Sionwage Sionwage marked this pull request as draft December 26, 2023 17:23
Copy link
Member

@BenediktBurger BenediktBurger left a comment

Choose a reason for hiding this comment

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

A second round of comments.

Thanks for your work, which is already in a good state.

pymeasure/instruments/hp/__init__.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp8753e.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp8753e.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp8753e.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp8753e.py Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
pymeasure/instruments/ni/daqmx.py Outdated Show resolved Hide resolved
tests/instruments/hp/test_hp8753e.py Show resolved Hide resolved
tests/instruments/hp/test_hp8753e.py Show resolved Hide resolved
tests/instruments/hp/test_hp8753e_with_device.py Outdated Show resolved Hide resolved
@Sionwage
Copy link
Author

Is there a way to change the branch to merge from? I have somehow completely hosed my git clone and cannot update/sync my copied repo with the changes made in pymeasure:master since opening this.

Otherwise I'll just copy out my code, nuke my fork repo, refork the repo and create a branch before putting my code back in so I can sync upstream changes.

@BenediktBurger
Copy link
Member

You cannot change the branch name to be merged from.

You can, however use different commits in the branch:

  1. create a temporary branch, where you are at right now (and maybe the files)
  2. delete your current branch
  3. create a new branch with the name of the current branch (for example on the current master)
  4. Do the changes you want (e.g. copying the files)
  5. Push your changes to your github repo (using push force)

Copy link

codecov bot commented Apr 3, 2024

Codecov Report

Attention: Patch coverage is 58.75000% with 66 lines in your changes are missing coverage. Please review.

Project coverage is 58.47%. Comparing base (fb5f3b2) to head (99a4ba2).
Report is 16 commits behind head on master.

Files Patch % Lines
pymeasure/instruments/hp/hp8753e.py 58.49% 66 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1004      +/-   ##
==========================================
+ Coverage   58.16%   58.47%   +0.30%     
==========================================
  Files         259      262       +3     
  Lines       17934    18257     +323     
==========================================
+ Hits        10432    10676     +244     
- Misses       7502     7581      +79     
Flag Coverage Δ
unittests 58.47% <58.75%> (+0.30%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Sionwage
Copy link
Author

Sionwage commented Apr 3, 2024

As I see it, I think there are two/three items still needing to get addressed before you would accept this pull request.

  • PrologixAdapter fixture for unit-testing the HP8753E needs to be resolved
  • May need more unit tests to cover the 40% or so of instrument code that isn't in a unit-test.
  • May need to rewrite the measurement_parameter property to use Instrument.control

@Sionwage Sionwage marked this pull request as ready for review April 4, 2024 15:01
@BenediktBurger
Copy link
Member

May need more unit tests to cover the 40% or so of instrument code that isn't in a unit-test.

Don't worry about less than 100% patch coverage.
Tests are good, but we do not have any limit for merging pull requests.

@Sionwage
Copy link
Author

I think I am close to done with all the requests made and just need answers to the last 3 unresolved conversations to finish.

@BenediktBurger
Copy link
Member

Hey @Sionwage,
I'm in the process of reviewing, but I'll need some time, due to time constraints.
I ask for your patience.

Copy link
Member

@BenediktBurger BenediktBurger left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution.

I mentioned some incosistencies and mainly documentation issues. The instrument looks already good.

I noticed quite a lot dynamic properties. Do you intend to use them as dynamic properties or is it "just in case"?

docs/api/instruments/hp/hp8753E.rst Show resolved Hide resolved
tests/instruments/hp/test_hp8753e.py Outdated Show resolved Hide resolved
tests/instruments/hp/test_hp8753e.py Outdated Show resolved Hide resolved
tests/instruments/test_all_instruments.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp8753e.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp8753e.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp8753e.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp8753e.py Outdated Show resolved Hide resolved
pymeasure/instruments/hp/hp8753e.py Outdated Show resolved Hide resolved
@Sionwage
Copy link
Author

Thanks for your contribution.

I mentioned some incosistencies and mainly documentation issues. The instrument looks already good.

I noticed quite a lot dynamic properties. Do you intend to use them as dynamic properties or is it "just in case"?

There are different configurations for the 8753E so this allows others to override the defaults set for their instrument.

@Sionwage
Copy link
Author

Not sure how to resolve WARNING: Field list ends without a blank line; unexpected unindent.

Otherwise I think everything has been addressed now.

Comment on lines +49 to +53
prologix = PrologixAdapter(resource_name=prologix_address, visa_library="@py", auto=1)
# need to ensure `eot_enable` is set to zero otherwise you will have to read twice to
# get rid of the extra new line character
prologix.write("++eot_enable 0")
vna = HP8753E(adapter=prologix.gpib(int(gpib_address)))
Copy link
Member

Choose a reason for hiding this comment

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

By the way, you do not need to create a PrologixAdapter and then call gpib.
The following two options result in the same behavior:

temp_adapter = PrologixAdapter(resource_name)
adapter = temp_adapter.gpib(gpib_address)

# or
adapter = PrologixAdapter(resource_name, gpib_address)

Comment on lines +281 to +282
# this test will wear out the mechanical relays and should be run only as necessary
@pytest.mark.skip
Copy link
Member

Choose a reason for hiding this comment

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

You can add a reason to the skip:

Suggested change
# this test will wear out the mechanical relays and should be run only as necessary
@pytest.mark.skip
@pytest.mark.skip(reason="This test will wear out the mechanical relays and should be run only as necessary")

tests/instruments/hp/test_hp8753e_with_device.py Outdated Show resolved Hide resolved
Copy link
Member

@BenediktBurger BenediktBurger left a comment

Choose a reason for hiding this comment

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

Some comments.

Yes, it comes good together, we're almost done.

Comment on lines +53 to +55
:param max_power: Optional set the maximum validator for `HP8753E.power` on initialization
(float in dBm).
"""
Copy link
Member

Choose a reason for hiding this comment

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

I think that is the culprit for the warning.
For such a list, sphinx expects the last line to start with :param or an empty line, so you could do:

  • either move (float ind dBm). to the end of the previous line 53 (such that the last line starts with :param...
  • or add an empty line before the end of the docstring.

We have a line length limit of 100, so the first option should work.

Copy link
Member

Choose a reason for hiding this comment

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

Please revert the changes in this file.

PRs should be based on the master branch and merge there.

The v0.14 branch is there to write the changelog for the next release.

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.

None yet

3 participants