mr_REF_nc.close() wind_REF_nc.close() bouy_U05_nc.close() mr_U05_nc.close() wind_U05_nc.close() C_REF_ts = np.nanmean(C_REF, axis = (1, 2)) C_U05_ts = np.nanmean(C_U05, axis = (1, 2)) ### Do plotting ### print 'Plotting' fig = plt.figure() ax = fig.add_subplot(1, 1, 1) if (len(times_REF) == len(C_REF_ts)) and (len(times_U05) == len(C_U05_ts)): ax.plot(times_REF+240., C_REF_ts, color = 'k', marker = 'o', markerfacecolor = 'white', label = 'REF') ax.plot([240., 1200.], [10., 10.], color = 'grey', ls = '--', label = 'REF:spd') ax.plot([240., 1200.], [5., 5.], color = 'blue', ls = '--', label = 'U05:spd') ax.plot(times_U05+240., C_U05_ts, color = 'k', marker = 'o', markerfacecolor = 'k', label = 'U05') else: ax.plot(np.linspace(240., 1200., len(C_REF_ts)), C_REF_ts, color = 'k', marker = 'o', markerfacecolor = 'white', label = 'REF') ax.plot(np.linspace(240., 1200., len(C_U05_ts)), C_U05_ts, color = 'k', marker = 'o', markerfacecolor = 'k', label = 'U05') ax.plot([240., 1200.], [10., 10.], color = 'grey', ls = '--', label = 'REF:spd') ax.plot([240., 1200.], [5., 5.], color = 'blue', ls = '--', label = 'U05:spd') plt.legend(loc = 0) plt.savefig('../cold_pool_stuff.png') send_email(message = 'Cold pools is complete.', subject = 'cold_pools.py -> complete', attachments = ['../cold_pool_stuff.png'], isAttach = True)
input_nc.close() print '[' + dt.now().strftime("%H:%M:%S") + '] Closing the output_nc' output_nc.close() print '[' + dt.now().strftime("%H:%M:%S") + '] Complete.' # Create the land-sea mask interpolated field <<<<<<< HEAD lsm_nc = Dataset('/work/n02/n02/xb899100/island_masks/lsm50_1600m.nc', 'r') ======= lsm_nc = Dataset('/work/n02/n02/xb899100/island_masks/lsm50.nc', 'r') >>>>>>> 62279a4ff074ba2a906de6d583e07e7c7ce0c696 lsm_var_interp = bilinear_interpolation(X, Y, lsm_nc.variables['lsm'][0,:,:,:], swath_x.flatten(), swath_y.flatten(), kind = 2).reshape((int(swath_width/res + 1), len(R))) lsm_nc.close() p = Pool(processes = len(hours)) p.map(createSwathNC, hours) p.close() p.join() <<<<<<< HEAD send_email(message = 'Completed w swath for ' + my_path.split('/')[-2] + ' experiment.', subject = 'regrid_w_along_flow.py', attachments = [''], isAttach = False) ======= #in_plane_winds(u, v, orientation = 90.) >>>>>>> 62279a4ff074ba2a906de6d583e07e7c7ce0c696
spinup_data['theta_new'] = np.concatenate( (spinup_data['theta_new'], np.array([1200.0])), axis=0) spinup_data['theta_new_z'] = np.concatenate( (spinup_data['theta_new_z'], np.array([40000.0])), axis=0) # RDP to a few heights heights, spinup_data['theta_new'] = RDP(spinup_data['theta_new_z'], spinup_data['theta_new'], 0.1) print[int(h) for h in heights] print[round(t, 2) for t in spinup_data['theta_new']] print len(heights) my_message = 'heights:' for h in heights: my_message = my_message + str(int(h)) + ',' # remove the last comma and add a new line my_message = my_message[:-1] + '\n' for t in spinup_data['theta_new']: my_message = my_message + str(round(t, 2)) + ',' # remove the last comma and add a new line my_message = my_message[:-1] + '\n' my_message = my_message + str(len(heights)) send_email(message=my_message, subject='Stronger inversion', attachments=[ '../original_spinup_skewT.png', '../strong_inversion_skewT.png' ])
Y - np.max(Y), lsm_data[0, 0, :, :], levels=[1e-08], colors=my_island_contour) ax.set_xlabel('x (km)') ax.set_ylabel('y (km)') # Plot the original domain ax.plot([0, 0, np.max(X), np.max(X), 0], [0, np.max(Y), np.max(Y), 0, 0], 'k--') ax.set_title(r'$\theta_e$ at ' + str(round(z[0], 2)) + ' m and T+' + "{0:04d}".format(int(times[it])) + ' mins') plt.savefig('../theta_e/theta_e_T' + "{0:04d}".format(int(times[it])) + '.png', dpi=100) plt.close('all') p = Pool() p.map(my_plot, range(1, len(times))) plt.show() p.close() my_command = 'convert -delay 30 -loop 0 ../theta_e/*.png ../theta_e/theta_e_anim.gif' os.system(my_command) send_email(message='Finished creating gif.', subject='cold_pools_thetaE.py', attachments=['../theta_e/theta_e_anim.gif'], isAttach=True)
# read in the netCDFs bouy_nc = Dataset('../bouy_' + hour + '.nc', 'r') fluxes_nc = Dataset('../fluxes_' + hour + '.nc', 'r') wind_nc = Dataset('../wind_' + hour + '.nc', 'r') # keys temp_key = u'STASH_m01s16i004' # bouy.nc pres_key = u'STASH_m01s00i408' # fluxes.nc q_key = u'STASH_m01s00i010' # bouy.nc u_key = u'STASH_m01s00i002' # wind.nc v_key = u'STASH_m01s00i003' # wind.nc z = bouy_nc.variables[u'thlev_zsea_theta'][:] * 1. times = bouy_nc.variables[u'min10_0'][:] * 1. for I in xrange(len(times)): if not ((hour == '00') and (I == 0)): print 'Hour = ' + hour + ', time = ' + str(int(times[I])) get_soundings(I) bouy_nc.close() fluxes_nc.close() wind_nc.close() send_email(message="Finished plotting downwind soundings!", subject="downwind_soundings.py", attachments=[ '../Soundings/Radius_10/AlongWind_sounding_T0720_R10.png', '../Soundings/Radius_20/AlongWind_sounding_T0720_R10.png' ], isAttach=True)
print 'l_spinup : ' + str(l_spinup) print 'l_short : ' + str(l_short) print 'create_netCDF: ' + str(create_netCDF) print '\nRegridding winds...' if create_WIND: winds(path, l_spinup, l_short, l_diagnostics) print '\nComputing boundary layer and cloud characteristics...' zi_lcl(path, ID, l_spinup, l_short, create_netCDF, l_diagnostics) if l_spinup: UG = -10.0#float(raw_input('Input zonal geostrophic wind:')) create_IC(path, ID, UG, l_diagnostics) send_email(message = 'Finished Processing ' + ID, subject='Process 1', attachments=['../zi_lcl_cc_lwp_'+ID+'.png'], isAttach = True) ======= path = '/nerc/n02/n02/xb899100/CloudTrail/H150E250/' # raw_input('Input path:') ID = 'H150E250' # raw_input('Input experiment ID:') l_spinup = False # bool(int(raw_input('Is this a spinup experiment? (yes = 1, no = 0):'))) l_short = False #if not l_spinup: # l_short = bool(int(raw_input('Is this a short experiment? (yes = 1, no = 0):'))) #else: # l_short = False create_WIND = False # bool(int(raw_input('Do you want to regrid the winds? (yes = 1, no = 0):'))) create_netCDF = True # bool(int(raw_input('Do you want to create zi_lcl netCDF? (yes = 1, no = 0):'))) l_diagnostics = False print 'path : ' + path
### Define plume as areas that are 2 standard deviations warmer than the # horizontal mean at that height at that time ### x = np.arange(0., 116000., 100.) y = np.arange(0., 31900., 100.) X, Y = np.meshgrid(x, y) island_area = 50. # square kilometres island_radius = np.sqrt(island_area / np.pi) * 1000. # metres x_c = 100000. + 2. * island_radius y_c = 4. * island_radius R = np.sqrt((X - x_c)**2. + (Y - y_c)**2.) #print 'Working on hour == 00 for experiment: ' + experiment send_email(message='Working on experiment: ' + experiment, subject='Plume Lengths Update', attachments=[''], isAttach=False) my_length[experiment] = plume_length( bouy_nc.variables[theta_key][:, iz, :, :]) my_area[experiment] = plume_area(bouy_nc.variables[theta_key][:, iz, :, :]) bouy_nc.close() for hour in hours: #print 'Working on hour == ' + hour + ' for experiment: ' + experiment #send_email(message = 'Working on hour == ' + hour + ' for experiment: ' + experiment, subject = 'Plume Lengths Update', attachments = [''], isAttach = False) bouy_nc = Dataset(paths[experiment] + '/bouy_' + hour + '.nc', 'r') my_length[experiment] = np.concatenate( (my_length[experiment], plume_length(bouy_nc.variables[theta_key][:, iz, :, :])), axis=0) my_area[experiment] = np.concatenate(
>>>>>>> 62279a4ff074ba2a906de6d583e07e7c7ce0c696 f.close() ## qcld in updraft ## f = open(resultpath+'/qcld_ud_udthres_'+str(ud_thres)+'_'+str(pickup_ud[0])+'.pkl','wb') pickle.dump(qcld_ud_stat,f) f.close() ## qt in updraft ## f = open(resultpath+'/qt_ud_udthres_'+str(ud_thres)+'_'+str(pickup_ud[0])+'.pkl','wb') <<<<<<< HEAD pickle.dump(mt_ud_stat,f) ======= pickle.dump(qt_ud_stat,f) >>>>>>> 62279a4ff074ba2a906de6d583e07e7c7ce0c696 f.close() ## qt perturbation in updraft ## f = open(resultpath+'/qt_p_ud_udthres_'+str(ud_thres)+'_'+str(pickup_ud[0])+'.pkl','wb') <<<<<<< HEAD pickle.dump(mt_p_ud_stat,f) f.close() send_email('Gathering cloud statistics complete.\n\nRegards,\ncld_composite.py', 'cld_composite.py --> complete!', attachments = [], isAttach = False) ======= pickle.dump(qt_p_ud_stat,f) f.close() >>>>>>> 62279a4ff074ba2a906de6d583e07e7c7ce0c696
ax.plot(R, zi_cs / 1000., 'k', lw=2) ax.set_xlabel('Distance Downwind (km)') ax.set_ylabel('Height (km)') ax.set_ylim([0, 5]) ax.set_title('Latent Heat Flux (W m$^{-2}$)') # Resolved TKE ax = fig.add_subplot(3, 1, 3) TKE = ax.contourf(R, z_theta / 1000., tke_cs, cmap='viridis', levels=np.linspace(0., 5., 11), extend='max') fig.colorbar(TKE, ax=ax, label='TKE (m$^{2}$ s$^{-2}$)') ax.plot(R, zi_cs / 1000., 'k', lw=2) ax.set_xlabel('Distance Downwind (km)') ax.set_ylabel('Height (km)') ax.set_ylim([0, 5]) ax.set_title('Turbulence Kinetic Energy (m$^{2}$ s$^{-2}$)') plt.suptitle('Time-mean values for the period T+550 to T+900 mins', fontsize=20) fig.subplots_adjust(hspace=0.35) plt.savefig('../turbulence_analysis.png', dpi=100) plt.close('all') send_email('turbulence_analysis finished', 'turbulent_fluxes.py', ['../turbulence_analysis.png'])