예제 #1
0
def display__sf7():

    x_, y_, z_ = 0, 1, 2
    bx_, by_, bz_ = 3, 4, 5

    # ------------------------------------------------- #
    # --- [1] Arguments                             --- #
    # ------------------------------------------------- #
    import nkUtilities.load__constants as lcn
    cnfFile = "dat/parameter.conf"
    const = lcn.load__constants(inpFile=cnfFile)

    config = lcf.load__config()
    datFile = const["bfieldFile"]
    pngFile = "png/bfield_{0}.png"

    # ------------------------------------------------- #
    # --- [2] Fetch Data                            --- #
    # ------------------------------------------------- #
    import nkUtilities.load__pointFile as lpf
    Data = lpf.load__pointFile(inpFile=datFile, returnType="point")

    # ------------------------------------------------- #
    # --- [3] config Settings                       --- #
    # ------------------------------------------------- #
    cfs.configSettings(configType="cMap_def", config=config)
    config["FigSize"] = (8, 3)
    config["cmp_position"] = [0.16, 0.12, 0.97, 0.88]
    config["xTitle"] = "Z (m)"
    config["yTitle"] = "R (m)"
    config["xMajor_Nticks"] = 8
    config["yMajor_Nticks"] = 3
    config["cmp_xAutoRange"] = True
    config["cmp_yAutoRange"] = True
    config["cmp_xRange"] = [-5.0, +5.0]
    config["cmp_yRange"] = [-5.0, +5.0]
    config["vec_AutoScale"] = True
    config["vec_AutoRange"] = True
    config["vec_AutoScaleRef"] = 200.0
    config["vec_nvec_x"] = 24
    config["vec_nvec_y"] = 6
    config["vec_interpolation"] = "nearest"

    # ------------------------------------------------- #
    # --- [4] plot Figure                           --- #
    # ------------------------------------------------- #
    cmt.cMapTri( xAxis=Data[:,z_], yAxis=Data[:,x_], cMap=Data[:,bz_], \
                 pngFile=pngFile.format( "Bz" ), config=config )
    cmt.cMapTri( xAxis=Data[:,z_], yAxis=Data[:,x_], cMap=Data[:,bx_], \
                 pngFile=pngFile.format( "Br" ), config=config )

    absB = np.sqrt(Data[:, bz_]**2 + Data[:, bx_]**2)
    fig = cmt.cMapTri(pngFile=pngFile.format("Bv"), config=config)
    fig.add__cMap(xAxis=Data[:, z_], yAxis=Data[:, x_], cMap=absB)
    fig.add__vector ( xAxis=Data[:,z_], yAxis=Data[:,x_], \
                      uvec=Data[:,bz_], vvec=Data[:,bx_], color="blue" )
    fig.save__figure()
예제 #2
0
def show__profile():

    # ------------------------------------------------- #
    # --- [1] Arguments                             --- #
    # ------------------------------------------------- #
    config = lcf.load__config()
    datFile = "dat/2a_Rs.dat"
    pngFile = datFile.replace("dat", "png")

    # ------------------------------------------------- #
    # --- [2] Fetch Data                            --- #
    # ------------------------------------------------- #
    import nkUtilities.load__pointFile as lpf
    Data = lpf.load__pointFile(inpFile=datFile, returnType="point")
    xr_ = Data[:, 0]
    yr_ = Data[:, 1]
    from scipy import interpolate
    f = interpolate.interp1d(xr_, yr_, kind="cubic")
    xAxis = np.linspace(22, 30, 5)
    yAxis = f(xAxis)

    # ------------------------------------------------- #
    # --- [3] config Settings                       --- #
    # ------------------------------------------------- #
    cfs.configSettings(configType="plot1D_def", config=config)
    config["plt_position"] = [0.24, 0.24, 0.94, 0.94]
    config["FigSize"] = (2.5, 2.5)
    config["xTitle"] = "2a (mm)"
    config["yTitle"] = "Rs (M" + "$\Omega$" + "/m)"
    config["plt_xAutoRange"] = False
    config["plt_yAutoRange"] = False
    # config["plt_yAutoRange"] = True
    config["plt_xRange"] = [+20.0, +32.0]
    config["plt_yRange"] = [+40, +64]
    config["plt_linewidth"] = 1.8
    config["xMajor_Nticks"] = 7
    config["yMajor_Nticks"] = 7
    config["xMinor_Nticks"] = 1
    config["yMinor_Nticks"] = 1
    config["plt_color"] = "Orange"
    config["plt_marker"] = "o"

    # ------------------------------------------------- #
    # --- [4] plot Figure                           --- #
    # ------------------------------------------------- #
    fig = pl1.plot1D(config=config, pngFile=pngFile)
    fig.add__plot(xAxis=xAxis, yAxis=yAxis)
    fig.set__axis()
    fig.save__figure()
