Code Monkey home page Code Monkey logo

data-analysis-graph-plotter's Introduction

data-analysis-graph-plotter

This code is a GUI wrapper around polyfit and scipy curve optimize to easily allow users to plot polynomial and custom law graphs. The code gives values for fitting parameters with uncertainties and reduced chi squared values for data analysis and comparison with theory.

This code allows users to easily create their own plots of experimental data for polynomial fits or for custom laws defined by the user. The code is fully GUI based for simplicity to use. If you are using the anaconda distribution of python (the default for UoM physics) then you do not need any extra library instillations you wil be able to run the code straight away.

Image of UI

Above is an example of the default window you will get when running the code. First a data file needs to be specified, this can be done by copying and pasting the directory where the file is stored then adding \filename.txt or \filename.csv to the end of it depending on which format your data file is written in.

Next you can specify an output directory, this is where the graph that is plotted will be saved to automatically. As before just copy and paste the directory you would like the file to be stored in but do not add anything to the end of this one, titling will be done automatically. If you do not specify an output directory the file will be saved in the same directory as the code.

Next there are three entry fields, these will add the title to the graph, the x-label to the graph and the y-label to the graph respectively. For these just enter the text string that you wish to be displayed on the graph. The output file will be named as [graph_title].png in the directory specified.

Next you can choose between a polynomial fit or custom law fit, just click on whichever one you want and the radio button will change to the one you have clicked.

If you are using a polynomial fit then the next thing to specify is the highest power of x you want to fit the graph to. For example if you wanted to fit a quartic graph just type the number 4 in and it will fit a graph in the style ax^4+bx^3+cx^2+dx+e. If you want to get the gradient of the fit at a specifica x value then type this x value in the entry field below. For example if you want the gradient at x=5 just type 5 in this box. Only do this if you are fitting a graph that is not linear as a linear graph will give the gradient of the whole line by default.

Custom Formatting

If you are using the custom law fit you instead need to specify an equation to fit to. If you do not understand how to do this then click the custom help button below for more detailed information and a video outlining how to do this or see the image above. The equation already has y= which can be seen in the label, therefore you just need to type an expression in terms of x in the entry field. An example can be seen above for Malus' law. Next some fitting parameters need to be specified, these are constants that the code is allowed to adjust for optimising the fit. It can be seen that this example uses I0 and phi for the fitting parameters. In the experiment I0 was a value of light intensity (as a voltage reaction) without any polariser in front which was measured to be 3.6V hence a guess value was put in as 3.6. There was no predicted phase shift in the values so a phase shift parameter was put in with a guess value of 0. The guess values do not need to be exact, as long as they are in similar order of magnitudes to the true values. You will be able to tell from the graphs if it has not optimised far enough as the fitting line will be too far from the data, if you over estimated your parameter it could be above the data and if you underestimated it could be below so you will know which way the guess needs adjusting. It is unlikely you will be far enough away to require this.

When you press the plot button if there is anything wrong with the inputs you have specified you will get an error mesaage explaining why it has not worked and how you could fix it. If you have no errors then the graph will plot and display in a new window. The graph will be interactive, if you only want to focus on a certain range you can enhance it using the buttons at the top of the graph window to interact with it. This graph has been automatically saved to the output directory specified earlier, if you want a copy of zoomed in or edited range then when the graph is how you want it you can press save at the top of the graph window to get a copy of that version. If you look back to the main window after plotting a graph all of the fitting parameters will now be listed below the plot button and can be written down to go with the corresponding graph.

Three test data files have been included to practice using this code with, one of these is made up linear data, one of these is made up quadratic data and one of these is real custom mode data. The real custom data is fit with Malus' law as shown in the images above.

Advanced styling options are a new trial feature where the user can enter some extra styling options for their displayed graphs. These are not yet fully error handled so if your graph fails to plot after using them you have entered an advanced option incorrectly. All but one of these has links to documentation to find available options for that styling parameter, the one that doesn't just takes a number as input for a marker size. No documentation is available for this hence the lack of a link.

data-analysis-graph-plotter's People

Contributors

utting98 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.