def savePlots(): try: os.mkdir('plots') except FileExistsError: pass #get callee name: frame,filename,line_number,function_name,lines,index = inspect.stack()[1] myname = os.path.splitext(os.path.basename(filename))[0] for n in pylab.get_fignums(): fig = pylab.figure(n) ax = fig.axes[0] if not fig._suptitle is None: title=fig._suptitle.get_text() fig._suptitle.set_visible(False) else: title = ax.get_title() descriptor = "_".join((myname, "fig"+str(n), title )) print("saving {}".format(descriptor)) if "REFERENCE" in os.environ: filename="./plots/{0}_ref.pdf".format(descriptor) else: filename="./plots/{0}.pdf".format(descriptor) fig.savefig(filename)
def wp_ok(window, panel): ''' Quick test to see if requested window, panel combination is available ''' try: if window in plt.get_fignums(): if panel > 0 and panel <= len(plt.figure(window).get_axes()): return True except: print('WP_OK: Syntax truth = wp_ok(window, panel)') return False
def capture_figures(self): """ captures all figures that are plotted and store them in the report """ print 'Capturing figures and writing to report ...' for i in pl.get_fignums(): f = pl.figure(i) self.figure(f) self.newpage()
def capture_figures(self): """ captures all figures that are plotted and store them in the report """ print 'Capturing figures and writing to report ...' for i in pl.get_fignums(): f = pl.figure(i) self.figure(f) self.newpage()
def get_axes(window=None): panel_axes = [] cbar_axes = [] if window is None: window, panel = last_wp() if window in plt.get_fignums(): fig = plt.figure(window) axes = fig.get_axes() # Remove any axes from list that are not "Subplot" axes for ax in axes: if str(ax).find('Subplot') == -1: cbar_axes.append(ax) else: panel_axes.append(ax) return {'pax':panel_axes, 'cax':cbar_axes}
def save_results(gy, de,ro, pe, N=None, P=None, K=None, fold= None, fname =None): if fold==None: fold="C:\Apps\WinPython-64bit-2.7.10.3\IPEWG\\" if fname==None: fname = "PDSS_results.p" data={} data['gy'] = gy.__dict__ data['de'] = de.__dict__ data['ro'] = ro.__dict__ data['pe'] = pe.__dict__ if N != None: data['N'] = N.__dict__ if P != None: data['P'] = P.__dict__ if K != None: data['K'] = K.__dict__ with open(fold+fname, 'wb') as wfp: pickle.dump(data, wfp) print ('PDSS simulation saved to ', fname) for i in plt.get_fignums(): plt.figure(i) plt.savefig(fold+'figure%d.png' % i)
def track_vesicles(model, device, movie_name, save_name, batch_size=8, _is_debug=False): reader = MovieReader(str(movie_name)) tot = len(reader) img_h, img_w = reader.height, reader.width mod = CoordGetter(model, device, img_h, img_w) images_batch = [] traj_dat = [] prev_out_loc = None index_prev = None current_traj_id = 0 for current_frame, (_, img_o) in enumerate(tqdm.tqdm(reader)): images_batch.append(img_o) if len(images_batch) >= batch_size or current_frame == tot - 1: curr_batch_size = len(images_batch) outs = mod.process_batch(images_batch) images_batch = [] for i_offset, (out_clf, out_loc) in enumerate(outs): #tracker part roi_size = np.abs(out_loc[..., 2:] - out_loc[..., :2]).mean(axis=1) coord_x = (out_loc[..., 0] + out_loc[..., 2]) / 2 coord_y = (out_loc[..., 1] + out_loc[..., 3]) / 2 frame_number = current_frame - curr_batch_size + (i_offset + 1) index_current = list( range(current_traj_id + 1, current_traj_id + out_loc.shape[0] + 1)) current_traj_id += len(index_current) if prev_out_loc is not None: jaccard_ind = get_jaccard_index(prev_out_loc, out_loc) prev_intersect_f = [ np.where(x > 0.5)[0] for x in jaccard_ind ] simple_pairs = [ (i_prev, vv[0]) for i_prev, vv in enumerate(prev_intersect_f) if len(vv) == 1 ] for i1, i2 in simple_pairs: index_current[i2] = index_prev[i1] for lab, rs, cx, cy, ind in zip(out_clf, roi_size, coord_x, coord_y, index_current): row_data = (ind, frame_number, -1, cx, cy, -1, rs, ind, lab) traj_dat.append(row_data) prev_out_loc = out_loc index_prev = index_current if _is_debug: import matplotlib.pylab as plt fig, axs = plt.subplots(1, 1, sharex=True, sharey=True) axs.imshow(img_o) for lab, (x0, y0, x1, y1) in zip(out_clf, out_loc): c = 'y' if lab == 1 else 'r' axs.plot((x0, x1, x1, x0, x0), (y0, y0, y1, y1, y0), c) if len(plt.get_fignums()) > 0: break with tables.File(save_name, 'r+') as fid: trajectories_data = _init_table(fid) trajectories_data.append(traj_dat)
else: # Resized Manifold experiment exp = ExperimentManifold(unit, max_step=100, imgsize=imgsize, corner=corner, backend="torch", savedir=savedir, explabel="%s_rf_fit" % (unit_lab)) # exp.load_traj("Evolv_%s_%d_%d_%d_rf_fit.npz" % (unit[1], unit[2], unit[3], unit[4])) # load saved traj exp.run() exp.save_last_gen() exp.analyze_traj() exp.visualize_trajectory() exp.visualize_best() score_sum, figsum = exp.run_manifold([(1, 2), (24, 25), (48, 49), "RND"], interval=9) plt.close(figsum) # np.save(join(savedir, "Manifold_score_%s_rf_fit" % (unit_lab)), score_sum) # np.savez(join(savedir, "Manifold_set_%s_rf_fit.npz" % (unit_lab)), # Perturb_vec=exp.Perturb_vec, imgsize=exp.imgsize, corner=exp.corner, # evol_score=exp.scores_all, evol_gen=exp.generations) t2 = time() print("RF fitting Exp Processing time %.f" % (t2 - t0)) plt.close("all") print("Existing figures %d" % (len(plt.get_fignums()))) # print("Pair Processing time %.f" % (t2 - t0)) # %%
observations[:, 0] = _np.linspace(0.0, 1., num) observations[:, 1] = _kumaraswamy.cdf(a_target, b_target, observations[:, 0]) a, b, rms, i = _kumaraswamy.approximate(observations, accuracy=1e-5, max_iterations=100000) if ((a_target - a)**2 + (b_target - b)**2)**0.5 > max_error: raise Exception("Approximation failed for parameters {},{}".format( a_target, b_target)) #plot the last test: plt.plot(observations[:, 0], observations[:, 1]) plt.plot(observations[:, 0], _kumaraswamy.cdf(a, b, observations[:, 0]), linestyle=':') if __name__ == '__main__': import os try: os.mkdir('plots') except FileExistsError: pass for n in pylab.get_fignums(): myname = os.path.splitext(os.path.basename(__file__))[0] if "REFERENCE" in os.environ: filename = "./plots/{0}_fig{1}_ref.pdf".format(myname, n) else: filename = "./plots/{0}_fig{1}.pdf".format(myname, n) pylab.figure(n).savefig(filename)
def plot_map(map=None, cont=False, over=False, panel=None, about_center=False, bcolor='white', border=True, bthick=1, cbar=False, center=None, color=None, composite=False, date_only=False, dmax=None, dmin=None, drange=None, drotate=False, duration=None, durtitle=False, fov=None, grid=0., last_scale=False, levels=None, limb=False, log=False, newwindow=False, #mark_point=mark_point, minus_only=False, multi=[1,1], new=False, nlevels=10, no_data=False, noaxes=False, nodata=False, nodate=False, noerase=False, saved_map=None, nolabels=False, notitle=False, original_time=False, percent=False, plus_only=False, roll_angle=0., smooth=False, title=None, window=None, xrange=None, xshift=0., yrange=None, yshift=0., **kwargs): #-- some variables saved in memory for overlay import pickle import os from copy import deepcopy from scipy.ndimage import gaussian_filter from time import sleep # Implement common block functionality by use of a pickle file "pmap_shared.pkl" common_file = 'pmap_shared.pkl' # Set default values if file does not exist last = {'window':None, 'panel':None, 'time':None, 'drange':None, 'scale': False, 'xrange':None, 'yrange':None, 'multi':None, 'roll':0., 'rcenter':[0.,0.], 'b0':None, 'l0':0., 'rsun':960., 'saved_map':None, 'roll_correct':False, 'center':[0.,0.]} if os.path.exists(common_file): # Read file if it exists fp = open(common_file, "rb") last.update(pickle.load(fp)) fp.close() shifting = False rolling = False # Strip any grid and limb keywords from kwargs, and set to value or default glabel = default(kwargs, 'glabel', False) gcolor = default(kwargs, 'gcolor', 'w') gstyle = default(kwargs, 'gstyle', ':') gthick = default(kwargs, 'gthick', 1) gfont = default(kwargs, 'gfont', None) lcolor = default(kwargs, 'lcolor', 'w') lstyle = default(kwargs, 'lstyle', '-') lthick = default(kwargs, 'lthick', 1) #-- overlay limb and/or grid on previous plot if over and map is None: from mapping.plot_helio import plot_helio if last['time'] is None: print('PLOT_MAP: Error: No previous image on which to overlay limb/grid') return False if about_center: rcenter = last['center'] else: rcenter = last['rcenter'] if xrange is None: xrange = last['xrange'] if yrange is None: yrange = last['yrange'] axes = np.array(plt.figure(last['window']).get_axes()).flatten() if len(axes) <= last['panel']: axis = axes[last['panel']-1] else: axis = None plot_helio(last['time'], roll=last['roll'], axis=axis, grid=grid, over=True, rcenter=rcenter, l0=last['l0'], glabel=glabel, gcolor=gcolor, gfont=gfont, gstyle=gstyle, gthick=gthick, limb=limb, lcolor=lcolor, lthick=lthick, lstyle=lstyle, xrange=xrange, yrange=yrange, tgrid=0.5, no_roll_correct=last['roll_correct']) return #-- check input map if map is None: print('PLOT_MAP: Syntax plot_map,map') return if not valid_map(map): print('PLOT_MAP: Error, the provided argument is not a valid map dict.') return #-- check image scalings if log and 'log_scale' in map.keys(): if map['log_scale']: print('PLOT_MAP: Input map already log-scaled.') log = False #-- always overlay as a contour unless composite = True if not cont and not composite: cont = over if not noerase: noerase = over rolling = (roll_angle % 360.) != 0. shifting = xshift != 0. or yshift != 0. #-- open a new figure if one doesn't exist #-- else get axis for previous plot nowindow = False nopanel = False if window is None: # No window specified in call, so default to the last-used window window = last['window'] if not (window in plt.get_fignums()): # The requested window is not open nowindow = True nopanel = True last['panel'] = None if not nowindow: # There is an open window, so look for a viable axis if panel is None: # No panel was specified in call, so default to the last-used panel panel = last['panel'] # Compare with available axes in the window fig = plt.figure(window) axes = fig.get_axes() # Remove any axes from list that are not "Subplot" axes good_axes = [] for ax in axes: if str(ax).find('Subplot') != -1: good_axes.append(ax) axes = good_axes # See if the current axis is in the window naxes = len(axes) if panel <= naxes: axis = axes[panel-1] # Current axis was found, so use it for an overplot, or increment # to next available axis if not if not over: if panel == naxes: # Need a new axis, but the current axis is already the last one. nopanel = True if newwindow: nowindow = True else: panel = 1 axis = axes[panel-1] axis.cla() else: # Set axis to the next available axis. axis = axes[panel] panel += 1 else: panel = None nopanel = True if over: if nowindow: print('PLOT_MAP: Overlay base window unavailable') return if nopanel: print('PLOT_MAP: Overlay panel unavailable') return else: if nowindow: # Open a new window for plotting fig, axes = plt.subplots(multi[1],multi[0]) last['multi'] = multi window = fig.number axes = fig.get_axes() panel = 1 axis = axes[panel-1] # fig, window and panel now point to the correct figure, window, and panel for the next plot. last['window'] = window last['panel'] = panel #-- translating or rolling map saved_icenter = [map['xc'],map['yc']] saved_rcenter = get_map_prop(map,'roll_center',default=saved_icenter) if shifting or rolling: saved_map = deepcopy(map) if rolling: map = rot_map(map, roll_angle) if shifting: map = shift_map(map, xshift, yshift) odmin = float(np.min(map['data'])) odmax = float(np.nanmax(map['data'])) if odmin == 0 and odmax == 0: print('PLOT_MAP: Error, All data are zero') return #-- filter NaN's off_scale = odmax*100. if map['data'].dtype == np.byte: pic = np.float(map['data']) else: pic = deepcopy(map['data']) inan = np.where(np.isnan(pic)) if cont: pic[inan] = off_scale else: pic[inan] = 0. #-- smoothing? if smooth: pic = gaussian_filter(pic, sigma=smooth) odmin = float(np.nanmin(pic)) odmax = float(np.nanmax(pic)) odrange = [odmin,odmax] if log: ok = np.where(pic > 0.) if len(ok[0]) == 0: print('PLOT_MAP: Warning, all data are negative. Cannot plot on a log scale. Using linear scale.') log = False if log: pmin = np.nanmin(pic[ok]) pmax = np.nanmax(pic[ok]) odrange = [np.float(pmin),np.float(pmax)] #-- establish plot labels units = get_map_prop(map,'units',default='arcsec') units = units xunits = units yunits = units xunits = get_map_prop(map,'xunits',xunits) yunits = get_map_prop(map,'yunits',yunits) xtitle='X ('+xunits+')' ytitle='Y ('+yunits+')' if nolabels: xtitle='' ytitle='' #-- if solar rotating, check that we are rotating relative to last time image # rotated otime = get_map_prop(map, 'time') rtime = get_map_prop(map, 'rtime', default=otime) mtitle = get_map_prop(map, 'id', default='') if not over: mtime = rtime if original_time: mtime = otime if durtitle: mtitle += ' '+mtime s_time = Time(mtime).mjd e_time = Time(s_time + get_map_prop(map, 'dur', default=0.)/86400.,format='mjd').iso mtitle += '-'+e_time else: if date_only: date_obs = mtime[:10] else: date_obs = mtime+' UT' mtitle = mtitle+' '+date_obs mtitle = mtitle.strip() if title: mtitle = title if notitle: mtitle = '' #-- get some map properties oxrange = get_map_xrange(map, edge=True) oyrange = get_map_yrange(map, edge=True) dx = map['dx'] dy = map['dy'] dx2 = dx/2. dy2 = dy/2. icenter = [map['xc'], map['yc']] curr_roll = get_map_prop(map, 'roll_angle', default=0.) curr_rcenter = get_map_prop(map, 'roll_center', default=icenter) #-- retrieve coordinate transformation angles for plotting limb and # overlaying ang_error = '' #if map['id'].find('SOHO'): # Calculate the angles for this date in case they are not already in the map angles = pb0r(otime) # Override with the map values if they exist b0 = get_map_prop(map, 'b0', default=angles['b0']) l0 = get_map_prop(map, 'l0', default=angles['l0']) angles['rsun'] *= 60. rsun = get_map_prop(map, 'rsun', default=angles['rsun']) #-- establish plot ranges # (start with image, then FOV, then XRANGE/YRANGE keywords) dcenter = icenter if valid_map(fov): dcenter = get_map_center(fov) if center: if valid_map(center): dcenter = get_map_center(center) else: dcenter = center dxrange = oxrange dyrange = oyrange if fov: if valid_map(fov): dfov = get_map_fov(fov, edge=True) else: dfov = 60.*np.array([fov[0],fov[-1]]) half_fov = dfov/2. dxrange = [dcenter[0] - half_fov[0], dcenter[0] + half_fov[0]] dyrange = [dcenter[1] - half_fov[1], dcenter[1] + half_fov[1]] if center and not fov: dxrange[0] += dcenter[0] - icenter[0] dxrange[1] += dcenter[0] - icenter[0] dyrange[0] += dcenter[1] - icenter[1] dyrange[1] += dcenter[1] - icenter[1] #-- if overlaying, match with previous viewport if over: if not last['xrange'] is None: dxrange = last['xrange'] if not last['yrange'] is None: dyrange = last['yrange'] #-- overide with user input ranges if not xrange is None: dxrange = xrange if not yrange is None: dyrange = yrange dxrange.sort() if min(dxrange) == max(dxrange): dxrange = oxrange dyrange.sort() if min(dyrange) == max(dyrange): dyrange = oyrange #-- bail out if trying to display at the sub-pixel level diff_x = max(dxrange) - min(dxrange) diff_y = max(dyrange) - min(dyrange) if diff_x < dx2 or diff_y < dy2: print('PLOT_MAP: Error, Cannot display below half pixel resolution limit') return #-- define viewport xmin, xmax = dxrange ymin, ymax = dyrange if xmin == xmax or ymin == ymax: print('PLOT_MAP: Error, Plot scale MIN/MAX must differ') return #-- don't extract sub-region if contouring, since contour procedure # takes care of it via drange if not cont: ranges = get_map_sub_ranges(map, xrange=dxrange, yrange=dyrange, xcor=None, ycor=None) irange = ranges['irange'] if irange is None: return # NB: data array x and y dimensions of numpy arrays are swapped pic = pic[irange[0]:irange[1]+1, irange[2]:irange[3]+1] xmin, xmax, ymin, ymax = ranges['arange'] #-- plot axes & viewport #-- try to preserve aspect ratio (won't work if multi is set) #-- if contouring and not overlaying, then check for roll no_drotate = not drotate no_project = no_drotate ilimb = False olimb = False no_roll_correct = rolling or last['roll_correct'] #-- get data plot limits if cont: if over: trans = [0,0] if about_center: rcenter = last['center'] else: rcenter = last['rcenter'] keep_limb = default(kwargs, 'keep_limb', False) xp, yp = drot_map(map, time=last['time'], trans=trans, b0=last['b0'], l0=last['l0'], rsun=last['rsun'], roll=last['roll'], rcenter=rcenter, no_data = True, no_drotate=no_drotate, keep_limb=keep_limb, no_project=no_project, no_roll_correct=no_roll_correct, about_center=about_center) # ranges = get_map_sub_ranges(map, xrange=dxrange, yrange=dyrange, xcor=None, ycor=None) # xp = xp[irange[0]:irange[1]+1,irange[2]:irange[3]+1] # yp = yp[irange[0]:irange[1]+1,irange[2]:irange[3]+1] #-- send off-limb points to outside fov olimb = np.isnan(xp) if np.sum(olimb) != 0: pic[np.where(olimb)] = off_scale ilimb = (xp == -9999.) if np.sum(ilimb) != 0: pic[np.where(ilimb)] = off_scale else: xp = get_map_xp(map) yp = get_map_yp(map) # ranges = get_map_sub_ranges(map, xrange=dxrange, yrange=dyrange, xcor=None, ycor=None) # xp = xp[irange[0]:irange[1]+1,irange[2]:irange[3]+1] # yp = yp[irange[0]:irange[1]+1,irange[2]:irange[3]+1] prange = odrange #-- override with user keywords if dmin: prange[0] = dmin if dmax: prange[1] = dmax if drange: if valid_map(drange): prange = [np.nanmin(drange['data']),np.nanmax(drange['data'])] else: prange = np.float(drange) prange.sort() if min(prange) == max(prange): prange = odrange if plus_only or minus_only: if plus_only: ok = np.logical_and(pic >= 0., pic != off_scale) nok = np.logical_not(ok) else: ok = np.logical_and(pic <= 0., pic != off_scale) nok = np.logical_not(ok) if np.sum(ok) == 0: if plus_only: print('PLOT_MAP: Error, All data are negative') else: print('PLOT_MAP: Error, All data are positive') return if np.sum(nok) > 0: pic[np.where(nok)] = off_scale #-- log scale? if log: ok = np.logical_and(pic > 0., pic != off_scale) nok = np.logical_not(ok) if np.sum(ok) == 0: print('PLOT_MAP: Warning, all data are negative. Cannot plot on a log scale. Using linear scale.') log = False else: okidx = np.where(ok) pmin = np.nanmin(pic[okidx]) pmax = np.nanmax(pic[okidx]) if np.sum(nok) > 0: nokidx = np.where(nok) if cont: pic[nokidx] = off_scale else: pic[nokidx] = pmin pic = np.log10(pic) if prange[0] <= 0: prange[0] = odrange[0] if prange[1] <= 0: prange[1] = odrange[1] prange = np.log10(prange) #-- override with last scaling if last['scale']: if last['drange']: prange = last['drange'] if log: prange = np.log10(last['drange']) #-- make an empty plot to establish scaling # import pdb; pdb.set_trace() axis.set_xlim(xmin, xmax) axis.set_ylim(ymin, ymax) axis.set_aspect('equal','box') if no_data: return if cont: #-- plot contours nlevels = max(nlevels,2) dlevels = (prange[1] - prange[0])/(nlevels - 1.) def_levels = prange[0] + np.arange(nlevels)*dlevels plevels = def_levels if not levels is None: plevels = np.unique(levels) if percent: plevels = plevels*prange[1]/100. elif log: ok, = np.where(plevels > 0) if len(ok) == 0: print('PLOT_MAP: Warning, Contour levels must be greater than zero for log scale - using default set') plevels = def_levels else: plevels = np.log10(plevels[ok]) if not color is None: # For compatibility with IDL version, setting color keyword should be # interpreted as plotting all contours the same color kwargs.update({'colors':color}) if 'fill' in kwargs.keys(): kwargs.pop('fill') axis.contourf(xp, yp, pic, plevels, origin='lower', **kwargs) else: kwargs['linewidths'] = default(kwargs,'linewidths',0.5) kwargs['colors'] = default(kwargs,'colors','k') axis.contour(xp, yp, pic, plevels, origin='lower', **kwargs) else: #-- plot image if cbar: cbpos = default(kwargs,'cbpos','right') if cbpos == 'top' or cbpos == 'bottom': cbor = 'horizontal' else: cbor = 'vertical' im = axis.imshow(pic, origin='lower', extent=[xmin, xmax, ymin, ymax], vmin=prange[0], vmax=prange[1], **kwargs) # Add colorbar if cbar: from mpl_toolkits.axes_grid1 import make_axes_locatable divider = make_axes_locatable(axis) # if 'cbpos' in kwargs.keys(): # cbpos = kwargs.pop('cbpos') # else: # cbpos = 'right' cax = divider.append_axes(cbpos, size=0.1, pad = 0.05) fig.colorbar(im, cax=cax, orientation=cbor, **kwargs) #-- plot axes and labels if not over: axis.set_xlabel(xtitle) axis.set_ylabel(ytitle) axis.set_title(mtitle) #-- overlay a solar latitude-longitude grid if (grid != 0. or limb): from mapping.plot_helio import plot_helio if shifting: rcenter = saved_rcenter else: rcenter = curr_rcenter plot_helio(otime, roll=curr_roll, axis=axis, over=True, rcenter=rcenter, no_roll_correct=no_roll_correct, grid=grid, glabel=glabel, gcolor=gcolor, gfont=gfont, gstyle=gstyle, gthick=gthick, limb=limb, lcolor=lcolor, lthick=lthick, lstyle=lstyle, l0=l0) #-- mark point # mark_point,mark_point #-- plot border edges # if border then begin # !p.multi[0]=sp # oplot,xedge,yedge,thick=bthick,color=bcolor # endif #-- save last settings if not over: last.update({'xrange':dxrange}) last.update({'yrange':dyrange}) if not last['scale']: if log: prange = 10**prange last.update({'drange':prange}) if not rtime is None: last.update({'time':rtime}) else: last.update({'time':otime}) if not curr_roll is None: last.update({'roll':curr_roll}) if not curr_rcenter is None: last.update({'rcenter':curr_rcenter}) if b0: last.update({'b0':b0}) if l0: last.update({'l0':l0}) if rsun: last.update({'rsun':rsun}) if not icenter is None: last.update({'center':icenter}) if rolling: last.update({'roll_correct':True}) if shifting or rolling: if valid_map(saved_map): map = saved_map axis.set_aspect('equal','box') # Repeat this call, because somehow it is getting overridden # Write any changed information for the next call. fp = open(common_file,"wb") pickle.dump(last,fp) fp.close() sleep(0.1) return
peaks_string = 'NULL' else: peaks_inds, props = find_peaks(flags_pooled, height=peak_threshold, distance=pool_window / 2) peaks_times = start_point + peaks_inds * fps peaks_string = ';'.join([str(x) for x in peaks_times]) if _debug: #%% plt.figure() plt.plot(flags.mean(axis=0)) plt.plot(flags_pooled) plt.plot(peaks_inds, props['peak_heights'], 'xr') plt.title(key) #%% if len(plt.get_fignums()) > 100: break basename = basename[:-8] row2save = (basename, start_point, segment_size_seconds, peaks_string) rows2save.append(row2save) if not _debug: df = pd.DataFrame( rows2save, columns=['basename', 'start_point', 'segment_size', 'events']) df.to_csv(save_name, index=False)
def saveAllCurrentlyOpenedFigures(): for cntFig in plt.get_fignums(): saveNameForPNGHelp = plt.figure(cntFig).canvas.get_window_title() saveNameForPNG = saveNameForPNGHelp.replace('.sav', '.png') plt.savefig(saveNameForPNG)
def saveAllCurrentlyOpenedFigures(): for cntFig in plt.get_fignums(): saveNameForPNGHelp = plt.figure(cntFig).canvas.get_window_title() saveNameForPNG = saveNameForPNGHelp.replace('.sav', '.png') plt.savefig(saveNameForPNG)