コード例 #1
0
def verify_CECE_LOS(ECRad_results_file):
    res = ECRadResults()
    res.load(ECRad_results_file)
    x,y = plot1DECE(project="toroidal" , freq=res.Scenario["diagnostic"]["f"][0][0]/1.e9,doPlot=False, verb=False)
    R,z = plot1DECE(project="poloidal" , freq=res.Scenario["diagnostic"]["f"][0][0]/1.e9,doPlot=False, verb=False)
    fig_top = plt.figure()
    ax_top = fig_top.add_subplot(111)
    fig_side = plt.figure()
    ax_side = fig_side.add_subplot(111)
    label_Pedro = "Pedro"
    for i in [0, 2, 4]:
        ax_top.plot(x, y.T[i], "--", label=label_Pedro)
        ax_side.plot(R, z.T[i], "--", label=label_Pedro)
        label_Pedro =None
    label_ECRad = "ECRad"
    for ir in range(res.Config["Physics"]["N_ray"]):
        phi = np.arctan2(np.array(res["ray"]["y"][0][0][0][ir],dtype=np.float), 
                         np.array(res["ray"]["x"][0][0][0][ir],dtype=np.float))
        phi_rot = 22.5 * 8.5
        x_ECRad = res["ray"]["R"][0][0][0][ir] * np.cos(phi - np.deg2rad(phi_rot))
        y_ECRad = res["ray"]["R"][0][0][0][ir] * np.sin(phi - np.deg2rad(phi_rot))
        ax_top.plot(x_ECRad, y_ECRad, "-", label=label_ECRad)
        ax_side.plot(res["ray"]["R"][0][0][0][ir], res["ray"]["z"][0][0][0][ir], "-", label=label_ECRad)
        label_ECRad = None
    ax_top.set_xlabel(r"$x$ [m]")
    ax_top.set_xlim(1,3)
    ax_top.set_ylim(-0.1,0.2)
    ax_top.set_ylabel(r"$y$ [m]")
    ax_side.set_xlabel(r"$R$ [m]")
    ax_side.set_ylabel(r"$z$ [m]")
    ax_side.set_xlim(1,3)
    ax_side.set_ylim(-0.1,0.2)
    ax_top.legend()
    ax_side.legend()
    plt.show()
コード例 #2
0
def CECE_workflow(working_dir, Results_filename, time):
    Results = ECRadResults()
    Results.load(Results_filename)
    logfile = open(os.path.join(working_dir, f"CECE_params_{Results.Scenario['shot']}"), "w")
    run_ECE_TORBEAM_ECRad_Scenario(working_dir, Results, time, logfile=logfile)
    get_BPD_width(Results, 0, logfile=logfile)
    logfile.close()
    plt.show()
コード例 #3
0
def plot_harmonics_and_frequencies(res_file):
    Results = ECRadResults()
    Results.load(res_file)
    fig = plt.figure()
    pc_obj = PlottingCore(fig=fig)
    ich_list = np.arange(0,
                         len(Results.Scenario["diagnostic"]["f"][0]),
                         3,
                         dtype=np.int)
    imode_list = np.zeros(ich_list.shape, dtype=np.int)
    ir_list = np.zeros(ich_list.shape, dtype=np.int)
    pc_obj.B_plot(Results, 0, ich_list, imode_list, ir_list)
    plt.show()
コード例 #4
0
def compare_f_dia(shot, time, EQ_exp, EQ_diag, EQ_ed):
    from Plotting_Configuration import plt
    EQObj = EQData(shot, EQ_exp=EQ_exp, EQ_diag=EQ_diag, EQ_ed=EQ_ed)
    EQ_t = EQObj.GetSlice(time)
    rho = np.linspace(0.0, 1.0, 100)
    ffp = EQObj.getQuantity(rho, "FFP", time)
    ffp_spl = InterpolatedUnivariateSpline(rho, ffp)
    f_sq_spl = ffp_spl.antiderivative(1)
    magn_field_axis = EQObj.MBI_shot.getSignal("BTFABB", \
                                              tBegin=time - 5.e-5, tEnd=time + 5.e-5)
    f_spl = InterpolatedUnivariateSpline(rho, np.sign(magn_field_axis) * \
                                                               (np.sqrt(2.0 * f_sq_spl(rho) + \
                                                                        (EQ_t.R_ax * magn_field_axis)**2)))
    psi_prof = EQObj.rhop_to_Psi(time, rho)
    plt.plot(psi_prof, f_spl(rho))
    gpol = EQObj.getQuantity(rho, "Jpol", time) * cnst.mu_0 / 2.0 / np.pi
    plt.plot(psi_prof, gpol, "--")
    plt.show()
