forked from scholi/libSIF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sif2npz
31 lines (26 loc) · 807 Bytes
/
sif2npz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python
# *-* coding: utf-8 *-*
import sys
import os
from SIF import SIF
import numpy as np
def sif2npz(fname, bgname=None):
sig=SIF(fname)
Signal=sig.sig.imageData
dname = fname[:-4]+".npz"
if bgname!=None:
print "Background image given"
print "It will be subtracted from the Signal"
bg=SIF(bgname)
BG=bg.sig.imageData
Signal=Signal-BG
if sig.sig.CenterWavelength>0 and (sig.sig.poly==np.array([0,1,0,0])).all():
if sig.sig.CenterWavelength==699.98:
sig.sig.poly=np.array([ 4.14274195e+02, 5.58106514e-01, 9.53039510e-07,-2.19417467e-09])
np.savez(str(dname),sig=Signal,cw=sig.sig.CenterWavelength,poly=sig.sig.poly)
if __name__ == "__main__":
if len(sys.argv)>1:
if len(sys.argv)>2:
sif2npz(sys.argv[1],"BG_"+sys.argv[1])
else:
sif2npz(sys.argv[1])