1 | cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
---|
2 | real function sol2ls(sol) |
---|
3 | |
---|
4 | c convert a given martian day number (sol) |
---|
5 | c into corresponding solar longitude, Ls (in degr.), |
---|
6 | c where sol=0=Ls=0 is the |
---|
7 | c northern hemisphere spring equinox. |
---|
8 | |
---|
9 | implicit none |
---|
10 | |
---|
11 | c input |
---|
12 | real sol |
---|
13 | c output |
---|
14 | real ls |
---|
15 | |
---|
16 | c local variables |
---|
17 | double precision year_day,peri_day,timeperi,e_elips |
---|
18 | double precision pi,radtodeg |
---|
19 | c number of martian days (sols) in a martian year |
---|
20 | parameter (year_day=668.6) |
---|
21 | c perihelion date (in sols) |
---|
22 | parameter (peri_day=485.35) |
---|
23 | c orbital eccentricity |
---|
24 | parameter (e_elips=0.09340) |
---|
25 | parameter (pi=3.14159265358979) |
---|
26 | c radtodeg: 180/pi |
---|
27 | parameter (radtodeg=57.2957795130823) |
---|
28 | c timeperi: 2*pi*( 1 - Ls(perihelion)/ 360 ); Ls(perihelion)=250.99 |
---|
29 | parameter (timeperi=1.90258341759902) |
---|
30 | |
---|
31 | double precision zanom,xref,zx0,zdx,zteta,zz |
---|
32 | c xref: mean anomaly, zx0: eccentric anomaly, zteta: true anomaly |
---|
33 | integer iter |
---|
34 | |
---|
35 | zz=(sol-peri_day)/year_day |
---|
36 | zanom=2.*pi*(zz-nint(zz)) |
---|
37 | xref=dabs(zanom) |
---|
38 | |
---|
39 | c The equation zx0 - e * sin (zx0) = xref, solved by Newton |
---|
40 | zx0=xref+e_elips*dsin(xref) |
---|
41 | do 110 iter=1,10 |
---|
42 | zdx=-(zx0-e_elips*dsin(zx0)-xref)/(1.-e_elips*dcos(zx0)) |
---|
43 | if(dabs(zdx).le.(1.d-7)) then |
---|
44 | goto 120 |
---|
45 | endif |
---|
46 | zx0=zx0+zdx |
---|
47 | 110 continue |
---|
48 | 120 continue |
---|
49 | zx0=zx0+zdx |
---|
50 | if(zanom.lt.0.) zx0=-zx0 |
---|
51 | |
---|
52 | c compute true anomaly zteta, now that eccentric anomaly zx0 is known |
---|
53 | zteta=2.*datan(dsqrt((1.+e_elips)/(1.-e_elips))*dtan(zx0/2.)) |
---|
54 | |
---|
55 | c compute Ls |
---|
56 | ls=real(zteta-timeperi) |
---|
57 | if(ls.lt.0.) ls=ls+2.*real(pi) |
---|
58 | if(ls.gt.2.*pi) ls=ls-2.*real(pi) |
---|
59 | c convert Ls in deg. |
---|
60 | ls=real(radtodeg)*ls |
---|
61 | |
---|
62 | sol2ls = ls |
---|
63 | return |
---|
64 | end |
---|
65 | |
---|
66 | cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
---|
67 | real function ls2sol(ls) |
---|
68 | |
---|
69 | c Returns solar longitude, Ls (in deg.), from day number (in sol), |
---|
70 | c where sol=0=Ls=0 at the northern hemisphere spring equinox |
---|
71 | |
---|
72 | implicit none |
---|
73 | |
---|
74 | c Arguments: |
---|
75 | real ls |
---|
76 | |
---|
77 | c Local: |
---|
78 | double precision xref,zx0,zteta,zz |
---|
79 | double precision peri_day,timeperi,e_elips |
---|
80 | double precision pi,degrad |
---|
81 | double precision,parameter :: year_day=668.6 |
---|
82 | parameter (peri_day=485.35) |
---|
83 | parameter (timeperi=1.90258341759902) |
---|
84 | parameter (e_elips=0.0934) |
---|
85 | parameter (pi=3.14159265358979) |
---|
86 | parameter (degrad=57.2957795130823) |
---|
87 | |
---|
88 | if (abs(ls).lt.1.0e-5) then |
---|
89 | if (ls.ge.0.0) then |
---|
90 | ls2sol = 0.0 |
---|
91 | else |
---|
92 | ls2sol = real(year_day) |
---|
93 | end if |
---|
94 | return |
---|
95 | end if |
---|
96 | |
---|
97 | zteta = ls/degrad + timeperi |
---|
98 | zx0 = 2.0*datan(dtan(0.5*zteta)/dsqrt((1.+e_elips)/(1.-e_elips))) |
---|
99 | xref = zx0-e_elips*dsin(zx0) |
---|
100 | zz = xref/(2.*pi) |
---|
101 | ls2sol = real(zz*year_day + peri_day) |
---|
102 | if (ls2sol.lt.0.0) ls2sol = ls2sol + real(year_day) |
---|
103 | if (ls2sol.ge.year_day) ls2sol = ls2sol - real(year_day) |
---|
104 | |
---|
105 | return |
---|
106 | end |
---|