-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathconftest.py
114 lines (90 loc) · 3.07 KB
/
conftest.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import os
import pytest
import numpy as np
import tables as tb
import pandas as pd
@pytest.fixture(scope = 'session')
def ICARO():
krc = os.environ['ICARO']
return os.path.join(krc, "test_data")
@pytest.fixture(scope = 'session')
def DSTDIR(ICARO):
return os.path.join(ICARO, "dst")
@pytest.fixture(scope = 'session')
def MAPSDIR(ICARO):
return os.path.join(ICARO, "maps")
@pytest.fixture(scope = 'session')
def KDSTDIR(ICARO):
return os.path.join(ICARO, "kdst")
@pytest.fixture(scope = 'session')
def LDSTDIR(ICARO):
return os.path.join(ICARO, "ldst")
@pytest.fixture(scope = 'session')
def config_tmpdir(tmpdir_factory):
return tmpdir_factory.mktemp('configure_tests')
@pytest.fixture(scope = 'session')
def output_tmpdir(tmpdir_factory):
return tmpdir_factory.mktemp('output_files')
@pytest.fixture(scope = 'session')
def folder_test_dst(ICARO):
return os.path.expandvars('$ICARO/test_data/dst/')
@pytest.fixture(scope='session')
def test_dst_file():
return 'kdst_7517_LB_0-100_TestMapScript.h5'
@pytest.fixture(scope = 'session')
def test_map_file(ICARO):
return os.path.expandvars('$ICARO/test_data/maps/test_map_nan.h5')
@pytest.fixture(scope='session')
def output_maps_tmdir(tmpdir_factory):
return tmpdir_factory.mktemp('output_maps')
@pytest.fixture(scope='session')
def dst_filenames():
return ['dst_6284_trigger1_0000_7920.h5']
@pytest.fixture(scope='session')
def ldst_filename():
return 'lst_6284_trigger1_0000_7920.h5'
@pytest.fixture(scope='session')
def map_filename():
return 'kr_maps_xy_6284.h5'
@pytest.fixture(scope='session')
def map_filename_ts():
return 'kr_maps_xy_ts_6284.h5'
@pytest.fixture(scope='session')
def dst_filenames_path(DSTDIR, dst_filenames):
return [os.path.join(DSTDIR, dst_filenames[0])]
@pytest.fixture(scope='session')
def ldst_filename_path(LDSTDIR, ldst_filename):
return os.path.join(LDSTDIR, ldst_filename)
@pytest.fixture(scope='session')
def map_filename_path(MAPSDIR, map_filename):
return os.path.join(MAPSDIR, map_filename)
@pytest.fixture(scope='session')
def map_filename_ts_path(MAPSDIR, map_filename_ts):
return os.path.join(MAPSDIR, map_filename_ts)
@pytest.fixture(scope='session')
def dstData():
# define dst
D = {}
D['X'] = np.random.random(20) * 100
D['Y'] = np.random.random(20) * 100
D['Z'] = np.random.random(20) * 100
D['R'] = np.random.random(20) * 100
D['Phi'] = np.random.random(20) * 100
D['S2e'] = np.random.random(20) * 100
D['S1e'] = np.random.random(20) * 100
D['S2q'] = np.random.random(20) * 100
D['time'] = np.arange(0,100,5)
dst = pd.DataFrame.from_dict(D)
### Define x & y bins
xb = np.arange(0,101,25)
yb = np.arange(0,101,25)
nbx = len(xb) -1
nby = len(yb) -1
# define time bins
nt = 5
t0 = dst.time.values[0]
tf = dst.time.values[-1]
step = int((tf - t0) / nt)
indx = [(0, 19), (19, 38), (38, 57), (57, 76), (76, 95)]
ts = [9.5, 28.5, 47.5, 66.5, 85.5]
return dst, xb, yb, nbx, nby, nt, t0, tf, step, indx, ts