예제 #3
0
def display():
    # ------------------------------------------------- #
    # --- [1] Arguments                             --- #
    # ------------------------------------------------- #
    config = lcf.load__config()
    datFile = "dat/superfish.dat"
    pngFile = "png/alongAxis.png"

    # ------------------------------------------------- #
    # --- [2] Fetch Data                            --- #
    # ------------------------------------------------- #
    import nkUtilities.load__pointFile as lpf
    Data = lpf.load__pointFile(inpFile=datFile, returnType="point")
    eps = 1.e-8
    val = 1.e-3
    index = np.where(np.abs(Data[:, 1] - val) <= eps)
    Data = Data[index][:]
    xAxis = Data[:, 0] - 0.5 * (Data[0, 0] + Data[-1, 0])
    Ez = Data[:, 3] * 1.e-6
    Er = Data[:, 4] / (val * 100.0) * 1.e-6
    # Hp    = Data[:,6] / ( val * 100.0 )

    # ------------------------------------------------- #
    # --- [3] config Settings                       --- #
    # ------------------------------------------------- #
    cfs.configSettings(configType="plot1D_def", config=config)
    config["FigSize"] = (4, 4)
    config["yTitle"] = "Ez (MV/m), Er/r (MV/m/cm)"
    config["xTitle"] = "Z (m)"
    config["plt_xAutoRange"] = False
    config["plt_yAutoRange"] = False
    config["plt_xRange"] = [-0.0, +0.05]
    config["plt_yRange"] = [-0.0, +3.0]
    config["plt_linewidth"] = 1.8
    config["xMajor_Nticks"] = 6
    config["yMajor_Nticks"] = 4

    # ------------------------------------------------- #
    # --- [4] plot Figure                           --- #
    # ------------------------------------------------- #
    fig = pl1.plot1D(config=config, pngFile=pngFile)
    fig.add__plot(xAxis=xAxis, yAxis=Er, label="Er/r")
    fig.add__plot(xAxis=xAxis, yAxis=Ez, label="Ez")
    # fig.add__plot( xAxis=xAxis, yAxis=Hp, label="Hp" )
    fig.add__legend()
    fig.set__axis()
    fig.save__figure()
예제 #4
0
def display(datFile=None, pngFile=None, config=None):
    # ------------------------------------------------- #
    # --- [1] Arguments                             --- #
    # ------------------------------------------------- #
    if (datFile is None): datFile = "bfield_xAxis.dat"
    if (pngFile is None): pngFile = "bfield_xAxis.png"
    if (config is None): config = lcf.LoadConfig()

    # ------------------------------------------------- #
    # --- [2] Fetch Data                            --- #
    # ------------------------------------------------- #
    with open(datFile, "r") as f:
        Data = np.loadtxt(f)
    xAxis = Data[:, 3]
    yAxis = Data[:, 8]

    index = np.argsort(xAxis)
    xAxis = xAxis[index]
    yAxis = yAxis[index]

    # ------------------------------------------------- #
    # --- [3] config Settings                       --- #
    # ------------------------------------------------- #
    cfs.configSettings(configType="plot1D_def", config=config)
    config["xTitle"] = "r (m)"
    config["yTitle"] = "B (T)"
    config["plt_xAutoRange"] = True
    config["plt_yAutoRange"] = True
    config["plt_xRange"] = [-5.0, +5.0]
    config["plt_yRange"] = [-5.0, +5.0]
    config["plt_linewidth"] = 1.0
    config["xMajor_Nticks"] = 5
    config["yMajor_Nticks"] = 5
    config["plt_marker"] = "o"
    config["plt_linewidth"] = 0.5

    # ------------------------------------------------- #
    # --- [4] plot Figure                           --- #
    # ------------------------------------------------- #
    fig = pl1.plot1D(config=config, pngFile=pngFile)
    fig.add__plot(xAxis=xAxis, yAxis=yAxis, label="ans")
    fig.add__legend()
    fig.set__axis()
    fig.save__figure()
예제 #5
0
def display( datFile1=None, datFile2=None, pngFile=None, config=None ):
    # ------------------------------------------------- #
    # --- [1] Arguments                             --- #
    # ------------------------------------------------- #
    if ( datFile1 is None ): datFile1 = "dat/xa_fa.dat"
    if ( datFile2 is None ): datFile2 = "dat/xp_fp.dat"
    if ( pngFile  is None ): pngFile  = "png/out.png"
    if ( config   is None ): config   = lcf.LoadConfig()

    # ------------------------------------------------- #
    # --- [2] Fetch Data                            --- #
    # ------------------------------------------------- #
    with open( datFile1, "r" ) as f:
        Data = np.loadtxt( f )
    xa = Data[:,0]
    fa = Data[:,1]
    with open( datFile2, "r" ) as f:
        Data = np.loadtxt( f )
    xp = Data[:,0]
    fp = Data[:,1]
    
    # ------------------------------------------------- #
    # --- [3] config Settings                       --- #
    # ------------------------------------------------- #
    cfs.configSettings( configType="plot1D_def", config=config )
    config["xTitle"]         = "X"
    config["yTitle"]         = "Y"
    config["plt_xAutoRange"] = True
    config["plt_yAutoRange"] = True
    config["plt_xRange"]     = [-5.0,+5.0]
    config["plt_yRange"]     = [-5.0,+5.0]
    config["plt_linewidth"]  = 1.0
    config["xMajor_Nticks"]  = 5
    config["yMajor_Nticks"]  = 5

    # ------------------------------------------------- #
    # --- [4] plot Figure                           --- #
    # ------------------------------------------------- #
    fig = pl1.plot1D( config=config, pngFile=pngFile )
    fig.add__plot( xAxis=xa, yAxis=fa, label="fa" )
    fig.add__plot( xAxis=xp, yAxis=fp, label="fp", linestyle="--" )
    fig.add__legend()
    fig.set__axis()
    fig.save__figure()
