예제 #1
0
def radar_to_cappi(radar1_filename, radar2_filename,**kwargs):
	ini_fname=kwargs.get('ini_fname', os.getenv('HOME')+'/bom_mds/bom_mds.ini')
	loud=kwargs.get('loud', False)
	ini_dict=parse_ini.parse_ini(ini_fname)
	if loud: print "Loading radar file 1"
	if 'radar1_path' in ini_dict.keys():
		radar1=read_radar.load_radar(ini_dict['radar1_path']+radar1_filename)
	else:
		radar1=pyradar.load_radar(radar1_filename)
	if loud: print "Loading radar file 2"
	if 'radar2_path' in ini_dict.keys():
		radar2=read_radar.load_radar(ini_dict['radar2_path']+radar2_filename)
	else:
		radar2=pyradar.load_radar(radar2_filename)
	cappi_z_bounds=ini_dict.get('cappi_z_bounds', [500,15000])
	cappi_xy_bounds=ini_dict.get('cappi_xy_bounds', [-50000, 50000])
	cappi_resolution=ini_dict.get('cappi_resolution', [100, 40])
	levs=linspace(cappi_z_bounds[0], cappi_z_bounds[1], cappi_resolution[1])
	xar=linspace(cappi_xy_bounds[0], cappi_xy_bounds[1], cappi_resolution[0])
	yar=linspace(cappi_xy_bounds[0], cappi_xy_bounds[1], cappi_resolution[0])
	displace=mathematics.corner_to_point(radar1[0]['radar_loc'], radar2[0]['radar_loc'])
	if loud: print "Cappi-ing radar 1"
	radar1_cube=radar_to_cart.make_cube(radar1, xar, yar, levs)
	if loud: print "Cappi-ing radar 2"
	radar2_cube=radar_to_cart.make_cube(radar2, xar, yar, levs, displacement=displace)
	cube_fname=ini_dict['cube_path']+'cappi_'+std_datestr(radar1_cube['date'])+'.nc'
	netcdf_utis.save_data_cube(radar1_cube, radar2_cube, cube_fname)
