def get_response_content(fs): # read the matrix from the form data R = fs.matrix nrows, ncols = R.shape # assert that the number of rows and columns is valid for a codon matrix states = Codon.g_sorted_non_stop_codons if nrows != len(states): msg = 'expected %d rows but got %d' % (len(states), nrows) raise HandlingError(msg) if ncols != len(states): msg = 'expected %d columns but got %d' % (len(states), ncols) raise HandlingError(msg) # define the row and column labels labels = [] for codon in states: label = '%s.%s.' % (Codon.g_codon_to_aa_letter[codon], codon) labels.append(label) row_labels = labels column_labels = labels # initialize the base class with this row major matrix heatmap = HeatMap.LabeledHeatMap(R.tolist(), fs.maxcategories, row_labels, column_labels) renderer = HeatMap.PreHeatMap(heatmap) html_string = renderer.get_example_html() # return the response return html_string + '\n'
def drawMap(self): #onFleetRaw = onFleetRaw[4727:] onFleetRaw = self.readExcel() for i in range(0,len(onFleetRaw)): onFleetRaw[i].append(datetime.datetime.utcfromtimestamp((onFleetRaw[i][10] - 25569) * 86400.0)) myDict = HeatMap.createDictByHour(onFleetRaw,24) key = HeatMap.timeDiff(datetime.datetime.now()) location=[] if (key >= 0) & (key <=17): location = BaseFunction().getColumn(myDict[key],6) lats = [] lngs = [] for i in range(0,len(location)): com = location[i].index(",") temp = float(location[i][(com+1):]) lats.append(float("{0:.6f}".format(temp))) temp = float(location[i][0:com]) lngs.append(float("{0:.6f}".format(temp))) #draw map gmap = gmplot.GoogleMapPlotter(37.778, -122.412, 16) gmap.heatmap(lats, lngs,radius=25,opacity=0.8) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) gmap.draw(os.path.join(BASE_DIR, 'templates/mymap.html'))
def testNoLandFallCols(self): df = hm.loadData() df_no_landfall = hm.hurricaneNoLandFall(df) found = df_no_landfall[df_no_landfall['Event'].str.contains('L', na=False)] land_count = len(found) self.assertEqual(land_count, 0)
def index(): end_date = str(datetime.date.today()) start_date1 = pd.to_datetime(end_date) start_date = start_date1 - datetime.timedelta(days=70) tdate = str(start_date.strftime("%Y-%m-%d")) cursor = db.cursor() all_rows = sqd.getAllDB(cursor) print("All_rows") print(all_rows) row0 = sqd.getRow0DB(cursor) #print(row0) if row0[3] < end_date: all_rows = sqd.getAllDB(cursor) for row in all_rows: score, score1, validTicker, sDates1, sCloses, tCases = latestScores( start_date, end_date, row[0]) sqd.updateDB(db, row[0], score, score1, end_date) query = 'tickersymbol' # Ticker Symbol Entered if query in request.args: inputTS = request.args[query].upper() else: inputTS = defaultTS tickerSymbol = inputTS score, score1, validTicker, sDates1, sCloses, tCases = latestScores( tdate, end_date, tickerSymbol) if validTicker == False: tickerSymbol = defaultTS corrrow = sqd.getMaxDBCorr(cursor) rsirow = sqd.getMaxDBrsi(cursor) print("RSIrow") print(rsirow) sqd.updateDB(db, tickerSymbol, score, score1, end_date) plot_url = Plot.Plot(sDates1, sCloses, tickerSymbol, tCases) cmap2 = matplotlib.cm.spring plot_url1 = HeatMap.HeatMap(score, tickerSymbol, cmap2, corrrow[1], corrrow[0], -100, 100) cmap = matplotlib.cm.GnBu plot_url2 = HeatMap.HeatMap(score1, tickerSymbol, cmap, rsirow[2], rsirow[0], 0, 100) return render_template('index.html', title=('%s vs COVID-19' % tickerSymbol), validTicker=validTicker, plot_url1=plot_url1, plot_url2=plot_url2, plot_url=plot_url, symbol=inputTS)
def testLandFallCols(self): df = hm.loadData() df_landfall = hm.hurricaneLandFall(df) found = df_landfall[df_landfall['Event'].str.contains('L')] land_count = len(found) df_unique_id = hm.unique(df_landfall['ID'].tolist()) id_count = len(df_unique_id) self.assertEqual(land_count, id_count)
def __run_session(self, code_string): res = self.Response(code_string) if res.get('vis_type') == str(0) : # FilterVis core = FilterVis(model_n = res.get('model_name'), layer_n = res.get('layer_name'), act_index = res.get('act_index'), test_im = res.get('test_image')) core.run() print('FilterVis executed successufely') if res.get('vis_type') == str(1) : # FilterMax core = FilterMax(plot_all = res.get('plot_all'), plot_firstn = res.get('plot_firstn'), n = res.get('n'), plot_list = res.get('plot_list'), plotting_list = res.get('plotting_list'), model_n = res.get('model_name')) core.run() print('FilterMax executed successufely') print('res.get = {}'.format(res.get('vis_type'))) c = res.get('vis_type') if res.get('vis_type') == str(2) : print('executing Heatmap on the model' + res.get('model_name') + '/' + res.get('layer_name') + 'with the test image : ' + res.get('test_image')) core = HeatMap(res.get('model_name'), res.get('test_image'), res.get('layer_name')) core.run() print('HeatMap executed successufely') if res.get('vis_type') == str(3) : # Archi print('executing Archi on the model' + res.get('model_name') + '/' + res.get('layer_name') + 'with the test image : ' + res.get('test_image')) core = Archi(res.get('model_name')) core.run()
def _stacked_ground_truth_heatmaps(self, X, y): ground_truth_heatmaps = [] for i in range(NUM_COCO_KEYPOINTS): heatmap = y[:, :, i] hm = HeatMap.HeatMap(X, heatmap) heatmap_array = hm.get_heatmap_array(transparency=0.5) ground_truth_heatmaps.append(heatmap_array) for i, heatmap in enumerate(ground_truth_heatmaps): if (i == 0): stacked_ground_truth_heatmaps = ground_truth_heatmaps[0] else: stacked_ground_truth_heatmaps = np.hstack( (stacked_ground_truth_heatmaps, heatmap)) return stacked_ground_truth_heatmaps
def pluginEXE(Rec, geoMat, numToGen): #Assume that record is loaded, but not tested #Apply ttest and heat map bit to record #look up platform from sqliteDB and translate to 570Plus # #Display binary as 1,0s and colors #button to compare to other binaries (may take time :-( #List ~20 most similar? geoMat = Ttest.pluginEXE(Rec,geoMat,0.05) PSids = geoMat[-1] colMat = HeatMap.pluginEXE(Rec,geoMat,'bit') #print "a ok" con = sqlite3.connect(r"C:\Users\francis\Documents\platforms\AffyHuman.sqlite") c = con.cursor() mat2save = [[],[]] pos = 0 #print len(PSids) #print len(colMat) while pos < len(PSids): #print pos query = PSids[pos] c.execute('''select Homolog from %s where AffyPSId = ?''' %Rec[1], [query]) Hlog = c.fetchone() if not Hlog == None: c.execute('''select Position from GPL570Plus where Homolog = ?''', [Hlog[0]]) hLogPos = c.fetchone() if not hLogPos == None: nLogPos = int(hLogPos[0]) if not nLogPos == 15: if not hLogPos in mat2save[0]: mat2save[0].append(nLogPos) mat2save[1].append(colMat[pos]) else: seeker = 0 while seeker < len(mat2save[0]): if mat2save[0][seeker] == nLogPos: if not colMat[pos] == mat2save[1][seeker]: mat2save[1].pop(seeker) mat2save[0].remove(nLogPos) seeker = len(mat2save[0]) seeker += 1 pos += 1 con.close() #print "b ok" if numToGen > 0: return binarysearchEXE(mat2save,numToGen) else: return mat2save
def pluginEXE(Rec, geoMat, numToGen): # Assume that record is loaded, but not tested # Apply ttest and heat map bit to record # look up platform from sqliteDB and translate to 570Plus # # Display binary as 1,0s and colors # button to compare to other binaries (may take time :-( # List ~20 most similar? geoMat = Ttest.pluginEXE(Rec, geoMat, 0.05) PSids = geoMat[-1] colMat = HeatMap.pluginEXE(Rec, geoMat, "bit") # print "a ok" con = sqlite3.connect(r"C:\Users\francis\Documents\platforms\AffyHuman.sqlite") c = con.cursor() mat2save = [[], []] pos = 0 # print len(PSids) # print len(colMat) while pos < len(PSids): # print pos query = PSids[pos] c.execute("""select Homolog from %s where AffyPSId = ?""" % Rec[1], [query]) Hlog = c.fetchone() if not Hlog == None: c.execute("""select Position from GPL570Plus where Homolog = ?""", [Hlog[0]]) hLogPos = c.fetchone() if not hLogPos == None: nLogPos = int(hLogPos[0]) if not nLogPos == 15: if not hLogPos in mat2save[0]: mat2save[0].append(nLogPos) mat2save[1].append(colMat[pos]) else: seeker = 0 while seeker < len(mat2save[0]): if mat2save[0][seeker] == nLogPos: if not colMat[pos] == mat2save[1][seeker]: mat2save[1].pop(seeker) mat2save[0].remove(nLogPos) seeker = len(mat2save[0]) seeker += 1 pos += 1 con.close() # print "b ok" if numToGen > 0: return binarysearchEXE(mat2save, numToGen) else: return mat2save
def get_filters(request): layer_id = int(request.POST["layer"]) datas.set_layer(layer_id) res = {} # Filters start = time.clock() visu = FilterVis(datas) res["filters"] = visu.run() end = time.clock() print("compute filters in ", end - start, "clocks") # HeatMap visu = HeatMap(datas) start = time.clock() res["heatMap"] = visu.run() end = time.clock() print("compute heat map in ", end - start, "clocks") return HttpResponse(json.dumps(res, ensure_ascii=False))
def add_colors(tree, selection): """ Add branch colors to a newick tree. @param tree: a newick tree @param selection: a list of taxon names """ # set the tip states for node in tree.gen_tips(): if node.name in selection: node.state = 'a' else: node.state = 'b' # get the total length of the tree total_length = sum(node.blen for node in tree.gen_non_root_nodes()) # define the rate matrix states = ('a', 'b') mu = 1.0 / total_length row_major_rate_matrix = [[-mu, mu], [mu, -mu]] rate_matrix_object = RateMatrix.RateMatrix(row_major_rate_matrix, states) # repeatedly reroot and calculate root state distributions internal_nodes = list(tree.gen_internal_nodes()) for node in internal_nodes: tree.reroot(node) rate_matrix_object.add_probabilities(tree) weights = [node.state_to_subtree_prob[state] for state in states] node.state_distribution = Util.weights_to_distribution(weights) for node in tree.gen_tips(): node.state_distribution = [] for state in states: if state == node.state: node.state_distribution.append(1.0) else: node.state_distribution.append(0.0) # set the color of each branch for node in tree.gen_non_root_nodes(): parent_probability = node.parent.state_distribution[0] current_probability = node.state_distribution[0] p = (parent_probability + current_probability) / 2.0 r, g, b = HeatMap.blue_red_gradient(p) rgb_string = ('%02x%02x%02x' % (r, g, b)).upper() node.branch_color = rgb_string
def add_colors(tree, selection): """ Add branch colors to a newick tree. @param tree: a newick tree @param selection: a list of taxon names """ # set the tip states for node in tree.gen_tips(): if node.name in selection: node.state = 'a' else: node.state = 'b' # get the total length of the tree total_length = sum(node.blen for node in tree.gen_non_root_nodes()) # define the rate matrix states = ('a', 'b') mu = 1.0 / total_length row_major_rate_matrix = [[-mu, mu], [mu, -mu]] rate_matrix_object = RateMatrix.RateMatrix(row_major_rate_matrix, states) # repeatedly reroot and calculate root state distributions internal_nodes = list(tree.gen_internal_nodes()) for node in internal_nodes: tree.reroot(node) rate_matrix_object.add_probabilities(tree) weights = [node.state_to_subtree_prob[state] for state in states] node.state_distribution = Util.weights_to_distribution(weights) for node in tree.gen_tips(): node.state_distribution = [] for state in states: if state == node.state: node.state_distribution.append(1.0) else: node.state_distribution.append(0.0) # set the color of each branch for node in tree.gen_non_root_nodes(): parent_probability = node.parent.state_distribution[0] current_probability = node.state_distribution[0] p = (parent_probability + current_probability) / 2.0 r, g, b = HeatMap.blue_red_gradient(p) rgb_string = ('%02x%02x%02x' % (r, g, b)).upper() node.branch_color = rgb_string
def __init__(self, parent): super(QWidget, self).__init__(parent) self.layout = QVBoxLayout(self) # Initialize tab screen self.tabs = QTabWidget() # Initial Conditions Tab self.ic_tab = QWidget() # HeatMap Tab self.heatmap_tab = HeatMap.HeatMap() self.select_heatmap_trajectory_button = QPushButton( "Send to Relative Trajectory Tab") self.heatmap_tab.bottom_layout.addWidget( self.select_heatmap_trajectory_button) self.select_heatmap_trajectory_button.clicked.connect( self.when_heatmap_to_relloc_button_clicked) self.target_tab = Targeter.Targeter() self.select_targeted_trajectory_button = QPushButton( "Send to Relative Trajectory Tab") self.target_tab.bottom_layout.addWidget( self.select_targeted_trajectory_button) self.select_targeted_trajectory_button.clicked.connect( self.when_targeted_trajectory_to_relloc_button_clicked) # Relative Location Tab self.relloc_tab = RelativeLocator.RelativeLocator() # Size tabs self.tabs.resize(600, 400) self.x_pos = QLineEdit("0.1") # 0.0 self.x_p_var = QLineEdit("0.1") self.y_pos = QLineEdit("0.1") # 0.1 self.y_p_var = QLineEdit("0.1") self.z_pos = QLineEdit("0.01") # 0.01 self.z_p_var = QLineEdit("0.1") self.x_vel = QLineEdit("-0.02") # -0.02 self.x_v_var = QLineEdit("0.1") self.y_vel = QLineEdit("0.0") # 0.0 self.y_v_var = QLineEdit("0.1") self.z_vel = QLineEdit("0.01") # 0.01 self.z_v_var = QLineEdit("0.1") self.state_elements = [ self.x_pos, self.y_pos, self.z_pos, self.x_vel, self.y_vel, self.z_vel ] self.state_variances = [ self.x_p_var, self.y_p_var, self.z_p_var, self.x_v_var, self.y_v_var, self.z_v_var ] self.reference_inclination = QLineEdit(".52") self.reference_semimajor_axis = QLineEdit("6678136.6") self.maximum_distance_threshold = QLineEdit("30") self.minimum_distance_threshold = QLineEdit("0") nominal_formation = [.1, 1, .1, 0, 0, 0] * 1 / np.linalg.norm( [1, 1, 0, 0, 0, 0]) for i in range(len(nominal_formation)): nominal_formation[i] = 20 * nominal_formation[i] self.targeted_x = QLineEdit(str(nominal_formation[0])[:7]) self.targeted_y = QLineEdit(str(nominal_formation[1])[:7]) self.targeted_z = QLineEdit(str(nominal_formation[2])[:7]) self.targeted_xd = QLineEdit(str(nominal_formation[3])[:7]) self.targeted_yd = QLineEdit(str(nominal_formation[4])[:7]) self.targeted_zd = QLineEdit(str(nominal_formation[5])[:7]) self.propagation_time = QLineEdit("10000") self.values_record = QLineEdit("1000") self.resolution = QLineEdit("3") self.heatmap_drop_down_menu_x_axis = QComboBox(self) self.heatmap_drop_down_menu_y_axis = QComboBox(self) self.heatmap_x_axis = 3 self.heatmap_y_axis = 4 self.maximum_distance_threshold_value = None self.minimum_distance_threshold_value = None self.reference_orbit = None # Add tabs self.tabs.addTab(self.ic_tab, "Initial Conditions") self.tabs.addTab(self.heatmap_tab, "Initial State HeatMap") self.tabs.addTab(self.target_tab, "Targeted Trajectory") self.tabs.addTab(self.relloc_tab, "Relative Trajectory") self.start_button_heatmap = QPushButton( "Get HeatMap From Entered Conditions") self.start_button_heatmap.clicked.connect( self.when_start_button_heatmap_clicked) self.select_relloc_trajectory_button = QPushButton( "Get Trajectory From Entered Conditions") self.select_relloc_trajectory_button.clicked.connect( self.when_start_relloc_button_clicked) self.select_target_trajectory_button = QPushButton( "Target a Trajectory From Entered Conditions") self.select_target_trajectory_button.clicked.connect( self.when_start_button_target_clicked) # Add tabs to widget self.layout.addWidget(self.tabs) self.setLayout(self.layout) # Create textboxes self.starmap_name_frame = QFrame() self.relmot_frame = QFrame() self.reforbit_frame = QFrame() self.set_ic_title_layout() self.set_ic_tab_orbit_threshold_timing() total_layout = QVBoxLayout() total_layout.addWidget(self.starmap_name_frame) total_layout.addWidget(self.reforbit_frame) total_layout.addWidget(self.start_button_heatmap) total_layout.addWidget(self.select_relloc_trajectory_button) total_layout.addWidget(self.select_target_trajectory_button) self.ic_tab.setLayout(total_layout)
X_batch, y_stacked = generator[168] # choose one image for evaluation name_no_extension = "tmp" ## Uncomment below for arbitrary images img_name = 'IMG_8175.jpg' name_no_extension = img_name.split('.')[0] X_batch, y_stacked = evaluation.load_and_preprocess_img( os.path.join('data', img_name), eval.num_hg_blocks) y_batch = y_stacked[0] # take first hourglass section X, y = X_batch[0], y_batch[0] # take first example of batch # Get predicted heatmaps for image predict_heatmaps = eval.predict_heatmaps(X_batch) # Get predicted keypoints from last hourglass (last element of list) # Dimensions are (hourglass_layer, batch, x, y, keypoint) keypoints = eval.heatmaps_to_keypoints(predict_heatmaps[-1, 0, :, :, :]) print(keypoints) # Get bounding box image from heatmap heatmap = y[:, :, 0] hm = HeatMap(X, heatmap) img = np.array(hm.image) # Clear plot image plt.clf() eval.visualize_keypoints(np.zeros(INPUT_DIM), keypoints, name_no_extension + '_no-bg') eval.visualize_keypoints(X, keypoints, name_no_extension) # %%
def do_analysis(mixture_model, alignment, tree): """ @param mixture_model: a mixture of nucleotide rate matrices @param alignment: a nucleotide alignment @param tree: the phylogenetic tree with branch lengths @return: an html string representing a whole html file """ # For each column of the alignment get the likelihood for each category. # The rest of the analysis can proceed from this data alone. likelihood_columns = [] # create a hash table to help decorate the tree header_to_node = {} for header in alignment.headers: try: node = tree.get_unique_node(header) except Newick.NewickSearchError as e: raise HandlingError(e) header_to_node[header] = node # get the information for each column for column in alignment.columns: # decorate the tree with the ordered states of the current column for header, state in zip(alignment.headers, column): header_to_node[header].state = state # get the likelihood for each category likelihoods = [] for p, matrix in zip(mixture_model.mixture_parameters, mixture_model.rate_matrices): likelihoods.append(p * matrix.get_likelihood(tree)) likelihood_columns.append(likelihoods) # The likelihood_columns variable has everything we need # to write the response. # Define the likelihood legend. likelihood_column_sums = [ sum(likelihoods) for likelihoods in likelihood_columns ] likelihood_legend = HeatMap.Legend(likelihood_column_sums, 5, 'L', HeatMap.white_red_gradient) # get the mixture for each column implied by the likelihoods at the column mixture_columns = [] for likelihoods in likelihood_columns: total = sum(likelihoods) mixtures = [likelihood / total for likelihood in likelihoods] mixture_columns.append(mixtures) # get the conditional mixtures for the whole alignment total_mixture = [] for proportions in zip(*mixture_columns): total_mixture.append(sum(proportions) / len(alignment.columns)) # define the mixture legend flattened_columns = list(itertools.chain.from_iterable(mixture_columns)) mixture_legend = HeatMap.Legend(flattened_columns, 5, 'M', HeatMap.white_blue_gradient) # start writing the web page out = StringIO() print >> out, '<html>' print >> out, '<head>' print >> out, '<style>' for legend in (likelihood_legend, mixture_legend): for line in legend.gen_style_lines(): print >> out, line print >> out, '</style>' print >> out, '</head>' print >> out, '<body>' # write the log likelihood log_likelihood = sum( math.log(sum(likelihoods)) for likelihoods in likelihood_columns) print >> out, 'log likelihood:' print >> out, '<br/>' print >> out, '%f' % log_likelihood # write the log likelihood per column print >> out, '<br/><br/>' print >> out, 'log likelihood per column:' print >> out, '<br/>' print >> out, '%f' % (log_likelihood / len(alignment.columns)) # write the conditional mixtures for the whole alignment print >> out, '<br/><br/>' print >> out, 'conditional mixture:' print >> out, '<br/>' for proportion in total_mixture: print >> out, '%f</br>' % proportion # begin the pre environment print >> out, '<pre>' # write the alignment labels = alignment.headers labels += ['category 1', 'category 2', 'category 3', 'likelihood'] element_lists = [list(seq) for seq in alignment.sequences] for proportions in zip(*mixture_columns): mixture_elements = [] for proportion in proportions: css_class = mixture_legend.value_to_css_class(proportion) mixture_elements.append('<span class="%s"> </span>' % css_class) element_lists.append(mixture_elements) likelihood_elements = [] for likelihood in likelihood_column_sums: css_class = likelihood_legend.value_to_css_class(likelihood) likelihood_elements.append('<span class="%s"> </span>' % css_class) element_lists.append(likelihood_elements) for line in do_analysis_helper(labels, element_lists, 60): print >> out, line # write the legend print >> out, '' print >> out, 'mixture key:' for line in reversed(list(mixture_legend.gen_legend_lines())): print >> out, line print >> out, '' print >> out, 'likelihood key:' for line in reversed(list(likelihood_legend.gen_legend_lines())): print >> out, line # end the pre environment print >> out, '</pre>' # terminate the file print >> out, '</body>' print >> out, '</html>' return out.getvalue()
sys.path.append('Analysis/') from AverageShape import PlotAvgShape N = 1000 S = 100 sample_size = 50 rel = False fig = plt.figure() title = 'log(%N)' """ 1. The Broken Stick Model constrained by N and S """ ax = fig.add_subplot(3, 3, 1) RACsample = Models.SimBrokenStick(N, S, sample_size, rel) fig = HeatMap.RACHeatMap(fig, RACsample) fig = PlotAvgShape(fig, RACsample) plt.title('Broken Stick', fontsize=13) plt.xlabel('Rank') #plt.ylabel('Abundance') plt.ylabel(title) print 'finished broken stick\n' """ 2. The Log-normal (75/25) constrained by N and S """ ax = fig.add_subplot(3, 3, 2) RACsample = Models.SimLogNormFloat(N, S, sample_size, rel) fig = HeatMap.RACHeatMap(fig, RACsample) fig = PlotAvgShape(fig, RACsample)
def fig2(SADModels): '''Heat map of one site, observed v heat from each model''' # Still working... #1. get obs for one site 2. put into each model 3. heat map fig = plt.figure() for i, model in enumerate(SADModels): fig.add_subplot(2, 2, i + 1) obs_pred_data = import_obs_pred_data(mydir + '/Results/' + model + '.txt') obs = ((obs_pred_data["obs"])) site = ((obs_pred_data["site"])) obs_data = [] for sites in np.unique(site): obs_data.append(obs[sites == site]) OBSSad = obs_data[10] OBSSad = map(int, OBSSad.tolist()) N = sum(OBSSad) S = len(OBSSad) sample_size = 100 print OBSSad if model == 'SimBrokenStick': prdSADs = Models.SimBrokenStick(N, S, sample_size) HeatMap.RACHeatMap(fig, prdSADs) plt.plot(np.log(AverageShape.AvgShape(prdSADs)), color='lime', label='Predicted', lw=2) elif model == 'SimLogNormInt': prdSADs = Models.SimLogNormInt(N, S, sample_size) HeatMap.RACHeatMap(fig, prdSADs) plt.plot(np.log(AverageShape.AvgShape(prdSADs)), color='lime', label='Predicted', lw=2) elif model == 'SimpleRandomFraction': prdSADs = Models.SimpleRandomFraction(N, S, sample_size) HeatMap.RACHeatMap(fig, prdSADs) plt.plot(np.log(AverageShape.AvgShape(prdSADs)), color='lime', label='Predicted', lw=2) elif model == 'SimParetoInt': prdSADs = Models.SimParetoInt(N, S, sample_size) HeatMap.RACHeatMap(fig, prdSADs) plt.plot(np.log(AverageShape.AvgShape(prdSADs)), color='lime', label='Predicted', lw=2) plt.title(model) plt.plot(np.log(OBSSad), color='m', lw=3, label="Observed", alpha=1.0) leg = plt.legend(loc=1, prop={'size': 8}) leg.draw_frame(False) plt.text(10, 8, 'N =' + str(N) + ', S =' + str(S), fontsize=8) plt.xlim(0, S + 2) plt.xlabel('Rank in abundance', fontsize=12) plt.ylabel('log(abundance)', fontsize=12) plt.subplots_adjust(wspace=.35, hspace=.35) plt.savefig( '/Users/Nathan_Hillis/GitHub/SADModels/Projects/Mar2015meeting/HeatMaps_OneSite.png', dpi=600, bbox_inches='tight', pad_inches=0.03) plt.show() return
ax.set_ylim(0, yLimit) ax.set_yticks(np.arange(0, yLimit, step = 50)) ax.text(0, yLimit - 200, 'Summary Stats:\n' + \ str(categoryDurationData2[col].count()) + ' Storms\n' + \ str(categoryDurationData1[col].loc['Min']) + ' hours minimum\n' + \ str(categoryDurationData1[col].loc['Max']) + ' hours maximum\n' + \ str(categoryDurationData1[col].loc['Median']) + ' hours median\n' + \ str(round(categoryDurationData1[col].loc['Mean'], 2)) + ' hours mean\n', \ size = 'x-small') ax.set_ylabel('Duration (hrs)', \ size = 'small') ax.set_title('Category ' + str(col)) ax.set_xticks([]) plt.subplots_adjust(wspace = 0.25, hspace = 0.25) plt.show() fig4.savefig('hurricaneDurationByCategoryHistogram.png') ## HeatMap df_heatmap = hm.loadData() # Landfall HeatMap df_landfall = hm.hurricaneLandFall(df_heatmap) hm.mapHurricane(df_landfall, "landfall.html") # No Landfall HeatMap df_no_landfall = hm.hurricaneNoLandFall(df_heatmap) hm.mapHurricane(df_no_landfall, "no_landfall.html")
from StudentData import * from WriteData import * from GradeData import * from ReadData import * from HeatMap import * import sys import json import datetime videos = VideoData() students = StudentData() fileData = WriteData() grades = GradeData() readedData = ReadData() heatMap = HeatMap() #************UPLOAD JSON FILE****************************# jsonfile=open("/Users/LearningAnalytics/Dropbox/14-15/DadesIntroductionMoocOfAlgebra/tot_arr.json") print "LOADING .JSON FILE..." json_file=json.load(jsonfile) print ".JSON FILE LOADED" #************SYSTEM VARIABLES****************************# li_names_stud=students.calculateNameStudents(json_file) fileData.writeName("NameStudents.txt", li_names_stud) print "NAME STUDENTS CALCULATED, TOTAL STUDENTS: "+str(len(li_names_stud)) li_ids_video = videos.calculate_video_ids(json_file) fileData.writeName("CodeVideos.txt", li_ids_video)
def HeatMap(): for ExFile in os.listdir(path_heatMap): HM.PlotHeatMap(path_heatMap, ExFile)
Well it was a nice try but I ran out of memory.''' SADModels = ['SimBrokenStick', 'SimLogNormInt', 'SimpleRandomFraction', 'SimParetoInt'] N = 40000 S = 100 sample_size = 100 fig = plt.figure() for i, model in enumerate(SADModels): fig.add_subplot(2, 2, i+1) if model == 'SimBrokenStick': prdSADs = Models.SimBrokenStick(N, S, sample_size) HeatMap.RACHeatMap(fig, prdSADs) plt.plot(np.log(AverageShape.AvgShape(prdSADs)), color = 'lime', label = 'Predicted', lw = 2) print 'BS' elif model == 'SimLogNormInt': prdSADs = Models.SimLogNormInt(N, S, sample_size) HeatMap.RACHeatMap(fig, prdSADs) plt.plot(np.log(AverageShape.AvgShape(prdSADs)), color = 'lime', label = 'Predicted', lw = 2) print 'SLN' elif model == 'SimpleRandomFraction': prdSADs = Models.SimpleRandomFraction(N, S, sample_size) HeatMap.RACHeatMap(fig, prdSADs) plt.plot(np.log(AverageShape.AvgShape(prdSADs)), color = 'lime', label = 'Predicted', lw = 2) print 'RandFrac'