Giter VIP home page Giter VIP logo

psplot's Introduction

PSplot logo

PSplot

A lightweight tool for obtaining and visualising the discrete near-infrared (NIR) data using the Plastic Scanner.

PSplot screenshot

WARNING: still in early development, not a stable release! See GitHub issues

Installation

Requires python 3.10, pipenv Install python dependencies (listed in Pipfile):

$ pipenv install

Start the shell and run the program:

$ pipenv shell
$ python psplot.py

Use exit or Ctrl+D to exit pipenv shell

Usage

The interface is divided up in 3 sections:

Data in/out

Here you can select your developement board, if no COM port is available/selected it will use dummy data (to help the developers!) You can also import or export data to load previous dataset or to export your data once you are done.

Measuring

In this section you can:

  • calibrate with reference material
  • fill in details about (un)known sample
  • take a measurement

Data visualisation

The last section shows the visualisation of the measurement. It has four sections

  1. 2D spectrum graph, this shows the measurement from the sample, with the reference measurement as an ideal straight line and with the SNV applied. It shows the last 3 measurements
  2. 3D scatter plot, this shows a 3D plot with the previous measurements. The colors are based on the "Sample Material" input. It defaults to the axis that we think are the most interesting, but with the drop down menus you can play around to see what works for you.
  3. WARNING: this is a first experiment! It is a bar chart, that shows what the computer thinks is the most likely type of plastic, this is at the moment only an experiment for HDPE, PET, PP and PS

  4. Table with the raw measurement values. In this table you can also edit the material of a measurement after taking the measurement by editing one of cells.

Contributing

Feel free to improve, modify and contribute to this project. It's part of the Plastic Scanner open source hardware development, check out the docs as well!

psplot's People

Contributors

joostscheffer avatar jurc192 avatar jerzeek avatar gillens avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

psplot's Issues

Have a slider for minimal light threshold