예제 #2
0
파일: bom_mds.py 프로젝트: scollis/bom_mds
def simple_reconstruction_3d_pytest(tim, lvl_str, use_guess):
	lvl=int(lvl_str)
	ber, gp=netcdf_utis.load_cube('/bm/gdata/scollis/cube_data/20060122_'+tim+'_ver_hr_big.nc')
	print gp['levs'][lvl]
	Re=6371.0*1000.0
	rad_at_radar=Re*sin(pi/2.0 -abs(gp['zero_loc'][0]*pi/180.0))#ax_radius(float(lat_cpol), units='degrees')
	lons=gp['zero_loc'][1]+360.0*gp['xar']/(rad_at_radar*2.0*pi)
	lats=gp['zero_loc'][0] + 360.0*gp['yar']/(Re*2.0*pi)	
	ber_loc=[-12.457, 130.925]
	gp_loc=	 [-12.2492,  131.0444]
	if use_guess=='none':
		igu=ones(ber['CZ'].shape, dtype=float)*0.0
		igv=ones(ber['CZ'].shape, dtype=float)*0.0
	else:
		ber_ig, gp_ig=netcdf_utis.load_cube(use_guess)
		print gp_ig.keys()
		igu=gp_ig['u_array']
		igv=gp_ig['v_array']
	mywts=ones(ber['CZ'].shape, dtype=float)
	angs=array(propigation.make_lobe_grid(ber_loc, gp_loc, lats,lons))
	wts_ang=zeros(gp['CZ'][:,:,0].shape, dtype=float)
	for i in range(angs.shape[0]):
			for j in range(angs.shape[1]):
				if (angs[i,j] < 150.0) and (angs[i,j] > 30.0): wts_ang[i,j]=1.0
	for lvl_num in range(len(gp['levs'])):
		#create a weighting grid
		mask_reflect=10.0#dBZ	
		mask=(gp['CZ'][:,:,lvl_num]/mask_reflect).round().clip(min=0., max=1.0) 
		mask_vel_ber=(ber['VR'][:,:,lvl_num]+100.).clip(min=0., max=1.)
		mywts[:,:,lvl_num]=mask*mask_vel_ber*wts_ang	
	f=0.0
	gv_u=zeros(ber['CZ'].shape, dtype=float)
	gv_v=zeros(ber['CZ'].shape, dtype=float)
	wts=mask*mask_vel_ber*wts_ang
	gu,gv,f= grad_conj_solver_plus_plus.meas_cost(gv_u, gv_v, f, igu, igv, ber['i_comp'], ber['j_comp'], gp['i_comp'], gp['j_comp'],  ber['VR'], gp['VR'], mywts)
	print "Mean U gradient", gu.mean(), "gv mean", gv.mean(), "F ", f
	for i in range(len(gp['levs'])):
		print "U,V ", (igu[:,:,i]).sum()/mywts[:,:,i].sum(), (igv[:,:,i]).sum()/mywts[:,:,i].sum()
		#gv_u,gv_v,cost = vel_2d_cost(gv_u,gv_v,cost,u_array,v_array,i_cmpt_r1,j_cmpt_r1,i_cmpt_r2,j_cmpt_r2,vr1,vr2,weights,nx=shape(gv_u,0),ny=shape(gv_u,1))
      		print gracon_vel2d.vel_2d_cost(gv_u[:,:,i]*0.0,gv_v[:,:,i]*0.0,0.0,igu[:,:,i],igv[:,:,i],ber['i_comp'][:,:,i], ber['j_comp'][:,:,i], gp['i_comp'][:,:,i], gp['j_comp'][:,:,i],  ber['VR'][:,:,i], gp['VR'][:,:,i],mywts[:,:,i])[2]
	gv_u,gv_v,f,u_array,v_array = grad_conj_solver_plus_plus.gracon_vel2d_3d( gv_u, gv_v, f, igu, igv, ber['i_comp'], ber['j_comp'], gp['i_comp'], gp['j_comp'], ber['VR'], gp['VR'], mywts)#, nx=nx, ny=ny, nz=nz)
	gp.update({'u_array': u_array, 'v_array':v_array})
	netcdf_utis.save_data_cube(ber, gp, '/bm/gdata/scollis/cube_data/20060122_'+tim+'_winds_ver1.nc', gp['zero_loc'])
	plotit=True
	if plotit:
		for lvl in range(len(gp['levs'])):
			print lvl
			f=figure()
			mapobj=pres.generate_darwin_plot(box=[130.8, 131.2, -12.4, -12.0])
			diff=gp['VR']-(u_array*gp['i_comp']+ v_array*gp['j_comp'])
			gp.update({'diff':diff})
			pres.reconstruction_plot(mapobj, lats, lons, gp, lvl, 'diff',u_array[:,:,lvl],v_array[:,:,lvl], angs, mywts[:,:,lvl])
			#pres.quiver_contour_winds(mapobj, lats, lons, (wts*u_array).clip(min=-50, max=50),(wts*v_array).clip(min=-50, max=50))
			t1='Gunn Point CAPPI (dBZ) and reconstructed winds (m/s) at %(lev)05dm \n 22/01/06 ' %{'lev':gp['levs'][lvl]}
			title(t1+tim) 
			ff=os.getenv('HOME')+'/bom_mds/output/recons_22012006/real_%(lev)05d_' %{'lev':gp['levs'][lvl]}
			savefig(ff+tim+'_2d_3d.png')
			close(f)	
예제 #3
0
def save_cube_test(date,gpnum, bernum):
	gp_0740=read_rays.construct_lassen_scan(path='/bm/gdata/scollis/gunn_pt/'+date+gpnum+'/')
	ber_0740=read_rays.construct_uf_scan(path='/bm/gdata/scollis/berrimah/'+date+'_'+bernum+'/')	
	ber_loc=[-12.457, 130.925]
	gp_loc=	 [-12.2492,  131.0444]
	displace=mathematics.corner_to_point(gp_loc, ber_loc)
	ldict={'lat_0':gp_loc[0], 'lon_0':gp_loc[1],'llcrnrlat':-13.0, 'llcrnrlon':130.2, 'urcrnrlat':-12.0 , 'urcrnrlon':131.2, 'lat_ts':gp_loc[0]}
	levs=linspace(500,15000, 21)
	xar=linspace(-50.,50., 100)*1000.0
	yar=linspace(-50.,50., 100)*1000.0
	gp_cube=radar_to_cart.make_cube(gp_0740, xar, yar, levs)
	ber_cube=radar_to_cart.make_cube(ber_0740, xar-displace[0], yar-displace[1], levs)
	netcdf_utis.save_data_cube(ber_cube, gp_cube, '/bm/gdata/scollis/cube_data/'+date+'_'+bernum[0:4]+'_ver1.nc', gp_loc)