예제 #6
0
def display():
    # ------------------------------------------------- #
    # --- [1] Arguments                             --- #
    # ------------------------------------------------- #
    config   = lcf.load__config()
    datFile1 = "dat/result.dat"
    datFile2 = "dat/source.dat"
    pngFile1 = datFile1.replace( "dat", "png" )
    pngFile2 = datFile2.replace( "dat", "png" )

    # ------------------------------------------------- #
    # --- [2] Fetch Data                            --- #
    # ------------------------------------------------- #
    import nkUtilities.load__pointFile as lpf
    Data1  = lpf.load__pointFile( inpFile=datFile1, returnType="point" )
    xAxis1 = Data1[:,0]
    yAxis1 = Data1[:,1]
    zAxis1 = Data1[:,2]
    
    Data2  = lpf.load__pointFile( inpFile=datFile2, returnType="point" )
    xAxis2 = Data2[:,0]
    yAxis2 = Data2[:,1]
    zAxis2 = Data2[:,2]
    
    # ------------------------------------------------- #
    # --- [3] config Settings                       --- #
    # ------------------------------------------------- #
    cfs.configSettings( configType="cMap_def", config=config )
    config["FigSize"]        = (5,5)
    config["cmp_position"]   = [0.16,0.12,0.97,0.88]
    config["xTitle"]         = "X (m)"
    config["yTitle"]         = "Y (m)"
    config["cmp_xAutoRange"] = True
    config["cmp_yAutoRange"] = True
    config["cmp_xRange"]     = [-5.0,+5.0]
    config["cmp_yRange"]     = [-5.0,+5.0]

    # ------------------------------------------------- #
    # --- [4] plot Figure                           --- #
    # ------------------------------------------------- #
    cmt.cMapTri( xAxis=xAxis1, yAxis=yAxis1, cMap=zAxis1, pngFile=pngFile1, config=config )
    cmt.cMapTri( xAxis=xAxis2, yAxis=yAxis2, cMap=zAxis2, pngFile=pngFile2, config=config )
예제 #7
0
def display():
    # ------------------------------------------------- #
    # --- [1] Arguments                             --- #
    # ------------------------------------------------- #
    config = lcf.load__config()
    datFile = "dat/bfield_biot.dat"
    pngFile = datFile.replace("dat", "png")

    # ------------------------------------------------- #
    # --- [2] Fetch Data                            --- #
    # ------------------------------------------------- #
    import nkUtilities.load__pointFile as lpf
    Data = lpf.load__pointFile(inpFile=datFile, returnType="point")
    xAxis = Data[:, 0]
    yAxis = Data[:, 1]
    zAxis = Data[:, 5]

    # ------------------------------------------------- #
    # --- [3] config Settings                       --- #
    # ------------------------------------------------- #
    cfs.configSettings(configType="cMap_def", config=config)
    config["FigSize"] = (5, 5)
    config["cmp_position"] = [0.16, 0.12, 0.97, 0.88]
    config["xTitle"] = "X (m)"
    config["yTitle"] = "Y (m)"
    config["cmp_xAutoRange"] = True
    config["cmp_yAutoRange"] = True
    config["cmp_xRange"] = [-5.0, +5.0]
    config["cmp_yRange"] = [-5.0, +5.0]

    # ------------------------------------------------- #
    # --- [4] plot Figure                           --- #
    # ------------------------------------------------- #
    cmt.cMapTri(xAxis=xAxis,
                yAxis=yAxis,
                cMap=zAxis,
                pngFile=pngFile,
                config=config)
