Commit 0d51d05e authored by Leonie Pick's avatar Leonie Pick

Update pl.Selection() and pl.IndexDist()

parent 2d98190a
......@@ -32,9 +32,9 @@ def Selection(Time,Date,HMC,Index_thres1,StormIndices,IndexMin,IndexMin1,IndexMi
ax[i].plot(Time[start:end,4],HMC[start:end]-100,color='gray')
ax[i].plot(Time[start:end,4],HMC[start:end]-200,color='gray')
ax[i].plot(Time[start:end,4],HMC[start:end]-300,color='gray')
ax[i].scatter(Time[np.asarray(IndexMin),4],HMC[np.asarray(IndexMin)]-100,color='midnightblue',s=5,zorder=4)
ax[i].scatter(Time[np.asarray(IndexMin1,dtype=int),4],HMC[np.asarray(IndexMin1,dtype=int)]-200,color='midnightblue',s=5,zorder=5)
ax[i].scatter(Time[np.asarray(IndexMin2,dtype=int),4],HMC[np.asarray(IndexMin2,dtype=int)]-300,color='maroon',s=5,zorder=6)
ax[i].scatter(Time[np.asarray(IndexMin),4],HMC[np.asarray(IndexMin)]-100,color='midnightblue',s=10,zorder=4)
ax[i].scatter(Time[np.asarray(IndexMin1,dtype=int),4],HMC[np.asarray(IndexMin1,dtype=int)]-200,color='midnightblue',s=10,zorder=5)
ax[i].scatter(Time[np.asarray(IndexMin2,dtype=int),4],HMC[np.asarray(IndexMin2,dtype=int)]-300,color='maroon',s=10,zorder=6)
ax[i].text(0.02,0.94,'Step 1',transform=ax[i].transAxes);ax[i].text(0.02,0.745,'Step 2a',transform=ax[i].transAxes)
ax[i].text(0.02,0.535,'Step 2b',transform=ax[i].transAxes);ax[i].text(0.02,0.325,'Step 3',transform=ax[i].transAxes)
......@@ -80,11 +80,14 @@ def IndexDist(Time,YearsIndex,Storms,Kp_all,KpHours_all,HMC,Save):
# Overlap of storm times with Kp
Kp_indices = np.where(np.logical_and(KpHours_all >= min(TimeDecYear[YearsIndex]),KpHours_all < max(TimeDecYear[YearsIndex])))[0]
Kp_red = Kp_all[Kp_indices]; KpHours_red = KpHours_all[Kp_indices]
Kp_range = np.around(np.arange(0,9,0.3333333),3)
Kp_step = 0.3333333
Kp_range = np.around(np.arange(0,9,Kp_step),3)
Storms1932 = np.where(TimeDecYear[Storms] >= 1932.000171)[0]
HMC_range = np.linspace(-np.ceil(np.nanmax(HMC[Storms[Storms1932]])),-np.floor(np.nanmin(HMC[Storms[Storms1932]])),len(Kp_range))
HMC_step = 7.78
HMC_range = np.arange(10,480+HMC_step,HMC_step)
Index_range = HMC_range
Index_range = Kp_range #HMC_range
step = Kp_step #HMC_step
years = np.arange(1932,2016,1)
Percentages = np.zeros((len(years),len(Index_range)))
......@@ -98,7 +101,6 @@ def IndexDist(Time,YearsIndex,Storms,Kp_all,KpHours_all,HMC,Save):
else:
Kp_indices = np.where(np.logical_and(KpHours_red >= years[l],KpHours_red < years[l]+1))[0]
StormsBlock = np.where(np.logical_and(TimeDecYear[Storms] >= years[l],TimeDecYear[Storms] < years[l]+1))[0]
#Kp_year = Kp_red[Kp_indices]; KpHours_year = KpHours_red[Kp_indices]
Kp = Kp_red[Kp_indices]; KpHours = KpHours_red[Kp_indices]
Kp_hours = np.zeros((len(Kp)*3,2))
......@@ -110,7 +112,6 @@ def IndexDist(Time,YearsIndex,Storms,Kp_all,KpHours_all,HMC,Save):
j+=3
KpStorms = np.where(np.in1d(np.around(Kp_hours[:,0],6),TimeDecYear[Storms][Storms1932]))[0]
#KpValues = Kp_hours[KpStorms,1]
KpValues = np.zeros(len(KpStorms))
for k in range(len(KpStorms)):
if (KpStorms[k]+13 in range(len(Kp_hours)) and KpStorms[k]-13 in range(len(Kp_hours))):
......@@ -120,11 +121,11 @@ def IndexDist(Time,YearsIndex,Storms,Kp_all,KpHours_all,HMC,Save):
HMCValues = -HMC[Storms[StormsBlock]]
#KpValuesAll.extend(KpValues.tolist())
#Hist[l,:], bin_edges = np.histogram(KpValues, bins = Index_range)
KpValuesAll.extend(KpValues.tolist())
Hist[l,:], bin_edges = np.histogram(KpValues, bins = Index_range)
KpValuesAll.extend(HMCValues.tolist())
Hist[l,:], bin_edges = np.histogram(HMCValues, bins = Index_range)
#KpValuesAll.extend(HMCValues.tolist())
#Hist[l,:], bin_edges = np.histogram(HMCValues, bins = Index_range)
Hist[l,:] *= 100/len(Storms1932)
......@@ -155,43 +156,32 @@ def IndexDist(Time,YearsIndex,Storms,Kp_all,KpHours_all,HMC,Save):
ax1.set_yticks(np.arange(0,len(years)-1,1)-0.5,minor=True)
ax1.set_yticks(np.arange(0,len(years)-1,4)-0.5)
ax1.set_yticklabels(years[0:len(years)-1][::4])
ax1.axvline((bound25-Index_range[0])/27-0.5,color='black',linestyle='--')
ax1.axvline((bound75-Index_range[0])/27-0.5,color='black',linestyle='--')
#ax1.axvline(np.where(Index_range == bound25)[0]-0.5,color='black',linestyle='--')
#ax1.axvline(np.where(Index_range == bound75)[0]-0.5,color='black',linestyle='--')
ax1.axvline((bound25-Index_range[0])/step-0.5,color='black',linestyle='--')
ax1.axvline((bound75-Index_range[0])/step-0.5,color='black',linestyle='--')
cax=plt.subplot(gs[1])
bar=plt.colorbar(im,cax=cax,orientation='vertical')
bar.set_label('Occurrence [%]')
ax2.bar(np.arange(0,len(Index_range)-1,1),SumHist,width=1.0,align='edge',color='gray',zorder=1)
ax2.axvline((bound25-Index_range[0])/27,color='black',linestyle='--',label='Q1')
ax2.axvline((bound75-Index_range[0])/27,color='black',linestyle='--',label='Q3')
#ax2.axvline(np.where(Index_range == bound25)[0],color='black',linestyle='--',label='Q1')
#ax2.axvline(np.where(Index_range == bound75)[0],color='black',linestyle='--',label='Q3')
ax2.axvline((bound25-Index_range[0])/step,color='black',linestyle='--',label='Q1')
ax2.axvline((bound75-Index_range[0])/step,color='black',linestyle='--',label='Q3')
ax2.set_xticks(np.arange(0,len(Index_range),3))
ax2.set_xticks(np.arange(0,len(Index_range),1),minor=True)
ax2.set_xlim([0,27])
ax2.legend(loc=4,ncol=1,frameon=False,fontsize=10)
ax2.set_ylabel('Occurrence [%]')
#ax2.set_xticklabels(np.arange(0,10,1))
#ax2.set_xlabel('Kp level')
#ax2.set_ylim([0,10.5])
ax2.set_xticklabels(np.arange(0,10,1))
ax2.set_xlabel('Kp')
ax2.set_ylim([0,10.5])
ax2.set_xticklabels(np.around(Index_range[::3]/100,1))
ax2.set_xlabel('-HMC/100 [nT]')
ax2.set_ylim([0,45])
#ax3.fill_between(np.arange(0,len(Kp_range)-1,1)+0.5,CumSum,CumSum2,color='maroon')
#ax3.set_ylim([0,105])
#ax3.set_ylabel('Cum. Occurrence [%]')
#ax3.spines['right'].set_color('maroon')
#ax3.tick_params(axis='y', colors='maroon')
#ax3.yaxis.label.set_color('maroon')
#ax2.set_xticklabels(np.around(Index_range[::3]/100,1))
#ax2.set_xlabel('-HMC/100 [nT]')
#ax2.set_ylim([0,45])
if Save == True:
fig.savefig('./Dump/Fig/HMCDist.pdf',format='pdf',dpi=200,transparent=True)
#fig.savefig('./Dump/Fig/HMCDist.png',format='png',dpi=200,transparent=True)
fig.savefig('./Dump/Fig/KpDist.pdf',format='pdf',dpi=200,transparent=True)
#fig.savefig('./Dump/Fig/KpDist.png',format='png',dpi=200,transparent=True)
plt.show()
###
###
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment