vaft 0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vaft-0.1/PKG-INFO +16 -0
- vaft-0.1/README.md +13 -0
- vaft-0.1/setup.cfg +4 -0
- vaft-0.1/setup.py +25 -0
- vaft-0.1/test/test_change_time_convention.py +10 -0
- vaft-0.1/test/test_import.py +23 -0
- vaft-0.1/test/test_load_sample.py +17 -0
- vaft-0.1/test/test_plot_submodule.py +14 -0
- vaft-0.1/test/test_save_load.py +0 -0
- vaft-0.1/test/test_save_sample.py +0 -0
- vaft-0.1/vaft/__init__.py +12 -0
- vaft-0.1/vaft/code/__init__.py +1 -0
- vaft-0.1/vaft/code/chease.py +0 -0
- vaft-0.1/vaft/code/efit.py +0 -0
- vaft-0.1/vaft/code/gpec.py +0 -0
- vaft-0.1/vaft/database/__init__.py +2 -0
- vaft-0.1/vaft/database/ods.py +160 -0
- vaft-0.1/vaft/database/raw.py +815 -0
- vaft-0.1/vaft/formula/__init__.py +4 -0
- vaft-0.1/vaft/formula/equilibrium.py +3 -0
- vaft-0.1/vaft/formula/green.py +253 -0
- vaft-0.1/vaft/formula/vacuum.py +0 -0
- vaft-0.1/vaft/formula/virial.py +0 -0
- vaft-0.1/vaft/machine_mapping/__init__.py +0 -0
- vaft-0.1/vaft/machine_mapping/from_file.py +111 -0
- vaft-0.1/vaft/machine_mapping/from_raw_database.py +216 -0
- vaft-0.1/vaft/machine_mapping/static.py +164 -0
- vaft-0.1/vaft/omas/__init__.py +5 -0
- vaft-0.1/vaft/omas/formula_wrapper.py +5 -0
- vaft-0.1/vaft/omas/general.py +154 -0
- vaft-0.1/vaft/omas/process_wrapper.py +365 -0
- vaft-0.1/vaft/omas/sample.py +35 -0
- vaft-0.1/vaft/omas/update.py +122 -0
- vaft-0.1/vaft/plot/__init__.py +6 -0
- vaft-0.1/vaft/plot/animation.py +0 -0
- vaft-0.1/vaft/plot/onedim.py +67 -0
- vaft-0.1/vaft/plot/time.py +1441 -0
- vaft-0.1/vaft/plot/topview.py +4 -0
- vaft-0.1/vaft/plot/twodim.py +32 -0
- vaft-0.1/vaft/process/__init__.py +7 -0
- vaft-0.1/vaft/process/default.py +17 -0
- vaft-0.1/vaft/process/electromagnetics.py +368 -0
- vaft-0.1/vaft/process/equilibrium.py +110 -0
- vaft-0.1/vaft/process/magnetics.py +514 -0
- vaft-0.1/vaft/process/profile.py +0 -0
- vaft-0.1/vaft/process/signal_processing.py +154 -0
- vaft-0.1/vaft/profile/__init__.py +0 -0
- vaft-0.1/vaft/profile/gfile.py +0 -0
- vaft-0.1/vaft/profile/profile.py +26 -0
- vaft-0.1/vaft/version.py +3 -0
- vaft-0.1/vaft.egg-info/PKG-INFO +16 -0
- vaft-0.1/vaft.egg-info/SOURCES.txt +53 -0
- vaft-0.1/vaft.egg-info/dependency_links.txt +1 -0
- vaft-0.1/vaft.egg-info/requires.txt +10 -0
- vaft-0.1/vaft.egg-info/top_level.txt +1 -0
vaft-0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: vaft
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: Versatile Analytical Framework for Tokamak
|
|
5
|
+
Home-page: https://github.com/VEST-Tokamak/vaft
|
|
6
|
+
Author: satelite2517, Hikitonic
|
|
7
|
+
Author-email: satelite2517@snu.ac.kr, peppertonic18@snu.ac.kr
|
|
8
|
+
Requires-Dist: h5py
|
|
9
|
+
Requires-Dist: numpy
|
|
10
|
+
Requires-Dist: uncertainties
|
|
11
|
+
Requires-Dist: omas
|
|
12
|
+
Requires-Dist: matplotlib
|
|
13
|
+
Provides-Extra: dev
|
|
14
|
+
Requires-Dist: pytest; extra == "dev"
|
|
15
|
+
Requires-Dist: black; extra == "dev"
|
|
16
|
+
Requires-Dist: flake8; extra == "dev"
|
vaft-0.1/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# VAFT(Versatile Analytical Framework for Tokamak)
|
|
2
|
+
|
|
3
|
+
All users are allowed to read these datasets, but if modification/deletion permissions are needed, please contact email. Databse system uses HSDS and if you want to get the h5 file format follow [h5pyd github](https://github.com/HDFGroup/h5pyd). This repository utilizes hdf5 and ODS data strucure ([omas github](https://github.com/gafusion/omas?tab=readme-ov-file)), if you need more information about this structure can be found on the following website: [omas](https://gafusion.github.io/omas/).
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
follow the [Learn Usage](https://satelite2517.github.io/vaft/)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## Reporting bugs
|
|
11
|
+
|
|
12
|
+
Leave comment on [issue](https://github.com/satelite2517/vaft/issues) or mail us (satelite2517@snu.ac.kr, peppertonic18@snu.ac.kr)
|
|
13
|
+
If you need more infomation about VEST find [Nuplex](http://nuplex.snu.ac.kr)
|
vaft-0.1/setup.cfg
ADDED
vaft-0.1/setup.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="vaft",
|
|
5
|
+
version="0.1",
|
|
6
|
+
packages=find_packages(),
|
|
7
|
+
description="Versatile Analytical Framework for Tokamak",
|
|
8
|
+
author="satelite2517, Hikitonic",
|
|
9
|
+
author_email="satelite2517@snu.ac.kr, peppertonic18@snu.ac.kr",
|
|
10
|
+
url="https://github.com/VEST-Tokamak/vaft",
|
|
11
|
+
install_requires=[
|
|
12
|
+
"h5py",
|
|
13
|
+
"numpy",
|
|
14
|
+
"uncertainties",
|
|
15
|
+
"omas",
|
|
16
|
+
"matplotlib",
|
|
17
|
+
],
|
|
18
|
+
extras_require={
|
|
19
|
+
"dev": [
|
|
20
|
+
"pytest",
|
|
21
|
+
"black",
|
|
22
|
+
"flake8",
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import vaft
|
|
2
|
+
from vaft.process import *
|
|
3
|
+
from vaft.plot import *
|
|
4
|
+
from vaft.machine_mapping import *
|
|
5
|
+
from vaft.formula import *
|
|
6
|
+
from vaft.omas import *
|
|
7
|
+
from vaft.code import *
|
|
8
|
+
from vaft.database import *
|
|
9
|
+
from vaft.database.file import *
|
|
10
|
+
from vaft.database.raw import *
|
|
11
|
+
# from vaft.database.ods import *
|
|
12
|
+
# Traceback (most recent call last):
|
|
13
|
+
# File "/Users/yun/Library/CloudStorage/OneDrive-Personal/Documents/Research/Code/vaft/test/test_import.py", line 11, in <module>
|
|
14
|
+
# from vaft.database.ods import *
|
|
15
|
+
# File "/Users/yun/Library/CloudStorage/OneDrive-Personal/Documents/Research/Code/vaft/vaft/database/ods/__init__.py", line 1, in <module>
|
|
16
|
+
# from .default import *
|
|
17
|
+
# File "/Users/yun/Library/CloudStorage/OneDrive-Personal/Documents/Research/Code/vaft/vaft/database/ods/default.py", line 23, in <module>
|
|
18
|
+
# def exist_file(username=h5pyd.getServerInfo()['username'], shot=None):
|
|
19
|
+
# File "/Users/yun/miniforge3/envs/fusion/lib/python3.8/site-packages/h5pyd/_hl/serverinfo.py", line 37, in getServerInfo
|
|
20
|
+
# http_conn = HttpConn(
|
|
21
|
+
# File "/Users/yun/miniforge3/envs/fusion/lib/python3.8/site-packages/h5pyd/_hl/httpconn.py", line 205, in __init__
|
|
22
|
+
|
|
23
|
+
print(f"vaft version: {vaft.__version__}")
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import vest
|
|
2
|
+
import pkg_resources
|
|
3
|
+
from omas import *
|
|
4
|
+
|
|
5
|
+
# load sample ods from file
|
|
6
|
+
data_path = pkg_resources.resource_filename('vest', 'data/39915.json')
|
|
7
|
+
|
|
8
|
+
# load the ods file
|
|
9
|
+
ods = ODS()
|
|
10
|
+
ods = ods.load(data_path, consistency_check=False)
|
|
11
|
+
|
|
12
|
+
# print the ods keys
|
|
13
|
+
print(ods.keys())
|
|
14
|
+
|
|
15
|
+
# print the ods['equilibrium'] keys
|
|
16
|
+
print(ods['equilibrium'].keys())
|
|
17
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# in this file, we test the all available plot submodule functions
|
|
2
|
+
# we will use the sample ods file in the data folder
|
|
3
|
+
from omas import *
|
|
4
|
+
import vaft
|
|
5
|
+
import pkg_resources
|
|
6
|
+
|
|
7
|
+
data_path = pkg_resources.resource_filename('vest', 'data/39915.json')
|
|
8
|
+
# load sample ods from file
|
|
9
|
+
ods = ODS()
|
|
10
|
+
ods = ods.load(data_path, consistency_check=False)
|
|
11
|
+
|
|
12
|
+
# plot pf_active
|
|
13
|
+
vaft.plot.time_pf_active_all_current(ods)
|
|
14
|
+
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Top-level package initialization
|
|
2
|
+
from .version import __version__
|
|
3
|
+
|
|
4
|
+
__all__ = ['process', 'formula', 'machine_mapping', 'plot', 'omas', 'code', 'database']
|
|
5
|
+
|
|
6
|
+
from . import process
|
|
7
|
+
from . import formula
|
|
8
|
+
from . import machine_mapping
|
|
9
|
+
from . import plot
|
|
10
|
+
from . import omas
|
|
11
|
+
from . import code
|
|
12
|
+
from . import database
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from . import *
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import urllib3
|
|
3
|
+
import h5pyd, h5py
|
|
4
|
+
import omas
|
|
5
|
+
import subprocess
|
|
6
|
+
import numpy
|
|
7
|
+
from uncertainties import ufloat
|
|
8
|
+
from uncertainties.unumpy import uarray
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def is_connect():
|
|
12
|
+
"""
|
|
13
|
+
Check if the user is connected to the server.
|
|
14
|
+
|
|
15
|
+
input: None
|
|
16
|
+
output: True if the user is connected to the server, False otherwise.
|
|
17
|
+
|
|
18
|
+
"""
|
|
19
|
+
try:
|
|
20
|
+
if h5pyd.getServerInfo()['state']=='READY':
|
|
21
|
+
username = h5pyd.getServerInfo()['username']
|
|
22
|
+
return True
|
|
23
|
+
else:
|
|
24
|
+
return False
|
|
25
|
+
except requests.exceptions.ConnectTimeout:
|
|
26
|
+
return False
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def exist_file(username=h5pyd.getServerInfo()['username'], shot=None):
|
|
30
|
+
"""
|
|
31
|
+
Check if the file exists.
|
|
32
|
+
|
|
33
|
+
If the 'username' or 'shot' parameter is provided, the function will check if a file with a matching prefix exists.
|
|
34
|
+
If 'username' or 'shot' is not provided, the function will list all files in the user's folder.
|
|
35
|
+
|
|
36
|
+
Parameters:
|
|
37
|
+
username (str): The username to access the corresponding folder.
|
|
38
|
+
shot (int, optional): The shot number to search for (default is None).
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
bool: True if the file or folder exists, False if it does not or if a connection error occurs.
|
|
42
|
+
"""
|
|
43
|
+
try:
|
|
44
|
+
Folder = list(h5pyd.Folder("/" + username + "/"))
|
|
45
|
+
if shot is not None:
|
|
46
|
+
file_list = list(Folder)
|
|
47
|
+
file_exist = False
|
|
48
|
+
|
|
49
|
+
for file in file_list:
|
|
50
|
+
if file.split("_")[0] == str(shot):
|
|
51
|
+
file_exist = True
|
|
52
|
+
print(file)
|
|
53
|
+
return True
|
|
54
|
+
|
|
55
|
+
if not file_exist:
|
|
56
|
+
print("File does not exist")
|
|
57
|
+
return False
|
|
58
|
+
else:
|
|
59
|
+
print(list(Folder))
|
|
60
|
+
except urllib3.exceptions.MaxRetryError:
|
|
61
|
+
return False
|
|
62
|
+
return True
|
|
63
|
+
|
|
64
|
+
def save(ods, shot, filename=None, env='server'):
|
|
65
|
+
"""
|
|
66
|
+
Function to save an ODS (Open Data Structure) file either locally or to an HDF5 server.
|
|
67
|
+
|
|
68
|
+
This function handles saving the ODS data to an HDF5 file, either on the local file system or
|
|
69
|
+
remotely to an HDF5 server using the `hsload` command. If no filename is provided, the function
|
|
70
|
+
defaults to using the shot number with an `.h5` extension.
|
|
71
|
+
|
|
72
|
+
Parameters:
|
|
73
|
+
ods (object): The Open Data Structure (ODS) object that needs to be saved.
|
|
74
|
+
shot (int): The shot number associated with the ODS data, used to generate the filename if not provided.
|
|
75
|
+
filename (str, optional): The name of the file to save the ODS data. Defaults to `None`, which generates a name based on the shot number.
|
|
76
|
+
env (str, optional): The environment where the file will be saved. It can be either 'server' for server upload or 'local' for local storage. Defaults to 'server'.
|
|
77
|
+
|
|
78
|
+
Returns:
|
|
79
|
+
None: The function doesn't return any specific value but prints information about the saving process.
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
# If no filename is provided, use the shot number to create a default file name
|
|
83
|
+
if filename is None:
|
|
84
|
+
filename = str(shot) + '.h5'
|
|
85
|
+
|
|
86
|
+
# If the environment is 'local', save the file locally using OMAS
|
|
87
|
+
if env == 'local':
|
|
88
|
+
omas.save_omas_h5(ods, filename)
|
|
89
|
+
|
|
90
|
+
# Test the connection to the server, and exit if the connection fails
|
|
91
|
+
if is_connect() != True:
|
|
92
|
+
print('Error: Connection to the server failed')
|
|
93
|
+
return
|
|
94
|
+
|
|
95
|
+
# Get the current username from the HDF5 server and construct the file path
|
|
96
|
+
username = 'public' if h5pyd.getServerInfo()['username'] == 'admin' else h5pyd.getServerInfo()['username']
|
|
97
|
+
file_path = "hdf5://{}/{}".format(username, filename)
|
|
98
|
+
omas.save_omas_h5(ods, filename)
|
|
99
|
+
|
|
100
|
+
command = ['hsload', '--h5image', filename, file_path]
|
|
101
|
+
result = subprocess.run(command, capture_output=True, text=True)
|
|
102
|
+
|
|
103
|
+
subprocess.run(['rm', filename], capture_output=True, text=True)
|
|
104
|
+
|
|
105
|
+
def convertDataset(ods, data):
|
|
106
|
+
"""
|
|
107
|
+
Recursive utility function to map HDF5 structure to ODS
|
|
108
|
+
|
|
109
|
+
:param ods: input ODS to be populated
|
|
110
|
+
|
|
111
|
+
:param data: HDF5 dataset of group
|
|
112
|
+
"""
|
|
113
|
+
import h5py
|
|
114
|
+
|
|
115
|
+
keys = data.keys()
|
|
116
|
+
try:
|
|
117
|
+
keys = sorted(list(map(int, keys)))
|
|
118
|
+
except ValueError:
|
|
119
|
+
pass
|
|
120
|
+
for oitem in keys:
|
|
121
|
+
item = str(oitem)
|
|
122
|
+
if item.endswith('_error_upper'):
|
|
123
|
+
continue
|
|
124
|
+
if isinstance(data[item], h5py.Dataset):
|
|
125
|
+
if item + '_error_upper' in data:
|
|
126
|
+
if isinstance(data[item][()], (float, numpy.floating)):
|
|
127
|
+
ods.setraw(item, ufloat(data[item][()], data[item + '_error_upper'][()]))
|
|
128
|
+
else:
|
|
129
|
+
ods.setraw(item, uarray(data[item][()], data[item + '_error_upper'][()]))
|
|
130
|
+
else:
|
|
131
|
+
ods.setraw(item, data[item][()])
|
|
132
|
+
elif isinstance(data[item], h5py.Group):
|
|
133
|
+
convertDataset(ods.setraw(oitem, ods.same_init_ods()), data[item])
|
|
134
|
+
|
|
135
|
+
def load(shot, directory=None):
|
|
136
|
+
|
|
137
|
+
if isinstance(shot, list):
|
|
138
|
+
shot_list = shot
|
|
139
|
+
ods_list = []
|
|
140
|
+
for shot in shot_list:
|
|
141
|
+
ods = omas.ODS()
|
|
142
|
+
if directory is None:
|
|
143
|
+
filename = f'hdf5://public/{shot}.h5'
|
|
144
|
+
else:
|
|
145
|
+
filename = f'hdf5://{directory}/{shot}.h5'
|
|
146
|
+
with h5py.File(h5pyd.H5Image(filename)) as data:
|
|
147
|
+
convertDataset(ods, data)
|
|
148
|
+
ods_list.append(ods)
|
|
149
|
+
return ods_list
|
|
150
|
+
|
|
151
|
+
else:
|
|
152
|
+
ods = omas.ODS()
|
|
153
|
+
shot_list = [int(shot)]
|
|
154
|
+
if directory is None:
|
|
155
|
+
filename = f'hdf5://public/{shot}.h5'
|
|
156
|
+
else:
|
|
157
|
+
filename = f'hdf5://{directory}/{shot}.h5'
|
|
158
|
+
with h5py.File(h5pyd.H5Image(filename)) as data:
|
|
159
|
+
convertDataset(ods, data)
|
|
160
|
+
return ods
|