예제 #8
0
def time_vs_probeData(nums=None, axis=None):

    t_ = 0
    x_, y_, z_ = 1, 2, 3
    vx_, vy_, vz_ = 4, 5, 6
    ex_, ey_, ez_ = 7, 8, 9
    bx_, by_, bz_ = 10, 11, 12

    cnsFile = "dat/particle.conf"
    import nkUtilities.load__constants as lcn
    pconst = lcn.load__constants(inpFile=cnsFile)

    # ------------------------------------------------- #
    # --- [1] Arguments                             --- #
    # ------------------------------------------------- #
    if (nums is None):
        print(
            "[trajectory__tx] please input particle number : ( e.g. :: 1 2 3, 1-4, [empty::all] ) >>> ",
            end="")
        nums = input()
        if (len(nums) == 0):
            nums = list(range(1, pconst["npt"] + 1))
        elif (len(nums.split("-")) == 2):
            imin = int((nums.split("-")[0]).strip())
            imax = int((nums.split("-")[0]).strip())
            nums = list(range(imin, imax + 1))
        else:
            nums = [int(num) for num in nums.split()]

    if (axis is None):
        print(
            "[trajectory__tx] please input axis ( x/y/z )  : ( e.g. :: x     ) >>> ",
            end="")
        axis = input()

    if ( not( axis.lower() in ["x" ,"y" ,"z" ,"vx","vy","vz",\
                               "ex","ey","ez","bx","by","bz"] ) ):
        print("[trajectory__tx] axis != x/y/z   [ERROR] ")
        sys.exit()

    pngFile = "png/time_vs_{0}.png".format(axis)
    config = lcf.load__config()

    # ------------------------------------------------- #
    # --- [2] config Settings                       --- #
    # ------------------------------------------------- #
    cfs.configSettings(configType="plot1D_def", config=config)
    config["xTitle"] = "Time (s)"
    config["yTitle"] = yTitle
    config["plt_xAutoRange"] = True
    config["plt_yAutoRange"] = True
    config["plt_xRange"] = [-5.0, +5.0]
    config["plt_yRange"] = [-5.0, +5.0]
    config["plt_linewidth"] = 1.0
    config["xMajor_Nticks"] = 5
    config["yMajor_Nticks"] = 5
    config["plt_marker"] = None

    import nkUtilities.generate__colors as col
    colors = col.generate__colors(nColors=len(nums))

    # ------------------------------------------------- #
    # --- [3] axis settings                         --- #
    # ------------------------------------------------- #
    if (axis.lower() == "x"):
        p_ = x_
        yTitle = "x (m)"
        config["plt_xAutoRange"] = False
        config["plt_xRange"] = [0.0, 0.020]
    elif (axis.lower() == "y"):
        p_ = y_
        yTitle = "y (m)"
    elif (axis.lower() == "z"):
        p_ = z_
        yTitle = "z (m)"
    elif (axis.lower() == "vx"):
        p_ = vx_
        yTitle = "vx (m/s)"
    elif (axis.lower() == "vy"):
        p_ = vy_
        yTitle = "vy (m/s)"
    elif (axis.lower() == "vz"):
        p_ = vz_
        yTitle = "vz (m/s)"
    elif (axis.lower() == "ex"):
        p_ = ex_
        yTitle = "ex (V/m)"
    elif (axis.lower() == "ey"):
        p_ = ey_
        yTitle = "ey (V/m)"
    elif (axis.lower() == "ez"):
        p_ = ez_
        yTitle = "ez (V/m)"
    elif (axis.lower() == "bx"):
        p_ = bx_
        yTitle = "bx (T)"
    elif (axis.lower() == "by"):
        p_ = by_
        yTitle = "by (T)"
    elif (axis.lower() == "bz"):
        p_ = bz_
        yTitle = "bz (T)"

    # ------------------------------------------------- #
    # --- [4] plot Figure                           --- #
    # ------------------------------------------------- #
    fig = pl1.plot1D(config=config, pngFile=pngFile)
    for ik, num in enumerate(nums):
        inpFile = "prb/probe{0:06}.dat".format(num)
        Data = lpf.load__pointFile(inpFile=inpFile, returnType="point")
        xAxis = Data[:, t_]
        yAxis = Data[:, p_]
        fig.add__plot(xAxis=xAxis, yAxis=yAxis, color=colors[ik])
    fig.set__axis()
    fig.save__figure()
예제 #9
0
def check__carbonIdeal(datFile=None, pngFile=None, config=None):
    # ------------------------------------------------- #
    # --- [1] Arguments                             --- #
    # ------------------------------------------------- #
    if (config is None): config = lcf.LoadConfig()
    if (datFile1 is None): datFile1 = "dat/bfield_from_aoki.dat"
    if (pngFile1 is None): pngFile1 = "png/bfield_from_aoki.png"
    if (datFile2 is None): datFile2 = "dat/bfield_ideal_acoord.dat"
    if (pngFile2 is None): pngFile2 = "png/bfield_ideal_acoord.png"

    # ------------------------------------------------- #
    # --- [2] Fetch Data                            --- #
    # ------------------------------------------------- #
    with open(datFile1, "r") as f:
        Data1 = np.loadtxt(f)
    xAxis1 = Data1[:, 0]
    yAxis1 = Data1[:, 1]
    zAxis1 = Data1[:, 2]

    with open(datFile2, "r") as f:
        Data2 = np.loadtxt(f)
    xAxis2 = Data2[:, 0]
    yAxis2 = Data2[:, 1]
    zAxis2 = Data2[:, 2]

    pngFile3 = "png/bfield_error.png"
    xAxis3 = np.copy(xAxis2)
    yAxis3 = np.copy(yAxis2)
    zAxis3 = np.copy(zAxis2) - np.copy(zAxis1)

    # ------------------------------------------------- #
    # --- [3] config Settings                       --- #
    # ------------------------------------------------- #
    cfs.configSettings(configType="cMap_def", config=config)
    config["FigSize"] = (5, 5)
    config["cmp_position"] = [0.16, 0.12, 0.97, 0.88]
    config["xTitle"] = "X"
    config["yTitle"] = "Y"
    config["cmp_xAutoRange"] = True
    config["cmp_yAutoRange"] = True
    config["cmp_xRange"] = [-5.0, +5.0]
    config["cmp_yRange"] = [-5.0, +5.0]

    # ------------------------------------------------- #
    # --- [4] plot Figure                           --- #
    # ------------------------------------------------- #
    cmt.cMapTri(xAxis=xAxis1,
                yAxis=yAxis1,
                cMap=zAxis1,
                pngFile=pngFile1,
                config=config)
    cmt.cMapTri(xAxis=xAxis2,
                yAxis=yAxis2,
                cMap=zAxis2,
                pngFile=pngFile2,
                config=config)
    cmt.cMapTri(xAxis=xAxis3,
                yAxis=yAxis3,
                cMap=zAxis3,
                pngFile=pngFile3,
                config=config)
