Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified convert.py
100644 → 100755
Empty file.
Empty file modified convert_gui.py
100644 → 100755
Empty file.
914 changes: 474 additions & 440 deletions spc/spc.py

Large diffs are not rendered by default.

25 changes: 14 additions & 11 deletions spc/sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import struct
import numpy as np

from .global_fun import read_subheader
from .util import read_subheader


class subFile:
Expand All @@ -26,6 +26,8 @@ class subFile:
"""

def __init__(self, data, fnpts, fexp, txyxy, tsprec, tmulti):
# fixed header size, 32 bytes
y_dat_pos = 32

# extract subheader info
self.subflgs, \
Expand All @@ -38,16 +40,10 @@ def __init__(self, data, fnpts, fexp, txyxy, tsprec, tmulti):
self.subscan, \
self.subwlevel, \
self.subresv \
= read_subheader(data[:32])

# header is 32 bytes
y_dat_pos = 32
= read_subheader(data[:y_dat_pos])

if txyxy:
# only reason to use subnpts if x data is here
pts = self.subnpts
else:
pts = fnpts
# only reason to use subnpts if x data is here
pts = self.subnpts if txyxy else fnpts

# Choosing exponent
# -----------------
Expand Down Expand Up @@ -118,7 +114,7 @@ class subFileOld:
"""

def __init__(self, data, pts, fexp, txyxy):
# fixed header size
# fixed header size, 32 bytes
y_dat_pos = 32

# extract subheader info
Expand Down Expand Up @@ -192,3 +188,10 @@ def __init__(self, data, pts, fexp, txyxy):
# if 1 subfile changed
# if 8 if peak table should not be used
# if 128 if subfile modified by arithmetic

class subFileShimadzu:
"""A "subFile" class for Shimadzu files
This is a dummy class, currently used only to maintain consistency
"""
def __init__(self, y):
self.y = y
6 changes: 3 additions & 3 deletions spc/global_fun.py → spc/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

author: Rohan Isaac
"""

from __future__ import division, absolute_import, unicode_literals, print_function
import struct


# ------------------------------------------------------------------------
# Process subfile data
# ------------------------------------------------------------------------


def read_subheader(subheader):
"""
Return the subheader as a list
Expand Down Expand Up @@ -44,14 +45,13 @@ def read_subheader(subheader):

return item_cpy


# ------------------------------------------------------------------------
# Decode a character to boolean array
# ------------------------------------------------------------------------


def flag_bits(n):
"""Return the bits of a byte as a boolean array:

n (charater):
8-bit character passed

Expand Down
Binary file added test_data/Renishaw Ramascope Raman.spc
Binary file not shown.
Binary file added test_data/Shimadzu UV-Vis.spc
Binary file not shown.
43 changes: 43 additions & 0 deletions test_data/txt2/Renishaw Ramascope Raman.spc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
368.1315625 1739.97631836
369.204176897 1670.51464844
370.276791295 1772.1072998
371.349405692 1729.35314941
372.422020089 1637.3717041
373.494634487 1650.23095703
374.567248884 1707.82946777
375.639863281 1652.10180664
376.712477679 1703.54992676
377.785092076 1768.54199219
378.857706473 1679.75842285
379.930320871 1747.78295898
381.002935268 1659.63220215
382.075549665 1673.01416016
383.148164062 1700.8236084
384.22077846 1699.73352051
385.293392857 1661.68554688
386.366007254 1687.59521484
387.438621652 1603.41943359
388.511236049 1688.19128418
389.583850446 1628.76904297
390.656464844 1626.72216797
391.729079241 1617.99267578
392.801693638 1552.7010498
393.874308036 1615.81506348
394.946922433 1611.68823242
396.01953683 1625.23168945
397.092151228 1644.00622559
398.164765625 1622.30163574
399.237380022 1646.70056152
400.30999442 1661.34460449
401.382608817 1725.60058594
402.455223214 1588.95654297
403.527837612 1690.34729004
404.600452009 1583.52783203
405.673066406 1707.29284668
406.745680804 1627.45410156
407.818295201 1573.32958984
408.890909598 1660.47509766
409.963523996 1703.47851562
411.036138393 1625.2565918
412.10875279 1587.6986084
413.181367187 1587.55078125
Loading