Python used for calculators/converters. - Page 1
Forum section: electronics / general

author: mendip_discovery
author_rank: Super Contributor
timestamp: July 07, 2023, 05:24:32 pm
content: <coat="flameproof">I have never been a coder as such. More of a tinkerer, as I can work out some code and mod it for my use. I just don't have a coding brain, some argue I am brain free. I also like maths though I never really learnt much of it at school and didn't do any at college my understanding is limited at times.Anyway, I am messing around with Python and Jupyter. I would like to use it for doing some maths. I know you can get a lot of these sites that will do the calculation for you but I always have an edge case that means I end up using Excel for it. Before I go faffing about making these up are there any published gits or sites for it?For example PT100 and K-type maths. But I also need to do stuff for sine bars, water ml in g etc.

author: RAPo
author_rank: Super Contributor
timestamp: July 07, 2023, 05:33:25 pm
content: It is even the standardPython distrib.For k-type, lookhere.

author: mendip_discovery
author_rank: Super Contributor
timestamp: July 07, 2023, 05:43:24 pm
content: Quote from: RAPo on July 07, 2023, 05:33:25 pmThe PT100 one looks to only be a table lookup but that was just a cursory scan of the code.The thermocouple one looks nice.

author: radiogeek381
author_rank: Regular Contributor
timestamp: July 16, 2023, 05:57:48 pm
content: Python has become my general-purpose desktop calculator. If I know I'll be in a session for a while, or if the calculations involve vectors or data files, I'll fire up a Jupyter session.And mendip_discovery's comment about the availability of libraries illustrates an important point: no matter how weird your requirement is, there is a good chance someone has written a python library for it. Some are pretty good, others passable, and some are awful. But it is still better than starting with a flat rock.

author: mendip_discovery
author_rank: Super Contributor
timestamp: July 16, 2023, 07:36:04 pm
content: I use online calculators and I also do a fair bit in excel. But it's hard to show how I worked it out and the formula it came from.I am teaching myself LaTEX for the formulas.For work I have had to do maths for measuring thread pitch diameters using cyclinders, and also taking into account for rake and compression. That put my in maths meltdown for a while. In excel it's ok but would be nice to use it as a function.Last week I had to convert a pressure gauge that measures in tons to psi knowing the piston size is 75mm. All doable online but I always fear the online stuff will disappear the next time I need it. Plus many of them fail to explain how they get there so I cant be sure the numbers are correct.I will go ahead with my plans. I just will put them on github for the next person who has to do the same maths. Hopefully it will help the next idiot who has to workout stuff.

author: eugene
author_rank: Frequent Contributor
timestamp: July 17, 2023, 02:02:03 pm
content: There are lots of ways to do what it seems like you want to do. I tend to use Octave for a lot of things, because no matter how hard I try, I just can't grow fond of Python. But that's just me. I know several PhD'ed researchers that use Python for almost everything, and others that accomplish heroic feats in Excel. It all depends on where you feel comfortable.

author: RoGeorge
author_rank: Super Contributor
timestamp: July 17, 2023, 02:51:39 pm
content: Quote from: mendip_discovery on July 16, 2023, 07:36:04 pmMy understanding is TeX is the typesetting language, while LaTeX is the language together with some predefined things, like it would be C plus the standard libraries. For formulas only, it is not needed to learn TeX. There are online helpers that can tell you the syntax, help you to find a certain symbol, and so on.This post has a link with more examples than needed for formulas:https://www.eevblog.com/forum/beginners/how-does-posting-math-notation-work/msg3994178/#msg3994178EEVblog forum supports MathJax, a LaTeX like syntax but not the full TeX language.About Python vs a spreadsheet like Excel or Calc (Calc is the spreadsheet application from the free office package LibreOffice, compatible with Excel), or spreadsheet vs Matlab (Octave is the free Matlab, also compatible) use whatever comes natural to you.A spreadsheet would be easier to draft some calculations for a one go, Python or Octave will be more powerful but will require more effort.The spreadsheet wins for draft calculations, because you can see the result "live". You type the input number in a cell, hit enter, and in another cell you see the result instantly, all under your eyes and at known positions on the screen, easy to comment about them in a nearby cell, to color them, plot a chart with a couple of mouse clicks, to save all for later, and so on.When it comes to more elaborated data analysis, then Python (or Octave) is the right tool.

author: abeyer
author_rank: Frequent Contributor
timestamp: July 17, 2023, 09:07:10 pm
content: If you're using python for the calculations, you can also generate the LaTeX for an annotated function w/ google's latexify:https://github.com/google/latexify_py

author: bpiphany
author_rank: Regular Contributor
timestamp: July 18, 2023, 08:24:47 am
content: For those with an affinity for python and spreadsheets, try pythonandspreadsheets. I haven't tried it myself, but I have a friend who keeps raving about it.https://en.wikipedia.org/wiki/Pyspread

author: RAPo
author_rank: Super Contributor
timestamp: July 18, 2023, 09:23:49 am
content: Don't tell them a disaster waiting to happen.Quote from: bpiphany on July 18, 2023, 08:24:47 am

author: RoGeorge
author_rank: Super Contributor
timestamp: July 18, 2023, 09:50:53 am
content: Behind any office software package, there is a backend programming language already, usually accessible to the end user (without installing anything extra, and for free even in Excel) with all the classes that were used by developers, which means it can easily handle object from a spreadsheet, like cells or values, etc.Usually it's as easy as hitting ALT+F11 in a spreadsheet, to open a code editor and start writing your own programs.For Microsoft Office products (including Excel) the programming language is VBA (Visual Basic for Applications). It is not unusual to see a spreadsheet as a GUI for one's own programs. That's an unexpectedly powerful technique (for those fluent in VBA), just look at this 3 minutes demo:Excel MagicEngineeringFunThough, would be nice to have a spreadsheet with Python as the backend language.Or at least to evaluate Python code in each cell, instead of just a spreadsheet formula.

author: abeyer
author_rank: Frequent Contributor
timestamp: July 18, 2023, 07:49:54 pm
content: Quote from: RoGeorge on July 18, 2023, 09:50:53 amhttps://www.xlwings.org/

author: RoGeorge
author_rank: Super Contributor
timestamp: July 19, 2023, 05:40:27 am
content: Something like that, from their demo videos xlwings looks very promising.Would have give it a try, unfortunately I don't use Excel, nor Google Sheets.

author: bpiphany
author_rank: Regular Contributor
timestamp: July 19, 2023, 12:05:15 pm
content: Quote from: RoGeorge on July 18, 2023, 09:50:53 amQuote from: https://pyspread.gitlab.io/manual/basic_concepts.htmlQuote from: RAPo on July 18, 2023, 09:23:49 amQuote from: https://pyspread.gitlab.io/manual/basic_concepts.htmlBasic Concepts | pyspread

author: eugene
author_rank: Frequent Contributor
timestamp: July 19, 2023, 08:33:36 pm
content: Everyone should know enough not to run an Excel sheet with macros unless written by someone you know and trust. The same would be true of sheets written for pyspread.