예제 #10
0
def display__axisymmField(inpFile=None):

    x_, y_, z_ = 0, 1, 2
    vx_, vy_, vz_ = 3, 4, 5

    # ------------------------------------------------- #
    # --- [1] Load Config & Eigenmode               --- #
    # ------------------------------------------------- #

    import nkUtilities.load__constants as lcn
    cnsFile = "dat/parameter.conf"
    pngFile = "png/{0}field_{1}_{2}.png"
    config = lcf.load__config()
    const = lcn.load__constants(inpFile=cnsFile)

    eflist = const["EFieldListFile"]
    bflist = const["BFieldListFile"]

    with open(eflist, "r") as f:
        efiles = f.readlines()
    with open(bflist, "r") as f:
        bfiles = f.readlines()

    # ------------------------------------------------- #
    # --- [2] config Settings                       --- #
    # ------------------------------------------------- #
    cfs.configSettings(configType="cMap_def", config=config)
    config["FigSize"] = (8, 4)
    config["cmp_position"] = [0.16, 0.12, 0.97, 0.88]
    config["xTitle"] = "Z (m)"
    config["yTitle"] = "R (m)"
    config["cmp_xAutoRange"] = True
    config["cmp_yAutoRange"] = True
    config["cmp_xRange"] = [-5.0, +5.0]
    config["cmp_yRange"] = [-5.0, +5.0]

    config["vec_AutoScale"] = True
    config["vec_AutoRange"] = True
    config["vec_AutoScaleRef"] = 200.0
    config["vec_nvec_x"] = 24
    config["vec_nvec_y"] = 6
    config["vec_interpolation"] = "nearest"

    # ------------------------------------------------- #
    # --- [4] plot Figure ( efield )                --- #
    # ------------------------------------------------- #

    for ik, efile in enumerate(efiles):

        import nkUtilities.load__pointFile as lpf
        efield = lpf.load__pointFile(inpFile=efile.strip(), returnType="point")

        xAxis = np.copy(efield[:, z_])
        yAxis = np.copy(efield[:, x_])
        absE = np.sqrt(efield[:, vx_]**2 + efield[:, vz_]**2)

        cmt.cMapTri( xAxis=xAxis, yAxis=yAxis, cMap=efield[:,vz_], \
                     pngFile=pngFile.format( "e", ik, "Ez" ), config=config )
        cmt.cMapTri( xAxis=xAxis, yAxis=yAxis, cMap=efield[:,vx_], \
                     pngFile=pngFile.format( "e", ik, "Er" ), config=config )

        fig = cmt.cMapTri(pngFile=pngFile.format(
            "e",
            ik,
            "Ev",
        ),
                          config=config)
        fig.add__cMap(xAxis=xAxis, yAxis=yAxis, cMap=absE)
        fig.add__vector ( xAxis=xAxis, yAxis=yAxis, uvec=efield[:,vz_], vvec=efield[:,vx_], \
                          color="blue" )
        fig.save__figure()

    # ------------------------------------------------- #
    # --- [5] plot Figure ( bfield )                --- #
    # ------------------------------------------------- #

    for ik, bfile in enumerate(bfiles):

        import nkUtilities.load__pointFile as lpf
        bfield = lpf.load__pointFile(inpFile=bfile.strip(), returnType="point")

        xAxis = np.copy(bfield[:, z_])
        yAxis = np.copy(bfield[:, x_])

        cmt.cMapTri( xAxis=xAxis, yAxis=yAxis, cMap=bfield[:,vy_], \
                     pngFile=pngFile.format( "b", ik, "Hp" ), config=config )
예제 #11
0
# ======================================== #
# ===  実行部                          === #
# ======================================== #

if ( __name__=="__main__" ):
    
    xAxis  = np.linspace( 0.0, 2.0*2.0*np.pi, 101 )
    yAxis  = 1.0 * np.sin(xAxis) + np.random.random( xAxis.shape ) * 0.05

    import nkUtilities.plot1D         as pl1
    import nkUtilities.configSettings as cfs
    x_,y_                    = 0, 1
    pngFile                  = "test/filter.png"
    config                   = lcf.load__config()
    config                   = cfs.configSettings( configType="plot.def", config=config )
    # config["filter.linear"]  = 0.5
    # config["filter.median"]  = 3
    config["filter.fourier"] = 0.5

    print( yAxis )
    xAxis_, yAxis_ = generalFilter( xAxis=xAxis, yAxis=yAxis, config=config )
    print( yAxis_ )
    
    fig     = pl1.plot1D( config=config, pngFile=pngFile )
    fig.add__plot( xAxis=xAxis_, yAxis=yAxis_, label="w/" , linestyle="-"  )
    fig.add__plot( xAxis=xAxis , yAxis=yAxis , label="w/o", linestyle="--" )
    fig.add__legend()
    fig.set__axis()
    fig.save__figure()
