Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ==============================================================================#
- #
- #
- #
- #
- #
- # ==============================================================================#
- # begin imports
- import math
- import os
- import numpy as np
- from smithplot import SmithAxes
- from matplotlib import rcParams, pyplot as plt, cm
- from matplotlib.colors import Normalize
- # end imports
- ##### DATA ACQUISITION FROM CSV FILE #####
- # open data file
- if os.path.exists('load_pull.csv'): # check for file
- file = np.genfromtxt("load_pull.csv", delimiter=',') # open file of name load_pull.csv
- else:
- print("error, file not found")
- # populate data into arrays
- z_mag = file[:, 2]
- z_phase = file[:, 3] * (math.pi / 180)
- gen_fwd = file[:, 7]
- gen_rev = file[:, 8]
- gen_load = gen_fwd - gen_rev
- freq = file[:, 9]
- v_rail = file[:, 10]
- pai = file[:, 11] / 10
- dc_pwr = np.array(pai * v_rail)
- p_diss = file[:, 12]
- # convert magnitude to real and imaginary parts
- zr = z_mag * np.cos(z_phase)
- zi = z_mag * np.sin(z_phase)
- # combine real and imaginary parts
- z = np.array(zr + (1j * zi))
- ##### END DATA ACQUISITION FROM CSV FILE #####
- def z2gamma(input_array, load):
- """
- converts the impedance z to the reflection coefficient gamma using a reference impedance of z0 (load) ohms
- :param input_array: array of element style (real + imag)
- :param load: number in ohms
- :return: reflection coefficient
- """
- for i in np.nditer(input_array):
- reflection_coefficient = np.array(np.subtract(input_array, load) / np.add(input_array, load))
- return reflection_coefficient
- gamma = z2gamma(z, 50) # creates new array called gamma and calls the z2gamma function with 50 ohm
- gr = np.real(gamma) # the real part of each value from gamma
- gi = np.imag(gamma) # the imaginary part of each value from gamma
- """
- Graphing
- """
- def graph_PARail_vs_Load():
- min_vrail = min(v_rail)
- max_vrail = max(v_rail)
- fig = plt.figure(figsize=(10, 10))
- ax = fig.add_subplot(1, 1, 1, projection='smith', grid_major_xmaxn=5, grid_major_ymaxn=14, grid_minor_enable=False)
- norm_vrail = Normalize(vmin=int(float(max_vrail)), vmax=int(float(min_vrail))) # normalize vrail for contour
- img = plt.imshow(np.array([[0, 1]]), cmap='YlOrRd_r', norm=norm_vrail) # create countour chart
- img.set_visible(False)
- cmap = plt.cm.YlOrRd_r
- plt.colorbar()
- for g in gamma:
- plot = plt.plot(gamma, datatype=SmithAxes.S_PARAMETER, color=cmap(norm_vrail(float(v_rail))), marker='o',
- markersize=12, alpha=0.3, markeredgewidth=0.5)
- plt.cla()
- plt.title("PA Rail V vs. Load")
- graph_PARail_vs_Load()
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement