-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdemo.py
31 lines (26 loc) · 1.06 KB
/
demo.py
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
# -*- coding: utf-8 -*-
import os
import numpy as np
from igorwriter import IgorWave5
def demo():
os.makedirs('./igor', exist_ok=True)
a = np.arange(2*3*4*5)
for typ in (np.int32, np.float64, np.complex128):
a_ = a.astype(typ)
w1 = IgorWave5(a_, '%s_1d' % typ.__name__)
w2 = IgorWave5(a_.reshape((2, -1)), '%s_2d' % typ.__name__)
w3 = IgorWave5(a_.reshape((2, 3, -1)), '%s_3d' % typ.__name__)
w4 = IgorWave5(a_.reshape((2, 3, 4, -1)), '%s_4d' % typ.__name__)
with open('./igor/waves_%s.itx' % typ.__name__, 'w') as fp:
# Igor Text files can contain multiple waves in one file.
w1.save_itx(fp)
w2.save_itx(fp)
w3.save_itx(fp)
w4.save_itx(fp)
# Igor Binary Wave files can only contain one wave per file.
w1.save('./igor/wave1_%s.ibw' % typ.__name__)
w2.save('./igor/wave2_%s.ibw' % typ.__name__)
w3.save('./igor/wave3_%s.ibw' % typ.__name__)
w4.save('./igor/wave4_%s.ibw' % typ.__name__)
if __name__ == '__main__':
demo()