예제 #12
0
def display__initialAxisymmField():

    x_, y_, z_ = 0, 1, 2
    vx_, vy_, vz_ = 3, 4, 5

    # ------------------------------------------------- #
    # --- [1] Load Config & Eigenmode               --- #
    # ------------------------------------------------- #

    import nkUtilities.load__constants as lcn
    cnsFile = "dat/parameter.conf"
    const = lcn.load__constants(inpFile=cnsFile)

    import nkUtilities.load__pointFile as lpf
    efield = lpf.load__pointFile(inpFile=const["EFieldFile"],
                                 returnType="point")
    bfield = lpf.load__pointFile(inpFile=const["BFieldFile"],
                                 returnType="point")

    config = lcf.load__config()
    pngFile = "png/field_init_{0}.png"

    # ------------------------------------------------- #
    # --- [2] config Settings                       --- #
    # ------------------------------------------------- #
    cfs.configSettings(configType="cMap_def", config=config)
    config["FigSize"] = (8, 4)
    config["cmp_position"] = [0.16, 0.12, 0.97, 0.88]
    config["xTitle"] = "Z (m)"
    config["yTitle"] = "R (m)"
    config["cmp_xAutoRange"] = True
    config["cmp_yAutoRange"] = True
    config["cmp_xRange"] = [-5.0, +5.0]
    config["cmp_yRange"] = [-5.0, +5.0]

    config["vec_AutoScale"] = True
    config["vec_AutoRange"] = True
    config["vec_AutoScaleRef"] = 200.0
    config["vec_nvec_x"] = 24
    config["vec_nvec_y"] = 6
    config["vec_interpolation"] = "nearest"

    # ------------------------------------------------- #
    # --- [4] plot Figure                           --- #
    # ------------------------------------------------- #

    xAxis = np.copy(efield[:, z_])
    yAxis = np.copy(efield[:, x_])

    cmt.cMapTri( xAxis=xAxis, yAxis=yAxis, cMap=efield[:,vz_], \
                 pngFile=pngFile.format( "Ez" ), config=config )
    cmt.cMapTri( xAxis=xAxis, yAxis=yAxis, cMap=efield[:,vx_], \
                 pngFile=pngFile.format( "Er" ), config=config )
    cmt.cMapTri( xAxis=xAxis, yAxis=yAxis, cMap=bfield[:,vy_], \
                 pngFile=pngFile.format( "Hp" ), config=config )

    fig = cmt.cMapTri(pngFile=pngFile.format("Ev"), config=config)
    fig.add__contour(xAxis=xAxis, yAxis=yAxis, Cntr=bfield[:, vy_])
    fig.add__cMap(xAxis=xAxis, yAxis=yAxis, cMap=bfield[:, vy_])
    fig.add__vector ( xAxis=xAxis, yAxis=yAxis, uvec=efield[:,vz_], vvec=efield[:,vx_], \
                      color="blue" )
    fig.save__figure()

    # ------------------------------------------------- #
    # --- [5] 1D plot                               --- #
    # ------------------------------------------------- #

    config["xTitle"] = "Z (m)"
    config["yTitle"] = "E (V/m)"

    val = 0.005
    eps = 1.e-10
    index = np.where((efield[:, x_] >= val - eps)
                     & (efield[:, x_] <= val + eps))
    xAxis = np.copy(efield[index][:, z_])
    ez = np.copy(efield[index][:, vz_])
    ex = np.copy(efield[index][:, vx_])

    import nkUtilities.plot1D as pl1

    fig = pl1.plot1D(config=config, pngFile=pngFile.format("1D"))
    fig.add__plot(xAxis=xAxis, yAxis=ez, color="royalblue", label="Ez")
    fig.add__plot(xAxis=xAxis, yAxis=ex, color="magenta", label="Ex")
    fig.add__legend()
    fig.set__axis()
    fig.save__figure()
예제 #13
0
def time_vs_energy(nums=None):

    t_ = 0
    x_, y_, z_ = 1, 2, 3
    vx_, vy_, vz_ = 4, 5, 6
    ex_, ey_, ez_ = 7, 8, 9
    bx_, by_, bz_ = 10, 11, 12

    cnsFile = "dat/particle.conf"
    import nkUtilities.load__constants as lcn
    pconst = lcn.load__constants(inpFile=cnsFile)

    # ------------------------------------------------- #
    # --- [1] Arguments                             --- #
    # ------------------------------------------------- #
    if (nums is None):
        print(
            "[time_vs_energy] please input particle number : ( def. :: all ) >>> ",
            end="")
        nums = input()
        if (len(nums) == 0):
            nums = list(range(1, pconst["npt"] + 1))
            # import glob
            # files = glob.glob( "prb/probe*.dat" )
            # nums  = [ int(num+1) for num in range( len(files) ) ]
        else:
            nums = [int(num) for num in nums.split()]

    pngFile = "png/time_vs_energy.png"
    config = lcf.load__config()
    cnsFile = "dat/parameter.conf"
    const = lcn.load__constants(inpFile=cnsFile)

    # ------------------------------------------------- #
    # --- [2] config Settings                       --- #
    # ------------------------------------------------- #
    cfs.configSettings(configType="plot1D_def", config=config)
    config["xTitle"] = "Time (s)"
    config["yTitle"] = "Energy (MeV)"
    config["plt_xAutoRange"] = True
    config["plt_yAutoRange"] = True
    config["plt_xRange"] = [-5.0, +5.0]
    config["plt_yRange"] = [-5.0, +5.0]
    config["plt_linewidth"] = 1.0
    config["xMajor_Nticks"] = 5
    config["yMajor_Nticks"] = 5
    config["plt_marker"] = None

    import nkUtilities.generate__colors as col
    colors = col.generate__colors(nColors=len(nums))

    # ------------------------------------------------- #
    # --- [4] plot Figure                           --- #
    # ------------------------------------------------- #
    fig = pl1.plot1D(config=config, pngFile=pngFile)
    for ik, num in enumerate(nums):
        inpFile = "prb/probe{0:06}.dat".format(num)
        Data = lpf.load__pointFile(inpFile=inpFile, returnType="point")
        xAxis = Data[:, t_]
        beta = np.sqrt(Data[:, vx_]**2 + Data[:, vy_]**2 +
                       Data[:, vz_]**2) / const["cv"]
        gamma = 1.0 / (np.sqrt(1.0 - beta**2))
        yAxis = (gamma -
                 1.0) * const["mp"] * const["cv"]**2 / const["qe"] / 1.e6

        fig.add__plot(xAxis=xAxis, yAxis=yAxis, color=colors[ik])

    fig.set__axis()
    fig.save__figure()