예제 #4
0
def pickle_to_cappi(gp_pickle, ber_pickle, **kwargs):
	path=kwargs.get('path', '/bm/gkeep/scollis/deal_ber/')
	debug=kwargs.get('debug', False)
	if debug: print "Loading Pickles"
	gp=pickle_zip.load(path+gp_pickle)
	ber=pickle_zip.load(path+ber_pickle)	
	ber_loc=[-12.457, 130.925]
	gp_loc=[-12.2492,  131.0444]
	displace=mathematics.corner_to_point(gp_loc, ber_loc)
	ldict={'lat_0':gp_loc[0], 'lon_0':gp_loc[1],'llcrnrlat':-13.0, 'llcrnrlon':130.2, 'urcrnrlat':-12.0 , 'urcrnrlon':131.2, 'lat_ts':gp_loc[0]}
	levs=linspace(500,10000, 30)
	xar=linspace(-50.,50., 100)*1000.0
	yar=linspace(-50.,50., 100)*1000.0
	gp_cube=radar_to_cart.make_cube(gp, xar, yar, levs)
	ber_cube=radar_to_cart.make_cube(ber, xar-displace[0], yar-displace[1], levs)
	print gp_cube['CZ'].shape
	netcdf_utis.save_data_cube(ber_cube, gp_cube, '/bm/gdata/scollis/cube_data/'+std_datestr(gp[0]['date'])+'_deal.nc', gp_loc)
