Jupyter Notebooks & Photon Budgets

Feasibility Analysis / Photon Budgets

When making a measurement the first questions you need to ask are:

  1. What are we measuring
  2. How can it be measured
  3. Is the measurement possible
  4. How good can we get

The order is only for the first iteration of thinking. As with all complex systems, feedback and iteration must exist. A good starting point is doing a basic pass through on a white board or the back of a napkin at lunch. There are always a few spherical cows and references to first order perturbations. The first pass can raise concerns and quantities that can need to be measured or estimated (hopefully both). After a first pass when you’ve figured out what paths you are pursuing it is useful to do a formal analysis which is known generically as a feasibility study/analysis and as a photon budget in some circles for optical measurements.

Example Use Case

The photon budget isn’t usually the final document for the measurement, it’s the map for a specific avenue of investigation. I was recently working on one for a silicon thermopile measurement in a factory application. We had taken some data but getting exhaustive information was dangerous, expensive, and probably statistically impossible. Instead I put together a rough simulation for the signals that we could expect and what the background would look like. I then tested the simulated results with the data already gathered. As the generated results were able to reproduce the measured data (to within a margin of error), we moved forward with the simulations as the basis for the pilot study. One unexpected benefit was being able to quickly reject different installation schemes. Having an acceptable model allowed for fast evaluation of different configurations. A bit of math could save a significant amount of time and resources. This simulation was nothing very special, the entire model fit in 75 lines of python.

This is a simple example that avoids some of the more subtle uses for a detailed photon budget such as noise analysis. That is arguably a more powerful area of focus and deserves its own description. This focus is on the tools.

Reports & Tools

My typical approach since university has been to write reports in LaTeX with plots generated from other sources, and saved in a common images file. This typically involves a separate source code for the images all tied together with a Make file to ensure the document is always up to date. This gives fine control over the look of the document but runs a huge risk for getting bogged down in the look instead of the material and the complexity of the build system. This approach uses 3+ ’languages’ spread over 3+ source files.Trying to collaborate is difficult. Other approaches using word processors only gain simplicity by doing away with the automatic build environment.

Writing in an environment with clutter is challenging, forcing the writer to deal with issues unrelated to the content. I’m told this is why typewriters are still used. Markdown is a great choice for a simple, uncluttered way to focus on writing, the complexity is similar to a typewriter. A program like Pandoc will generate just about any document format from it (even .doc & .docx). In the language of design patterns the view can be separated from the model. However the issue of the disparate source files and a cohesive build environment persists.

The aim is to have the build environment, source code, and report self contained as when writing an engineering notebook. The build system is integrated into the tool and the source code is inline with the report. Separate views can be written using templates as needed. Continuing to use the Model-View-Controller allegory, the business rules are not changed when the view changes. Enter MathCAD and Jupyter notebook.

One solution is MathCAD, this is what it was intended to do, write fully featured digital engineering notebooks. I’ve used older versions and can only assume the new versions are better still. On the open source side we have Jupyter notebook which I have found to be useful.

The Jupyter Notebook documentation is well written so worth looking through: https://jupyter-notebook.readthedocs.io/en/stable/notebook.html.

I’ve added an article with some of the settings I use for my Jupyter reports here.

Resources

Examples

Resources