是否有Python软件包可以在多个x和y值上跟踪具有高斯线形的曲线? [英] Is there a Python package that can trace a curve with a Gaussian lineshape over several x and y values?

查看:50
本文介绍了是否有Python软件包可以在多个x和y值上跟踪具有高斯线形的曲线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为自己的无知深表歉意;我只学习Python大约两个月.我在Stack Overflow上看到的每个示例问题似乎都在讨论一系列数据的单一分布,而不是每个带带宽扩展的数据点的分布.

我在x上有一些(基本上)无限细的条形,高度为y,我需要在上面画一条线,以便使其看起来像下面的照片:

条形图是从最右边的数据表中获得的.这就是我要绘制的曲线.

我正在做一些TD-DFT工作,以计算理论上的UV/可见光谱.它将输出特定波长的光(x值)的吸收强度(y值,即高度).从理论上讲,尽管我们通过实验获得了一条曲线,但通常将它们绘制成无限细的条形.通过在曲线上运行一条曲线,使其拥抱y = 0,并且在每个吸光度条周围都具有高斯线形,可以使理论数据看起来像实验光谱.

我不确定是否有一项功能可以帮我做到这一点,或者我是否需要做一些诸如对每个吸收度进行高斯曲线求和的循环,然后绘制得出的公式.

感谢阅读!

解决方案

似乎我的答案是使用Seaborn进行内核密度估计.因为不对KDE进行加权,而仅考虑x值的密度,所以我不得不创建一个小循环来创建一个新列表,该列表由x项乘以各自的强度组成:

<范围> <代码>对于范围(len(list1))中的j:#list1包含x值list5.append([list1 [j]] * int(list3 [j]))#list5为空;参见下面的list3#now从列表中删除括号:对于范围内的k(len(list5)):刚制作了#list5,其中包含与强度成比例的x值对于list5 [k]中的l:list4.append(l)#现在只是一个列表,而不是列表的列表

(必须将强度乘以1000000使其更早成为另一个整数)的列表:

  list3 = [i * list2中i的1000000]#list3现在包含整数强度 

My apologies for my ignorance in advance; I've only been learning Python for about two months. Every example question that I've seen on Stack Overflow seems to discuss a single distribution over a series of data, but not one distribution per data point with band broadening.

I have some (essentially) infinitely-thin bars at value x with height y that I need to run a line over so that it looks like the following photo:

The bars are the obtained from the the table of data on the far right. The curve is what I'm trying to make.

I am doing some TD-DFT work to calculate a theoretical UV/visible spectrum. It will output absorbance strengths (y-values, i.e., heights) for specific wavelengths of light (x-values). Theoretically, these are typically plotted as infinitely-thin bars, though we experimentally obtain a curve instead. The theoretical data can be made to appear like an experimental spectrum by running a curve over it that hugs y=0 and has a Gaussian lineshape around every absorbance bar.

I'm not sure if there's a feature that will do this for me, or if I need to do something like make a loop summing Gaussian curves for every individual absorbance, and then plot the resulting formula.

Thanks for reading!

解决方案

It looks like my answer was using Seaborn to do a kernel density estimation. Because a KDE isn't weighted and only considers the density of x-values, I had to create a small loop to create a new list consisting of the x-entries each multiplied out by their respective intensities:

for j in range(len(list1)):  #list1 contains x-values
    list5.append([list1[j]]*int(list3[j]))  #list5 was empty; see below for list3

#now to drop the brackets from within the list:

for k in range(len(list5)):  #list5 was just made, containing intensity-proportional x-values
    for l in list5[k]:
        list4.append(l)  #now just a list, rather than a list of lists

(had to make another list earlier of the intensities multiplied by 1000000 to make them all integers):

list3 = [i * 1000000 for i in list2]  #list3 now contains integer intensities

这篇关于是否有Python软件包可以在多个x和y值上跟踪具有高斯线形的曲线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