Skip to content

Commit 4568460

Browse files
authored
Refactor modules (#1)
* refactor parsers all in one spot * Create pyproject.toml * revise package imports * Update andor.py * lib dir was hiding initially called lib, but was ignored due to gitignore. renamed to `core` to avoid confusion with packaging parsers.__init__ underwent some revision * Create .pre-commit-config.yaml * some cleanup * Create pl_T_R_A.py * Delete main2.py * Create environment.yml * fixes from flake8 simply example script issues * example fixes * flake8: fix bad references * give a test * Create __init__.py * rename to troubleshoot pytest * Update python-app.yml * Update andor.py * Update horiba.py * Delete __init__.py
1 parent 3337597 commit 4568460

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+674
-588
lines changed

.github/workflows/python-app.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
python -m pip install --upgrade pip
2929
pip install flake8 pytest
3030
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
31+
pip install .
3132
- name: Lint with flake8
3233
run: |
3334
# stop the build if there are Python syntax errors or undefined names

.github/workflows/python-package-conda.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 24.10.0 # Replace by any tag/version: https://github.com/psf/black/tags
4+
hooks:
5+
- id: black
6+
language_version: python3 # Should be a command that runs python3.6+
7+
args: ["--line-length", "99"]
8+
9+
- repo: https://github.com/pre-commit/pre-commit-hooks
10+
rev: v5.0.0
11+
hooks:
12+
- id: trailing-whitespace
13+
- id: no-commit-to-branch
14+
args: [-b master]
15+
16+
default_language_version:
17+
python: python3

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,32 @@
22
Jin Group Tools for handling a variety of common data.
33
Builds upon the WrightTools Data object.
44

5-
6-
## Installation
7-
8-
Basic:
9-
10-
`pip install git+https://github.com/wright-group/makeitwright.git`
11-
12-
iontof support is considered optional; if you need to use iontof data, use
13-
14-
`pip install git+https://github.com/wright-group/makeitwright.git[iontof]`
15-
16-
175
## Features
186

197
- a module for each instrument featured
20-
- AFM
8+
- AFM (Gwiddion)
219
- Andor Neo Camera (Solis)
2210
- Becker and Hickl SPCM
2311
- Horiba LabRAM
2412
- Generic Images
2513
- ion TOF
2614
- XRD (Bruker)
27-
- various data importers to create the WrightTools Data objects.
2815
- preset styles and routines for making quick figures
2916

3017

18+
## Installation
19+
20+
### Basic
21+
22+
`pip install git+https://github.com/wright-group/makeitwright.git`
23+
24+
### IonTOF
25+
26+
support for iontof data is optional; if you need to use iontof data, specify additional imports using:
27+
28+
`pip install git+https://github.com/wright-group/makeitwright.git[iontof]`
29+
30+
3131
## Examples
3232

3333
TODO

scripts/AbsProcessing.py renamed to examples/AbsProcessing.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11

2-
# Process Reflectance/Transmittance/Absorbance Data from Wright group
2+
# Process Reflectance/Transmittance/Absorbance Data from Wright group Microscope
33

44
import pathlib
5-
import makeitwright.process.andor as andor
6-
from makeitwright.process.helpers import roi
7-
from makeitwright.parsers import parse
8-
from makeitwright.artists import setparams, setdpi
9-
from makeitwright.spectra import plot_spectra as plot
5+
import makeitwright as mw
6+
import matplotlib as mpl
107

118

12-
setparams()
13-
setdpi(150)
9+
andor = mw.andor
10+
roi = mw.helpers.roi
11+
parse = mw.parsers.parse
12+
plot = mw.spectra.plot_spectra
13+
14+
15+
mpl.rc(dpi=150)
16+
1417

1518
filepath = pathlib.Path().expanduser().resolve() / "Desktop/Research Data/Wright Table/Original/test"
1619
filename_R = "PEAPbBr4 R"

scripts/PLProcessing.py renamed to examples/PLProcessing.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
# Process PL Data from Wright group
33

44
import pathlib
5-
import makeitwright.process.andor as andor
6-
from makeitwright.process.helpers import roi
7-
from makeitwright.parsers import parse
8-
from makeitwright.artists import setparams, setdpi
9-
from makeitwright.spectra import plot_spectra as plot
5+
import makeitwright as mw
106

117

12-
setparams()
13-
setdpi(150)
8+
andor = mw.andor
9+
roi = mw.helpers.roi
10+
parse = mw.parsers.parse
11+
plot = mw.spectra.plot_spectra
12+
1413

1514
filepath = pathlib.Path().expanduser() / "Desktop" / "Research Data" / "Wright Table" / "Original" / "test"
1615
filename = "PEAPbI on FPEASnI PL 77K 4 2 hour wait for cool"

scripts/main.py renamed to examples/main.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import matplotlib as mpl
22
from pathlib import Path
33

4-
from makeitwright.process import andor
4+
import makeitwright as mw
55

6-
from makeitwright.process.helpers import show, roi, set_label
7-
from makeitwright.parsers import parse
8-
from makeitwright.artists import plot
6+
andor = mw.andor
7+
roi = mw.helpers.roi
8+
parse = mw.parsers.parse
9+
plot = mw.artists.plot
910

1011

1112
user_path = Path().expanduser().resolve()

scripts/main2.py renamed to examples/pl_T_R_A.py

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,49 @@
11
import pathlib
2-
import numpy as np
3-
import matplotlib.cm as cms
4-
import cmocean.cm as cmo
5-
from scipy.signal import savgol_filter as savgol
6-
from scipy.signal import medfilt2d
7-
from scipy.optimize import curve_fit
8-
from scipy.stats import pearsonr, spearmanr, ttest_ind
9-
import WrightTools as wt
2+
import matplotlib as mpl
3+
import makeitwright as mw
104

11-
import makeitwright.process.andor as andor
12-
import makeitwright.process.beckerhickl as becker
13-
import makeitwright.process.spectralprofile
145

15-
from makeitwright.process.helpers import show, roi, norm, set_label
16-
from makeitwright.parsers import parse
17-
from makeitwright.artists import setparams, setdpi
18-
from makeitwright.spectra import plot_spectra as plot
6+
roi = mw.helpers.roi
7+
parse = mw.parsers.parse
8+
andor = mw.andor
9+
becker = mw.beckerhickl
10+
plot = mw.spectra.plot_spectra
1911

20-
setparams()
21-
setdpi(150)
12+
fp = pathlib.Path().expanduser().resolve() / r"Desktop/Research Data/Wright Table/Original"
2213

23-
fp = pathlib.Path().expanduser().resolve() / r"Desktop/Research Data/Wright Table/Original" # filepath name to folder
14+
# set plotting parameters
15+
mpl.rcParams['font.sans-serif'] = "Arial"
16+
mpl.rcParams['font.family'] = "sans-serif"
17+
mpl.rcParams['font.size'] = 14
18+
mpl.rcParams['figure.dpi'] = 300
19+
mpl.rcParams['lines.linewidth'] = 4
20+
mpl.rcParams['pcolor.shading'] = 'auto'
21+
mpl.rcParams['figure.dpi'] = 150
2422

25-
26-
#
2723
if True: # Plot PL
2824
data = parse(fp, keywords='4 hr.asc')
29-
#andor.correct_PL_background(data, ybkg=[0, 20])
30-
#y_profile = roi(data, {'wl': ([400, 800], 'sum')}) # If need to check object area
31-
#plot(y_profile)
3225
PL_ROI = roi(data, {'y': ([1021, 1047], 'average')})
3326
plot(PL_ROI, channel=0, xrange=[500, 850])
34-
PL_output = open('C:/Users/kmfor/Desktop/Research Data/Wright Table/Original/4hr.txt', 'w')
27+
PL_output = open(fp / '4hr.txt', 'w')
3528
PL_dataTrace = zip(PL_ROI.axes[0], PL_ROI.channels[0])
3629
for x in PL_dataTrace:
3730
PL_output.write(str(x[0])+'\t')
3831
PL_output.write(str(x[1])+'\n')
3932
PL_output.close()
4033

41-
#
4234
if True: # Plot T/R/A
43-
data = parse('C:/Users/kmfor/Desktop/Research Data/Wright Table/Original/For Chris/23_11_21/4ClPEASnI n1', keywords='Object 3')
35+
data = parse(fp / 'For Chris/23_11_21/4ClPEASnI n1', keywords='Object 3')
4436
R = data[2]
4537
R_back = data[1]
4638
T = data[4]
4739
T_back = data[3]
48-
4940

5041
andor.compute_reflectance(R, R_back, dark_wavelength_range=None)
5142
y_profile = roi(R, {'wl': ([580, 750], 'sum')}) # If need to check object area
5243
plot(y_profile)
5344
plot(R, channel=1, ROI={'y': ([1020, 1070], 'average')}, xrange=[580, 750]) #Currently at 10 x mag
5445
R_ROI = roi(R, {'y': ([1020, 1070], 'average')})
55-
R_output = open('C:/Users/kmfor/Desktop/Research Data/Wright Table/Original/For Chris/23_11_21/4ClPEASnI n1/Object 3 R processed.txt', 'w')
46+
R_output = open(fp / 'For Chris/23_11_21/4ClPEASnI n1/Object 3 R processed.txt', 'w')
5647
R_dataTrace = zip(R_ROI.axes[0], R_ROI.channels[1])
5748
for x in R_dataTrace:
5849
R_output.write(str(x[0])+'\t')
@@ -64,15 +55,15 @@
6455
# plot(y_profile)
6556
plot(T, channel=1, ROI={'y': ([1020, 1070], 'average')}, xrange=[580, 750]) # Current 10x mag, 100x mag 54-70
6657
T_ROI = roi(T, {'y': ([1020, 1070], 'average')})
67-
T_output = open('C:/Users/kmfor/Desktop/Research Data/Wright Table/Original/For Chris/23_11_21/4ClPEASnI n1/Object 3 T Processed.txt', 'w')
58+
T_output = open(fp / 'For Chris/23_11_21/4ClPEASnI n1/Object 3 T Processed.txt', 'w')
6859
T_dataTrace = zip(T_ROI.axes[0], T_ROI.channels[1])
6960
for x in T_dataTrace:
7061
T_output.write(str(x[0])+'\t')
7162
T_output.write(str(x[1])+'\n')
7263
T_output.close()
7364
#
7465
andor.compute_absorbance(R, T)
75-
A_output = open('C:/Users/kmfor/Desktop/Research Data/Wright Table/Original/For Chris/23_11_21/4ClPEASnI n1/Object 3 A processed.txt', 'w')
66+
A_output = open(fp / 'For Chris/23_11_21/4ClPEASnI n1/Object 3 A processed.txt', 'w')
7667
A_ROI = roi(T, {'y': ([1020, 1070], 'average')}) # A is channel 2 in both R and T data objects
7768
plot(R, channel=2, ROI={'y': ([1020, 1070], 'average')}, xrange=[580, 750]) #Current 10x mag. can add vrange
7869
A_dataTrace = zip(A_ROI.axes[0], A_ROI.channels[2])

scripts/workup.py renamed to examples/workup.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
from scipy.signal import savgol_filter
99
from matplotlib import pyplot as plt
1010

11+
import makeitwright as mw
12+
13+
14+
parse = mw.parsers.parse
15+
__at = mw.helpers.find_nearest()
16+
roi = mw.helpers.roi
17+
set_label = mw.helpers.set_label
18+
norm = mw.helpers.norm
19+
1120

1221
def lorentz_fit_2(data, channel='darksub', xrange='all', bounds=None, plot=False):
1322

@@ -136,6 +145,7 @@ def test2(x, a1, u1, s1, a2, u2, s2):
136145
def residual(a, fit):
137146
return (a-fit)/a*100
138147

148+
139149
base = pathlib.Path().expanduser().resolve() / r'OneDrive/Documents/UW/research/data local/WG-microscope/biexciton-fluence-dependent-PL_20220909'
140150
fn1 = base / "n1BA"
141151
fn2 = base / 'n2BAMA_CRRsample'
@@ -201,7 +211,7 @@ def residual(a, fit):
201211
wlbkgsub = (d['sig'][:]-wlbkg)/exposure
202212
d.create_channel('constantbkgsub',values=constantbkgsub)
203213
d.create_channel('wlbkgsub',values=wlbkgsub)
204-
set_label(d, 'wlbkgsub', "PL intensity (cps)")
214+
# set_label(d, 'wlbkgsub', "PL intensity (cps)")
205215

206216
bn1 = roi(n1raw,{'y':'sum'})
207217
bn2 = roi(n2raw,{'y':'sum'})

makeitwright/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.1

0 commit comments

Comments
 (0)