# How can I model an optical filter using python?

Say I have an RGB LED which transmit intensity modulated signals, at one symbol transmission I want to send a symbol with all three chips.. Can I just model three bandpass optical filters like RF filters to filter out the individual intensities impinging the PD? I can't seem to find any design procedure on optical filters.

Basically I want to use color shift keying (CSK) to modulate the data symbols into the LED chips and be able to detect the CSK data symbols on the receiver side (as defined by the IEEE 802.15.7-2018 standard). On the transmitter side I am able to modulate (using python) the symbols but however I do not know how to model the RGB filter and I don't really understand the optical filter design process. Some details regarding CSK can be found at [ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=7482661]

Any direction to relevant literature is appreciated.

• What exactly are you trying to achieve? Are you trying to use three separate optical wavelengths for three separate communication channels? – jonk May 26 '20 at 18:11
• At one symbol transmission I want to send a symbol with all three chips. Basically I want to use color shift keying (CSK) to modulate the data symbols into the LED chips and be able to detect the CSK data symbols on the receiver side (as defined by the IEEE 802.15.7-2018). On the transmitter side I am able to modulate the symbols but however I do not know how to model the RGB filter and I don't really understand the optical filter design process. Some details regarding CSK can be found at [ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=7482661] – Supremum May 26 '20 at 18:35
• Thanks. That provides a lot more information than before. You should probably include all that information in your question, rather than expecting people to find it in the comments below. What you are on about is quite sophisticated and, given the article you link to, I'd say well beyond the capacity of a proper answer here at EESE. Multiple sub-disciplines are involved and one needs to be well versed in all of them (or have a team that is collectively well-informed) in order to continue that subject of research. It's cool stuff, though. No doubt. – jonk May 26 '20 at 18:41
• I've done a lot with optical filters, though more with thin film used in a bichromatic optical head used for phosphor thermometry (the energizing wavelengths are different from the phosphorescent return wavelengths.) I also have worked on RGB LEDs for a large manufacturer, OSRAM, doing binning and calibration using spectrophotometers. So some of what I know might apply here. But I'd need to do a lot of study of the work going on there before I could offer anything truly useful. You may need to narrow your focus if you want to post a question here, breaking things into manageable parts. – jonk May 26 '20 at 18:43
• @jonk I will edit my question to be more specific. What I am really interested in right now is the design procedure for optical filters. I was merely linking the paper because it does have some information regarding CSK modulation which use RGB LEDs. – Supremum May 26 '20 at 18:58

Yes, you can.

There are a great number of parallels between (certain) microwave filters and (certain) optical filters based on impedance concepts. This section of a video can illustrate this: https://youtu.be/pLl3q6WKtxw?t=2346

Both optical and RF signals and filters can be modeled with complex amplitude/phase responses VS frequency, and so you can use all the same mathematical ideas to model the impact of both in the same way.

Probably the simplest way to do this is to work in the wavelength (frequency) domain. You'll need the transmission curves for the three filters, the response curves for the detectors, the wavelengths/spectra of the LEDs, and some sort of background noise spectrum. Then, you can chain the components together - add the scaled spectra of the LEDs and the noise, then do a point by point multiply of that with the filter responses, then do a point by point multiply with the photodiode response, and finally sum all the elements to get the final output of the photodiode.

The Mueller optical calculus is well suited to handling this kind of problem, since the LEDs are intensity modulated. Using my optical calculus software, here is a simple computer simulation that assumes three independently modulated red, green and blue LEDs, three separate bandpass optical filters and one photodiode followed by a transimpedance amplifier:

This is my screenshot of my simulation program. It is not a drawing.

In this simulation, I assume that the wavelength space is discrete, consisting of 401 colors: 400 to 800 nm, in increments of 1 nm. The simulation runs from t = 0 to t = 1.6383 s, in increments of 0.0001 s. (This was to facilitate doing a 16k DFFT at the end of the simulation.) I used the following (not so realistic) LED spectra in the LED "light bulbs" in the simulation:

This is my screenshot of the LED spectra. The LED intensities are arbitrarily scaled and are purely synthetic: I did not have real digitized spectra available. These could trivially be replaced with real LED spectra: it is just an import of ASCII text files. The photodiode responsivity is shown by the black trace, with scale on the right. The units are A/W.

For the bandpass optical filters, I synthesized the following deliberately overlapping transmittance spectra:

This is my screenshot of the filter bandpass spectra and the photodiode's responsivity. For convenience, the photodiode responsivity is repeated: shown by the black trace, with scale on the right.