コード例 #5
0
def put_TRANSP_U_profiles_in_Scenario(Scenario, filename, time, scenario_name):
    from ufilelib import UFILELIB
    from Plotting_Configuration import plt
    u_file = UFILELIB()
    u_file.readfile(filename)
    it = np.argmin(np.abs(Scenario.plasma_dict["time"] - time))
    eq_slice = Scenario.plasma_dict["eq_data"][it]
    Scenario.plasma_dict["time"] = np.array([time])
    Scenario.plasma_dict["eq_data"] = [eq_slice]
    it_u_file = np.argmin(np.abs(u_file.ufdict["TE"]["Time"]))
    Scenario.plasma_dict["Te"] = [u_file.ufdict["TE"]["data"][it_u_file]]
    plt.plot(u_file.ufdict["TE"]["rho_tor"],
             u_file.ufdict["TE"]["data"][it_u_file] / 1.e3)
    it_u_file = np.argmin(np.abs(u_file.ufdict["NE"]["Time"]))
    Scenario.plasma_dict["ne"] = [
        u_file.ufdict["NE"]["data"][it_u_file] * 1.e6
    ]
    Scenario.plasma_dict["prof_reference"] = "rhot_prof"
    Scenario.plasma_dict["rhot_prof"] = u_file.ufdict["NE"]["rho_tor"]
    Scenario.to_mat_file(filename=scenario_name)
    plt.plot(u_file.ufdict["NE"]["rho_tor"],
             u_file.ufdict["NE"]["data"][it_u_file] / 1.e13)
    plt.show()
コード例 #6
0
            self.ECRad_results.ray[field + mode][it][ich][iray] = values

    def save(self, new_filename, comment=""):
        if (new_filename == self.org_results_file):
            print("This routine does not allow overwriting of the old file!")
            return
        self.ECRad_results.to_mat_file(new_filename, comment)


if (__name__ == "__main__"):
    from Plotting_Configuration import plt
    ECRad_manip = ECRadRayManipulator(
        "/mnt/c/Users/Severin/ECRad/Yu/ECRad_179328_EXT_ed10.mat")
    R, z = ECRad_manip.get_Rz_single_ray(0, 0)
    Te_spl = RectBivariateSpline(ECRad_manip.ECRad_results.Scenario.plasma_dict["eq_data"][0].R, \
                                 ECRad_manip.ECRad_results.Scenario.plasma_dict["eq_data"][0].z, \
                                 ECRad_manip.ECRad_results.Scenario.plasma_dict["Te"][0])
    rhop = ECRad_manip.get_field_single_ray("rhop", 0, 0)
    plt.plot(rhop[rhop >=0], \
             ECRad_manip.get_field_single_ray("Te", 0, 0)[rhop >= 0], "+",  label="before")
    ECRad_manip.set_field_single_ray("Te",
                                     Te_spl(R, z, grid=False) * 1.5, 0, 0)
    ECRad_manip.save("/mnt/c/Users/Severin/ECRad/Yu/ECRad_179328_EXT_ed10_1.5Te.mat", \
                     "increased Te by a factpr pf1.5")
    ECRad_manip = ECRadRayManipulator(
        "/mnt/c/Users/Severin/ECRad/Yu/ECRad_179328_EXT_ed10_1.5Te.mat")
    plt.plot(rhop[rhop >=0], \
             ECRad_manip.get_field_single_ray("Te", 0, 0)[rhop >= 0], "^", label="after")
    plt.legend()
    plt.show()