From: Craig A. Finseth <fin@unet.umn.edu>
Subject:  v04i001:  analemma_cf - Analemma v1.0, Part01/01
Newsgroups: comp.sources.hp48
Organization: University of Minnesota, Networking Services.
Followup-To: comp.sys.hp48
Approved: spell@seq.uncwil.edu

Checksum: 1531207743 (verify with brik -cv)
Submitted-by: Craig A. Finseth <fin@unet.umn.edu>
Posting-number: Volume 4, Issue 1
Archive-name: analemma_cf/part01

BEGIN_DOC analemma.doc
Craig A. Finseth			fin@unet.umn.edu
1343 Lafond				Craig.Finseth@nic.mr.net
St Paul MN 55104-2437			+1 612 644 4027
USA
When: 14 January 1992

What it does:

Many globes show a large "figure 8" somewhere over the Pacific Ocean.
(Oddly, this figure does not show on photographs taken from space...) 
This figure is called an "analemma," and it shows the position of the
Sun (in degrees of declination and minutes of right ascention (that
is, minutes as in "hours and minutes" not "degrees and minutes"))
relative to "where it is supposed to be."

For example, on May 14, the Sun is about 3 minutes and 41 seconds
ahead of nominal and about 20 degrees north of the ecliptic.

I said "many globes" because some manufacturers are removing this
useful piece of information from their globes. This program makes up
for this loss (as well as providing an excuse to write a program).

This program uses the graphics capabilities of the 48S/48SX to draw an
analemma for the year 2000.

The equations used are from:

	Meeus, Jean (1991) Astronomical Algorithms.  Richmond,
	Virginia: Willmann-Bell.  ISBN 0-943396-35-2.

In many cases, the definitions for the functions in this program give
equation numbers from this text.

Note: the shape on an analemma varies over time.  Also, an analemma is
*not* symmetric about the origin along either axis.
------------------------------------------------------------
Basic Operation:

Execute "GO".  Wait and watch.

When complete, you can enter the graphics environment and use the
cursor and COORD to identify the position in decimal minutes of right
ascention and degrees of declination.

The program operates in four phases:

1) Clear the screen and draw the grid (declination lines of -20, -10,
0, 10, and 20 degrees and a right ascention line of 0 degrees).

2) Draw the analemma curve.  Points are calculated every five days and
a line is drawn connecting the points.

3) Draw the tick marks.  These are drawn the first of every month and
21 Mar, 20 Jun, 21 Sep, and 20 Dec.  February is assumed to have 28
days.

4) Draw the labels.

The program objects all communicate via global variables.  Each
program uses those globals that it needs and stores its result in its
own global variable.

Because of these dependencies, the programs must be executed in the
following order:

	FIGJD
	FIGT
	FIG\GD
	FIG\Ge
	FIGL0	anytime after FIGT
	FIG\Ga
	FIGE
	FIG\Gd	anytime after FIGT

While FIGL0 may be computed anytime after FIGT, FIG\Ga and FIGE
(indirectly) must be computed after FIGL0.

As it turned out, this structure made it very easy to test the
modules.  A test Julian Day could be stored in JD, then the other
program calculated and their results examined.

The programs can, of course, be used separately.
------------------------------------------------------------
Accuracy:

The program calculates the analemma for the year 2000.  While the
analemma does vary over time, the variation is not much and the
displayed shape wouldn't change for a couple of centuries on each side
of the target year.

Most of the programs assume this range of time.  Higher-order terms
are not included in the programs, but could be added with minimal
effort.

The horizontal axis is "magnified" by a factor of four.  If you wish
to change this magnification, you will need to edit:

	PPAR	to set new limits
	FRAME	to set horizontal endpoints
	LBL	to position the labels

If you don't care about the lines and labels, you can drop the
invocations from GO and simply edit PPAR.  Then replot.

Internal computations are all performed in decimal degrees.  Where a
computation may result in a number of degrees significantly in excess
of 360, the value is taken mod 360 before being stored.
------------------------------------------------------------
Object Summary:	

GO	runs the program
BASE	computes the basic analemma
E	global variable: result variable for the equation of time
FIGE	computes E
FIGJD	computes the Julian Day
FIGL0	computes L0

FIGT	computes T
FIG\Ga	computes \Ga
FIG\GD	computes \GD\Ge and \GDp
FIG\Gd	computes \Gd
FIG\Ge	computes \Ge
FRAME	displays the frame

