Nathaniel R. Stickley

Software Engineer - Astrophysicist - Data Scientist

Somelight

A few months after moving to California for graduate school in 2008, I started a balcony garden and soon became aware of how little balcony space is useful for growing plants that need a significant amount of direct sunlight. When I selected my current apartment, one of the primary criteria was the orientation of the balcony; southern exposure was essential, however the optimal placement of the plants on the balcony was still not straightforward. After about a year, I figured out the best way to arrange the plants. I knew that it would be fairly straightforward to write a program to help solve the placement problem, but I wasn't motivated to actually write such a program until 1) I failed to find an existing solution and 2) I found out about a Python module, called PyEphem that simplified the process. During my free time over the past two weeks or so, I developed a bit of code, called Somelight, that solves the problem pretty well. The code simply computes when a given location in space has a direct line of sight to the Sun, in the presence of obscuring surfaces. Somelight does not attempt to account for reflected light—only direct light.

Basic Usage

In order to use Somelight, you need to do the following:

  1. Define a point in or near your garden as the origin of a Cartesian coordinate system.
  2. Decide which direction to define as the positive x axis of the coordinate system (the x and y coordinates must be horizontal and the +z direction must be straight up).
  3. Identify all objects that can significantly shade the garden (walls, fences, columns, roofs, neigboring houses, trees, hills, mountains etc.).
  4. Break the obscuring objects into quasi-planar segments and determine the (x, y, z) coordinates of the vertices of these segments. For objects like large buildings, mountains, or hills in the distance, you can construct proxy surfaces that have the same effect as the actual objects.
  5. Identify the offset of your coordinate system's +x-axis from North.
  6. Identify the longitude and latitude of the garden site.
  7. Enter the garden description into a somelight.GardenVolume object.
  8. Use the methods of the somelight.GardenVolume object to answer your questions about direct sunlight exposure.

The following example demonstrates the basic procedure:

For step 5, Google Earth is helpful. You can also use a compass, but be sure to take magnetic declination into account if you use a compass; you need to measure the offset from true North, not magnetic North (note that some compass apps on smart phones do not take magnetic declination into account, while others do). You can also use the output of Somelight to calibrate this angle.

Window Mode

If you want to use Somelight inside, you can set window_mode=True in the somelight.GardenVolume constructor. Then, the planes that you specify are interpreted as windows, rather than obscurring surfaces.

Output

Images of my balcony floor and corresponding output from the garden.showGarden method are shown below. Blue dots are points that are in direct sunlight. In the photographs, the +y-axis is perpendicular to the left banister and the +x-axis is perpendicular to the right banister (the position of the camera was about (0, .05, 5) or 5 length units above the origin of the coordinate system). The Somelight prediction agreees well with the actual Sun exposure, even though the balcony was not carefully measured.

The total direct sunlight exposure for any day of the year can be plotted. The figure below is the output of the command issued on the final line of the example above.

dec-30th-1

In addition to computing the number of minutes of direct sunlight exposure, Somelight can estimate the total radiant energy received. Here are plots of the radiant exposure for December 30th and May 15th. Note that the roof of the balcony greatly reduces the amount of light that the balcony recieves during the warmer months of the year, when the Sun is generally higher in the sky:

And here's an animation showing the radiant exposure on the balcony for every Sunday of 2017:

How Somelight Works

For each point of interest, Somelight projects each plane, specified using the addPlaneSegment method, onto the sphere of the sky. The Cartesian coordinates (x,y,z) are projected onto horizontal coordinates (altitude, azimuth). If any of the projected polygons contain the coordinates of the Sun, then the point is either shaded (if the planes represented obscuring surfaces) or in direct sunlight (if the planes represented windows). The figure below shows how the projected shapes of the planes change as the y-coordinate is varied in the example above. The left half of the figure represents the rear view (looking in the negative y direction), while the right half represents the forward view. You can see the North wall's apparent size shrink and watch as observation point passes into and out of the shadow of the column:

output

Get Somelight

The latest source can be obtained here: https://bitbucket.org/idius/somelight/src

Possible Future Steps

  • Add the ability to compute the radiant exposure-weighted and time exposure-weighted azimuth and altitude angles.
  • Add the ability to determine the altitude and azimuth angles of the Sun when the each point receives the most intense sunlight (i.e., the angles associated with the max irradiance).
  • Investigate alternative algorithms to improve efficiency.
  • Investigate the possibility of using the Shapely module for computational geometry.
  • Re-implement the computationally expensive bits in parallelized C++.
  • Add the ability to handle partially transparent surfaces and approximations to complex objects with many small "holes," such as fences and diciduous trees.
  • Add the ability to output the radiant exposure during a specified period of time and the instantaneous irradiance.

Wish list, if I had unlimited time to work on this:

  • Add ability to read OBJ or STL files (see numpy-stl) so that scenes can be created using 3D modelling software (even free web-based software like SculptGL or TinkerCAD. )
  • Integrate with Blender or other ray tracing code to handle reflected light realistically.
  • Develop into smart phone app that can automatically build a 3D model of the garden and overlay the output on live video (augmented reality).
Nathaniel R. Stickley
nrs@nrstickley.com
626-269-9830