Package: langmuir-trough
Langmuir TroughThis software is a custom controller and GUI for the research Langmuir trough
in the Gutow Lab at UW Oshkosh. It is written in Python and expects to run in a
Jupyter notebook environment. However, all of the parts that are not elements
of the user interface should work in a vanilla Python environment.Hardware requirements:
Raspberry Pi compatible system with aPi-Plates
DAQC2data acquisition plate
and a trough controlled by the DAQC2 plate. This software could be used with
a trough controlled some other way by rewriting the routines intrough_util. py. The GUI front end would need no rewriting to use with a different
trough if a custom backend controlling the barriers, reading the temperature
and Whilhelmy balance is written. The backend needs to continually monitor
the trough and respond to the following commands:Stop, Send, Start,  Direction, Speed, MoveTo, MotorCal, ConstPi, DataLabels, ShutDown.If you do not have compatible hardware the GUI will run with a simulated
trough, allowing you to see how it works.UsageOnce installed:Turn on the power supply for the trough.In a terminal navigate to the directory containing the trough software.Start the virtual environmentpipenv shell.Launch Jupyterjupyter notebook(jupyter labalso works and is now
more stable).Create a folder for the new day using theNewmenu near the top right
of the Jupyter browser page. Give it an appropriate name.Switch to that folder by clicking on it.Start a new ipython notebook using theNewmenu. Give it a
name that describes the experiment.In the first cell initialize the trough by running the commandfrom  Trough import Trough_GUI. This will take a while to run the first time
it is run each day because it needs to check the movement of the barriers.To control and monitor the trough or do calibrations run the commandTrough_GUI.Controls(Trough_GUI.calibrations)Do not do any real runs without making sure the calibrations are correct.To start data collection (a run) run the commandTrough_GUI.Collect_data.Run("name_for_run"),
where you replace name_for_run with the text for the name of the run (no
spaces).Set the run conditions.You can start data collection by clicking the green "Run" button.If you set the speed to zero the data collection will be displayed
versus time and will not stop until you click the red "Stop" button.InstallationOS setup - Ubuntu on PiBy default in Ubuntu 20.04 for Pis the gpio and spi groups do not exist.
The i2c group does (not always).Make sure that the following packages are installedrpi.gpio-common  python3-pigpio python3-gpiozero python3-rpi.gpio.You can avoid having to create a gpio group, by assigning users who need
gpio access to the dialout group. Check that /dev/gpiomem is part of that
group and that the dialout group has rw access. If not you will need to set
it.Users also need to be members of the i2c group. If it does not exist create
it and then make that the group for /dev/i2c-1 with group rw permissions.
THIS MAY NOT BE NECESSARY.The spi group needs to be created (addgroup?).Additionally the spi group needs to be given rw access to the spi devices
at each boot. To do this create a one line rule in a file named/etc/udev/rules.d/50-spidev.rulescontainingSUBSYSTEM=="spidev",  GROUP="spi", MODE="0660". The file should have rw permission for root
and read permission for everyone else.Make sure you havepipinstalled for
python 3:python3 -m pip --versionorpip3 --version. If you do not,
install usingapt  install python3-pip.Trough Software InstallationTo avoid library conflicts the software should be installed into avirtual environment.
Instructions for doing this usingpipenvfollow.Log into your chosen user account:Installpipenv:pip3 install  --user pipenv. You may
need to add~/.local/binto yourPATHto makepipenvavailable in your command shell. More discussion:The Hitchhiker's Guide to
Python.Create a directory for the virtual environment you will be installing
into (example:$ mkdir Trough).Navigate into the directory$ cd Trough.Create the virtual environment and enter it$ pipenv shell. To get out of
the environment you can issue the$ exitcommand on the command line.While still in the shell install the latest trough software and all its
requirements$ pip install -U langmuir_trough.Still within the environment shell test
this by starting jupyter$ jupyter notebook. Jupyter should launch in your
browser.Open a new notebook using the default (Python 3) kernel.In the first cell import the Trough_GUI:from Trough import Trough_GUI.
When run this cell sets things up and tries to talk to the trough.If you wish, you can make this environment available to an alternate Jupyter
install as a special kernel when you are the user.Make sure you are running in your virtual environment$ pipenv shellin the directory for  virtual environment will do that.Issue the command to add this as a kernel to your personal space:$ python -m ipykernel install --user --name=<name-you-want-for-kernel>.More information is available in the Jupyter/Ipython documentation.
A simple tutorial from Nikolai Jankiev (Parametric Thoughts) can be
foundhere.Change Log0.8.1 (May 15, 2023)BUG_FIX: Needed to reset cycles_on and cycles_off when speed updated.0.8.0 (May 12, 2023)Added capability to do very slow compressions (< 1 cm/min) by moving the
barriers intermittently at near their lowest continuous speed.Now record datapoint time_stamps as actual_time_stamp - run_time_stamp.
This avoids round off errors in the html based data storage file.BUG_FIXES:Errors in conversion of speeds between units.Make start boost voltage direction dependent.Fix inconsistent sign on skimmer corrections.Correct hanging of GUI updates during barrier calibrations.Fix wrong target value when units were cm**2.0.7.0 (Apr. 28, 2023)Added Access topandas_GUItools asTrough_GUI.newPlot(),Trough_GUI.newFit()andTrough_GUI.newCalculatedColumn().BUG_FIX: Opening a new notebook and importing Trough_GUI no longer
clobbers an already running notebook that is talking to the trough
A-to-D hardware.BUG_FIX: Stopping a data collection run now makes sure the barriers are
stopped.0.6.0 (Mar. 29, 2023)Documentation updates including Gutow Lab Standard Operating Procedures
(SOPs).Refactored everything to inside the moduleTrough.0.5.2 (Mar. 16, 2023) Now works in Jupyter Lab.Adjusted widget updating/clearing to work in Jupyter lab.Added JupyterLab >= 3.6.1 to requirements.0.5.1 (Mar. 9, 2023)Includespidevpackage in requirements.More details reported when unable to "find trough".0.5.0 (Mar. 4, 2023) First version with working GUI0.1.0 First pypi compatible package version.Known issues0.5.0 - 0.8.0 The estimated error on values converted to metric units
based on calibration fits appears to be too pessimistic.Inconsistent rendering of Latex ipywidget labels with ipywidgets >= 8.0.
Until figured out requiring ipywidgets < 8.0.Runs don't label graph axes reliably for x-axis units other than cm. This
appears to be associated with Latex in ipywidgets as well.DevelopmentCodeRepository|DocsFor development purposes clone the GIT repository.Create the virtual environment to run it in within the development
directorypipenv shell.Within the shell pip install for developmentpip install -e ..Constructing the DocumentationMake sure pdoc is installed and updated in the virtual environmentpip  install -U pdoc.Update any.mdfiles included in_init_.py.Generally URLs should be absolute, not relative.At the root level run pdocpdoc --logo-link https://gutow.github.io/Langmuir_Trough/ --footer-text "Langmuir_Trough vX.X.X"  --math -html -o docs TroughwhereX.X.Xis the version number.Because of the way the document building process works the background tasks
will be started.You will have to stop the document build after the
documentation is done building (watch thedocfolder) with a^Cto
terminate it.Releasing on PyPiProceed only if testing of the build is successful.Update packaging softwarepip install -U setuptools wheel twineDouble check the version number insetup.py.Rebuild the release:python -m setup sdist bdist_wheel.Upload it:python -m twine upload dist/*Make sure it works by installing it in a clean virtual environment.pip  install -U ....Copy the actual link from pypi.org.`. If it does not work, pull the release.Ideas/Things to doMake more robust by wrapping data collection intry ...so that it can
exit more gracefully and give up barrier monitoring?Add explanation of how to use the barrier watch deamon to prevent barrier
crashing if software fails.