# "area" : "50/-15/30/5", ## north/west/south/east # "type" : "an", # "class" : "e4", # "format" : "netcdf", # "padding" : "0", # "target" : "test.nc" # }) #============================================================================== # load ERA-40 as g1 and ERA-Interim as g2 print("[%s] Loading data..." % (str(datetime.now()))) g1 = DataField() g2 = DataField() g1.load('Spain.ERA.58-01.nc', 't2m', 'ERA-40') g2.load('Spain.ERA.01-13.nc', 't2m', 'ERA-40') # concatenate last = g1.time[-1] idx = np.where(g2.time == last)[0] + 1 ndays = g1.time.shape[0] + g2.time[idx:].shape[0] data = np.zeros((ndays, g1.lats.shape[0], g1.lons.shape[0])) time = np.zeros((ndays, )) data[:g1.time.shape[0], ...] = g1.data data[g1.time.shape[0]:, ...] = g2.data[idx:] time[:g1.time.shape[0]] = g1.time time[g1.time.shape[0]:] = g2.time[idx:]
cbar = plt.colorbar(format=r"%2.2f", shrink=0.75, ticks=np.arange(mi, ma + step, (ma - mi) / 8), aspect=25, drawedges=False) cbar.set_label(cbar_label) cbar_obj = plt.getp(cbar.ax.axes, 'yticklabels') plt.setp(cbar_obj, fontsize=10, color=(.1, .1, .1)) if filename != None: plt.savefig(filename) else: plt.show() g = DataField() g.load('tg_0.25deg_reg_v9.0.nc', 'tg') means = True daily = False if means: idx = 0 y = 1950 while idx < g.data.shape[0]: idx2 = g.find_date_ndx(date(y, 1, 1)) render_geo_field(g.data[idx:idx2, ...], g.lats, g.lons, None, None, False, 'Yearly mean temperature %s' % str(y), 'temperature [$^{\circ}C$]', 'imgs/temp_mean%s.png' % str(y)) y += 1 idx = idx2
#m.drawmeridians(np.arange(lons[0], lons[-1]+1, 10), dashes = [1,3], labels = [0,0,0,0], color = (.2, .2, .2), #fontsize = 8.5) plt.title(title) cbar = plt.colorbar(format = r"%2.2f", shrink = 0.75, ticks = np.arange(mi, ma + step, (ma-mi)/8), aspect = 25, drawedges = False) cbar.set_label(cbar_label) cbar_obj = plt.getp(cbar.ax.axes, 'yticklabels') plt.setp(cbar_obj, fontsize = 10, color = (.1, .1, .1)) if filename != None: plt.savefig(filename) else: plt.show() g = DataField() g.load('tg_0.25deg_reg_v9.0.nc', 'tg') means = True daily = False if means: idx = 0 y = 1950 while idx < g.data.shape[0]: idx2 = g.find_date_ndx(date(y,1,1)) render_geo_field(g.data[idx:idx2, ...], g.lats, g.lons, None, None, False, 'Yearly mean temperature %s' % str(y), 'temperature [$^{\circ}C$]', 'imgs/temp_mean%s.png' % str(y)) y += 1 idx = idx2 if daily: idx = g.find_date_ndx(date(2012,1,1)) for i in range(idx,idx+59):