sda.plot.fplotanalyzer ====================== .. py:module:: sda.plot.fplotanalyzer .. autoapi-nested-parse:: Created on Wed Dec 03 15:26:27 2014. @author: Erwan Pannier Plot any format of data immediatly GUI feature : - drag and drop text files in the box - they are plotted immediatly Features to implement : - if drag&drop several files then plot all of them on the same graph? - loadany ne marche pas si j'importe un fichier Lecroy avec des espaces au lieu de ',' # Do some test runs on standard plots Known bugs : - lastx is taken from figure : if x is resized during the plot (ex : s * 1e9 -> ns) then lines won't be plotted on the same figure. Should we create a SmartFigure class with "apparent x" and "real x" ? - TODO : titles should appear as header if multifile and header is None. Then keep the folder as title. - TODO : check that FastPlot is working if no X in input - TODO: script version. fplot %file or fplot %folder Classes ------- .. autoapisummary:: sda.plot.fplotanalyzer.utype sda.plot.fplotanalyzer.Analyser sda.plot.fplotanalyzer.FileListWidget sda.plot.fplotanalyzer.Interface Functions --------- .. autoapisummary:: sda.plot.fplotanalyzer.plotany sda.plot.fplotanalyzer.long_substr sda.plot.fplotanalyzer.is_substr Module Contents --------------- .. py:class:: utype(label, corrfactor=1.0) .. py:attribute:: label .. py:attribute:: corrfactor :value: 1.0 .. py:class:: Analyser(filename, plot=True, lastfig=None, norm=False, verbose=False, warnings=True) Methods to guess what kind of data we are looking at, and plot it. .. py:attribute:: verbose :value: False .. py:attribute:: warnings :value: True .. py:attribute:: normalize :value: False .. py:attribute:: plot :value: True .. py:attribute:: filename .. py:attribute:: lastfig :value: None .. py:attribute:: known_typex .. py:attribute:: known_typey .. py:attribute:: typex_family .. py:attribute:: header :value: None .. py:method:: analyse() Run the data analysis. Also create self.fig when plotting .. py:method:: apply_known_format() Update self.typex, self.typey. May change self.header, self.data too in very special cases (first row of data appears as non-explicit legend. .. py:method:: magnorder(a) Return average and maximum order of magnitude of the signal. .. py:method:: let_guess(guess, guessin) If guess were restricted to the list 'guessin' because of the file. format, then make sure the guess is in the list. If not restricted list, then accept. .. py:method:: guessx(x, guessin=None) Guessin : to limit the choices available. .. py:method:: guessy(y, guessin=None) Guessin : to limit the choices available. .. py:method:: get_figure(x, lastfig) Plot the new line on the same figure as previous plots. Plot if : - xdata was analysed to be the same datatype - or, if x is exactly the same. TODO : xdatatype is to be guessed from xlabel from the previous fig. It could be interesting to create a new class derived from Figure containing directly the real data, apparent data, and datatype. .. py:method:: getData(filename) .. py:method:: look_for_header_row() In some data set the first row / column may be used as an unformal. (= correct data type) header. In this function we detect this kind of row / column, fix the data and return the header file. .. py:method:: getLabel(filename) .. py:method:: scalex(x, typex) .. py:method:: scaley(y, typey) .. py:method:: plotData(data, label, header, lastfig=None) Plot the data. TODO : when adding several data, make sure x matches and update ylabel and title correctly. .. py:class:: FileListWidget(parent, verbose=True, norm=False) Bases: :py:obj:`PyQt5.QtWidgets.QListWidget` .. py:attribute:: verbose :value: True .. py:attribute:: normalize :value: False .. py:method:: dragEnterEvent(event) .. py:method:: dragMoveEvent(event) .. py:method:: dropEvent(event) .. py:method:: add_files(files) Add all items contained in files. Analyse and plot them. If 2 files, try to compare them. Else, just plot everyone one the same graph if possible .. py:method:: analyseData(filename, lastfig) Analyser and plot process. .. py:method:: clean_layout() Remove the common part not to have too huge titles. Add a legend if several graphs. # Todo: replace by remove common prefix / common suffix .. py:class:: Interface(verbose=True, norm=False) Bases: :py:obj:`PyQt5.QtWidgets.QWidget` Start interface for drag & dropping files in. .. py:attribute:: verbose :value: True .. py:attribute:: normalize :value: False .. py:attribute:: heights .. py:attribute:: lbds .. py:method:: initUI() .. py:method:: listItemRightClicked(QPos) .. py:method:: plot_files(files) External function to plot files directly from the command line. .. py:function:: plotany(datafiles) .. py:function:: long_substr(data) Longest common substring from a list of strings. Code taken from: http://stackoverflow.com/questions/2892931/longest-common-substring-from-more-than-two-strings-python. .. py:function:: is_substr(find, data)