witzit/README.md

242 lines
5.9 KiB
Markdown
Raw Permalink Normal View History

2022-01-22 23:18:26 -07:00
# witzit - What In The Zap Is That?
`witzit` --- What In The Zap Is That?
2022-01-24 16:55:47 -07:00
AI categorization of spectra from LIBS/XRF analyzers.
2022-01-22 23:18:26 -07:00
2022-05-27 14:40:54 -06:00
Example Jupyter plot from SciAps X-555 XRF:
![xrf-spectrum-sciaps](notebooks/xrf-spectrum.png)
Example plot from Olympus Vanta XRF:
![xrf-spectrum-vanta](notebooks/xrf-spectrum-vanta.png)
2022-01-22 23:18:26 -07:00
# Install
## Install Dependencies
Get system dependency and upgrade Python pip.
2022-05-25 13:01:44 -06:00
Perhaps do something like this, or set up a Python virtual environment.
2022-01-22 23:18:26 -07:00
```
sudo apt update
2023-01-29 15:47:16 -07:00
sudo apt install git python3-pip python3-virtualenv
2022-01-22 23:18:26 -07:00
```
2023-01-29 15:47:16 -07:00
2022-05-25 13:01:44 -06:00
## pysalx
The `pysalx` repo contains scripts for interacting with the device.
Install that too.
```
git clone https://spacecruft.org/spacecruft/pysalx.git
cd pysalx/
# Set the date
./scripts/pysalx-date-set
# whatever else...
..
```
2022-01-22 23:18:26 -07:00
## Clone Git Repo
Get source code with `git`.
2022-01-24 17:57:24 -07:00
The default `requirements.txt` installs a Tensorflow without
2022-01-24 14:34:23 -07:00
GPU support. You can edit the `requirements.txt` file to change
which is supported. The "generic" version supports both.
2023-01-29 15:47:16 -07:00
XXX tensorflow not available in pip 2023-01.
## Setup
Thusly.
2022-01-24 14:34:23 -07:00
2022-01-22 23:18:26 -07:00
```
git clone https://spacecruft.org/spacecruft/witzit
cd witzit/
2023-01-29 15:47:16 -07:00
virtualenv -p python3 env
source env/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
deactivate
2022-01-22 23:18:26 -07:00
```
2022-05-27 14:22:12 -06:00
2022-01-24 15:07:39 -07:00
# witzit scripts
2022-05-27 16:13:43 -06:00
* `witzit-load` --- Load and text display data from SciAps or Olympus XRF.
2022-05-27 17:05:44 -06:00
* `witzit-plot` --- Plot a sample from a SciAps X-555 or Olympus Vanta-M.
* `witzit-plot2png` --- Plot a sample from a SciAps X-555 or Olympus Vanta-M
and save to PNG.
2022-01-24 15:07:39 -07:00
2022-01-24 16:44:36 -07:00
Development is most easily done under Jupyter with Tensorboard
2022-01-24 16:59:16 -07:00
for training models. These files are in the `notebooks/` directory.
2022-01-24 16:44:36 -07:00
2022-05-27 17:05:44 -06:00
* `witzit-plot.ipynb` --- witzit Jupyter notebook, plotting application for
SciAps X-555 or Olympus Vanta-M.
2022-01-24 16:44:36 -07:00
* `witzit-predict.ipynb` --- witzit Jupyter notebook, prediction application.
* `witzit-train.ipynb` --- witzit Jupyter notebook, training application.
2022-01-24 17:19:40 -07:00
# Data
Note: Files in the `data/` directory may be deleted and/or manipulated
by scripts in this application.
Note well, the `data/` directory is ignored by git, and is a temporary
directory where data to be processed is stored. For example, if you have
a main original archive of 10,000 samples and you want to process just 1,000
of them, they would be copied to the `data/` directory.
2022-01-22 23:18:26 -07:00
2022-01-24 18:47:55 -07:00
Data is also stored here, which can also be deleted/moved by scripts:
`/srv/witzit/`
Each element sample will be stored under here:
`/srv/witzit/data/element/`
Each element model will be stored under here:
`/srv/witzit/data/models/`
Temporary logs during training may be written to the gitignored
`logs/` directory.
2022-01-22 23:18:26 -07:00
# Usage
2022-01-24 14:49:50 -07:00
HOWTO USE. Getting closer...
2022-01-22 23:18:26 -07:00
2022-01-24 14:49:50 -07:00
```
# Example:
2022-05-27 14:22:12 -06:00
debian@workstation:~/spacecruft/witzit$ ./witzit-load-x555
2022-05-25 16:12:03 -06:00
energy (eV) 2048
0 20.590676 0
1 45.021816 0
2 69.452957 0
3 93.884097 0
...
1023 25013.647367 175
1024 25038.078508 173
1025 25062.509648 155
1026 25086.940789 193
...
2047 50031.135199 1
```
## Jupyter Notebooks
2022-05-25 19:23:54 -06:00
2022-05-25 16:12:03 -06:00
Run jupyter thusly:
```
cd witzit/notebooks
jupyter-lab
2022-01-24 14:49:50 -07:00
```
# Hardware
2022-01-22 23:18:26 -07:00
* SciAps LIBS Analyzer
* SciAps XRF Analyzer
2022-05-27 14:22:12 -06:00
* Olympus XRF Analyzer
2022-01-22 23:18:26 -07:00
2022-01-22 23:37:49 -07:00
# Deep Learning Algorithm
Can use lots from `wut`.
* https://spacecruft.org/spacecruft/satnogs-wut/src/branch/master/wut-worker-mas.py#L67-L79
2022-01-22 23:40:17 -07:00
```
def uncompiled_model():
model = Sequential([
Conv2D(16, 3, padding='same', activation='relu', input_shape=(IMG_HEIGHT, IMG_WIDTH ,3)),
MaxPooling2D(),
Conv2D(32, 3, padding='same', activation='relu'),
MaxPooling2D(),
Conv2D(64, 3, padding='same', activation='relu'),
MaxPooling2D(),
Flatten(),
Dense(512, activation='relu'),
Dense(1, activation='sigmoid')
])
return model
```
Amazingly (to me), the paper
*Classification of radioxenon spectra with deep learning algorithm*
(2021) by Azimi, et al. uses nearly the identical CNN `Sequence()` as
2022-01-22 23:37:49 -07:00
`wut` uses, indicating it may be a very good base to start from.
Paper is non-gratis science:
* https://www.sciencedirect.com/science/article/abs/pii/S0265931X21001909
The `Sequence()` diagram is pulled from the Azimi paper, but is the
same as in `wut`, so makes a good reference.
2022-01-22 23:39:15 -07:00
![Deep Learning Sequence](img/sequence.png)
2022-01-23 23:31:01 -07:00
# Articles:
* https://www.sciencedirect.com/science/article/abs/pii/S0265931X21001909
*Classification of radioxenon spectra with deep learning algorithm*
2022-01-23 22:50:03 -07:00
* https://www.sciencedirect.com/science/article/pii/S0030401822000402
2022-01-23 23:31:01 -07:00
*Deep convolutional neural networks as a unified solution for Raman spectroscopy-based classification in biomedical applications*
* https://www.sciencedirect.com/science/article/abs/pii/S058485472030313X
*Automatic preprocessing of laser-induced breakdown spectra using partial least squares regression and feed-forward artificial neural network: Applications to Earth and Mars data*
* https://www.sciencedirect.com/science/article/abs/pii/S0584854719306068
*Determination of minor metal elements in steel using laser-induced breakdown spectroscopy combined with machine learning algorithms*
* https://www.sciencedirect.com/science/article/abs/pii/S1386142521009380
*Feature selection of infrared spectra analysis with convolutional neural network*
2022-01-23 22:50:03 -07:00
2023-01-29 15:47:16 -07:00
# Development
Setup like above, and also:
```
cd witzit/
source env/bin/activate
pip install -r requirements-dev.txt
```
Then before committing new code, make sure it is enprettified:
```
black foo.py
```
2022-01-24 15:10:29 -07:00
# See Also
2022-01-24 16:59:16 -07:00
* `pysalx` --- Unofficial scripts for interacting with the SciAps LIBS
and XRF analyzers.
https://spacecruft.org/spacecruft/pysalx/
2022-01-24 15:10:29 -07:00
* `wut?` --- *What U Think?* SatNOGS Observation AI.
https://spacecruft.org/spacecruft/satnogs-wut/
2022-05-27 14:22:12 -06:00
# Status
Alpha software under development.
Need to check:
* *API: 501 Not Implemented*
https://spacecruft.org/spacecruft/pysalx/issues/2
2022-01-22 23:18:26 -07:00
# Unofficial
2022-05-27 14:40:54 -06:00
Unofficial, unaffiliated with SciAps or Olympus.
2022-01-22 23:18:26 -07:00
# License
License: GPLv3 or any later version.
2023-01-29 15:47:16 -07:00
*Copyright © 2019-2023, Jeff Moe.*
2022-01-22 23:18:26 -07:00