Пример #1
0
"""
import argparse as argp
from data_io_util import DataIOUtil
from matplotlib.pyplot import *

parser = argp.ArgumentParser()
parser.add_argument("data_file_name", help="The path and file name of simulated data file.", type = str)
parser.add_argument("--data_dir", default = "c:/temp/data/", help="The directory of the results", type=str)
parser.add_argument("--suffix", default = "", help="The suffix of sample-related output files", type=str)
parser.add_argument("--space_dim", default = 2, help="The space dimension", type=int)
parser.add_argument("--alpha", default = 0.333, help="The alpha value for plot", type=float)
parser.add_argument("--pdf_format", default = 'True', help="Would you like pdf format and high resolution for the figure output(s)?", type=str)

args = parser.parse_args()

data_io = DataIOUtil(args.data_dir)

rc('font', size=24)  # default for labels (not axis labels)
rc('font', family='serif')  # default for labels (not axis labels)
rc('figure.subplot', bottom=.125, top=.875, right=.885, left=0.175)
# Use square shape
rc('figure', figsize=(10, 10))
rc('savefig', dpi=150)

def plot_two_dimensional_data(coords):
    x_coord,y_coord = coords.T
    fig, ax = subplots()
    if(args.pdf_format == 'True'):
      ax.scatter(x_coord,y_coord, c=(0.4, 0.0, 0.4), marker = ".", linewidth=0, alpha=args.alpha)
    else:
      ax.scatter(x_coord,y_coord, c=(0.4, 0.0, 0.4), marker = ".", alpha=args.alpha)
Пример #2
0
import argparse as argp
from data_io_util import DataIOUtil
from data_gen_util import DataGenUtil
from hstgram_creator import HistogramCreator

parser = argp.ArgumentParser()
parser.add_argument("--data_dir", default = "c:/temp/data/", help="The directory of the results", type=str)
parser.add_argument("--suffix", default = "", help="The suffix of sample-related output files", type=str)
parser.add_argument("--ndata", default = 3000, help="The number of samples", type=int)
parser.add_argument("--nserver", default = 10, help="The server number", type=int)
parser.add_argument("--nhst_resolution", default = 0, help="The histogram resolution", type=int)
parser.add_argument("--pdf_format", default = 'True', help="Would you like pdf format and high resolution for the figure output(s)?", type=str)

args = parser.parse_args()

data_io = DataIOUtil(args.data_dir)
utl = DataGenUtil(args)
hstgram_cr = HistogramCreator()

#coords = utl.multivariate_normal_data_coords([0,0], [[1,0],[0,1]]) # diagonal covariance, points lie on x or y-axis
#coords = utl.multivariate_exponential_scale_0_5_data_coords(2)
#coords = utl.multivariate_chisquare_df_3_data_coords(2)
#coords = utl.multivariate_uniform_data_coords(2,-3,3)
#coords = utl.multivariate_normal_mixture_K_data_coords(2,9,[[-4,-4],[-4,0],[0,-4],[-4,4],[0,0],[4,-4],[0,4],[4,0],[4,4]],[[[0.25,0],[0,0.25]],[[0.25,0],[0,0.25]],[[0.25,0],[0,0.25]],[[0.25,0],[0,0.25]],[[0.5,0],[0,0.5]],[[0.25,0],[0,0.25]],[[0.25,0],[0,0.25]],[[0.25,0],[0,0.25]],[[0.25,0],[0,0.25]]],[0.0625,0.0625,0.0625,0.0625,0.5,0.0625,0.0625,0.0625,0.0625])
#coords = utl.multivariate_normal_mixture_K_data_coords(2,9,[[-6,-6],[-6,0],[0,-6],[-6,6],[0,0],[6,-6],[0,6],[6,0],[6,6]],[[[0.1,0],[0,0.1]] for x in range(9)],[1.0/9.0 for x in range(9)])
#K=20
#coords = utl.multivariate_normal_mixture_K_data_coords(2,K,[[-4,-4],[-6,-2],[-2,-6],[-2.5,-2.5],[-0.75,-6],[0.75,-2],[4,-4],[6,-2],[2,-6],[2.5,-2.5],[-4,4],[-6,2],[-2,6],[-2.5,2.5],[-0.75,2],[0.75,6],[4,4],[6,2],[2,6],[2.5,2.5]],[[[0.15,0],[0,0.15]] for x in range(K)],[1.0/float(K) for x in range(K)])
K=16
coords = utl.multivariate_normal_mixture_K_data_coords(2,K,[[-4,4],[-4,2],[-4,0],[-4,-1],[-2,4],[-2,2],[-3,0],[0,4],[4,-4],[4,-2],[4,0],[4,1],[2,-4],[2,-2],[3,0],[0,-4]],[[[0.25,0],[0,0.25]] for x in range(K)],[1.0/float(K) for x in range(K)])
print coords
data_io.save_data_to_disk(args.suffix, coords)
Пример #3
0
"""
Created 2015-10-03 by Janos Szalai-Gindl;
Executing: e.g. python hstgram.py data.dat 2 10
"""

import argparse as argp
from data_io_util import DataIOUtil
from hstgram_creator import HistogramCreator

parser = argp.ArgumentParser()
parser.add_argument("data_file_name", help="The path and file name of simulated data file.", type=str)
parser.add_argument("space_dim", help="The space dimension", type=int)
parser.add_argument("nhst_resolution", help="The histogram resolution", type=int)
parser.add_argument("--data_dir", default="c:/temp/data/", help="The directory of the results", type=str)
parser.add_argument("--suffix", default="", help="The suffix of sample-related output files", type=str)
parser.add_argument("--ndata", default=3000, help="The number of samples", type=int)

args = parser.parse_args()

data_io = DataIOUtil(args.data_dir)
hstgram_cr = HistogramCreator()

coords = data_io.load_data_from_disk(args.data_file_name, args.space_dim)

hstgram = hstgram_cr.create_histogram(args.nhst_resolution, coords)
data_io.save_histogram_to_disk(args.suffix, args.ndata, hstgram)
Пример #4
0
parser = argp.ArgumentParser()
parser.add_argument("data_file_name", help="The path and file name of simulated data file.", type = str)
parser.add_argument("tiles_file_name", help="The path and file name of the result tiles.", type = str)
parser.add_argument("servers_file_name", help="The path and file name of the result tile-distribution for servers.", type = str)
parser.add_argument("space_dim", help="The space dimension", type = int)
parser.add_argument("nhst_resolution", help="The histogram resolution", type=int)
parser.add_argument("--data_dir", default = "c:/temp/data/", help="The directory of the results", type=str)
parser.add_argument("--suffix", default = "", help="The suffix of sample-related output files", type=str)
parser.add_argument("--pdf_format", default = 'True', help="Would you like pdf format and high resolution for the figure output(s)?", type=str)
parser.add_argument("--data_color", default = "(0.0,0.0,1.0)", help="The data color. The default color is blue.", type=str)
parser.add_argument("--data_alpha", default = 0.0, help="The alpha value for plot", type=float)
parser.add_argument("--rectangle_edges", default = 'False', help="Would you like rectangle edges?", type=str)
parser.add_argument("--legend_on", default = 'False', help="Would you like legend about servers?", type=str)
parser.add_argument("--direct_color", default = 'False', help="Would you like give the server colors?", type=str)
parser.add_argument("--color_tuples", default = "", help="The string of the server color tuples. The delimiter is the space character. So this is a good input: '(0.886,0.29,0.2) (0.46,0.46,0.46)' but this is a bad: '(0.886, 0.29, 0.2) (0.46, 0.46, 0.46)' for two servers", type=str)
parser.add_argument("--direct_server_idx_location", default = 'False', help="Would you like give the server index locations?", type=str)
parser.add_argument("--server_idx_location_tuples", default = "", help="The string of the server index location tuples. Note: the first coord of a tuple is related server. Note2: a server index can be repeated (e.g. because of outlier bins). The delimiter is the space character. So this is a good input: '(0,0.0,1.0) (1,1.0,0.0)' but this is a bad: '(0, 0.0, 1.0) (1, 1.0, 0.0)' for two servers", type=str)
parser.add_argument("--font_size_server_idx", default = "22", help="The font size of the server indices.", type=int)
args = parser.parse_args()

data_io = DataIOUtil(args.data_dir)
utl = PlotResultUtil(args)
coords = data_io.load_data_from_disk(args.data_file_name, args.space_dim)
tilesCoords = data_io.load_tiles_from_disk(args.tiles_file_name, args.space_dim)
tiles_to_servers, nserver, hefts_of_servers = data_io.load_servers_from_disk(args.servers_file_name)

print tilesCoords
print '---------'
print tiles_to_servers

utl.plot_two_dimensional_data(coords, tilesCoords, nserver, tiles_to_servers, hefts_of_servers)