예제 #14
0
def display__particles():

    # ------------------------------------------------- #
    # --- [1] Arguments                             --- #
    # ------------------------------------------------- #
    config = lcf.load__config()
    datFile = "dat/particles.dat"
    vtkFile = "png/particles.vtu"
    pngFile = (datFile.replace("dat", "png")).replace(".png", "_{0}.png")

    # ------------------------------------------------- #
    # --- [2] Fetch Data                            --- #
    # ------------------------------------------------- #
    import nkUtilities.load__pointFile as lpf
    Data = lpf.load__pointFile(inpFile=datFile, returnType="point")
    xAxis = Data[:, 0]
    yAxis = Data[:, 1]
    zAxis = Data[:, 2]

    # ------------------------------------------------- #
    # --- [3] config Settings                       --- #
    # ------------------------------------------------- #
    cfs.configSettings(configType="plot1D_def", config=config)
    cfs.configSettings(configType="plot1D_mark", config=config)
    config["xTitle"] = "X (m)"
    config["yTitle"] = "Y (m)"
    config["plt_xAutoRange"] = True
    config["plt_yAutoRange"] = True
    config["plt_xRange"] = [-5.0, +5.0]
    config["plt_yRange"] = [-5.0, +5.0]
    config["plt_linewidth"] = 1.0
    config["xMajor_Nticks"] = 5
    config["yMajor_Nticks"] = 5
    config["plt_linewidth"] = 0.0

    # ------------------------------------------------- #
    # --- [4] x-y plot Figure                       --- #
    # ------------------------------------------------- #
    config["xTitle"] = "X (m)"
    config["yTitle"] = "Y (m)"
    fig = pl1.plot1D(config=config, pngFile=pngFile.format("xy"))
    fig.add__plot(xAxis=xAxis, yAxis=yAxis)
    fig.add__legend()
    fig.set__axis()
    fig.save__figure()

    # ------------------------------------------------- #
    # --- [5] y-z plot Figure                       --- #
    # ------------------------------------------------- #
    config["xTitle"] = "Y (m)"
    config["yTitle"] = "Z (m)"
    fig = pl1.plot1D(config=config, pngFile=pngFile.format("yz"))
    fig.add__plot(xAxis=yAxis, yAxis=zAxis)
    fig.add__legend()
    fig.set__axis()
    fig.save__figure()

    # ------------------------------------------------- #
    # --- [6] z-x plot Figure                       --- #
    # ------------------------------------------------- #
    config["xTitle"] = "X (m)"
    config["yTitle"] = "Z (m)"
    fig = pl1.plot1D(config=config, pngFile=pngFile.format("xz"))
    fig.add__plot(xAxis=xAxis, yAxis=zAxis)
    fig.add__legend()
    fig.set__axis()
    fig.save__figure()

    # ------------------------------------------------- #
    # --- [7] convert particles plot into vtk       --- #
    # ------------------------------------------------- #
    import nkVTKRoutines.scatter__vtkPoint as sct
    sct.scatter__vtkPoint(Data=Data, vtkFile=vtkFile)
예제 #15
0
def trajectory__xy(nums=None, plain=None):

    x_, y_, z_ = 1, 2, 3

    # ------------------------------------------------- #
    # --- [1] Arguments                             --- #
    # ------------------------------------------------- #
    if (nums is None):
        print(
            "[trajectory__tx] please input particle number            >> ( e.g. :: 1 2 3 )"
        )
        nums = input()
        nums = [int(num) for num in nums.split()]

    if (plain is None):
        print(
            "[trajectory__tx] please input plain (xy/yx/yz/zy/zx/xz/) >> ( e.g. :: xy    )"
        )
        plain = input()

    if (not (plain.lower() in ["xy", "yz", "zx", "yx", "zy", "xz"])):
        print("[trajectory__tx] plain != (xy/yx/yz/zy/zx/xz/)  [ERROR] ")
        sys.exit()

    pngFile = "png/trajectory__{0}.png".format(plain)
    config = lcf.load__config()

    # ------------------------------------------------- #
    # --- [2] axis settings                         --- #
    # ------------------------------------------------- #

    if (plain.lower() == "xy"):
        a1_, a2_ = x_, y_
        xTitle, yTitle = "X (m)", "Y (m)"
    elif (plain.lower() == "yx"):
        a1_, a2_ = y_, x_
        xTitle, yTitle = "Y (m)", "X (m)"
    elif (plain.lower() == "yz"):
        a1_, a2_ = y_, z_
        xTitle, yTitle = "Y (m)", "Z (m)"
    elif (plain.lower() == "zy"):
        a1_, a2_ = z_, y_
        xTitle, yTitle = "Z (m)", "Y (m)"
    elif (plain.lower() == "zx"):
        a1_, a2_ = z_, x_
        xTitle, yTitle = "Z (m)", "X (m)"
    elif (plain.lower() == "xz"):
        a1_, a2_ = x_, z_
        xTitle, yTitle = "X (m)", "Z (m)"

    # ------------------------------------------------- #
    # --- [3] config Settings                       --- #
    # ------------------------------------------------- #
    cfs.configSettings(configType="plot1D_def", config=config)
    config["xTitle"] = xTitle
    config["yTitle"] = yTitle
    config["plt_xAutoRange"] = True
    config["plt_yAutoRange"] = True
    config["plt_xRange"] = [-5.0, +5.0]
    config["plt_yRange"] = [-5.0, +5.0]
    config["plt_linewidth"] = 1.0
    config["xMajor_Nticks"] = 5
    config["yMajor_Nticks"] = 5

    import nkUtilities.generate__colors as col
    colors = col.generate__colors(nColors=len(nums))

    # ------------------------------------------------- #
    # --- [4] plot Figure                           --- #
    # ------------------------------------------------- #
    fig = pl1.plot1D(config=config, pngFile=pngFile)
    for ik, num in enumerate(nums):
        # inpFile = "trk/track{0:06}.dat".format( num )
        inpFile = "prb/probe{0:06}.dat".format(num)
        Data = lpf.load__pointFile(inpFile=inpFile, returnType="point")
        xAxis = Data[:, a1_]
        yAxis = Data[:, a2_]
        fig.add__plot(xAxis=xAxis, yAxis=yAxis, color=colors[ik])
    fig.set__axis()
    fig.save__figure()
