コード例 #1
0
ファイル: genTwoLayerICs.py プロジェクト: jmaack24/VortexSim
# Build each file
print "Generating positions..."
root = args.file + "_%0" + str(len(str(args.nfiles))) + "d"

info = "# npvs: " + str(N) + "\n"
info += "# seed: %d\n"
info += "# dist: "
for item in args.dist:
    info += str(item) + " "
info += "\n"
info += "# def radius: " + str(domain.defrad) + "\n"

for k in range(args.start, args.nfiles):
    # Progress bar
    pvp.reportProgress(k - args.start, args.nfiles - args.start, 80)
    # Set seed
    np.random.seed(seed + k)
    # Generate Positions
    if (distribution == NORM):
        pos = np.random.multivariate_normal(mean, cov, N)
    elif (distribution == TWO_PATCH):
        pos = np.zeros((N, 2))
        indx1 = np.nonzero(layer == -1)
        indx2 = np.nonzero(layer == 1)
        pos[indx1, :] = np.random.multivariate_normal(mean1, cov1, Nlayer)
        pos[indx2, :] = np.random.multivariate_normal(mean2, cov2, Nlayer)

        # pos = np.zeros((N, 2))
        # rad = np.sqrt(np.random.uniform(low=0.0, high=radius, size=N))
        # ang = np.random.uniform(low=-np.pi, high=np.pi, size=N)
コード例 #2
0
    levels = np.arange(0.0, max_vort + dx, dx)
    # File numbering scheme that will be appended to root name
    format_str = "_dist_%0" + str(len(str(args.nentries))) + "d.png"

    # Open position data file
    if not args.no_positions:
        data_file = MOVIE + "/" + args.root + "/" + args.root + "_"
        data_file += "0" * len(str(nfiles)) + ".pos"
        pos = open(data_file, "r")
        fne = pvp.findNumEntries(pos)
        if (fne != nentries):
            print "Number of positions in data file", data_file, "has", fne, "entries. Expected", nentries, "Unable to make movie."
            quit()

    for k in range(time.size):
        pvp.reportProgress(k, time.size, WIDTH)

        # File specific stuff
        fstr = format_str % k
        title = "Simulation Time:%8.3f" % time[k]

        if not args.no_positions:
            # Get position plots of point vortices
            (sts, num, dim, tm, ly, vort,
             position) = pvp.readPositionEntry(pos)
            if (sts != 0):
                print "**ERROR:: readPositionEntry returned", sts
                quit()

        if domain.type == se.Domain.TWO_LAYER:
            fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(8 * 2, 8))
コード例 #3
0
ファイル: computeAPE.py プロジェクト: jmaack24/VortexSim
posfmt = MOVIE + args.root + "/" + args.root + "_%0"
posfmt += str(len(str(nfiles))) + "d.pos"

#grid = ps.Grid(GRID_SIZE)
grid = ps.LegGrid(GRID_SIZE, 4 * rd)
APEavg = np.zeros(nentries)

for l in range(nfiles):
    posfile = posfmt % l
    print "Processing file", posfile
    print "Reading file..."
    sts, ti, layer, vort, pos = pvp.readPositionFile(posfile, npvs, 2, True)
    print "Computing..."
    for i in range(nentries):
        pvp.reportProgress(i, nentries, WIDTH)
        dx = (pos[i, :, 0] - np.tile(grid.xmat,
                                     (npvs, 1, 1)).transpose()).transpose()
        dy = (pos[i, :, 1] - np.tile(grid.ymat,
                                     (npvs, 1, 1)).transpose()).transpose()
        # ri = kd * np.sqrt(dx*dx + dy*dy)
        ri = kd * np.sqrt(dx * dx + dy * dy)
        k0 = scipy.special.k0(ri)
        psic = (-layer * k0.transpose()).transpose()
        # psic = (-layer * k0.transpose()).transpose()
        psic = gamma * 0.25 / np.pi * np.sum(psic, 0)
        ape = kd**2 * np.sum(grid.wmat * psic**2)
        APEavg[i] += 1.0 / (l + 1.) * (ape - APEavg[i])

    pvp.reportProgress(nentries, nentries, WIDTH)
コード例 #4
0
            quit()

    data = open(args.file, mode='r')

    nentries = pvp.findNumEntries(data)
    if (nentries < 1):
        print "Number of entries is non positive -- got", nentries
        quit()
    else:
        pad = len(str(nentries))
        format_str = "_%0" + str(pad) + "d.png"

    processed = 0
    while (processed < nentries):

        pvp.reportProgress(processed, nentries, WIDTH)

        sts, num, dim, time, layer, vort, pos = pvp.readPositionEntry(data)

        if (sts != 0):
            print "**ERROR:: readPositionEntry returned", sts
            quit()

        # Create and save the plot for this entry --
        # this won't work on sphere
        lys = np.unique(layer)
        if lys.size == 1:
            fig = plt.figure(figsize=(8, 8))
            plt.scatter(pos[:, 0], pos[:, 1], c=pargs[0])
            plt.xlim(a, b)
            plt.ylim(c, d)