Skip to main content

Python Package with tools for Undergraduate Physics Laboratory

Project description

LabPartner - A Tool for Undergraduate Physics Students

PyPI package version number Actions Status License

Struggling with Lab? Me too!

Over the course of my undergraduate studies at the University of Manchester, UK, I had three years of lab. Now, as someone who teaches those labs alongside my PhD, I thought it would be useful to automate some of the more painful parts of lab, so the students can just focus on understanding the physics and assessing their results.

This Python is Package can:

  • Apply Linear and Quadratic ANY fit to Data, and Plot Results
  • Propagate Errors for all functions

It is important to acknowledge that there are other similar, very useful tools (OriginPro, LSFR, your own code). I just wanted to try making something that works as an all-in-one system, effectively acting as a Lab Partner!

Installation

To install this package, simply type:

pip install labpartner_uom

PyPI might use labpartner-uom, but this command does the same. Someday I hope to remove the '_uom'!

Usage

Data Analysis and Plotting

There are a few presets which allow you to auto-analyse your results.

import labpartner_uom as lp

# For data arrays
lp.analyse(x, y, yerr, fit="Linear")

# For data in .csv files
lp.analyse_from_file(filename, fit="Linear")

# Example with specific labels
lp.analyse(t, d, derr, fit="Quadratic", xlabel="Time (s)", ylabel="Distance (s)")

This should print the results of the fitting, as well save a .png and .pdf of the plot.

Options of fits include: Linear, Quadratic, Gaussian, Exponential, Logarithmic, Sine, Cosine and more! You can also add your own functions to fit:

lp.analyse(x, y, yerr, fit="a * exp(b * x) * sin(c * x) + d")

Error Propagation

To propagate errors, simply write up the function and the variables which have uncertainties.

import labpartner_uom as lp
prop = lp.errorpropagator.propagate_error(func, vars)

# Example
prop = lp.errorpropagator.propagate_error("A*x**2 + B*y + C", ["x", "y"])

Examples

I have given some full examples on how to use the code for a lab experiment. The first example contains a simple analysis, while the other is for free and forced oscillations, a lab I demonstrated.

You can find these examples here

Advanced Usage

The guide above gives you a quick result. However, there is more for advanced users:

  • Customisation of Plots
  • Fitting without Errors

You can find more details on this in more-stuff.md


Siddharth Sule, 2024

Based On Tom Chen's Example Package: https://github.com/tomchen/example_pypi_package

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

labpartner_uom-1.0.4.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

labpartner_uom-1.0.4-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file labpartner_uom-1.0.4.tar.gz.

File metadata

  • Download URL: labpartner_uom-1.0.4.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for labpartner_uom-1.0.4.tar.gz
Algorithm Hash digest
SHA256 ac62e1ece6fc5e7301dc2a553c53d2f8b95b5456c636432e6029ef6c2214d3dc
MD5 5059d52608ba2f6c06a1108d971f51f0
BLAKE2b-256 5e363afe179a56cdabff5f07dff79921bf38f10c21d0d374307ab37088aa5451

See more details on using hashes here.

File details

Details for the file labpartner_uom-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for labpartner_uom-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bea397764c3e505b2f84fdbb83c592c9947c4c9f804710796382b82fcf79cd7b
MD5 141cf3dbe75dd64af506d5f5b6b54d37
BLAKE2b-256 d5199daff905ec70429b8b524402bb91db6dc43e7de417f12f506d379d97a608

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page