예제 #5
0
def radar_to_winds(datestr, **kwargs):
	#check to see if we have the radar files
	#check to see if there are deailased files
	#kwargs={}
	loud=kwargs.get('loud', False)
	
	#datestr='200601220700'
	ini_fname=kwargs.get('ini_fname', os.getenv('HOME')+'/bom_mds/bom_mds.ini')
	
	dateobj=num2date(datestr2num(datestr))
	ini_fname=kwargs.get('ini_fname', os.getenv('HOME')+'/bom_mds/bom_mds.ini')
	ini_dict=parse_ini.parse_ini(ini_fname)
	radar1_deal_list=os.listdir(ini_dict['radar1_path'])
	radar2_deal_list=os.listdir(ini_dict['radar2_path'])
	radar1_raw_list=os.listdir(ini_dict['radar1_raw_path'])
	radar2_raw_list=os.listdir(ini_dict['radar2_raw_path'])
	
	radar1_target=ini_dict['radar1_prefix']+std_datestr(dateobj, ini_dict['radar1_type'])
	radar2_target=ini_dict['radar2_prefix']+std_datestr(dateobj, ini_dict['radar2_type'])
	
	poss_deal_files1=[]
	for item in radar1_deal_list:
		if radar1_target in item: poss_deal_files1.append(item)
	
	if len(poss_deal_files1)==0:
		poss_raw_files1=[]
		print "No dealiased files found... Dealiasing"
		for item in radar1_raw_list:
			if radar1_target in item: poss_raw_files1.append(item)
		if len(poss_raw_files1)==0:
			#print "no files found"
			raise IOError, 'Radar 2 File not there'
			#return
		else:
			print "Dealiasing "+poss_raw_files1[0]
			radar1_filename=dealias.dealias_arb(poss_raw_files1[0], ini_dict['radar1_type'], ini_dict['radar1_raw_path'], ini_dict['radar1_path'], ini_dict['radar1_prefix'])
	else:
		radar1_filename=poss_deal_files1[0]
	
	poss_deal_files2=[]
	for item in radar2_deal_list:
		if radar2_target in item: poss_deal_files2.append(item)
	
	if len(poss_deal_files2)==0:
		poss_raw_files2=[]
		print "No dealiased files found... Dealiasing"
		for item in radar2_raw_list:
			if radar2_target in item: poss_raw_files2.append(item)
		if len(poss_raw_files2)==0:
			#print "no files found"
			raise IOError, 'Radar 2 File not there'
		else:
			radar2_filename=dealias.dealias_arb(poss_raw_files2[0], ini_dict['radar2_type'], ini_dict['radar2_raw_path'], ini_dict['radar2_path'], ini_dict['radar2_prefix'])
	else:
		radar2_filename=poss_deal_files2[0]
	
	if loud: print "Loading radar file 1"
	
	if 'radar1_path' in ini_dict.keys():
		radar1=read_radar.load_radar(ini_dict['radar1_path']+radar1_filename)
	else:
		radar1=read_radar.load_radar(radar1_filename)
	
	if loud: print "Loading radar file 2"
	
	if 'radar2_path' in ini_dict.keys():
		radar2=read_radar.load_radar(ini_dict['radar2_path']+radar2_filename)
	else:
		radar2=read_radar.load_radar(radar2_filename)
	pres.plot_ppi(radar2[2],'VE', fig_path='/scratch/bom_mds_dumps/', fig_name='radar2_ve.png')
	pres.plot_ppi(radar2[2],'CZ', fig_path='/scratch/bom_mds_dumps/', fig_name='radar2_cz.png')
	cappi_z_bounds=ini_dict.get('cappi_z_bounds', [500,15000])
	cappi_xy_bounds=ini_dict.get('cappi_xy_bounds', [-50000, 50000])
	cappi_resolution=ini_dict.get('cappi_resolution', [100, 40])
	levs=linspace(cappi_z_bounds[0], cappi_z_bounds[1], cappi_resolution[1])
	xar=linspace(cappi_xy_bounds[0], cappi_xy_bounds[1], cappi_resolution[0])
	yar=linspace(cappi_xy_bounds[0], cappi_xy_bounds[1], cappi_resolution[0])
	displace=mathematics.corner_to_point(radar1[0]['radar_loc'], radar2[0]['radar_loc'])
	if loud: print "Cappi-ing radar 1"
	
	#radar1_cube_=radar_to_cart.make_cube(radar1, xar, yar, levs)
	radar1_cube=cappi_v2.make_cube_all(radar1,xar, yar,levs)
	#max_el=array([scan['Elev'][0] for scan in radar1]).max()
	#radar1_cube=cappi_v2.blend(radar1_cube_v,radar1_cube_h, max_el,loud=True)
	
	if loud: print "Cappi-ing radar 2"
	
	#radar2_cube_v=radar_to_cart.make_cube(radar2, xar, yar, levs, displacement=displace)
	radar2_cube=cappi_v2.make_cube_all(radar2,xar, yar,levs, displacement=displace)
	#max_el=array([scan['Elev'][0] for scan in radar2]).max()
	#radar2_cube=cappi_v2.blend(radar2_cube_v,radar2_cube_h, max_el,loud=True)
	#radar2_cube_v=radar_to_cart.make_cube(radar2, xar, yar, levs, displacement=displace)
	cube_fname=ini_dict['cube_path']+'cappi_'+std_datestr(radar1_cube['date'], "uf")+'.nc'
	#netcdf_utis.save_data_cube(radar1_cube, radar2_cube, cube_fname)
	
	#Initial Guess
	req=[ 'alt(m)',  'wspd(m/s)',  'wdir(degs)', 'tdry(degs)','press(hPa)' ]
	first_sonde,second_sonde = read_sounding.get_two_best_conc_sondes(datestr, req_vars=req)
	interp_sonde=read_sounding.interp_sonde_time(first_sonde, second_sonde, dateobj, levs)
		
	if ini_dict['initial_guess']=='sonde':
		#using a sonde for out initial gues
		u_ig=ones(radar1_cube['CZ'].shape, dtype=float)
		v_ig=ones(radar1_cube['CZ'].shape, dtype=float)
		w_ig=zeros(radar1_cube['CZ'].shape, dtype=float)
		for k in range(len(levs)):
			u_ig[:,:,k]=1.0*u_ig[:,:,k]*interp_sonde['wspd(m/s)'][k]*sin(pi*interp_sonde['wdir(degs)'][k]/180.0)
			v_ig[:,:,k]=1.0*v_ig[:,:,k]*interp_sonde['wspd(m/s)'][k]*cos(pi*interp_sonde['wdir(degs)'][k]/180.0)
	else:
		u_ig=zeros(radar1_cube['CZ'].shape, dtype=float)
		v_ig=zeros(radar1_cube['CZ'].shape, dtype=float)
		w_ig=zeros(radar1_cube['CZ'].shape, dtype=float)
	
	Re=6371.0*1000.0
	rad_at_radar=Re*sin(pi/2.0 -abs(radar1[0]['radar_loc'][0]*pi/180.0))#ax_radius(float(lat_cpol), units='degrees')
	lons=radar1[0]['radar_loc'][1]+360.0*xar/(rad_at_radar*2.0*pi)
	lats=radar1[0]['radar_loc'][0] + 360.0*yar/(Re*2.0*pi)	
	#Masking
	angs=array(propigation.make_lobe_grid(radar2[0]['radar_loc'], radar1[0]['radar_loc'], lats,lons))
	mywts=met.make_mask_bad1(radar2_cube, radar1_cube, angs, 1.0, 80.0)
	
	print "Mean gp masked Velocity ", (radar1_cube['VE']*mywts).mean()
	print "min gp masked Velocity ", (radar1_cube['VE']*mywts).min()
	print "max gp masked Velocity ", (radar1_cube['VE']*mywts).max()
	print "Mean Berrimah masked Velocity ", (radar2_cube['VE']*mywts).mean()
	print "min Berrimah masked Velocity ", (radar2_cube['VE']*mywts).min()
	print "max Berrimah masked Velocity ", (radar2_cube['VE']*mywts).max()
	print "Mean gp masked CZ ", (radar1_cube['CZ']*mywts).mean()
	print "min gp masked CZ ", (radar1_cube['CZ']*mywts).min()
	print "max gp masked CZ ", (radar1_cube['CZ']*mywts).max()
	print "Mean Berrimah masked CZ ", (radar2_cube['CZ']*mywts).mean()
	print "min Berrimah masked CZ ", (radar2_cube['CZ']*mywts).min()
	print "max Berrimah masked CZ ", (radar2_cube['CZ']*mywts).max()
	print "Number of masked points", (mywts.shape[0]*mywts.shape[1]*mywts.shape[2])-mywts.sum()
	print "Number of unmasked points ", mywts.sum()
	print "**********************FALLSPEED INFO****************************"
	#def terminal_velocity(refl, temps, levs, display=False):
	tdry=interp_sonde['tdry(degs)']
	pressure=interp_sonde['press(hPa)']
	dummy=met.terminal_velocity(radar1_cube['CZ']*mywts, tdry, radar1_cube['levs'], display=True)
	print "**********************FALLSPEED INFO****************************"
	f=0.0
	X=[u_ig,v_ig,w_ig]
	G,F,X=grad_conj_solver_3d.gracon_3d_packaged(X ,radar2_cube, radar1_cube, mywts, interp_sonde)
	u_array,v_array,w_array=X 
	radar1_cube.update({'u_array':u_array, 'v_array':v_array, 'w_array':w_array})
	netcdf_utis.save_data_cube(radar1_cube, radar2_cube,  '/data/cube_data/'+std_datestr(dateobj, "uf") +'_winds.nc')