JD	global variable: current Julian Day
L0	global variable: longitude of the Sun
LBL	displays the month labels	
PLACE	computes the coordinates for a day
PPAR	global variable: plotting parameters
T	global variable: current Julian Century

TICK	places month tick marks
\Ga	global variable: apparent Solar right ascention
\GD\Ge	global variable: nutation in obliquity
\GDp	global variable: nutation in longitude (p should be psi)
\Gd	global variable: Solar declination
\Ge	global variable: obliquity of the ecliptic
------------------------------------------------------------
Detailed Interfaces:

GO	Stack Input:	none
	Stack Output:	none
	Global Input:	none
	Global Output:	none
	Calls:		BASE, FRAME, LBL, TICK

	Saves the flags, sets degrees mode, clears and displays the
	PICT, draws the figure, restores the flags.

BASE	Stack Input:	none
	Stack Output:	none
	Global Input:	none
	Global Output:	none
	Calls:		PLACE

	Plots the basic analemma.

FIGE	Stack Input:	none
	Stack Output:	none
	Global Input:	L0, \Ga, \GDp, \Ge
	Global Output:	E
	Calls:		none

	Computes the equation of time (equation 27.1).

FIGJD	Stack Input:	day number within year (21 Mar = 0)
	Stack Output:	none
	Global Input:	none
	Global Output:	JD
	Calls:		none

	Computes the Julian Day

FIGL0	Stack Input:	none
	Stack Output:	none
	Global Input:	T
	Global Output:	L0
	Calls:		none

	Computes the Sun's mean longitude (equation 27.2).

FIGT	Stack Input:	none
	Stack Output:	none
	Global Input:	JD
	Global Output:	T
	Calls:		none

	Computes the Julian Century (equation 21.1).  The origin is
	1 Jan 2000.

FIG\Ga	Stack Input:	none
	Stack Output:	none
	Global Input:	L0, T, \Ge
	Global Output:	\Ga
	Calls:		none

	Computes the *apparent* Solar right ascention (equations 24.3,
	both unnumbered between 24.4 and 24.5 ("OD" refers to the
	circle with dot varaible), first two unnumbered between 24.5
	and 24.6, 24.6, and 24.8).

FIG\GD	Stack Input:	none
	Stack Output:	none
	Global Input:	T
	Global Output:	\GD\Ge, \GDp
	Calls:		none

	Computes the nutation in longitude (\GDp, p should be psi) and
	nutation in obliquity (\Ge) (the accuracy of 0.5 minutes
	equations on page 132).

FIG\Gd	Stack Input:	none
	Stack Output:	none
	Global Input:	T, \Ge
	Global Output:	\Gd
	Calls:		none

	Computes the Solar declination.  Uses simple first order
	approximation.

FIG\Ge	Stack Input:	none
	Stack Output:	none
	Global Input:	T
	Global Output:	\Ge
	Calls:		none

	Computes the mean obliquity of the ecliptic (equation 21.1).

FRAME	Stack Input:	none
	Stack Output:	none
	Global Input:	none
	Global Output:	none
	Calls:		none

	Plots the lines of declination (-20, -10, 0, 10, and 20
	degrees) and right ascention (0).

LBL	Stack Input:	none
	Stack Output:	none
	Global Input:	none
	Global Output:	none
	Calls:		none

	Plots the month name labels.

PLACE	Stack Input:	day number within year (21 Mar = 0)
	Stack Output:	complex coordinate of analemma point for that day
	Global Input:	E, \Gd
	Global Output:	none
	Calls:		FIGE, FIGJD, FIGL0, FIGT, FIG\Ga, FIG\GD
			FIG\Gd, FIG\Ge
	computes the coordinates for a day

TICK	Stack Input:	none
	Stack Output:	none
	Global Input:	none
	Global Output:	none
	Calls:		PLACE

	Plots the tick marks for the first of every month and 21 Mar,
	20 Jun, 21 Sep, and 20 Dec.

END_DOC
Checksum: #c6deh
Size: 2859.5
------------------------------------------------------------

BEGIN_RPL analemma.rpl
%%HP: T(3)A(D)F(.);
DIR
  GO
    \<< RCLF DEG
