OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
sunangs.f
Go to the documentation of this file.
1  subroutine sunangs(iyr,iday,gmt,xlon,ylat,sunz,suna)
2 c
3 c Given year, day of year, time in hours (GMT) and latitude and
4 c longitude, returns an accurate solar zenith and azimuth angle.
5 c Based on IAU 1976 Earth ellipsoid. Method for computing solar
6 c vector and local vertical from Patt and Gregg, 1993, Int. J.
7 c Remote Sensing.
8 c
9 c Subroutines required: sun2000
10 c gha2000
11 c jd
12 c
13  save !required for IRIX compilers
14  real suni(3),sung(3),up(3),no(3),ea(3)
15  real*8 pi,radeg,re,rem,f,omf2,omegae
16  real*8 sec,gha,ghar,day
17  common /gconst/pi,radeg,re,rem,f,omf2,omegae
18  data ea /0.0,0.0,0.0/
19 c
20 c Compute sun vector
21 c Compute unit sun vector in geocentric inertial coordinates
22  sec = gmt*3600.0d0
23  call sun2000(iyr,iday,sec,suni,rs)
24 
25 c Get Greenwich mean sidereal angle
26  day = iday + sec/86400.0d0
27  call gha2000(iyr,day,gha)
28  ghar = gha/radeg
29 
30 c Transform Sun vector into geocentric rotating frame
31  sung(1) = suni(1)*cos(ghar) + suni(2)*sin(ghar)
32  sung(2) = suni(2)*cos(ghar) - suni(1)*sin(ghar)
33  sung(3) = suni(3)
34 c
35 c Convert geodetic lat/lon to Earth-centered, earth-fixed (ECEF)
36 c vector (geodetic unit vector)
37  rlon = xlon/radeg
38  rlat = ylat/radeg
39  cosy = cos(rlat)
40  siny = sin(rlat)
41  cosx = cos(rlon)
42  sinx = sin(rlon)
43  up(1) = cosy*cosx
44  up(2) = cosy*sinx
45  up(3) = siny
46 c
47 c Compute the local East and North unit vectors
48  upxy = sqrt(up(1)*up(1)+up(2)*up(2))
49  ea(1) = -up(2)/upxy
50  ea(2) = up(1)/upxy
51  no(1) = up(2)*ea(3) - up(3)*ea(2) !cross product
52  no(2) = up(3)*ea(1) - up(1)*ea(3)
53  no(3) = up(1)*ea(2) - up(2)*ea(1)
54 
55 c Compute components of spacecraft and sun vector in the
56 c vertical (up), North (no), and East (ea) vectors frame
57  sunv = 0.0
58  sunn = 0.0
59  sune = 0.0
60  do j = 1,3
61  sunv = sunv + sung(j)*up(j)
62  sunn = sunn + sung(j)*no(j)
63  sune = sune + sung(j)*ea(j)
64  enddo
65 c
66 c Compute the solar zenith and azimuth
67  sunz = radeg*atan2(sqrt(sunn*sunn+sune*sune),sunv)
68 c Check for zenith close to zero
69  if (sunz .gt. 0.05d0)then
70  suna = radeg*atan2(sune,sunn)
71  else
72  suna = 0.0d0
73  endif
74  if (suna .lt. 0.0d0)suna = suna + 360.0d0
75 c
76  return
77  end
#define real
Definition: DbAlgOcean.cpp:26
subroutine sunangs(iyr, iday, gmt, xlon, ylat, sunz, suna)
Definition: sunangs.f:2
#define re
Definition: l1_czcs_hdf.c:701
#define pi
Definition: vincenty.c:23
int sun2000(size_t sdim, int32_t iyr, int32_t idy, double *sec, orb_array *sun)
#define omf2
Definition: l1_czcs_hdf.c:703
#define f
Definition: l1_czcs_hdf.c:702