python 如何在数组中的峰值点之后放置递减指数元素?

python how can I put decreasing exponential elements after a peak point in an array?

我想在包含一些峰的随机生成的数组中用指数斜率替换线性斜率。我怎样才能做到这一点?

我尝试运行如下所示的代码。

import numpy as np
import pylab as py
import matplotlib.pyplot as plt

#generate exposure time----------------------------------------------
time_range=np.linspace(1,100,10**3)
#generate random noise count---------------------------------------
count_list=np.random.uniform(low=5.-np.sqrt(5.),high=5.+np.sqrt(5.),size=(10**3,))
#generate photon count-----------------------------------------------
photon_list=np.random.uniform(low=40.-np.sqrt(40.),high=40.+np.sqrt(40.),size=(10**3,))



#select random photon count in the photon list-----------------------
select_photon=np.random.choice(photon_list,size=10)
#select random count in the noise count list-----------------------
select_count=np.random.choice(count_list,size=10)


#replace the random count with the photon count----------------------
for j in  range(len(select_photon)):    
    for n,i in enumerate(count_list):
        if i==select_count[j]:
            count_list[n]=select_photon[j]



spec_list=np.array(count_list)
time_range=np.array(time_range)



fig=py.figure(figsize=(10,3))
ax=fig.add_subplot(111)
ax.plot(time_range,spec_list,lw=0.8)    
ax.set_ylabel("spec")
ax.set_xscale('log')
plt.show()

必须如图(有颜色的)

figure

我想通了。

import numpy as np
import matplotlib.pyplot as plt
import pylab as py


#generate random noise count---------------------------------------
count_list=np.random.uniform(low=3.-np.sqrt(3.),high=3.+np.sqrt(3.),size=(10**3,))
#generate photon count-----------------------------------------------
photon_list=np.random.uniform(low=20.-np.sqrt(20.),high=20.+np.sqrt(20.),size=(10**3,))
#print(len(count_list),len(time_range))


#select random photon count in the photon list-----------------------
select_photon=np.random.choice(photon_list,size=10)
#select random count in the noise count list-----------------------
select_count=np.random.choice(count_list,size=10)


#replace the random count with the photon count----------------------,


for j in  range(len(select_photon)):    
    for n,i in enumerate(count_list):
        if i==select_count[j]:
            count_list[n]=select_photon[j]



spec_list=np.array(count_list)


indexs=[]
values=[]
replacements=[]

for jj,zz in enumerate(spec_list):
    if zz>10:
        #print(jj)
        #print(zz)
        indexs.append(jj)
        values.append(zz)
        replacements.append(np.logspace(np.log(zz/np.exp(1.63333)),np.log(2.),20))

indexss=[]
for i in indexs:
    indexss.append(np.linspace(i,i+19,20))

for i in range(10):
    for ii in range(20):
        spec_list[int(indexss[i][ii])]=replacements[i][ii]



time=np.linspace(0,100,len(spec_list))

fig=py.figure(figsize=(10,5))
ax=fig.add_subplot(111)
ax.plot(time,spec_list,lw=0.8)
ax.set_ylabel("count")
ax.set_xlabel("time")
plt.show()