# load data into file for line in input_data: if delimiter: words = line.split(delimiter) else: words = line.split() if len(words) < column: # skip any lines that don't have enough values continue try: # skip any lines where value is not a float data.append(float(words[column-1])) except ValueError: continue input_data.close() # Set up default ranges if (binrange[0] == 0 and binrange[1] == 0): xmaxminholder = utilities.minmax(data) binrange[0] = math.floor(xmaxminholder[0]) binrange[1] = math.ceil(xmaxminholder[1]) # Set up default number of bins according to "Scott's Choice" if bins == 0: inttmp = 3.5 * utilities.stdev(data,'no') / float(len(data)) ** (1/3.0) bins = int(math.ceil((binrange[1] - binrange[0])/inttmp)) if normalize: pointweight /= float(len(data)) * (binrange[1] - binrange[0])/bins interval = (binrange[1] - binrange[0])/bins # create a large 1-D array with every bin (x1y1 x1y2 ... x1yN x2y1 x2y2 ... ... xNyN) for x in range(bins):
words = line.split(opt.delimiter) if len(words) < maxcol: # skip any lines that don't have enough values continue try: # skip any lines where at least 1 of first 2 columns are not floats data1.append(float(words[col1].strip())) data2.append(float(words[col2].strip())) except ValueError: print words continue input_data.close() # Set up default ranges if (binrange[0] == 0 and binrange[1] == 0) or \ (binrange[2] == 0 and binrange[3] == 0): xmaxminholder = utilities.minmax(data1) ymaxminholder = utilities.minmax(data2) binrange[0] = math.floor(xmaxminholder[0]) binrange[1] = math.ceil(xmaxminholder[1]) binrange[2] = math.floor(ymaxminholder[0]) binrange[3] = math.ceil(ymaxminholder[1]) # Set up default number of bins according to "Scott's Choice" if bins[0] == 0 or bins[1] == 0: xinttmp = 3.5 * utilities.stdev(data1,'no') / float(len(data1)) ** (1/3) yinttmp = 3.5 * utilities.stdev(data2,'no') / float(len(data2)) ** (1/3) bins[0] = int(math.ceil((binrange[1] - binrange[0])/xinttmp)) bins[1] = int(math.ceil((binrange[3] - binrange[2])/yinttmp)) if opt.normalize: pointweight /= float(len(data1)) * ( binrange[1]-binrange[0])*(binrange[3]-binrange[2])/(bins[0]*bins[1])
# load data into file for line in input_data: if delimiter: words = line.split(delimiter) else: words = line.split() if len(words) < column: # skip any lines that don't have enough values continue try: # skip any lines where value is not a float data.append(float(words[column - 1])) except ValueError: continue input_data.close() # Set up default ranges if (binrange[0] == 0 and binrange[1] == 0): xmaxminholder = utilities.minmax(data) binrange[0] = math.floor(xmaxminholder[0]) binrange[1] = math.ceil(xmaxminholder[1]) # Set up default number of bins according to "Scott's Choice" if bins == 0: inttmp = 3.5 * utilities.stdev(data, 'no') / float(len(data))**(1 / 3.0) bins = int(math.ceil((binrange[1] - binrange[0]) / inttmp)) if normalize: pointweight /= float(len(data)) * (binrange[1] - binrange[0]) / bins interval = (binrange[1] - binrange[0]) / bins # create a large 1-D array with every bin (x1y1 x1y2 ... x1yN x2y1 x2y2 ... ... xNyN) for x in range(bins):