Fun with ODS Graphics: Eclipse animation

3

Motivated by Ted Conway's post on creating a sequence of graphs showing the Solar Eclipse, I thought it would be fun to extend his code and create a gif animation. I used a frame count to 81, and used the printerpath feature to create the animation using SGPLOT with BY variable.  The animation is shown below with the code.  Full code is in the link below.

Update:  Added some stars.

options papersize=('5 in', '3.8 in') printerpath=gif animation=start 
        animduration=0.1 animloop=yes noanimoverlay;
ods printer file='C:\Work\SASUser\SolarEcplise\Eclipse.gif';
 
ods graphics / width=4.8in height=3.6in;
proc sgplot data=eclipse noautolegend noborder nowall rattrmap=myrattrmap;      
by frame;
polygon id=id x=x y=y / colorresponse=id fill nooutline rattrid=myid;
bubble x=sunX y=sunY size=sz / colormodel=(yelloworange) colorresponse=sunX dataskin=sheen bradiusmax=120;
bubble x=moonX y=moonY size=sz / colormodel=(black) colorresponse=moonX dataskin=sheen bradiusmax=120;
yaxis display=none values=(0 to 1) min=0 max=1 offsetmin=0 offsetmax=0; 
xaxis display=none values=(0 to 1) min=0 max=1 offsetmin=0 offsetmax=0;
run;
 
options printerpath=gif animation=stop;
ods printer close;

 

I paused the animation for 5 frames during full eclipse.  Note, the sky changes color as the Moon passes over the Sun.  To do that, I use a polygon plot behind the Sun and Moon, and change the color of the polygon (and the moon) based on the frame number using a Range Attr Map.

SVG animation can also be created, and may create a cleaner gradient rendering of the Sun.

One additional feature could be to simulate the corona during the full eclipse.  Any thoughts?

Full Code:  Eclipse_Anim

Share

About Author

Sanjay Matange

Director, R&D

Sanjay Matange is R&D Director in the Data Visualization Division responsible for the development and support of the ODS Graphics system, including the Graph Template Language (GTL), Statistical Graphics (SG) procedures, ODS Graphics Designer and related software. Sanjay has co-authored a book on SG Procedures with SAS/PRESS.

Related Posts

Back to Top