Commit 9ed855d7 authored by Leonie Pick's avatar Leonie Pick

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

parent 4126ba84
......@@ -80,7 +80,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [
{
......@@ -234,7 +234,7 @@
"HMC5d = md.LowpassFilter(Var['HMC'],Frequency/(24*5),Frequency)\n",
"HMC11y = md.LowpassFilter(Var['HMC'],Frequency/(24*SiderealYear*11),Frequency)\n",
"\n",
"Save = False; Plot = False\n",
"Save = False; Plot = True\n",
"TargetEvents, TrainingFound, AllFound = md.Get_TargetEvents(Var['HMC'],HMC11y,HMC5d,dHMC,Var['Kp'],Var['KpHours'],Var['Training'],Var['Time'],Var['Hours'],YearStart,Plot,Save)\n",
"\n",
"##for i in range(len(TrainingFound)):\n",
......@@ -279,7 +279,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [
{
......@@ -402,10 +402,10 @@
" <tr>\n",
" <th>12</th>\n",
" <td>0.250</td>\n",
" <td>0.501</td>\n",
" <td>0.251</td>\n",
" <td>-0.238</td>\n",
" <td>0.490</td>\n",
" <td>0.749</td>\n",
" <td>0.499</td>\n",
" <td>-0.485</td>\n",
" <td>0.984</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
......@@ -424,7 +424,7 @@
"9 0.066 0.118 0.052 0.012 0.040\n",
"10 0.514 0.652 0.138 0.159 -0.021\n",
"11 0.636 0.610 0.026 0.068 -0.042\n",
"12 0.250 0.501 0.251 -0.238 0.490"
"12 0.250 0.749 0.499 -0.485 0.984"
]
},
"metadata": {},
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -127,7 +127,7 @@ def Search_TargetEvents(HMC, HMC11y, HMC5d, dHMC, HTime, DTime, grid, Save):
if HMC_diff <= -thresHMC:
IndexMin2.append(i)
#pl.Selection(HTime,DTime,HMC,Index_thres1,StormIndices,IndexMin,IndexMin1,IndexMin2,Save)
pl.Selection(HTime,DTime,HMC,Index_thres1,StormIndices,IndexMin,IndexMin1,IndexMin2,Save)
return IndexMin2
###
......@@ -208,7 +208,7 @@ def Get_TargetEvents(HMC, HMC11y, HMC5d, dHMC, Kp_all, KpHours_all, Training, Ti
display(pd.DataFrame(data=TrainingResults,columns=['No. CIRs','No. CMEs', 'Total'], index=['Training set', 'in Target set']))
###
#pl.IndexDist(Time,YearsIndex,StormsWin,Kp_all,KpHours_all,HMC,Plot)
pl.IndexDist(Time,YearsIndex,StormsWin[SelectStr],Kp_all,KpHours_all,HMC,Plot)
return StormsWin, TrFound, FoundStorms
###
......
......@@ -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,12 +80,15 @@ 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))
Index_range = HMC_range
HMC_step = 7.78
HMC_range = np.arange(10,480+HMC_step,HMC_step)
Index_range = Kp_range #HMC_range #Kp_range
step = Kp_step #HMC_step #Kp_step
years = np.arange(1932,2016,1)
Percentages = np.zeros((len(years),len(Index_range)))
Hist = np.zeros((len(years),len(Index_range)-1))
......@@ -120,11 +123,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,32 +158,28 @@ 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.set_xticks(np.arange(0,len(Index_range),3))
ax2.set_xticks(np.arange(0,len(Index_range),1),minor=True)
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,28,3))
ax2.set_xticks(np.arange(0,28,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])
ax2.set_xticklabels(np.around(Index_range[::3]/100,1))
ax2.set_xlabel('-HMC/100 [nT]')
ax2.set_ylim([0,45])
#ax2.set_xticklabels(np.around(Index_range[::3]/100,1))
#ax2.set_xlabel('-HMC/100 [nT]')
#ax2.set_ylim([0,20])
#ax3.fill_between(np.arange(0,len(Kp_range)-1,1)+0.5,CumSum,CumSum2,color='maroon')
#ax3.set_ylim([0,105])
......@@ -190,8 +189,8 @@ def IndexDist(Time,YearsIndex,Storms,Kp_all,KpHours_all,HMC,Save):
#ax3.yaxis.label.set_color('maroon')
if Save == True:
fig.savefig('./Dump/Fig/development/HMCDist.pdf',format='pdf',dpi=200,transparent=True)
#fig.savefig('./Dump/Fig/development/HMCDist.png',format='png',dpi=200,transparent=True)
fig.savefig('./Dump/Fig/development/KpDist_test.pdf',format='pdf',dpi=200,transparent=True)
fig.savefig('./Dump/Fig/development/KpDist_test.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