Skip to main content

Posts

Showing posts from May, 2021

conda env list

 all the env would be listed in users/current_user/.conda/environments.txt the content is : C:\ProgramData\miniconda3 C:\ProgramData\miniconda3\envs\GMS_VENV_PYTHON C:\ProgramData\Miniconda3\envs\GMS_VENV_PYTHON C:\ProgramData\Miniconda3\envs\em C:\ProgramData\Miniconda3\envs\tf

UI template II

https://github.com/Renfong/dm-script-tool/blob/master/UI_Template_2.s // Interactive UI template // // 2021/05/06 // Renfong interface call_functions{ number GetBoxNumber(object self); }; class UI_Functions : object { number true, false number UIObjectID object MainUI void SetUIObjectID(object self, number id) { UIObjectID = id MainUI = GetScriptObjectFromID(UIObjectID) }; UI_Functions(object self) { true = 1; false = 0 result("Obect \"UI_Functions\" ["+self.ScriptObjectGetID()+"] constructed. \n") }; ~UI_Functions(object self) { true = 1; false = 0 result("Obect\"UI_Functions\" ["+self.ScriptObjectGetID()+"] deconstructed. \n") }; void btn1response(object self) { number num = MainUI.GetBoxNumber() OKdialog("Number = "+num) }; }; class MainUI : UIFrame { TagGroup btn1, numbox object UI_Functions number true, false, ver MainUI(object self){ true = 1...

How to do PCA for EELS SI in python

PCA is the popular statistic tool to denoise the EELS spectrum image. Here is the simple example to apply PCA by numpy package ================================== """ ref: https://stackoverflow.com/questions/13224362/principal-component-analysis-pca-in-python/49629816#49629816 @author: renfong """ import numpy as np import matplotlib.pyplot as plt import hyperspy.api as hs from numpy import argsort from numpy.linalg import eigh #%% load data data = hs.load('t1.dm3').data #%% define pca def pca(data, pc_count = None):     """     Principal component analysis using eigenvalues     note: this mean-centers and auto-scales the data (in-place)     """     C = np.dot(data.T, data)       # covariance matrix     E, V = eigh(C)     key = argsort(E)[::-1][:pc_count]     E, V = E[key], V[:, key]     U = data @ V  # equvalent to np.dot(data, V)     return U, E, V #%% reconstruc...