Skip to main content

dig

Structure

  • dig, python package folder
  • notebooks, python notebook folder to demonstrate how can we use dig

Install

Prequisite:

  • MDSplus
  • We do not support Anaconda. Use virtualenv instead if you don't want to mess up your system built-in python environment.
# for clients
pip install dig-mhd 

# for developers
cd /to-somewhere-you-want-to-clone-the-repo
git clone https://github.com/WenyinWei/dig.git
cd dig # (not dig/dig)
pip install -e . # "-e" means editable

Add mhd_settings.ini (you can find a template at this repo) to you application data path, e.g.

  • C:\Users\<your-user-name>\mhd\mhd_settings.ini for Windows,
  • /home/<your-user-name>/.mhd/mhd_settings.ini for Debian systems like Ubuntu.

Parameters are stored in this .ini file and you need to check and modify some of them. Having configuring the .ini file in a right way, the following import should be successful.

import dig 

Use Python in Matlab

Common Data Format

*.npy, *.npz file formats are common in python/numpy community; while *.mat file format is common in matlab community. Matlab has professional documents to demonstrate how to use Python from Matlab and vice.

from scipy.io import loadmat
annots = loadmat('*.mat')
% In Matlab, npy-matlab module could help you read and write npy format files, https://github.com/kwikteam/npy-matlab
a = rand(5,4,3);
writeNPY(a, 'a.npy');
b = readNPY('a.npy');
% In Matlab, configure Python environment https://ww2.mathworks.cn/help/matlab/ref/pyenv.html
pyenv % 返回当前默认的 Python 环境
pyenv('Version', 3.8) % 寻找当前电脑上的对应版本的 Python 环境
pyenv('Version', path-to-your-python-executable) % 寻找当前电脑上的对应路径的 Python 环境

if count(py.sys.path,'path-to-your-package') == 0
    insert(py.sys.path,int32(0),'path-to-your-package');
end

py.importlib.import_module('dig')
py.importlib.reload('dig')
returned_tuple = py.dig.utilvar.get_EAST_EFIT_BR_BZ_Bt(shotnum, py.list({tpoint1, tpoint2, ...}));
R = returned_tuple{1};
Z = returned_tuple{2};
tpoints = returned_tuple{3};
BRs = returned_tuple{4};
BZs = returned_tuple{5};
Bts = returned_tuple{6};
# Rewrite all npy files in mat format, https://ww2.mathworks.cn/matlabcentral/answers/444998-how-do-read-npy-files-in-matlab#answer_624742
from scipy.io import savemat
import numpy as np
import glob
import os

npzFiles = glob.glob("*.npz")
for f in npzFiles:
    fm = os.path.splitext(f)[0]+'.mat'
    d = np.load(f)
    savemat(fm, d)
    print('generated ', fm, 'from', f)

Metadata

Release files for dig-mhd 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dig-mhd 0.0.1
File Size Uploaded
dig-mhd-0.0.1.tar.gz 17.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dig-mhd 0.0.1
File Interpreter ABI Platform
dig_mhd-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 36.3 kB

Release files / dig-mhd-0.0.1.tar.gz

Download URL dig-mhd-0.0.1.tar.gz
Size 17.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0f69399a5e2afdd020f6f0c020c60175c79597e01d6da8be3abc4629a1be2918
BLAKE2b-256 checksum
How to use checksums
aeacf46007447610cfb1a9aaf0d5126308cb85c3566ca9817f5ba90b5fd123b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release files / dig_mhd-0.0.1-py3-none-any.whl

Download URL dig_mhd-0.0.1-py3-none-any.whl
Size 18.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5da2edbe4f921de678d435544536b8bab941929306ae736bc6e444f11c6c0103
BLAKE2b-256 checksum
How to use checksums
058fb82474d345cb20831fd2435a92daa9d501c7d4ab67bc90bc8002392ce759
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page