fft2D分解如何产生分数频率阶次
我看到一片论文,分解出来的谐波频率存在分数频率阶次,请问依靠Maxwell提供的fft2D脚本如何实现? 或者有无别的方式进行fft2D分解生成所需要的分数频率阶次?Maxwell提供的fft2D 里面有详细的教程 请问一下 你这个大论文题目是? 你用官方的文件进行FFT2或者自己写FFT2结果还是一样的啊,原理都是一样的还能分出什么其他的吗 请问论文题目是? 方法都一样 根本就是对时间和空间都要进行分解 # encoding: utf-8
##############################################################
# Imports
##############################################################
import os, sys,clr
from BaseExampleUDO import BaseExampleUDOClass
from math import *
clr.AddReference("System.Windows.Forms")
clr.AddReference("System.Drawing")
from System.Windows.Forms import *
from System.Drawing import *
import datetime
# 定义输出FFT_data的数据类型,0:幅值, 1:复数
data_type = 0
def dft(x, inverse=False):
N = len(x)
inv = -1 if not inverse else 1
X = * N
for k in range(N):
for n in range(N):
X += x * e ** (inv * 2j * pi * k * n / N)
if inverse:
X /= N
return X
def dft2(x):
y =
y =
y = zip(*y)
return y
def myfun(aaa):
aaa = list(aaa)
for j in range(len(aaa)):
for i, a in enumerate(aaa):
try:
if a.isdigit() and aaa.isalpha():
del aaa
except:
break
return ''.join(aaa)
class UDOExtension(BaseExampleUDOClass):
_kOutputs = [['Mag', '']]
_kDynamicProbes = []
_kInputs = []
reportName = "FieldReport"
def __init__(self):
for vName, unit in self._kOutputs:
self.Data.AddDoubleQuantity("FFT2D", vName, unit)
sweepNames = ["Distance", "Time"]
self.Data._sweepNames = sweepNames
self.Data.AddDoubleProbe(self.reportName, "Select a transient field quantity", "Fields", "AirgapLine")
self._kInputs.append(["Order of time domain", '0', 'Multiples of fundamental electric frequency'])
self._kInputs.append(["Order of space domain", '0', 'Number of spatial modes, can be positive or negative'])
self._kInputs.append(["Export FFT2D datatable ?", ['Yes', 'No'], 'Select Yes or No'])
self._kInputs.append(
["Maximum time order", '0', 'The largest number of time domain order to export, input 0 for all orders'])
self._kInputs.append(
["Maximum space order", '0', 'The largest number of space domain order to export, input 0 for all orders'])
# -- ISA IUDOPluginExtension --------------
def GetUDSDescription(self):
return "FFT2D"
# -- ISA IUDOPluginExtension --------------
def GetUDSName(self):
return "FFT2D"
# -- ISA IUDOPluginExtension --------------
def GetInputUDSParams(self, udsParams, propList, userSelectedDynamicProbes):
# call base class to fill in the uds params
BaseExampleUDOClass.GetInputUDSParams(self, udsParams, propList, userSelectedDynamicProbes)
for name, value, description in self._kInputs:
if isinstance(value, list):
prop = propList.AddMenuProperty(name, value)
else:
prop = propList.AddNumberProperty(name, value)
prop.Description = description
def Compute(self, inData, outData, params, progMon):
sweepNames1 = inData.GetSweepNamesForProbe(self.reportName)
time = inData.GetSweepsDataForProbe(self.reportName, sweepNames1)
distance = inData.GetSweepsDataForProbe(self.reportName, sweepNames1)
data = inData.GetDoubleProbeData(self.reportName)
distance = list(set(distance))
distance.sort()
distance = distance[:-1]
time = list(set(time))
time.sort()
time = time[:-1]
data = zip(*( * (len(distance) + 1)))
data = for a in data[:-1]]
fft2_data = dft2(data)
factor = len(time) * len(distance) / 2.0
fft2_abs = [ for a in fft2_data]
fft2_abs /= 2.0
if data_type == 1:
fft2_data = dft2(data)
fft2_Complex = [ for a in fft2_data]
fft2_Complex /= 2.0
Order1 = params.GetNumberProperty(self._kInputs).ValueSI
Order2 = params.GetNumberProperty(self._kInputs).ValueSI
if Order2 < 0:
Order2 += len(distance)
Outputs = ]
outData.SetSweepsData("Distance", )
outData.SetSweepsData("Time", )
for vName, value in zip(zip(*self._kOutputs), Outputs):
outData.SetDoubleQuantityData(vName, )
export = params.GetMenuProperty(self._kInputs).SelectedMenuChoice
if export == 'Yes':
max_time_order = params.GetNumberProperty(self._kInputs).ValueSI
max_space_order = params.GetNumberProperty(self._kInputs).ValueSI
path = os.getcwd()
csv_path = os.path.join(path, 'FFT2D_data.csv')
if data_type == 1:
fft2_abs = list(fft2_Complex)
new_fft2_abs = fft2_abs
new_fft2_abs.append(fft2_abs)
export_data = list(reversed(new_fft2_abs))
new_export_data = []
if int(max_space_order) == 0:
if len(distance) % 2 == 1:
max_space_order = (len(distance) - 1) / 2
else:
max_space_order = (len(distance)) / 2 - 1
if int(max_time_order) == 0:
if len(time) % 2 == 1:
max_time_order = (len(time) - 1) / 2
else:
max_time_order = (len(time)) / 2 - 1
for each in export_data:
aa = []
aa = (each[-int(max_space_order) + len(distance):])
aa = aa + (each)
new_export_data.append(aa)
length = len(new_export_data)
with open(csv_path, 'w') as file:
file.write(
r'Time\Space,' + str(list(range(-int(max_space_order), int(max_space_order) + 1, 1))).strip(
'[').strip(']') + '\n')
for i in range(length):
file.write(str(i) + ',' + str(new_export_data).strip('[').strip(']') + '\n')
return True
sakymuni16 发表于 2021-8-7 11:23
# encoding: utf-8
##############################################################
# Imports ...
这个就是Maxwell自带的脚本,无奈鄙人是代码小白,努力学习ing,也希望得到前辈指导! 修改哪一步代码才能生成我想要的time里面的分数阶次,比如1/30、29/30这样的分数阶次; 你好,你这个论文的题目是什么呢? 你好,楼主,这个论文名字是什么呢?多谢!
页:
[1]