Ejemplo n.º 1
0
def append_ijk(sweep_dict):
    # [i,j] i is azmth, j is gates
    iar = zeros(sweep_dict["range"].shape, dtype=float)
    jar = zeros(sweep_dict["range"].shape, dtype=float)
    kar = zeros(sweep_dict["range"].shape, dtype=float)
    Re = 6371.0 * 1000.0
    p_r = 4.0 * Re / 3.0
    for az_num in range(sweep_dict["range"].shape[0]):
        r = sweep_dict["range"][az_num, :] * 1000.0
        ele = sweep_dict["Elev"][az_num]
        az = sweep_dict["Azmth"][az_num]
        z = (r ** 2 + p_r ** 2 + 2.0 * r * p_r * sin(ele * pi / 180.0)) ** 0.5 - p_r
        s = p_r * arcsin(r * cos(ele * pi / 180.0) / (p_r + z))
        dh = mathematics.dy(z)
        ds = mathematics.dy(s)
        angle = arctan(dh / ds)
        k_comp = sin(angle)
        r_comp = cos(angle)
        i_comp = r_comp * sin(az * pi / 180.0)
        j_comp = r_comp * cos(az * pi / 180.0)
        for gate in range(sweep_dict["range"].shape[1]):
            if sweep_dict["VR"][az_num, gate] == -999:
                i_comp[gate] = j_comp[gate] = k_comp[gate] = -999.0
            # print iar.shape
            # print i_comp.shape
        iar[az_num, :] = i_comp
        jar[az_num, :] = j_comp
        kar[az_num, :] = k_comp
    sweep_dict.update({"i_comp": iar, "j_comp": jar, "k_comp": kar})
    return sweep_dict
Ejemplo n.º 2
0
def generate_kdp(data, r,  RH_data,npts=5, bad_data=1.31072000e+05, ftype='hanning', RH_thresh=0.5):
	#Scan ray, find subsections of the ray which are hydro echos using RH
	dest_ray=numpy.zeros([len(data)], dtype=float)+bad_data
	curr_pos=0
	starts=[]
	ends=[]
	while curr_pos < len(data):
		#see if we are in a good data echo
		if (data[curr_pos]!=bad_data) and (RH_data[curr_pos]>RH_thresh):
			starts.append(curr_pos)
			sp=curr_pos
			this_block=[]
			this_r=[]
			while (data[curr_pos]!=bad_data)  and (RH_data[curr_pos]>RH_thresh):
				#now we are scanning in a region of meteo echos
				this_block.append(data[curr_pos])
				this_r.append(r[curr_pos])
				curr_pos=curr_pos+1
				if curr_pos >= len(data): break
			ep=curr_pos 
			ends.append(ep)
			print 'Len of list:', len(this_block)
			#Do stuff with this bit of data
			if len(this_block) >npts:
				this_array=smooth(mathematics.dy(numpy.array(this_block))/mathematics.dy(numpy.array(this_r)), window_len=npts, window=ftype)
			elif len(this_block) > 2:
				this_array=mathematics.dy(numpy.array(this_block))/mathematics.dy(numpy.array(this_r))
			if len(this_block)>2:
				print this_array.shape
				print sp, ep, ep-sp
				dest_ray[sp:ep]=this_array
		else:
			#we are in a non-meteo region
			curr_pos=curr_pos+1
	return dest_ray