def get_event_fc_loop(data_fc, events): event_fc={} for event in events: event_fc[event]={} event_pm=event[0] event_thres=convert_fracstr_to_flt(event[1:]) for start_date in start_dates: event_fc[event][start_date]={} for model in data_fc[start_date]: event_fc[event][start_date][model]=get_event_fc_rel(np.rollaxis(np.rollaxis(data_fc[start_date][model]['data'],2),2),event_pm,event_thres) #rollaxis commands to get ens_member and start_year dimensions at the front event_fc[event][start_date][model]=np.rollaxis(event_fc[event][start_date][model],2) return event_fc
# year_ind=20 # plt.figure() # #print fc_veri[veri][start_date][model][:,year_ind] # plt.plot(fc_veri[veri][start_date][model][:,year_ind],'k',linewidth=3) # for j in range(data_fc[start_date][model]['data'].shape[2]): plt.plot(data_fc[start_date][model]['data'][:,year_ind,j],'b') # plt.title('Verification: '+args.var+' '+start_date+' '+model+' year '+str(year_ind)) #Find whether an event occurred in observations on each forecast date if args.events: event_fc_veri={} for event in args.events: event_fc_veri[event]={} event_pm=event[0] event_thres=convert_fracstr_to_flt(event[1:]) for veri in args.veri: event_fc_veri[event][veri]={} for start_date in start_dates: event_fc_veri[event][veri][start_date]={} for model in data_fc[start_date]: event_fc_veri[event][veri][start_date][model]=get_event_fc_rel(fc_veri[veri][start_date][model].T[np.newaxis,...], event_pm,event_thres).T[...,0] #transpose fc_veri arrays and add axis at the front in the function call so their first two dimensions correspond to the ensemble members and different start dates, as expected by get_event_fc_rel() #Plotting diagnostics as a function of lead time #Assign linecolour and style to each model linecolors=['k','b','g','r','c','m','y','brown','gray'] ncols=len(linecolors) linestyles=['-', ':','-.'] #linestyles to cycle through for each set of colours - don't use '--' as I use this for plotting model RMSS below.