예제 #6
0
파일: bom_mds.py 프로젝트: scollis/bom_mds
def recon(date_str, latstr, lonstr):
     use_guess='sonde'
     sonde_file='/bm/gdata/scollis/twpice/darwin.txt'
     #tim='1350'
     tim_date=num2date(datestr2num(date_str)) 
     ber, gp=netcdf_utis.load_cube('/bm/gdata/scollis/cube_data/'+std_datestr(tim_date)+'_deal.nc')
     sonde_list=read_sounding.read_sounding_within_a_day(sonde_file, tim_date)
     #launch_dates=[sonde['date_list'][0] for sonde in sonde_list]
     #launch_date_offset=[date2num(sonde['date_list'][0])- date2num(tim_date)  for sonde in sonde_list]
     #best_sonde=sonde_list[argsort(abs(array(launch_date_offset)))[0]]
     #print 'Time of radar: ', tim_date, ' Time of sonde_launch: ', best_sonde['date_list'][0], ' Time of sonde_termination: ', best_sonde['date_list'][-1]
     req=[ 'alt(m)',  'wspd(m/s)', 'tdry(degs)',  'wdir(degs)']	
     first_sonde, second_sonde=read_sounding.get_two_best_conc_sondes(date_str, req_vars=req)
     interp_sonde=read_sounding.interp_sonde_time(first_sonde, second_sonde, tim_date, gp['levs'])
     u_sonde=ones(gp['CZ'].shape, dtype=float)
     v_sonde=ones(gp['CZ'].shape, dtype=float)
     w_sonde=zeros(gp['CZ'].shape, dtype=float)
     for k in range(len(gp['levs'])):
	     u_sonde[:,:,k]=-1.0*u_sonde[:,:,k]*interp_sonde['wspd(m/s)'][k]*sin(pi*interp_sonde['wdir(degs)'][k]/180.0)
	     v_sonde[:,:,k]=-1.0*v_sonde[:,:,k]*interp_sonde['wspd(m/s)'][k]*cos(pi*interp_sonde['wdir(degs)'][k]/180.0)
     Re=6371.0*1000.0
     rad_at_radar=Re*sin(pi/2.0 -abs(gp['zero_loc'][0]*pi/180.0))#ax_radius(float(lat_cpol), units='degrees')
     lons=gp['zero_loc'][1]+360.0*gp['xar']/(rad_at_radar*2.0*pi)
     lats=gp['zero_loc'][0] + 360.0*gp['yar']/(Re*2.0*pi)	
     ber_loc=[-12.457, 130.925]
     gp_loc= [-12.2492,  131.0444]
     
     if use_guess=='none':
	  igu=ones(ber['CZ'].shape, dtype=float)*0.0
	  igv=ones(ber['CZ'].shape, dtype=float)*0.0
	  igw=ones(ber['CZ'].shape, dtype=float)*0.0
     elif use_guess=='sonde':
	  igu=u_sonde
	  igv=v_sonde
	  igw=w_sonde
     else:
	  ber_ig, gp_ig=netcdf_utis.load_cube(use_guess)
	  print gp_ig.keys()
	  igu=gp_ig['u_array']
	  igv=gp_ig['v_array']
	  igw=ones(ber['CZ'].shape, dtype=float)*0.0
     
     #mywts=ones(ber['CZ'].shape, dtype=float)
     angs=array(propigation.make_lobe_grid(ber_loc, gp_loc, lats,lons))
     #wts_ang=zeros(gp['CZ'][:,:,0].shape, dtype=float)
     #for i in range(angs.shape[0]):
     #    for j in range(angs.shape[1]):
     #		 if (angs[i,j] < 150.0) and (angs[i,j] > 30.0): wts_ang[i,j]=1.0
     #for lvl_num in range(len(gp['levs'])):
     #	  #create a weighting grid
     #	  mask_reflect=10.0#dBZ	
     #	  mask=(gp['CZ'][:,:,lvl_num]/mask_reflect).round().clip(min=0., max=1.0) 
     #	  mask_vel_ber=(ber['VR'][:,:,lvl_num]+100.).clip(min=0., max=1.)
     #	  mywts[:,:,lvl_num]=mask*mask_vel_ber*wts_ang	
     mywts=met.make_mask(ber, gp, angs, 1.0, 80.0)
     print "Mean gp masked Velocity ", (gp['VE']*mywts).mean()
     print "min gp masked Velocity ", (gp['VE']*mywts).min()
     print "max gp masked Velocity ", (gp['VE']*mywts).max()
     print "Mean Berrimah masked Velocity ", (ber['VE']*mywts).mean()
     print "min Berrimah masked Velocity ", (ber['VE']*mywts).min()
     print "max Berrimah masked Velocity ", (ber['VE']*mywts).max()
     print "Mean gp masked CZ ", (gp['CZ']*mywts).mean()
     print "min gp masked CZ ", (gp['CZ']*mywts).min()
     print "max gp masked CZ ", (gp['CZ']*mywts).max()
     print "Mean Berrimah masked CZ ", (ber['CZ']*mywts).mean()
     print "min Berrimah masked CZ ", (ber['CZ']*mywts).min()
     print "max Berrimah masked CZ ", (ber['CZ']*mywts).max()
    
     print "Number of masked points", (mywts.shape[0]*mywts.shape[1]*mywts.shape[2])-mywts.sum()
     print "Number of unmasked points ", mywts.sum()
     print "**********************FALLSPEED INFO****************************"
     #def terminal_velocity(refl, temps, levs, display=False):
     tdry=interp_sonde['tdry(degs)']
     pressure=interp_sonde['press(hPa)']
     dummy=met.terminal_velocity(gp['CZ']*mywts, tdry, gp['levs'], display=True)
     print "**********************FALLSPEED INFO****************************"
     #print 
     
     
     f=0.0
     X=[igu,igv,igw]
     G,F,X=grad_conj_solver_3d.gracon_3d_packaged(X ,ber, gp, mywts, interp_sonde)
     u_array,v_array,w_array=X 
     lvl=2500.0
     lvl_num=argsort(abs(gp['levs']-lvl))[0]
     print "Level_num=", lvl_num
     if latstr=='max' or lonstr=='max':
	     maskedcz=gp['CZ'][:,:,lvl_num]*mywts[:,:,lvl_num]
	     i,j=mathematics.where_closest_2d(maskedcz.max(), maskedcz)
	     print i,j
	     lat=lats[j[0]]
	     lon=lons[i[0]]
	     print "Max CZ at ", lat, lon 
     else:
	     lon=float(lonstr)
	     lat=float(latstr)
     f=figure()
     #(lat_sl, lon_sl, lvl, data_cube, lats, lons, levs, u, v, w, angs, mask, par='CZ', w_mag=2.0, **kwargs)
     alat, alon, alvl=pres.plot_slices(lat, lon, lvl, gp, lats, lons, gp['levs'], u_array, v_array, w_array, angs, mywts, par='CZ', w_mag=2.0,box=[130.5, 131.5, -12.7, -12.0], bquiver=[0.05, 0.75], ksp=0.05)
     t1='Gunn Point reflectivity (dBZ) and reconstructed winds (m/s, *2.0 for w)\n sliced at %(alat)2.2fS and %(alon)3.2fE and %(alvl)d Metres on 22/01/06 at ' %{'alat':abs(alat), 'alon':alon, 'alvl':alvl}
     t2=" %(HH)02d%(MM)02dZ" %{'HH':tim_date.hour, 'MM':tim_date.minute}
     f.text( .1, .92, t1+t2) 
     inte_part=1000*(float(int(lat))-lat)
     print  {'alat':abs(alat), 'alon':alon, 'alvl':alvl}
     ff=os.getenv('HOME')+'/bom_mds/output/recons_'+std_datestr(tim_date)[0:-5]+'/slicer3_%(alat)2.02f_%(alon)3.02f_%(alvl)05d_' %{'alat':abs(alat), 'alon':alon, 'alvl':alvl}
     print ff
     savefig(ff+t2+'.png', dpi=200)
     gp.update({'u_array':u_array, 'v_array':v_array, 'w_array':w_array})
     netcdf_utis.save_data_cube(ber, gp, '/bm/gdata/scollis/cube_data/'+std_datestr(tim_date)+'_winds.nc', gp_loc)
     close(f)