Would be cool to add a slider or something to ignore scans in which the values are too low (ignore them or give a warning message).
Another option could be just to have a value (let's say 60% of the light compared to the reference tile) in the settings somewhere, and the tweak it.

Packaging, cross-platform, easier installation

It is tedious for non-tech users to install python, pip, pipenv and all dependencies to make spectraplot run. How can we make it simpler?
Even if it's in early development and probably does not deserve a "stable release", how can we distribute it to people?
One option I see is packaging it (wheel?) for installation with pip. Another is making a single-click-executables.

If anyone has experience with python packaging, I'll be glad to have a chat :)

Bar chart disabled by default

there is an experimental bar chart on the left of the graph that indicates what possible plastic it could be, it is very experimental, so maybe it is better to disable it by default, it already has the disable option with a check button.

Fix: make the default focus on the plot widget

Now the keyboard-based workflow is not so smooth since pressing tab/space/enter triggers actions in other widgets instead of performing a scan. Figure out how to make plot/window focused by default, instead of individual widets.

Sample naming

It would be cool to give a scan a name, so you know which sample is which.

Spectralon calibration option

Ideally, the chart shows values between 0 and 1, where 1 is the maximum reflection when the sensor is covered with Spectralon.

To do this I propose the following

  • Have a button to do a baseline scan (scanning when the sensor is covered with Spectralon), resulting in an array of MaxReadings
  • Divide new reading by MaxReadings and then plot it in graph

Option to make a previous reading stick

It would be cool if we can add the possibility to save previous scans so that you can see the difference instantly, sort of how I overlapped reading in the image below
image

Have a slider for averaging

Could be interesting to test by averaging scans to improve the quality of the reading. Now it always sends the command for 1 measurement, this could be changed to send multiple commands after each other and then average.

Fix auto-zooming

Plots viewport is now automatically adjusted on every measurement. However, it's misleading and confusing because from one measurement to another, the shape of the curve seemingly changes just a little - while the numbers could differ by an order of magnitude. If we find a range which fits most of the cases, I think it will serve the purpose better without auto zooming

COM port cannot be open if an Arduino Uno Clone is used

Whenever an Arduino uno clone is used, it does not want to use
In serial it outputs the following:
Cannot open serial port 'None', using dummy data Cannot open serial port 'None', using dummy data Cannot open serial port 'COM11', using dummy data Cannot open serial port 'COM11', using dummy data

instead of :
Cannot open serial port 'None', using dummy data Cannot open serial port 'None', using dummy data Opened serial port COM13 Opened serial port COM13

The clone has a CH340 serial chip

Add export functionality for the plots

Currently all of the plots have an export button, but this functionality has not yet been implemented.
For the 2d scatterplot and the histogram the user can right-click on the plots and select export.

It would be nice if exporting is implemented through the button, and for all of the plots.

Zoom only in the Y-axis

Now if we zoom in and out in the plotter, it also zooms out on the X-axis, but we will never measure beyond 1750nm or below 800nm
image

Use default system colours for plot

Grab colours from the colour palette of the system theme and use them as the colours for the lines and markers in the plot.
This would improve visibility

PyQt6 is broken on Python 3.9?

So, I was trying to install this tool on my RPI 3B+ running Raspbian 11(bullseye). Since it already comes installed with Python 3.9, I decided to just use the default build instead of building Python3.8(or greater) from source.

The pipenv install commands fails due to pyqt6 issue(after changing dependency to Python3.9). The log from pip install pyqt6 is as follows:

pi@raspberrypi:~/PSplot $ pip install pyqt6
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pyqt6
  Using cached PyQt6-6.3.0.tar.gz (1.0 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [29 lines of output]
      Traceback (most recent call last):
        File "/home/pi/.local/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 156, in prepare_metadata_for_build_wheel
          hook = backend.prepare_metadata_for_build_wheel
      AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "/home/pi/.local/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/home/pi/.local/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/pi/.local/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 160, in prepare_metadata_for_build_wheel
          whl_basename = backend.build_wheel(metadata_directory, config_settings)
        File "/tmp/pip-build-env-fhev88a7/overlay/lib/python3.9/site-packages/sipbuild/api.py", line 51, in build_wheel
          project = AbstractProject.bootstrap('pep517')
        File "/tmp/pip-build-env-fhev88a7/overlay/lib/python3.9/site-packages/sipbuild/abstract_project.py", line 83, in bootstrap
          project.setup(pyproject, tool, tool_description)
        File "/tmp/pip-build-env-fhev88a7/overlay/lib/python3.9/site-packages/sipbuild/project.py", line 594, in setup
          self.apply_user_defaults(tool)
        File "project.py", line 67, in apply_user_defaults
          super().apply_user_defaults(tool)
        File "/tmp/pip-build-env-fhev88a7/overlay/lib/python3.9/site-packages/pyqtbuild/project.py", line 70, in apply_user_defaults
          super().apply_user_defaults(tool)
        File "/tmp/pip-build-env-fhev88a7/overlay/lib/python3.9/site-packages/sipbuild/project.py", line 241, in apply_user_defaults
          self.builder.apply_user_defaults(tool)
        File "/tmp/pip-build-env-fhev88a7/overlay/lib/python3.9/site-packages/pyqtbuild/builder.py", line 67, in apply_user_defaults
          raise PyProjectOptionException('qmake',
      sipbuild.pyproject.PyProjectOptionException
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

For now, I've switched to pyqt5 using this command to install : sudo apt-get install python3-pyqt5 . And it works fine. I think this is an internal problem with pyqt6 since it is relatively new and needs some patchwork before it is a stable build.

Make serial ports work automagically regardless of the OS

The serial port is now hardcoded. Needs changing code when running on Linux/Windows, which is ugly - let's do something better.
Maybe dropdown menu with available serial ports = manual selection,
Maybe hardcoded defaults for each OS?
Something simple, but so that it doesn't need changing code every time

Cannot select COM port when PSplot is running

If the software is already open and I click the COM ports on the top, it refreshes and shows the available COM port, but when click on the terminal it gives an error saying cannot open COM port

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.