Thursday 5 September 2019

Twilight Photometer Part II - Analysis

This is a followup to the earlier post that described the construction of a Twilight Photometer. In this one, I'll describe the setup and analysis.

The basic idea is that as the sun sets, or rises, it sweeps a beam into the atmosphere that illuminates a segment of the sky above the photometer. By analysing the gradient of light changes directly above the photometer and calculating the sun shadow height it is possible to reveal the presence of any high altitude aerosols. The following diagram, from the original article, shows the theory of it:



In the original article, Forest Mims provides a spreadsheet that he uses to analyse the data. Based on this and a similar one from the NOAA I created a Python module to do the solar calculations.  The calculations are quite intricate but it's fascinating to see how given the date and latitude and longitude it's possible to calculate the sun shadow height (and a lot of other interesting things such as sun azimuthal angle and sunset time). I have a series of Python scripts which work together to:

  1. Download the data as a CSV file from the Photometer
  2. Add the observations to an SQLite database
  3. Generate the plots of shadow height vs intensity and intensity gradient.
The Python scripts are available on GitHub

In general, it all works pretty well and, as I hoped, it's more flexible than the spreadsheet allowing experimentation with different types of data smoothing and generation of plots for data from multiple days of sunset or sunrise recording.

Once I started generating plots I was pleased to see they followed the same general shape as those reported by Mimms. The first problem, however, was that the photometer seemed too sensitive, being at maximum intensity even sometime after sunset. So the plots look something like this: 

With the first 10 or so km missing because it's on maximum intensity. 

I'd used 40 GOhm resistors in the amplifier and even with the link removed to only use one it was still perhaps too sensitive. So I soldered an additional 40GOhm resistor over each one in order to halve the resistance:




This seemed to help but I also needed to extend the tube above the LED with a longer piece of brass tubing and an extra piece of black heatshrink tube I could cut. Then I could adjust it so that just before sunset it would be just below the maximum intensity. To help with the adjustment I added a Serial LCD to show the current intensity. This turned out to be a lot more complicated than I'd hoped since I was already using a fair amount of memory and using the SoftwareSerial tipped it into the region where it could no longer open a file on the SD card. I ended up trimming down as much memory usage as I could and moving to the Send-Only version of SoftwareSerial and SDFat library rather than the standard SD one. These savings freed up enough memory to allow the logging to work.

Eventually, I got the sensitivity about right for both sunset and sunrise recording. Here's a typical set of graphs from a fairly clear morning:





As expected the intensity graph gets noisier as the sun shadow is higher because the sky is still quite dark at that point and the signal generated by the LED is weak. 


What I have realised is that there may, in fact, be a limited application for this type of photometer given my location Mims notes that you really need at least one timezone of clear sky along the sun's azimuth at sunrise and sunset. For me, in Christchurch NZ, that's about halfway across the Tasman sea for sunset. Getting that level of clarity might be common in Texas, it's not so much here in the South Pacific. Here's the satellite image for the morning the above graphs were recorded:



You can see that it was clear above Christchurch but to the East, along the sun's azimuth of (60deg)  there were some significant clouds which probably explains the high altitude disruption. Very often I've recorded graphs like this:




There will be days that have sufficiently clear skies but it's likely to only be when there is very significant high pressure to the east or west of my position. That means that the useful data will be recorded mostly for a single type of climatic condition, and a relatively rare one at that.

In any case, I'm still keeping an eye on the forecast, hoping for clear skies and recording when it looks promising. I'm hoping to build up something of a baseline over the winter and perhaps when it's bushfire season in Australia I'll start to see evidence of high altitude aerosols.








Monday 29 July 2019

Twilight Photometer Part 1 - Construction

I'm a big fan of Forest M. Mims III.  Not only has he published some excellent reference books such as his charmingly hand-drawn Engineers Notebook, he very much represents the best of what's possible with Citizen Science. Mimms was one of the first to realise that light-emitting diodes (LEDs) can act as photosensors as well as light emitters and he has created some ingenious applications of this. A lot of what Mims promotes are simple, but rigorous observations. Even such things as measuring the 'temperature' of the sky with an IR thermometer or simply taking a photo in the same place at noon each day, provide a surprising amount of useful data. With simple equipment and careful observations and analysis, Mims shows that we can all do interesting science.