예제 #7
0
print "max gp masked CZ ", (radar1_cube['CZ']*mywts).max()
print "Mean Berrimah masked CZ ", (radar2_cube['CZ']*mywts).mean()
print "min Berrimah masked CZ ", (radar2_cube['CZ']*mywts).min()
print "max Berrimah masked CZ ", (radar2_cube['CZ']*mywts).max()
print "Number of masked points", (mywts.shape[0]*mywts.shape[1]*mywts.shape[2])-mywts.sum()
print "Number of unmasked points ", mywts.sum()
print "**********************FALLSPEED INFO****************************"
#def terminal_velocity(refl, temps, levs, display=False):
tdry=interp_sonde['tdry(degs)']
pressure=interp_sonde['press(hPa)']
dummy=met.terminal_velocity(radar1_cube['CZ']*mywts, tdry, radar1_cube['levs'], display=True)
print "**********************FALLSPEED INFO****************************"
f=0.0
X=[u_ig,v_ig,w_ig]
G,F,X=grad_conj_solver_3d.gracon_3d_packaged(X ,radar2_cube, radar1_cube, mywts, interp_sonde)
u_array,v_array,w_array=X 
radar1_cube.update({'u_array':u_array, 'v_array':v_array, 'w_array':w_array})
netcdf_utis.save_data_cube(radar1_cube, radar2_cube,  '/data/cube_data/'+std_datestr(dateobj, "uf") +'_winds.nc')