Using Observer Pro Horizons in SkySafari
Update (March 2, 2020): Observer Pro 1.3, with built-in support for exporting horizon profiles for Sky Safari is now available in the App Store.
In Observer Pro it’s quick and easy to measure your horizon obstructions, but sometimes you want to use that information in other applications. You can export the horizon altitude measurements by going into the Local Horizon settings for your observing site. Once there, tap the action button at the top right of the screen to export the horizon profile data as a “.hzn” file.
Several years ago I created a script that can convert an Observer Pro horizon file into an image that can be used in SkySafari. Since I’m not the only one who wants to do this, I thought I’d share it here for people to find and use.
The script is written to run in the Processing programming environment. Processing is free to download and use and supports macOS, Windows, and Linux operating systems. To start converting your Observer Pro horizons, download and install Processing, create a new Sketch, and replace its contents with the code listed below. Press the “Play” button near the top of the Processing window to run it. It will ask you to locate the horizon file that was exported out of Observer Pro and will produce a PNG file with the same name in the same folder as that horizon file. This PNG file is ready to import into SkySafari (consult the SkySafari documentation for the details on how to do that).
import java.io.File; PGraphics pg; void setup () { pg = createGraphics(2048, 1024); selectInput("Select a horizon file:", "fileSelected"); } void fileSelected(File selection) { if (selection != null) { String inFilePath = selection.getAbsolutePath(); String outFileName = split(selection.getName(), '.')[0]; String outFilePath = selection.getParent() + File.separator + outFileName + ".png"; pg.beginDraw(); pg.background(0,0,0,0); pg.noStroke(); pg.smooth(); // Draw ground pg.fill(0, 128, 0); // This sets the ground color: r, g, b pg.rect(0, 512, 2048, 512); // Draw horizon pg.fill(0, 128, 0, 200); // This sets the horizon color: r, g, b, alpha pg.beginShape(); pg.vertex(0, 1024); String lines[] = loadStrings(inFilePath); String vals0[]; String vals1[]; for (int i=0; i<lines.length; i++) { vals0 = split(lines[i], ','); if (i < lines.length - 1) { vals1 = split(lines[i+1], ','); } else { vals1 = split(lines[0], ','); vals1[0] = "360"; } if (vals0.length == 2 && vals1.length == 2) { float azi0 = float(vals0[0]); float alt0 = max(float(vals0[1]), 0.0); float azi1 = float(vals1[0]); float alt1 = max(float(vals1[1]), 0.0); int x0 = int(2048*azi0/360.0); int y0 = int(512*(1.0 - alt0/90.0)); int x1 = int(2048*azi1/360.0); int y1 = int(512*(1.0 - alt1/90.0)); pg.vertex(x0, y0); pg.vertex(x1, y1); } } pg.vertex(2048, 1024); pg.vertex(0, 1024); pg.endShape(); pg.endDraw(); pg.save(outFilePath); } exit(); } void draw() { }