With Monday nearing, solar eclipse fever is hitting new heights. So, figured I'd follow Robert Allison’s lead and join the frenzy with some eclipse-themed SAS code. Here's my quick SAS ODS Graphics take on solar eclipse time-lapse photography - put on your ISO certified glasses before viewing the output, kids!
* Fun w/SAS ODS Graphics: Solar Eclipse "Time-Lapse" (SGPANEL + BUBBLE Plots)
Inspired by forum.timescapes.org/phpBB3/viewtopic.php?f=4&t=7775;
data eclipse; /* Generate points for sun/moon */
do frame=1 to 11; /* At 11 different times/locations */
sunX=.5; sunY=.5; sz=50; output; /* Sun plotted at constant position in frame */
sunX=.; sunY=.;
if frame<=6 then /* Sun goes behind moon in first 6 frames */
moonX=.5+(6-frame)*(.775/5);
else /* Sun emerges from behind moon in last 5 frames */
moonX=.5-(frame-6)*(.775/5);
moonY=.5; sz=40; output; /* Make moon slightly smaller bubble than sun */
moonX=.; moonY=.;
sz=1; output; /* "Dummy" points with size=1 make sun/moon bigger */
end;
ods listing gpath='/folders/myfolders'; /* Use SGPANEL to plot frames in one image */
ods graphics on / reset antialias width=10in height=1in imagename="ECLIPSE";
proc sgpanel data=eclipse noautolegend; /* "Time-lapse" is 1x11 panel of bubble plots */
styleattrs backcolor=black wallcolor=black;
panelby frame / rows=1 columns=11 onepanel noheader noheaderborder noborder;
bubble x=sunX y=sunY size=sz / colormodel=(yelloworange) colorresponse=sunX dataskin=sheen bradiusmax=50;
bubble x=moonX y=moonY size=sz / colormodel=(black) colorresponse=moonX dataskin=sheen bradiusmax=50;
rowaxis display=none;
colaxis display=none values=(0 to 1) min=0 max=1 offsetmin=0 offsetmax=0;
run;
Editor's note: This is a great addition to the original post.
Building on Ted's work:
http://blogs.sas.com/content/graphicallyspeaking/2017/08/20/fun-ods-graphics-eclipse-animation/
Added some stars.
Awesome, TC. Great demonstration of using SG procedures for non-standard visuals. You could probably use FRAME as the BY variable with SGPLOT, and create an animated GIF or SVG.
Example code for animation using printerpath: http://blogs.sas.com/content/graphicallyspeaking/2013/05/23/animation-using-sgplot/
Editor's note: This is a great addition to the original post.
Building on Ted's work:
http://blogs.sas.com/content/graphicallyspeaking/2017/08/20/fun-ods-graphics-eclipse-animation/
Added some stars.
Great, Sanjay, but now I'll go blind because I looked at your animation without eye protection. Shame on you for not posting a warning!
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.