A few years ago he wrote a couple of articles in Make Magazine about Twilight Photometry. These really caught my imagination - the idea that what was essentially an LED pointed into the sky being able to detect aerosol layers tens of kilometres up seemed fascinating.  Of course, the Devil is in the Details and there are some important considerations to get this to work.  It's taken some years to get around to it but I've finally found the time to get started on this project.

The keys parts of the photometer are simple - a circuit to amplify the tiny current created by the LED as it points at the twilight (or dawn) sky. To do this requires a low noise amplifier with a very high gain circuit. This requires resistors in the GΩ range. These are by far and away the most expensive resistors I've ever purchased at $10 each!

Following the schematic in the Make article and Mim's related book, I used KiCad to design and layout a small PCB. The files for this are available on GitHub.

























Mims suggests that the LED, capacitor C2 and resistor R1 should be soldered directly to input,  pin 2 of the TLC271 in order to reduce noise. I'm hoping that because I'm on a "proper" PCB with a ground plane that it will be sufficient to just use the PCB connections as normal. I can always re-engineer it if the noise is a problem.

I followed Mim's suggestion to install everything in a metal enclosure and to make the LED mounted in a removable fitting. In my case, I used a metal 6.5mm phono plug which holds a LED and a piece of brass tubing (with some black heat shrink extension) as a collimator quite nicely.  I've set up both red and infra-red LEDs in phono plugs and these can be swapped out.

Data is collected using an Arduino and the excellent Adafruit Datalogger shield which contains both an SD card and a Real-Time Clock. Like all Adafruit products, it's well documented, robust and well-thought-out. As an interface between the output of the amplifier, I used the 16-Bit, 4 channel ADC also from Adafruit. This is an I2C device, easy to use and seems accurate. Since I'm running everything off 5V (supplied by the Arduino) there's not a lot of voltage range but hopefully, the 16bit ADC (running at 0.0635 mV resolution given the 2V full range setting ) will be sensitive enough.

The code for the Arduino is here. It's pretty straight-forward, several readings are taken for each channel and averaged giving a recording time of about once every second. One notable thing is I added the ability to download the datafiles (YYYYMMDD.CSV)  from the SD card over a serial connection to my laptop which saves constantly having to open up the enclosure and get the SD card out.


Here are some photos of the final enclosure:



Since there are three "unused" channels on the ADC I've added three additional LEDs (each in clear housings) attached to those channels as described in "Atmospheric Monitoring with Arduino". I did a test of various LEDs - using an RGB LED to generate various colours and measuring the response.




The response curves are not ideal as clearly a couple of them are saturating fairly easily but it seemed blue, yellow and red gave the best spread so I've used those. Daylight photometry is kind of tricky since there tends to be shade from ground features and clouds at some time during the day. At the very least I may be able to get some full sunshine measurements around noon for some days of the year.


Finally I decided to add a ground stake to the enclosure to keep electrical interference to a minimum. Here's a picture of it all set up on my deck on the first night I tried it. It's powered by my 'portable' SLA/Solar power box I used for water pumps and the like around the garden - the solar controller has a convenient USB output. You can see I mounted the photometer on a piece of plywood with a levelling mechanism made of some embedded threaded rod and some bolts. The ground stake connection goes off to the right and into the garden.




This was not an ideal night, a little hazy and with some low cloud to the west of us. However, a brief look at the data looks promising - if anything it might currently be too sensitive and need a longer tube over the LED as it was at its max reading until about 10 minutes after sunset but then steadily decreased over the 45 minutes. I'm keen to collect more data but we've had day after day of clouds. Here's hoping for a nice clear frosty morning or evening soon!

Part II will discuss the analysis of the data.






A Proton Precession Magnetometer - Part 1: Overview and Polarisation Coil

 A Proton Precession Magnetometer - Part 1: Overview and Polarisation Coil For some time now I've wanted to add a magnetometer to my wea...