Only a small amount of noise was added: 10 $$\\mu \$$V electrical noise after the preamp and 0.01% optical noise on each of the three color channels. The transimpedance was 10 k$$\\Omega \$$. There is no difficulty in adding noises. Rather, the difficulties are in knowing what noises to add, how much of each one to add, and where to add them. This is not trivial.

The two mirrors and two beamsplitting cubes were specified as being ideal, though that is not required. The three LED modulators are simply producing unipolar squarewaves at 100, 175 and 375 Hz.

When the simulation runs, which takes just over one minute, the voltage output is as shown below:

This is my screenshot of the temporal output, from the little oscilloscope. You get this when you double-click on the oscilloscope block.

The PSD is computed at the end of the single simulation and is shown below on a linear-linear scale:

This is my screenshot of the power spectral density output, from the little PSD block. You get this when you double-click on the PSD block.

The three fundamental frequencies, i.e., 100, 175 and 375 Hz, are clearly present, along with several squarewave harmonics.

In the above simulation, it was assumed that the LED emissions were unpolarized, but the full Mueller calculus was used anyway because there was nothing to be gained by simplification of the Mueller matrices and Stokes vectors.

So where is the math? Actually, it is all done in the blocks. An optical calculus is really just a little bit of linear algebra. For any one color, a Stokes 4-vector arrives at the input to a block, gets left-multiplied by the block's resident 4x4 Mueller matrix, and then the resulting Stokes 4-vector is sent out. For any given time step in the simulation, all Stokes vectors arriving at a given block are processed at once: an arriving stack of Stokes vectors is left-multiplied by a resident stack of Mueller matrices, producing an outgoing stack of Stokes vectors. See the Addendum below for the stack exchange format for the optical calculus blocks.

All this is intentionally invisible to the user, unless they happen to want to look at the commented source code. In that case, they would place the cursor on the block, hold down the option key, and double-click. Then the full commented source code, and all the rest, would be available for inspection, modification, etc.

However, if the light is unpolarized, then simplification is very simple: the situation is exactly as alex.forencich stated in his answer. The special case equations are then like this:

These are the equations I constructed using MathType and annotated with Keynote (all on a Mac). Here, i indexes the N+1 discrete colors, j indexes the evenly spaced simulation times and k indexes the three color channels. I do not know Python, but maybe this all will help a bit when you get to the programming.

The software I used consists of a commercial simulation program (Extend 6.0.8, from Imagine That, Inc.) together with my own free libraries of add-on blocks (named LightStone, my punning play on "optical calculus"). Unfortunately, as I found out fairly recently, my free libraries of blocks, developed and evolved since 1990, no longer work with the current ExtendSim program (versions 10 through 10.0.6). But they work fine with older versions of ExtendSim, e.g., ExtendSim 9.2 on a Window 10 PC. I hope to get this resolved because I have 30 years riding on it.

Addendum: The format for optical block stack exchanges, i.e., outputs and inputs of stacks of optical vectors, is shown in the next figure, which I drew about 25 years ago using (long dead now) Canvas 5.0.3:

My avatar happens to be the right hand side of Fig. 7. In this answer, there are 401 rows, i.e., discrete wavelengths. Since Mueller calculus is used, only the first column is used, i.e., the Stokes vector. Since the light is unpolarized, only the top element in the Stokes vector, i.e., "a" in the figure, is used. Of course, this is the light intensity element and it is both time and wavelength dependent: in Fig. 6, it is labeled as "Modulated LED intensity".

So it is stacks of optical vectors that are passed from optical block to optical block, kind of like this little animated cartoon GIF I made many years ago:

In actuality, the cartoon is a little misleading because stacks pass completely with each simulation time step. But it makes the important point that three dimensional arrays are passing, not just single real numbers.

• Please provide links or citations for the graphics you copied into your answer...it doesn't look like they came from the Wikipedia pages you linked. We want to be sure to give credit to the original creator of the art. – Elliot Alderson May 28 '20 at 20:58
• They are screenshots from my software! I will edit the answer to say that I created each one! – Ed V May 28 '20 at 21:01
• @EdV this is really insightful. I will look into all the aspects you have outlined in your answer and I will revert back if I need any clarifications after doing some reading. – Supremum May 29 '20 at 14:57
• Two of the optical calculus references I used when I invented my software are at my answer here. Feel free to ask if you want to and thanks for the upvote: I upvoted the other two answers and your question already. Upvotes on this stack exchange are not easy to get: it is a fast crowd! – Ed V May 29 '20 at 16:42