예제 #16
0
def display__sf7():

    # ------------------------------------------------- #
    # --- [1] Arguments                             --- #
    # ------------------------------------------------- #
    import nkUtilities.load__constants as lcn
    cnfFile = "dat/parameter.conf"
    const = lcn.load__constants(inpFile=cnfFile)

    config = lcf.load__config()
    datFile = const["spfFile"]
    pngFile = (const["spfFile"].replace("dat",
                                        "png")).replace(".png", "_{0}.png")

    # ------------------------------------------------- #
    # --- [2] Fetch Data                            --- #
    # ------------------------------------------------- #
    import nkUtilities.load__pointFile as lpf
    Data = lpf.load__pointFile(inpFile=datFile, returnType="point")
    xAxis = Data[:, 0]
    yAxis = Data[:, 1]
    zAxis = Data[:, 2]
    Ez = Data[:, 3]
    Er = Data[:, 4]
    Ea = Data[:, 5]
    Hp = Data[:, 6]

    # ------------------------------------------------- #
    # --- [3] config Settings                       --- #
    # ------------------------------------------------- #
    cfs.configSettings(configType="cMap_def", config=config)
    config["FigSize"] = (8, 3)
    config["cmp_position"] = [0.16, 0.12, 0.97, 0.88]
    config["xTitle"] = "Z (m)"
    config["yTitle"] = "R (m)"
    config["xMajor_Nticks"] = 8
    config["yMajor_Nticks"] = 3
    config["cmp_xAutoRange"] = True
    config["cmp_yAutoRange"] = True
    config["cmp_xRange"] = [-5.0, +5.0]
    config["cmp_yRange"] = [-5.0, +5.0]
    config["vec_AutoScale"] = True
    config["vec_AutoRange"] = True
    config["vec_AutoScaleRef"] = 200.0
    config["vec_nvec_x"] = 24
    config["vec_nvec_y"] = 6
    config["vec_interpolation"] = "nearest"

    # ------------------------------------------------- #
    # --- [4] plot Figure                           --- #
    # ------------------------------------------------- #
    cmt.cMapTri(xAxis=xAxis,
                yAxis=yAxis,
                cMap=Ez,
                pngFile=pngFile.format("Ez"),
                config=config)
    cmt.cMapTri(xAxis=xAxis,
                yAxis=yAxis,
                cMap=Er,
                pngFile=pngFile.format("Er"),
                config=config)
    cmt.cMapTri(xAxis=xAxis,
                yAxis=yAxis,
                cMap=Ea,
                pngFile=pngFile.format("Ea"),
                config=config)
    cmt.cMapTri(xAxis=xAxis,
                yAxis=yAxis,
                cMap=Hp,
                pngFile=pngFile.format("Hp"),
                config=config)

    fig = cmt.cMapTri(pngFile=pngFile.format("Ev"), config=config)
    fig.add__contour(xAxis=xAxis, yAxis=yAxis, Cntr=Hp)
    fig.add__cMap(xAxis=xAxis, yAxis=yAxis, cMap=Hp)
    fig.add__vector(xAxis=xAxis, yAxis=yAxis, uvec=Ez, vvec=Er, color="blue")
    fig.save__figure()
예제 #17
0
# ======================================== #
# ===  実行部                          === #
# ======================================== #
if (__name__ == "__main__"):

    import numpy as np
    xAxis = np.linspace(0.0, 2.0 * np.pi, 101)
    yAxis1 = np.sin(xAxis)
    yAxis2 = np.cos(xAxis) * 100.0

    import nkUtilities.load__config as lcf
    import nkUtilities.configSettings as cfs

    pngFile = "test/plot_sample.png"
    config = lcf.load__config()
    config = cfs.configSettings(configType="plot.def", config=config)
    config = cfs.configSettings(configType="plot.marker", config=config)
    config = cfs.configSettings(configType="plot.ax2", config=config)
    config["plt_xAutoRange"] = False
    config["plt_xRange"] = [0.0, 6.0]
    config["ax2.yMajor.nticks"] = 7
    config["ax2.yAutoRange"] = False
    config["ax2.yRange"] = [-120.0, +120.0]
    fig = plot1D(config=config, pngFile=pngFile)
    fig.add__plot(xAxis=xAxis, yAxis=yAxis1, label="sin(x)", color="Orange")
    fig.add__plot2(xAxis=xAxis,
                   yAxis=yAxis2,
                   label="cos(x)",
                   color="RoyalBlue")
    fig.add__legend()
    fig.set__axis()