ERASE { # 0h # 0h }
PVIEW FRAME BASE
TICK LBL 7 FREEZE
STOF
    \>>
  BASE
    \<< 0 PLACE 0 365
      FOR d d PLACE
DUP ROT LINE 5
      STEP DROP
    \>>
  E -3.19866112964
  FIGE
    \<< L0 .0057183 -
\Ga - \GDp \Ge COS * +
'E' STO
    \>>
  FIGJD
    \<< 78 +
2451545.5 + 'JD'
STO
    \>>
  FIGL0
    \<< T 10 / \-> \Gt
      \<< 280.4664567
360007.698278 \Gt * +
.03032028 \Gt SQ * +
360 MOD 'L0' STO
      \>>
    \>>
  FIGT
    \<< JD 2451545 -
36525 / 'T' STO
    \>>
  FIG\Ga
    \<< 357.5291
35999.0503 T * +
360 MOD \-> M
      \<< 1.9146
.004817 T * -
.000014 T SQ * - M
SIN * .019993
.000101 T * - M 2 *
SIN * + .00029 M 3
* SIN * + L0 + \-> OD
        \<< 125.04
1934.136 T * - 360
MOD \-> \GW
          \<< OD
.00569 - .00478 \GW
SIN * - \-> \Gl
            \<< \Ge
.00256 \GW COS * +
COS \Gl SIN * \Gl COS
SWAP R\->C ARG 360 +
360 MOD
            \>>
          \>>
        \>>
      \>> '\Ga' STO
    \>>
  FIG\GD
    \<< 125.04452
1934.136261 T * -
360 MOD 280.4665
36000.7698 T * +
360 MOD 218.3165
481267.8813 T * +
360 MOD \-> \GW L LP
      \<< -.00172
HMS\-> \GW SIN *
.000132 HMS\-> 2 L *
SIN * - .000023
HMS\-> 2 LP * SIN * -
.000021 HMS\-> 2 \GW *
SIN * + '\GDp' STO
.00092 HMS\-> \GW COS *
.000057 HMS\-> L 2 *
COS * + .00001 HMS\->
LP 2 * COS * +
.000009 HMS\-> \GW 2 *
COS * - '\GD\Ge' STO
      \>>
    \>>
  FIG\Gd
    \<< T 36525 * 78
- 365 / 360 * 360
MOD SIN \Ge * '\Gd' STO
    \>>
  FIG\Ge
    \<< 23.2621448
HMS\-> .0046815 HMS\->
T * - .000000059
HMS\-> T SQ * - \GD\Ge +
'\Ge' STO
    \>>
  FRAME
    \<< (-51.17,-20)
(51.17,-20) LINE
(-51.17,-10)
(51.17,-10) LINE
(-51.17,0)
(51.17,0) LINE
(-51.17,10)
(51.17,10) LINE
(-51.17,20)
(51.17,20) LINE
(0,-25) (0,25) LINE
    \>>
  JD 2451967.5
  L0 336.902466384
  LBL
    \<< PICT (-32,1)
"Mar" 2 \->GROB GXOR
PICT (-32,16) "Aug"
2 \->GROB GXOR PICT
(-32,25) "Jul" 1
\->GROB GXOR PICT
(27,25) "Jun" 1
\->GROB GXOR PICT
(27,19) "May" 1
\->GROB GXOR PICT
(27,13) "Apr" 1
\->GROB GXOR PICT
(27,4) "Sep" 2
\->GROB GXOR PICT
(27,-6) "Oct" 2
\->GROB GXOR PICT
(27,-17) "Nov" 1
\->GROB GXOR PICT
(27,-22) "Dec" 1
\->GROB GXOR PICT
(-32,-19) "Jan" 1
\->GROB GXOR PICT
(-32,-9) "Feb" 2
\->GROB GXOR
    \>>
  PLACE
    \<< FIGJD FIGT
FIG\GD FIG\Ge FIGL0
FIG\Ga FIGE FIG\Gd E 4
* \Gd R\->C
    \>>
  PPAR {
(-51.17,-25)
(51.17,25) X 0
(0,0) PARAMETRIC Y
}
  T
1.15674195756E-2
  TICK
    \<< { 0 10 40 71
91 101 132 163 184
193 224 254 274 285
316 344 } DUP SIZE
\-> d n
      \<< 1 n
        FOR j d j
GET PLACE PIXOFF
        NEXT
      \>>
    \>>
  \Ga 340.091306964
  \GD\Ge
-4.10799632761E-4
  \GDp
-4.47118519728E-3
  \Gd -8.10071364255
  \Ge 23.4387298868
END
END_RPL

BEGIN_ASC analemma.asc
%%HP: T(1)A(D)F(.);
"69A20FF75851000000103910339201008688927834320B100010291033920000

2B2130ED6C"
END_ASC

BYTES: #C6DEh 2863.5

BEGIN_UU analemma.uue
begin 644 analemma
M2%!(4#0X+466*O!_A14````!DP$S*1``:(@IAT,CL`$``9(!,RD``%5"-G$`G
M@;D!``*;<`(S*7"9*)=1&'%$V0$``IN3`C,I8)EA)V.9!T'9`0`!C`$S*2``D
M9&DPD0`TL`$`!%1)0TL$G2W@82-T*D`K*C,I$````````!`PDP(!````````G
M!#,I$````````'$PDP(!```````0"3,I(```````$!`PDP("```````R`3,I$
M(```````,!8PDP("``````"$`3,I(```````,!DPDP("```````D`C,I(```4
M````0"4PDP("``````!T`C,I(```````4"@PDP("```````6`S,I(```````3
M0#2P$@.'^X&;',$TTN8"`61M+A#@YF$CR:+2Y@(!;J`QTN8"`6IM+A!`UN8"H
M`6K&UX'D`@503$%#143CP20C_C628R,K,3`>``%4`3,I@)E65QET5A&P`0`$_
M4%!!4@1T*G"7`@$`````<!&5`0``````4))W*1```````!=1$````````"6`-
MY`(!6+2B<I<"`````````````````````,'F@>0"`5DK,1`*``503$%#106=F
M+>!A(T@N4&"4=*1$A.0"!$9)1U1(+D!@E'2TB>0"!$9)1Y-(+E!@E'3$!(/DR
M`@1&24>,2"Y`8)1T5(3D`@1&24>22"X04(0P*NZM@>0"`9*>QY%C(RLQ\`L`4
M`TQ"3`.=+>!A(S;D<9<"`0``````(),``````````2PJL```36%RWJ+26A[DV
MY&%#'G<I$````````#(9````````%L"B`@L`$%1WYBTJK>5!3AXVY'&7`@$`/
M`````""3`0``````4`(L*K```$IU;,FBTEH>Y.1A0QYW*1`````````G$```$
M`````"7`H@(+`*!4YY8L*JWE04X>-N1QEP(!``````!P`@$``````)`!+"JPT
M``!-87G)HM):'N3D84,>=RD0````````)Q`````````3P*(""P`0!">7+"JM9
MY4%.'C;D<9<"`0``````<`(`````````!"PJL```4V5PWJ+26A[DY&%#'G<IV
M$````````"<`````````8,FB`@L`\#1&YRTJK>5!3AXVY'&7`@$``````'`"$
M`0``````<)$L*K```$YO=LFBTEH>Y.1A0QYW*1`````````G$````````"+)\
MH@(+`$!4-I8L*JWE04X>-N1QEP(!```````@DP$``````)"1+"JP``!*86[)+
MHM):'N3D84,>=RD0````````,@D```````"0R:(""P!@5";F+2JMY4%.'CDVX
MLA(#B@,@P`0C,),"`D`X9B20-@,=`""@1"0PDP(&``!09QE%`AT`4&`D%=143
M5-#9`AXV<I<"`0````!P$94!````````DG<I$```````%U$0````````((DYR
M'G<I$```````%U$9````````$'F7`@$`````<!$%`0```````)&8XW&7`@$`'
M````<!&5``````````!W*1```````!=1``````````"`.1YW*1```````!=15
M&0```````!!PEP(!`````'`1!0$````````!F.-QEP(!`````'`1E0$`````U
M```"=RD0```````741`````````@@#D>=RD``````````!`````````E>9<"T
M```````````!``````!0`ICCD6,C*S'`'P`$1DE'DP2=+>!A(S,I$```@$0AA
M)B/@\QLS*7"9````4(%&X/,;2"X00.7>&@FM,9,"D@D`````D`4^OX'D`@%4[
M)K3AWAH)K8'D`@*;DV>K064C2"X0,)EG(\T,DF,C*S$0#``$1DE'D@2=+>!A5
M(T@N$$`UDP($`````"5E`^ZM,9,"`0``````@`<)K3&3`@(``````&4#!:\QT
MDP("``````!@`^ZM,9,"`@``````8`--OL%*&T@N$##IWAI4-H+D`@&2>3;2=
MS"`Y-K(2`]8`0&"4=+1)T-D"'C8RDP("```@100E`3,I,```86(3-!F`Y`(!%
M5.ZMD=`:,RD@````````-M#D&S,I(````%!F!"@PDP($``"8=@!@`T@N$$#E'
MWAIGJS&3`@(``````&`#3;XQDP("````93$8`C,I4```$XAG$DB`Y`(!5.ZM2
M<;8:,RD@````````-M#D&\$TTN8"`9UM+A#`U.8"`DQ0'C8RDP*7"0````!R<
MD3Z_T>8"`9VLM.'>&C,I8)D`````(!/@\QO>HM+F`@%,[JW!2AONK9'0&C,II
M4)D``````"/@\QO>HM+F`@),4.ZMP4H;[JV1T!HS*5"9```````AX/,;WJ+2Z
MY@(!G>ZMP4H;[JUQMAI4-H+D`@*;<'DVTLP@,RE@F0``````DN#S&VTN$-!9+
M4!ONK3&3`I4)`````'`%/K_1Y@(!3-ZBXMX:!;7AWAIGJS&3`I4)```````!S
M/K_1Y@("3%#>HN+>&@6UX=X:9ZLQDP*4"0``````"3Z_T>8"`9W>HN+>&@6U)
MX=X:":U!92-(+B"P.9EG(\T,XE\C.3:R$@-+`T!@E'3$2-#9`AXV,I,"`@``Y
M`)%25P,S*4```#!0D)DU@.0"`53NK7&V&C,I(````````#;0Y!O!--+F`@%-K
M'C8RDP(``````$:1`3,I<)D`````%TB`Y`(!5.ZMD=`:,RE0F0``````%(#DO
M`@%4)K3AWAH)K='F`@%-K+3AWAHS*8"9````,)D9,),"E@D``````0%(+A!`3
MY=X:":W1Y@(!3=ZBXMX:K+3AWAIGJS&3`I8)`````)`";2X0T#0O*NZMP4H;?
M[JUQMAI(+B#`!'.V&L$TTN8"`D]$'C8RDP("``````0E`3,I,````&`3-!F`Y
MY`(!5.ZMD=`:,RD@````````-M#D&\$TTN8"`9T>-M+F`@)/1#,I<)D`````@
MD%:0T!HS*7"9`````(!'T.8"`9VLM.'>&@FM$4PC;2X08.EA(T@N$#`YDP*7J
M"0````!6`FTN$-!94!ONK7&V&@6UT>8"`9:LM.'>&FTN$&!94!N]^^%Y'-NR(
M,9,"`@``````8`-GJS&3`@(``````&`#3;[A7R/^->)?(_XU0F4C2"X0P)AGW
M(\T,DF,C*S'`-0`$1DE'5`2=+>!A(T@N(*!$-),"!@```$4510()K3&3`@0`>
M````)64#!:]!92-(+A!`E6<CS0R28R,K,7`'``5&24=,,`6=+>!A(T@N$$`UC
MDP(!`````````06O$4PC;2X0D.EA(S,I(```9T5F!"@PDP(%@">8=@!@`VTN,
M$)#IWAIGJS&3`I@)```H(`,#;2X0D&E"&^ZM<;8:,RD@````````-M#D&U0VF
M@N0"`DPP>3;2S"#^-9)C(RLQL`\`!49)1TI$!9TMX&$C,RD0````````>'"VA
M&C,I8````%54421PMAI4-H+D`@)*1'DVTLP@.3:R$@-P`$!@E'141-#9`AXV<
M@N0"`DPP,REPF0```#`85Y#0&D@N$,"8T!I(+B"P"8?D`@&3!;7AWAIGJT%EJ
M(T@N$%"49R/-#))C(RLQX`@``44!,RD``&0I$6:8,;D!``1"05-%!)TMX&$CS
MM**"Y`(%4$Q!0T6THC*3`@(``````&4#H#'2Y@(!9&TN$$"&Y`(%4$Q!0T6'V
M^^'`'YCCT3$J@#."O1\Y-K(2`Y8`('#T)-#9`AXVDF$<F</Q)1YT*N"D`A4`6
M``````````#@I`(5````````````L!(#\.*!Y`(%1E)!345(+D`@%#15A.0"^
8!%1)0TM(+C#`),1T-"JDI?%G'#DVLA(#Q
``
end
END_UU
