v0.9.1
Macros | Enumerations | Functions | Variables
spa.c File Reference
#include <math.h>
#include "spa.h"

Go to the source code of this file.

Macros

#define PI   3.1415926535897932384626433832795028841971
 
#define SUN_RADIUS   0.26667
 
#define L_COUNT   6
 
#define B_COUNT   2
 
#define R_COUNT   5
 
#define Y_COUNT   63
 
#define L_MAX_SUBCOUNT   64
 
#define B_MAX_SUBCOUNT   5
 
#define R_MAX_SUBCOUNT   40
 
#define TERM_Y_COUNT   TERM_X_COUNT
 

Enumerations

enum  { TERM_A, TERM_B, TERM_C, TERM_COUNT }
 
enum  {
  TERM_X0, TERM_X1, TERM_X2, TERM_X3,
  TERM_X4, TERM_X_COUNT
}
 
enum  {
  TERM_PSI_A, TERM_PSI_B, TERM_EPS_C, TERM_EPS_D,
  TERM_PE_COUNT
}
 
enum  { JD_MINUS, JD_ZERO, JD_PLUS, JD_COUNT }
 
enum  { SUN_TRANSIT, SUN_RISE, SUN_SET, SUN_COUNT }
 

Functions

double rad2deg (double radians)
 
double deg2rad (double degrees)
 
int integer (double value)
 
double limit_degrees (double degrees)
 
double limit_degrees180pm (double degrees)
 
double limit_degrees180 (double degrees)
 
double limit_zero2one (double value)
 
double limit_minutes (double minutes)
 
double dayfrac_to_local_hr (double dayfrac, double timezone)
 
double third_order_polynomial (double a, double b, double c, double d, double x)
 
int validate_inputs (spa_data *spa)
 
double julian_day (int year, int month, int day, int hour, int minute, double second, double dut1, double tz)
 
double julian_century (double jd)
 
double julian_ephemeris_day (double jd, double delta_t)
 
double julian_ephemeris_century (double jde)
 
double julian_ephemeris_millennium (double jce)
 
double earth_periodic_term_summation (const double terms[][TERM_COUNT], int count, double jme)
 
double earth_values (double term_sum[], int count, double jme)
 
double earth_heliocentric_longitude (double jme)
 
double earth_heliocentric_latitude (double jme)
 
double earth_radius_vector (double jme)
 
double geocentric_longitude (double l)
 
double geocentric_latitude (double b)
 
double mean_elongation_moon_sun (double jce)
 
double mean_anomaly_sun (double jce)
 
double mean_anomaly_moon (double jce)
 
double argument_latitude_moon (double jce)
 
double ascending_longitude_moon (double jce)
 
double xy_term_summation (int i, double x[TERM_X_COUNT])
 
void nutation_longitude_and_obliquity (double jce, double x[TERM_X_COUNT], double *del_psi, double *del_epsilon)
 
double ecliptic_mean_obliquity (double jme)
 
double ecliptic_true_obliquity (double delta_epsilon, double epsilon0)
 
double aberration_correction (double r)
 
double apparent_sun_longitude (double theta, double delta_psi, double delta_tau)
 
double greenwich_mean_sidereal_time (double jd, double jc)
 
double greenwich_sidereal_time (double nu0, double delta_psi, double epsilon)
 
double geocentric_right_ascension (double lamda, double epsilon, double beta)
 
double geocentric_declination (double beta, double epsilon, double lamda)
 
double observer_hour_angle (double nu, double longitude, double alpha_deg)
 
double sun_equatorial_horizontal_parallax (double r)
 
void right_ascension_parallax_and_topocentric_dec (double latitude, double elevation, double xi, double h, double delta, double *delta_alpha, double *delta_prime)
 
double topocentric_right_ascension (double alpha_deg, double delta_alpha)
 
double topocentric_local_hour_angle (double h, double delta_alpha)
 
double topocentric_elevation_angle (double latitude, double delta_prime, double h_prime)
 
double atmospheric_refraction_correction (double pressure, double temperature, double atmos_refract, double e0)
 
double topocentric_elevation_angle_corrected (double e0, double delta_e)
 
double topocentric_zenith_angle (double e)
 
double topocentric_azimuth_angle_astro (double h_prime, double latitude, double delta_prime)
 
double topocentric_azimuth_angle (double azimuth_astro)
 
double surface_incidence_angle (double zenith, double azimuth_astro, double azm_rotation, double slope)
 
double sun_mean_longitude (double jme)
 
double eot (double m, double alpha, double del_psi, double epsilon)
 
double approx_sun_transit_time (double alpha_zero, double longitude, double nu)
 
double sun_hour_angle_at_rise_set (double latitude, double delta_zero, double h0_prime)
 
void approx_sun_rise_and_set (double *m_rts, double h0)
 
double rts_alpha_delta_prime (double *ad, double n)
 
double rts_sun_altitude (double latitude, double delta_prime, double h_prime)
 
double sun_rise_and_set (double *m_rts, double *h_rts, double *delta_prime, double latitude, double *h_prime, double h0_prime, int sun)
 
void calculate_geocentric_sun_right_ascension_and_declination (spa_data *spa)
 
void calculate_eot_and_sun_rise_transit_set (spa_data *spa)
 
int spa_calculate (spa_data *spa)
 

Variables

const int l_subcount [L_COUNT] = {64,34,20,7,3,1}
 
const int b_subcount [B_COUNT] = {5,2}
 
const int r_subcount [R_COUNT] = {40,10,6,2,1}
 
const double L_TERMS [L_COUNT][L_MAX_SUBCOUNT][TERM_COUNT]
 Earth Periodic Terms. More...
 
const double B_TERMS [B_COUNT][B_MAX_SUBCOUNT][TERM_COUNT]
 
const double R_TERMS [R_COUNT][R_MAX_SUBCOUNT][TERM_COUNT]
 
const int Y_TERMS [Y_COUNT][TERM_Y_COUNT]
 Periodic Terms for the nutation in longitude and obliquity. More...
 
const double PE_TERMS [Y_COUNT][TERM_PE_COUNT]
 

Macro Definition Documentation

◆ B_COUNT

#define B_COUNT   2

Definition at line 128 of file spa.c.

◆ B_MAX_SUBCOUNT

#define B_MAX_SUBCOUNT   5

Definition at line 133 of file spa.c.

◆ L_COUNT

#define L_COUNT   6

Definition at line 127 of file spa.c.

◆ L_MAX_SUBCOUNT

#define L_MAX_SUBCOUNT   64

Definition at line 132 of file spa.c.

◆ PI

#define PI   3.1415926535897932384626433832795028841971

Definition at line 124 of file spa.c.

◆ R_COUNT

#define R_COUNT   5

Definition at line 129 of file spa.c.

◆ R_MAX_SUBCOUNT

#define R_MAX_SUBCOUNT   40

Definition at line 134 of file spa.c.

◆ SUN_RADIUS

#define SUN_RADIUS   0.26667

Definition at line 125 of file spa.c.

◆ TERM_Y_COUNT

#define TERM_Y_COUNT   TERM_X_COUNT

Definition at line 142 of file spa.c.

◆ Y_COUNT

#define Y_COUNT   63

Definition at line 130 of file spa.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
TERM_A 
TERM_B 
TERM_C 
TERM_COUNT 

Definition at line 136 of file spa.c.

Definition: spa.c:136
Definition: spa.c:136
Definition: spa.c:136

◆ anonymous enum

anonymous enum
Enumerator
TERM_X0 
TERM_X1 
TERM_X2 
TERM_X3 
TERM_X4 
TERM_X_COUNT 

Definition at line 137 of file spa.c.

◆ anonymous enum

anonymous enum
Enumerator
TERM_PSI_A 
TERM_PSI_B 
TERM_EPS_C 
TERM_EPS_D 
TERM_PE_COUNT 

Definition at line 138 of file spa.c.

◆ anonymous enum

anonymous enum
Enumerator
JD_MINUS 
JD_ZERO 
JD_PLUS 
JD_COUNT 

Definition at line 139 of file spa.c.

Definition: spa.c:139
Definition: spa.c:139
Definition: spa.c:139
Definition: spa.c:139

◆ anonymous enum

anonymous enum
Enumerator
SUN_TRANSIT 
SUN_RISE 
SUN_SET 
SUN_COUNT 

Definition at line 140 of file spa.c.

Function Documentation

◆ aberration_correction()

double aberration_correction ( double  r)

Definition at line 813 of file spa.c.

814 {
815  return -20.4898 / (3600.0*r);
816 }

◆ apparent_sun_longitude()

double apparent_sun_longitude ( double  theta,
double  delta_psi,
double  delta_tau 
)

Definition at line 818 of file spa.c.

819 {
820  return theta + delta_psi + delta_tau;
821 }

◆ approx_sun_rise_and_set()

void approx_sun_rise_and_set ( double m_rts,
double  h0 
)

Definition at line 977 of file spa.c.

978 {
979  double h0_dfrac = h0/360.0;
980 
981  m_rts[SUN_RISE] = limit_zero2one(m_rts[SUN_TRANSIT] - h0_dfrac);
982  m_rts[SUN_SET] = limit_zero2one(m_rts[SUN_TRANSIT] + h0_dfrac);
983  m_rts[SUN_TRANSIT] = limit_zero2one(m_rts[SUN_TRANSIT]);
984 }
double limit_zero2one(double value)
Definition: spa.c:572
Definition: spa.c:140
Definition: spa.c:140

◆ approx_sun_transit_time()

double approx_sun_transit_time ( double  alpha_zero,
double  longitude,
double  nu 
)

Definition at line 959 of file spa.c.

960 {
961  return (alpha_zero - longitude - nu) / 360.0;
962 }

◆ argument_latitude_moon()

double argument_latitude_moon ( double  jce)

Definition at line 763 of file spa.c.

764 {
765  return third_order_polynomial(1.0/327270.0, -0.0036825, 483202.017538, 93.27191, jce);
766 }
double third_order_polynomial(double a, double b, double c, double d, double x)
Definition: spa.c:597

◆ ascending_longitude_moon()

double ascending_longitude_moon ( double  jce)

Definition at line 768 of file spa.c.

769 {
770  return third_order_polynomial(1.0/450000.0, 0.0020708, -1934.136261, 125.04452, jce);
771 }
double third_order_polynomial(double a, double b, double c, double d, double x)
Definition: spa.c:597

◆ atmospheric_refraction_correction()

double atmospheric_refraction_correction ( double  pressure,
double  temperature,
double  atmos_refract,
double  e0 
)

Definition at line 902 of file spa.c.

904 {
905  double del_e = 0;
906 
907  if (e0 >= -1*(SUN_RADIUS + atmos_refract))
908  del_e = (pressure / 1010.0) * (283.0 / (273.0 + temperature)) *
909  1.02 / (60.0 * tan(deg2rad(e0 + 10.3/(e0 + 5.11))));
910 
911  return del_e;
912 }
double deg2rad(double degrees)
Definition: spa.c:528
#define SUN_RADIUS
Definition: spa.c:125

◆ calculate_eot_and_sun_rise_transit_set()

void calculate_eot_and_sun_rise_transit_set ( spa_data spa)

Definition at line 1058 of file spa.c.

1059 {
1060  spa_data sun_rts;
1061  double nu, m, h0, n;
1062  double alpha[JD_COUNT], delta[JD_COUNT];
1063  double m_rts[SUN_COUNT], nu_rts[SUN_COUNT], h_rts[SUN_COUNT];
1064  double alpha_prime[SUN_COUNT], delta_prime[SUN_COUNT], h_prime[SUN_COUNT];
1065  double h0_prime = -1*(SUN_RADIUS + spa->atmos_refract);
1066  int i;
1067 
1068  sun_rts = *spa;
1069  m = sun_mean_longitude(spa->jme);
1070  spa->eot = eot(m, spa->alpha, spa->del_psi, spa->epsilon);
1071 
1072  sun_rts.hour = sun_rts.minute = sun_rts.second = 0;
1073  sun_rts.delta_ut1 = sun_rts.timezone = 0.0;
1074 
1075  sun_rts.jd = julian_day (sun_rts.year, sun_rts.month, sun_rts.day, sun_rts.hour,
1076  sun_rts.minute, sun_rts.second, sun_rts.delta_ut1, sun_rts.timezone);
1077 
1079  nu = sun_rts.nu;
1080 
1081  sun_rts.delta_t = 0;
1082  sun_rts.jd--;
1083  for (i = 0; i < JD_COUNT; i++) {
1085  alpha[i] = sun_rts.alpha;
1086  delta[i] = sun_rts.delta;
1087  sun_rts.jd++;
1088  }
1089 
1091  h0 = sun_hour_angle_at_rise_set(spa->latitude, delta[JD_ZERO], h0_prime);
1092 
1093  if (h0 >= 0) {
1094 
1095  approx_sun_rise_and_set(m_rts, h0);
1096 
1097  for (i = 0; i < SUN_COUNT; i++) {
1098 
1099  nu_rts[i] = nu + 360.985647*m_rts[i];
1100 
1101  n = m_rts[i] + spa->delta_t/86400.0;
1102  alpha_prime[i] = rts_alpha_delta_prime(alpha, n);
1103  delta_prime[i] = rts_alpha_delta_prime(delta, n);
1104 
1105  h_prime[i] = limit_degrees180pm(nu_rts[i] + spa->longitude - alpha_prime[i]);
1106 
1107  h_rts[i] = rts_sun_altitude(spa->latitude, delta_prime[i], h_prime[i]);
1108  }
1109 
1110  spa->srha = h_prime[SUN_RISE];
1111  spa->ssha = h_prime[SUN_SET];
1112  spa->sta = h_rts[SUN_TRANSIT];
1113 
1114  spa->suntransit = dayfrac_to_local_hr(m_rts[SUN_TRANSIT] - h_prime[SUN_TRANSIT] / 360.0,
1115  spa->timezone);
1116 
1117  spa->sunrise = dayfrac_to_local_hr(sun_rise_and_set(m_rts, h_rts, delta_prime,
1118  spa->latitude, h_prime, h0_prime, SUN_RISE), spa->timezone);
1119 
1120  spa->sunset = dayfrac_to_local_hr(sun_rise_and_set(m_rts, h_rts, delta_prime,
1121  spa->latitude, h_prime, h0_prime, SUN_SET), spa->timezone);
1122 
1123  } else spa->srha= spa->ssha= spa->sta= spa->suntransit= spa->sunrise= spa->sunset= -99999;
1124 
1125 }
double alpha
Definition: spa.h:150
double sunrise
Definition: spa.h:177
int month
Definition: spa.h:69
double sta
Definition: spa.h:167
int hour
Definition: spa.h:71
Definition: spa.c:140
double sun_rise_and_set(double *m_rts, double *h_rts, double *delta_prime, double latitude, double *h_prime, double h0_prime, int sun)
Definition: spa.c:1006
double suntransit
Definition: spa.h:176
double srha
Definition: spa.h:165
static constexpr double delta
FTensor::Index< 'n', 2 > n
Definition: PlasticOps.hpp:68
double sun_mean_longitude(double jme)
Definition: spa.c:948
double atmos_refract
Definition: spa.h:113
Definition: spa.c:139
int year
Definition: spa.h:68
Definition: spa.c:139
double latitude
Definition: spa.h:94
void approx_sun_rise_and_set(double *m_rts, double h0)
Definition: spa.c:977
double rts_sun_altitude(double latitude, double delta_prime, double h_prime)
Definition: spa.c:997
double delta
Definition: spa.h:151
double eot
Definition: spa.h:164
double jd
Definition: spa.h:120
double eot(double m, double alpha, double del_psi, double epsilon)
Definition: spa.c:954
FTensor::Index< 'm', 2 > m
Definition: PlasticOps.hpp:67
double nu
Definition: spa.h:148
Definition: spa.h:64
void calculate_geocentric_sun_right_ascension_and_declination(spa_data *spa)
Definition: spa.c:1017
double jme
Definition: spa.h:125
double dayfrac_to_local_hr(double dayfrac, double timezone)
Definition: spa.c:592
int day
Definition: spa.h:70
double epsilon
Definition: spa.h:143
double limit_degrees180pm(double degrees)
Definition: spa.c:549
double longitude
Definition: spa.h:91
double delta_ut1
Definition: spa.h:75
double julian_day(int year, int month, int day, int hour, int minute, double second, double dut1, double tz)
Definition: spa.c:633
double sun_hour_angle_at_rise_set(double latitude, double delta_zero, double h0_prime)
Definition: spa.c:964
Definition: spa.c:140
double rts_alpha_delta_prime(double *ad, double n)
Definition: spa.c:986
int minute
Definition: spa.h:72
double del_psi
Definition: spa.h:140
double delta_t
Definition: spa.h:82
double ssha
Definition: spa.h:166
double approx_sun_transit_time(double alpha_zero, double longitude, double nu)
Definition: spa.c:959
double sunset
Definition: spa.h:178
#define SUN_RADIUS
Definition: spa.c:125
double timezone
Definition: spa.h:88
FTensor::Index< 'i', 2 > i
[Common data]
Definition: ContactOps.hpp:26
double second
Definition: spa.h:73
Definition: spa.c:140

◆ calculate_geocentric_sun_right_ascension_and_declination()

void calculate_geocentric_sun_right_ascension_and_declination ( spa_data spa)

Definition at line 1017 of file spa.c.

1018 {
1019  double x[TERM_X_COUNT];
1020 
1021  spa->jc = julian_century(spa->jd);
1022 
1023  spa->jde = julian_ephemeris_day(spa->jd, spa->delta_t);
1024  spa->jce = julian_ephemeris_century(spa->jde);
1025  spa->jme = julian_ephemeris_millennium(spa->jce);
1026 
1027  spa->l = earth_heliocentric_longitude(spa->jme);
1028  spa->b = earth_heliocentric_latitude(spa->jme);
1029  spa->r = earth_radius_vector(spa->jme);
1030 
1031  spa->theta = geocentric_longitude(spa->l);
1032  spa->beta = geocentric_latitude(spa->b);
1033 
1034  x[TERM_X0] = spa->x0 = mean_elongation_moon_sun(spa->jce);
1035  x[TERM_X1] = spa->x1 = mean_anomaly_sun(spa->jce);
1036  x[TERM_X2] = spa->x2 = mean_anomaly_moon(spa->jce);
1037  x[TERM_X3] = spa->x3 = argument_latitude_moon(spa->jce);
1038  x[TERM_X4] = spa->x4 = ascending_longitude_moon(spa->jce);
1039 
1040  nutation_longitude_and_obliquity(spa->jce, x, &(spa->del_psi), &(spa->del_epsilon));
1041 
1042  spa->epsilon0 = ecliptic_mean_obliquity(spa->jme);
1044 
1045  spa->del_tau = aberration_correction(spa->r);
1046  spa->lamda = apparent_sun_longitude(spa->theta, spa->del_psi, spa->del_tau);
1047  spa->nu0 = greenwich_mean_sidereal_time (spa->jd, spa->jc);
1048  spa->nu = greenwich_sidereal_time (spa->nu0, spa->del_psi, spa->epsilon);
1049 
1050  spa->alpha = geocentric_right_ascension(spa->lamda, spa->epsilon, spa->beta);
1051  spa->delta = geocentric_declination(spa->beta, spa->epsilon, spa->lamda);
1052 }
double alpha
Definition: spa.h:150
Definition: spa.c:137
Definition: spa.c:137
double ecliptic_mean_obliquity(double jme)
Definition: spa.c:800
Definition: spa.c:137
double x2
Definition: spa.h:136
double lamda
Definition: spa.h:146
double nu0
Definition: spa.h:147
double earth_heliocentric_longitude(double jme)
Definition: spa.c:698
double mean_anomaly_moon(double jce)
Definition: spa.c:758
double jce
Definition: spa.h:124
double x4
Definition: spa.h:138
double earth_heliocentric_latitude(double jme)
Definition: spa.c:710
double mean_anomaly_sun(double jce)
Definition: spa.c:753
double geocentric_right_ascension(double lamda, double epsilon, double beta)
Definition: spa.c:834
double epsilon0
Definition: spa.h:142
double geocentric_longitude(double l)
Definition: spa.c:734
double apparent_sun_longitude(double theta, double delta_psi, double delta_tau)
Definition: spa.c:818
double delta
Definition: spa.h:151
double aberration_correction(double r)
Definition: spa.c:813
double jde
Definition: spa.h:123
double jc
Definition: spa.h:121
double l
Definition: spa.h:127
double jd
Definition: spa.h:120
double x3
Definition: spa.h:137
double nu
Definition: spa.h:148
double julian_ephemeris_century(double jde)
Definition: spa.c:664
double beta
Definition: spa.h:132
double x1
Definition: spa.h:135
double jme
Definition: spa.h:125
double r
Definition: spa.h:129
Definition: spa.c:137
double epsilon
Definition: spa.h:143
double theta
Definition: spa.h:131
void nutation_longitude_and_obliquity(double jce, double x[TERM_X_COUNT], double *del_psi, double *del_epsilon)
Definition: spa.c:784
double greenwich_sidereal_time(double nu0, double delta_psi, double epsilon)
Definition: spa.c:829
double geocentric_declination(double beta, double epsilon, double lamda)
Definition: spa.c:843
double x0
Definition: spa.h:134
double earth_radius_vector(double jme)
Definition: spa.c:722
double del_tau
Definition: spa.h:145
double julian_century(double jd)
Definition: spa.c:654
double julian_ephemeris_millennium(double jce)
Definition: spa.c:669
double julian_ephemeris_day(double jd, double delta_t)
Definition: spa.c:659
double ascending_longitude_moon(double jce)
Definition: spa.c:768
double greenwich_mean_sidereal_time(double jd, double jc)
Definition: spa.c:823
Definition: spa.c:137
double ecliptic_true_obliquity(double delta_epsilon, double epsilon0)
Definition: spa.c:808
double del_psi
Definition: spa.h:140
double delta_t
Definition: spa.h:82
double mean_elongation_moon_sun(double jce)
Definition: spa.c:748
double b
Definition: spa.h:128
double argument_latitude_moon(double jce)
Definition: spa.c:763
double del_epsilon
Definition: spa.h:141
double geocentric_latitude(double b)
Definition: spa.c:743

◆ dayfrac_to_local_hr()

double dayfrac_to_local_hr ( double  dayfrac,
double  timezone 
)

Definition at line 592 of file spa.c.

593 {
594  return 24.0*limit_zero2one(dayfrac + timezone/24.0);
595 }
double limit_zero2one(double value)
Definition: spa.c:572

◆ deg2rad()

double deg2rad ( double  degrees)

Definition at line 528 of file spa.c.

529 {
530  return (PI/180.0)*degrees;
531 }
#define PI
Definition: spa.c:124

◆ earth_heliocentric_latitude()

double earth_heliocentric_latitude ( double  jme)

Definition at line 710 of file spa.c.

711 {
712  double sum[B_COUNT];
713  int i;
714 
715  for (i = 0; i < B_COUNT; i++)
717 
718  return rad2deg(earth_values(sum, B_COUNT, jme));
719 
720 }
double earth_values(double term_sum[], int count, double jme)
Definition: spa.c:685
const double B_TERMS[B_COUNT][B_MAX_SUBCOUNT][TERM_COUNT]
Definition: spa.c:296
const int b_subcount[B_COUNT]
Definition: spa.c:145
#define B_COUNT
Definition: spa.c:128
double earth_periodic_term_summation(const double terms[][TERM_COUNT], int count, double jme)
Definition: spa.c:674
double rad2deg(double radians)
Definition: spa.c:523
FTensor::Index< 'i', 2 > i
[Common data]
Definition: ContactOps.hpp:26

◆ earth_heliocentric_longitude()

double earth_heliocentric_longitude ( double  jme)

Definition at line 698 of file spa.c.

699 {
700  double sum[L_COUNT];
701  int i;
702 
703  for (i = 0; i < L_COUNT; i++)
705 
706  return limit_degrees(rad2deg(earth_values(sum, L_COUNT, jme)));
707 
708 }
double earth_values(double term_sum[], int count, double jme)
Definition: spa.c:685
#define L_COUNT
Definition: spa.c:127
const int l_subcount[L_COUNT]
Definition: spa.c:144
double earth_periodic_term_summation(const double terms[][TERM_COUNT], int count, double jme)
Definition: spa.c:674
const double L_TERMS[L_COUNT][L_MAX_SUBCOUNT][TERM_COUNT]
Earth Periodic Terms.
Definition: spa.c:151
double limit_degrees(double degrees)
Definition: spa.c:538
double rad2deg(double radians)
Definition: spa.c:523
FTensor::Index< 'i', 2 > i
[Common data]
Definition: ContactOps.hpp:26

◆ earth_periodic_term_summation()

double earth_periodic_term_summation ( const double  terms[][TERM_COUNT],
int  count,
double  jme 
)

Definition at line 674 of file spa.c.

675 {
676  int i;
677  double sum=0;
678 
679  for (i = 0; i < count; i++)
680  sum += terms[i][TERM_A]*cos(terms[i][TERM_B]+terms[i][TERM_C]*jme);
681 
682  return sum;
683 }
Definition: spa.c:136
Definition: spa.c:136
Definition: spa.c:136
FTensor::Index< 'i', 2 > i
[Common data]
Definition: ContactOps.hpp:26

◆ earth_radius_vector()

double earth_radius_vector ( double  jme)

Definition at line 722 of file spa.c.

723 {
724  double sum[R_COUNT];
725  int i;
726 
727  for (i = 0; i < R_COUNT; i++)
729 
730  return earth_values(sum, R_COUNT, jme);
731 
732 }
double earth_values(double term_sum[], int count, double jme)
Definition: spa.c:685
const double R_TERMS[R_COUNT][R_MAX_SUBCOUNT][TERM_COUNT]
Definition: spa.c:311
double earth_periodic_term_summation(const double terms[][TERM_COUNT], int count, double jme)
Definition: spa.c:674
#define R_COUNT
Definition: spa.c:129
const int r_subcount[R_COUNT]
Definition: spa.c:146
FTensor::Index< 'i', 2 > i
[Common data]
Definition: ContactOps.hpp:26

◆ earth_values()

double earth_values ( double  term_sum[],
int  count,
double  jme 
)

Definition at line 685 of file spa.c.

686 {
687  int i;
688  double sum=0;
689 
690  for (i = 0; i < count; i++)
691  sum += term_sum[i]*pow(jme, i);
692 
693  sum /= 1.0e8;
694 
695  return sum;
696 }
FTensor::Index< 'i', 2 > i
[Common data]
Definition: ContactOps.hpp:26

◆ ecliptic_mean_obliquity()

double ecliptic_mean_obliquity ( double  jme)

Definition at line 800 of file spa.c.

801 {
802  double u = jme/10.0;
803 
804  return 84381.448 + u*(-4680.93 + u*(-1.55 + u*(1999.25 + u*(-51.38 + u*(-249.67 +
805  u*( -39.05 + u*( 7.12 + u*( 27.87 + u*( 5.79 + u*2.45)))))))));
806 }

◆ ecliptic_true_obliquity()

double ecliptic_true_obliquity ( double  delta_epsilon,
double  epsilon0 
)

Definition at line 808 of file spa.c.

809 {
810  return delta_epsilon + epsilon0/3600.0;
811 }

◆ eot()

double eot ( double  m,
double  alpha,
double  del_psi,
double  epsilon 
)

Definition at line 954 of file spa.c.

955 {
956  return limit_minutes(4.0*(m - 0.0057183 - alpha + del_psi*cos(deg2rad(epsilon))));
957 }
double limit_minutes(double minutes)
Definition: spa.c:582
FTensor::Index< 'm', 2 > m
Definition: PlasticOps.hpp:67
double deg2rad(double degrees)
Definition: spa.c:528

◆ geocentric_declination()

double geocentric_declination ( double  beta,
double  epsilon,
double  lamda 
)

Definition at line 843 of file spa.c.

844 {
845  double beta_rad = deg2rad(beta);
846  double epsilon_rad = deg2rad(epsilon);
847 
848  return rad2deg(asin(sin(beta_rad)*cos(epsilon_rad) +
849  cos(beta_rad)*sin(epsilon_rad)*sin(deg2rad(lamda))));
850 }
double deg2rad(double degrees)
Definition: spa.c:528
double rad2deg(double radians)
Definition: spa.c:523

◆ geocentric_latitude()

double geocentric_latitude ( double  b)

Definition at line 743 of file spa.c.

744 {
745  return -b;
746 }

◆ geocentric_longitude()

double geocentric_longitude ( double  l)

Definition at line 734 of file spa.c.

735 {
736  double theta = l + 180.0;
737 
738  if (theta >= 360.0) theta -= 360.0;
739 
740  return theta;
741 }
FTensor::Index< 'l', 2 > l
Definition: ContactOps.hpp:29

◆ geocentric_right_ascension()

double geocentric_right_ascension ( double  lamda,
double  epsilon,
double  beta 
)

Definition at line 834 of file spa.c.

835 {
836  double lamda_rad = deg2rad(lamda);
837  double epsilon_rad = deg2rad(epsilon);
838 
839  return limit_degrees(rad2deg(atan2(sin(lamda_rad)*cos(epsilon_rad) -
840  tan(deg2rad(beta))*sin(epsilon_rad), cos(lamda_rad))));
841 }
double deg2rad(double degrees)
Definition: spa.c:528
double limit_degrees(double degrees)
Definition: spa.c:538
double rad2deg(double radians)
Definition: spa.c:523

◆ greenwich_mean_sidereal_time()

double greenwich_mean_sidereal_time ( double  jd,
double  jc 
)

Definition at line 823 of file spa.c.

824 {
825  return limit_degrees(280.46061837 + 360.98564736629 * (jd - 2451545.0) +
826  jc*jc*(0.000387933 - jc/38710000.0));
827 }
double limit_degrees(double degrees)
Definition: spa.c:538

◆ greenwich_sidereal_time()

double greenwich_sidereal_time ( double  nu0,
double  delta_psi,
double  epsilon 
)

Definition at line 829 of file spa.c.

830 {
831  return nu0 + delta_psi*cos(deg2rad(epsilon));
832 }
double deg2rad(double degrees)
Definition: spa.c:528

◆ integer()

int integer ( double  value)

Definition at line 533 of file spa.c.

534 {
535  return value;
536 }

◆ julian_century()

double julian_century ( double  jd)

Definition at line 654 of file spa.c.

655 {
656  return (jd-2451545.0)/36525.0;
657 }

◆ julian_day()

double julian_day ( int  year,
int  month,
int  day,
int  hour,
int  minute,
double  second,
double  dut1,
double  tz 
)

Definition at line 633 of file spa.c.

634 {
635  double day_decimal, julian_day, a;
636 
637  day_decimal = day + (hour - tz + (minute + (second + dut1)/60.0)/60.0)/24.0;
638 
639  if (month < 3) {
640  month += 12;
641  year--;
642  }
643 
644  julian_day = integer(365.25*(year+4716.0)) + integer(30.6001*(month+1)) + day_decimal - 1524.5;
645 
646  if (julian_day > 2299160.0) {
647  a = integer(year/100);
648  julian_day += (2 - a + integer(a/4));
649  }
650 
651  return julian_day;
652 }
int integer(double value)
Definition: spa.c:533
double julian_day(int year, int month, int day, int hour, int minute, double second, double dut1, double tz)
Definition: spa.c:633

◆ julian_ephemeris_century()

double julian_ephemeris_century ( double  jde)

Definition at line 664 of file spa.c.

665 {
666  return (jde - 2451545.0)/36525.0;
667 }

◆ julian_ephemeris_day()

double julian_ephemeris_day ( double  jd,
double  delta_t 
)

Definition at line 659 of file spa.c.

660 {
661  return jd+delta_t/86400.0;
662 }

◆ julian_ephemeris_millennium()

double julian_ephemeris_millennium ( double  jce)

Definition at line 669 of file spa.c.

670 {
671  return (jce/10.0);
672 }

◆ limit_degrees()

double limit_degrees ( double  degrees)

Definition at line 538 of file spa.c.

539 {
540  double limited;
541 
542  degrees /= 360.0;
543  limited = 360.0*(degrees-floor(degrees));
544  if (limited < 0) limited += 360.0;
545 
546  return limited;
547 }

◆ limit_degrees180()

double limit_degrees180 ( double  degrees)

Definition at line 561 of file spa.c.

562 {
563  double limited;
564 
565  degrees /= 180.0;
566  limited = 180.0*(degrees-floor(degrees));
567  if (limited < 0) limited += 180.0;
568 
569  return limited;
570 }

◆ limit_degrees180pm()

double limit_degrees180pm ( double  degrees)

Definition at line 549 of file spa.c.

550 {
551  double limited;
552 
553  degrees /= 360.0;
554  limited = 360.0*(degrees-floor(degrees));
555  if (limited < -180.0) limited += 360.0;
556  else if (limited > 180.0) limited -= 360.0;
557 
558  return limited;
559 }

◆ limit_minutes()

double limit_minutes ( double  minutes)

Definition at line 582 of file spa.c.

583 {
584  double limited=minutes;
585 
586  if (limited < -20.0) limited += 1440.0;
587  else if (limited > 20.0) limited -= 1440.0;
588 
589  return limited;
590 }

◆ limit_zero2one()

double limit_zero2one ( double  value)

Definition at line 572 of file spa.c.

573 {
574  double limited;
575 
576  limited = value - floor(value);
577  if (limited < 0) limited += 1.0;
578 
579  return limited;
580 }

◆ mean_anomaly_moon()

double mean_anomaly_moon ( double  jce)

Definition at line 758 of file spa.c.

759 {
760  return third_order_polynomial(1.0/56250.0, 0.0086972, 477198.867398, 134.96298, jce);
761 }
double third_order_polynomial(double a, double b, double c, double d, double x)
Definition: spa.c:597

◆ mean_anomaly_sun()

double mean_anomaly_sun ( double  jce)

Definition at line 753 of file spa.c.

754 {
755  return third_order_polynomial(-1.0/300000.0, -0.0001603, 35999.05034, 357.52772, jce);
756 }
double third_order_polynomial(double a, double b, double c, double d, double x)
Definition: spa.c:597

◆ mean_elongation_moon_sun()

double mean_elongation_moon_sun ( double  jce)

Definition at line 748 of file spa.c.

749 {
750  return third_order_polynomial(1.0/189474.0, -0.0019142, 445267.11148, 297.85036, jce);
751 }
double third_order_polynomial(double a, double b, double c, double d, double x)
Definition: spa.c:597

◆ nutation_longitude_and_obliquity()

void nutation_longitude_and_obliquity ( double  jce,
double  x[TERM_X_COUNT],
double del_psi,
double del_epsilon 
)

Definition at line 784 of file spa.c.

786 {
787  int i;
788  double xy_term_sum, sum_psi=0, sum_epsilon=0;
789 
790  for (i = 0; i < Y_COUNT; i++) {
791  xy_term_sum = deg2rad(xy_term_summation(i, x));
792  sum_psi += (PE_TERMS[i][TERM_PSI_A] + jce*PE_TERMS[i][TERM_PSI_B])*sin(xy_term_sum);
793  sum_epsilon += (PE_TERMS[i][TERM_EPS_C] + jce*PE_TERMS[i][TERM_EPS_D])*cos(xy_term_sum);
794  }
795 
796  *del_psi = sum_psi / 36000000.0;
797  *del_epsilon = sum_epsilon / 36000000.0;
798 }
#define Y_COUNT
Definition: spa.c:130
double xy_term_summation(int i, double x[TERM_X_COUNT])
Definition: spa.c:773
double deg2rad(double degrees)
Definition: spa.c:528
const double PE_TERMS[Y_COUNT][TERM_PE_COUNT]
Definition: spa.c:455
FTensor::Index< 'i', 2 > i
[Common data]
Definition: ContactOps.hpp:26

◆ observer_hour_angle()

double observer_hour_angle ( double  nu,
double  longitude,
double  alpha_deg 
)

Definition at line 852 of file spa.c.

853 {
854  return limit_degrees(nu + longitude - alpha_deg);
855 }
double limit_degrees(double degrees)
Definition: spa.c:538

◆ rad2deg()

double rad2deg ( double  radians)

Definition at line 523 of file spa.c.

524 {
525  return (180.0/PI)*radians;
526 }
#define PI
Definition: spa.c:124

◆ right_ascension_parallax_and_topocentric_dec()

void right_ascension_parallax_and_topocentric_dec ( double  latitude,
double  elevation,
double  xi,
double  h,
double  delta,
double delta_alpha,
double delta_prime 
)

Definition at line 862 of file spa.c.

864 {
865  double delta_alpha_rad;
866  double lat_rad = deg2rad(latitude);
867  double xi_rad = deg2rad(xi);
868  double h_rad = deg2rad(h);
869  double delta_rad = deg2rad(delta);
870  double u = atan(0.99664719 * tan(lat_rad));
871  double y = 0.99664719 * sin(u) + elevation*sin(lat_rad)/6378140.0;
872  double x = cos(u) + elevation*cos(lat_rad)/6378140.0;
873 
874  delta_alpha_rad = atan2( - x*sin(xi_rad) *sin(h_rad),
875  cos(delta_rad) - x*sin(xi_rad) *cos(h_rad));
876 
877  *delta_prime = rad2deg(atan2((sin(delta_rad) - y*sin(xi_rad))*cos(delta_alpha_rad),
878  cos(delta_rad) - x*sin(xi_rad) *cos(h_rad)));
879 
880  *delta_alpha = rad2deg(delta_alpha_rad);
881 }
static constexpr double delta
double deg2rad(double degrees)
Definition: spa.c:528
double rad2deg(double radians)
Definition: spa.c:523

◆ rts_alpha_delta_prime()

double rts_alpha_delta_prime ( double ad,
double  n 
)

Definition at line 986 of file spa.c.

987 {
988  double a = ad[JD_ZERO] - ad[JD_MINUS];
989  double b = ad[JD_PLUS] - ad[JD_ZERO];
990 
991  if (fabs(a) >= 2.0) a = limit_zero2one(a);
992  if (fabs(b) >= 2.0) b = limit_zero2one(b);
993 
994  return ad[JD_ZERO] + n * (a + b + (b-a)*n)/2.0;
995 }
Definition: spa.c:139
double limit_zero2one(double value)
Definition: spa.c:572
FTensor::Index< 'n', 2 > n
Definition: PlasticOps.hpp:68
Definition: spa.c:139
Definition: spa.c:139

◆ rts_sun_altitude()

double rts_sun_altitude ( double  latitude,
double  delta_prime,
double  h_prime 
)

Definition at line 997 of file spa.c.

998 {
999  double latitude_rad = deg2rad(latitude);
1000  double delta_prime_rad = deg2rad(delta_prime);
1001 
1002  return rad2deg(asin(sin(latitude_rad)*sin(delta_prime_rad) +
1003  cos(latitude_rad)*cos(delta_prime_rad)*cos(deg2rad(h_prime))));
1004 }
double deg2rad(double degrees)
Definition: spa.c:528
double rad2deg(double radians)
Definition: spa.c:523

◆ spa_calculate()

int spa_calculate ( spa_data spa)

Definition at line 1131 of file spa.c.

1132 {
1133  int result;
1134 
1135  result = validate_inputs(spa);
1136 
1137  if (result == 0)
1138  {
1139  spa->jd = julian_day (spa->year, spa->month, spa->day, spa->hour,
1140  spa->minute, spa->second, spa->delta_ut1, spa->timezone);
1141 
1143 
1144  spa->h = observer_hour_angle(spa->nu, spa->longitude, spa->alpha);
1146 
1148  spa->h, spa->delta, &(spa->del_alpha), &(spa->delta_prime));
1149 
1151  spa->h_prime = topocentric_local_hour_angle(spa->h, spa->del_alpha);
1152 
1153  spa->e0 = topocentric_elevation_angle(spa->latitude, spa->delta_prime, spa->h_prime);
1155  spa->atmos_refract, spa->e0);
1156  spa->e = topocentric_elevation_angle_corrected(spa->e0, spa->del_e);
1157 
1158  spa->zenith = topocentric_zenith_angle(spa->e);
1160  spa->delta_prime);
1162 
1163  if ((spa->function == SPA_ZA_INC) || (spa->function == SPA_ALL))
1165  spa->azm_rotation, spa->slope);
1166 
1167  if ((spa->function == SPA_ZA_RTS) || (spa->function == SPA_ALL))
1169  }
1170 
1171  return result;
1172 }
double sun_equatorial_horizontal_parallax(double r)
Definition: spa.c:857
double alpha
Definition: spa.h:150
double elevation
Definition: spa.h:97
Definition: spa.h:61
Definition: spa.h:60
int validate_inputs(spa_data *spa)
Definition: spa.c:603
int month
Definition: spa.h:69
double e
Definition: spa.h:162
double delta_prime
Definition: spa.h:156
int hour
Definition: spa.h:71
double e0
Definition: spa.h:160
double xi
Definition: spa.h:154
double del_e
Definition: spa.h:161
double topocentric_zenith_angle(double e)
Definition: spa.c:919
Definition: spa.h:59
double h_prime
Definition: spa.h:158
double topocentric_azimuth_angle_astro(double h_prime, double latitude, double delta_prime)
Definition: spa.c:924
double atmos_refract
Definition: spa.h:113
double incidence
Definition: spa.h:174
double topocentric_right_ascension(double alpha_deg, double delta_alpha)
Definition: spa.c:883
int year
Definition: spa.h:68
double temperature
Definition: spa.h:103
double topocentric_elevation_angle(double latitude, double delta_prime, double h_prime)
Definition: spa.c:893
double latitude
Definition: spa.h:94
double topocentric_local_hour_angle(double h, double delta_alpha)
Definition: spa.c:888
double observer_hour_angle(double nu, double longitude, double alpha_deg)
Definition: spa.c:852
void right_ascension_parallax_and_topocentric_dec(double latitude, double elevation, double xi, double h, double delta, double *delta_alpha, double *delta_prime)
Definition: spa.c:862
double alpha_prime
Definition: spa.h:157
double topocentric_elevation_angle_corrected(double e0, double delta_e)
Definition: spa.c:914
double delta
Definition: spa.h:151
double jd
Definition: spa.h:120
double surface_incidence_angle(double zenith, double azimuth_astro, double azm_rotation, double slope)
Definition: spa.c:938
double h
Definition: spa.h:153
double topocentric_azimuth_angle(double azimuth_astro)
Definition: spa.c:933
double nu
Definition: spa.h:148
void calculate_geocentric_sun_right_ascension_and_declination(spa_data *spa)
Definition: spa.c:1017
double r
Definition: spa.h:129
double atmospheric_refraction_correction(double pressure, double temperature, double atmos_refract, double e0)
Definition: spa.c:902
int function
Definition: spa.h:116
int day
Definition: spa.h:70
double pressure
Definition: spa.h:100
double longitude
Definition: spa.h:91
void calculate_eot_and_sun_rise_transit_set(spa_data *spa)
Definition: spa.c:1058
double delta_ut1
Definition: spa.h:75
double julian_day(int year, int month, int day, int hour, int minute, double second, double dut1, double tz)
Definition: spa.c:633
double azm_rotation
Definition: spa.h:109
double del_alpha
Definition: spa.h:155
double azimuth
Definition: spa.h:173
double azimuth_astro
Definition: spa.h:172
double zenith
Definition: spa.h:171
int minute
Definition: spa.h:72
double slope
Definition: spa.h:106
double timezone
Definition: spa.h:88
double second
Definition: spa.h:73

◆ sun_equatorial_horizontal_parallax()

double sun_equatorial_horizontal_parallax ( double  r)

Definition at line 857 of file spa.c.

858 {
859  return 8.794 / (3600.0 * r);
860 }

◆ sun_hour_angle_at_rise_set()

double sun_hour_angle_at_rise_set ( double  latitude,
double  delta_zero,
double  h0_prime 
)

Definition at line 964 of file spa.c.

965 {
966  double h0 = -99999;
967  double latitude_rad = deg2rad(latitude);
968  double delta_zero_rad = deg2rad(delta_zero);
969  double argument = (sin(deg2rad(h0_prime)) - sin(latitude_rad)*sin(delta_zero_rad)) /
970  (cos(latitude_rad)*cos(delta_zero_rad));
971 
972  if (fabs(argument) <= 1) h0 = limit_degrees180(rad2deg(acos(argument)));
973 
974  return h0;
975 }
double deg2rad(double degrees)
Definition: spa.c:528
double limit_degrees180(double degrees)
Definition: spa.c:561
double rad2deg(double radians)
Definition: spa.c:523

◆ sun_mean_longitude()

double sun_mean_longitude ( double  jme)

Definition at line 948 of file spa.c.

949 {
950  return limit_degrees(280.4664567 + jme*(360007.6982779 + jme*(0.03032028 +
951  jme*(1/49931.0 + jme*(-1/15300.0 + jme*(-1/2000000.0))))));
952 }
double limit_degrees(double degrees)
Definition: spa.c:538

◆ sun_rise_and_set()

double sun_rise_and_set ( double m_rts,
double h_rts,
double delta_prime,
double  latitude,
double h_prime,
double  h0_prime,
int  sun 
)

Definition at line 1006 of file spa.c.

1008 {
1009  return m_rts[sun] + (h_rts[sun] - h0_prime) /
1010  (360.0*cos(deg2rad(delta_prime[sun]))*cos(deg2rad(latitude))*sin(deg2rad(h_prime[sun])));
1011 }
double deg2rad(double degrees)
Definition: spa.c:528

◆ surface_incidence_angle()

double surface_incidence_angle ( double  zenith,
double  azimuth_astro,
double  azm_rotation,
double  slope 
)

Definition at line 938 of file spa.c.

940 {
941  double zenith_rad = deg2rad(zenith);
942  double slope_rad = deg2rad(slope);
943 
944  return rad2deg(acos(cos(zenith_rad)*cos(slope_rad) +
945  sin(slope_rad )*sin(zenith_rad) * cos(deg2rad(azimuth_astro - azm_rotation))));
946 }
double deg2rad(double degrees)
Definition: spa.c:528
double rad2deg(double radians)
Definition: spa.c:523

◆ third_order_polynomial()

double third_order_polynomial ( double  a,
double  b,
double  c,
double  d,
double  x 
)

Definition at line 597 of file spa.c.

598 {
599  return ((a*x + b)*x + c)*x + d;
600 }
const Tensor1_Expr< const dTensor0< T, Dim, i >, typename promote< T, double >::V, Dim, i > d(const Tensor0< T * > &a, const Index< i, Dim > index, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: dTensor0.hpp:27

◆ topocentric_azimuth_angle()

double topocentric_azimuth_angle ( double  azimuth_astro)

Definition at line 933 of file spa.c.

934 {
935  return limit_degrees(azimuth_astro + 180.0);
936 }
double limit_degrees(double degrees)
Definition: spa.c:538

◆ topocentric_azimuth_angle_astro()

double topocentric_azimuth_angle_astro ( double  h_prime,
double  latitude,
double  delta_prime 
)

Definition at line 924 of file spa.c.

925 {
926  double h_prime_rad = deg2rad(h_prime);
927  double lat_rad = deg2rad(latitude);
928 
929  return limit_degrees(rad2deg(atan2(sin(h_prime_rad),
930  cos(h_prime_rad)*sin(lat_rad) - tan(deg2rad(delta_prime))*cos(lat_rad))));
931 }
double deg2rad(double degrees)
Definition: spa.c:528
double limit_degrees(double degrees)
Definition: spa.c:538
double rad2deg(double radians)
Definition: spa.c:523

◆ topocentric_elevation_angle()

double topocentric_elevation_angle ( double  latitude,
double  delta_prime,
double  h_prime 
)

Definition at line 893 of file spa.c.

894 {
895  double lat_rad = deg2rad(latitude);
896  double delta_prime_rad = deg2rad(delta_prime);
897 
898  return rad2deg(asin(sin(lat_rad)*sin(delta_prime_rad) +
899  cos(lat_rad)*cos(delta_prime_rad) * cos(deg2rad(h_prime))));
900 }
double deg2rad(double degrees)
Definition: spa.c:528
double rad2deg(double radians)
Definition: spa.c:523

◆ topocentric_elevation_angle_corrected()

double topocentric_elevation_angle_corrected ( double  e0,
double  delta_e 
)

Definition at line 914 of file spa.c.

915 {
916  return e0 + delta_e;
917 }

◆ topocentric_local_hour_angle()

double topocentric_local_hour_angle ( double  h,
double  delta_alpha 
)

Definition at line 888 of file spa.c.

889 {
890  return h - delta_alpha;
891 }

◆ topocentric_right_ascension()

double topocentric_right_ascension ( double  alpha_deg,
double  delta_alpha 
)

Definition at line 883 of file spa.c.

884 {
885  return alpha_deg + delta_alpha;
886 }

◆ topocentric_zenith_angle()

double topocentric_zenith_angle ( double  e)

Definition at line 919 of file spa.c.

920 {
921  return 90.0 - e;
922 }

◆ validate_inputs()

int validate_inputs ( spa_data spa)

Definition at line 603 of file spa.c.

604 {
605  if ((spa->year < -2000) || (spa->year > 6000)) return 1;
606  if ((spa->month < 1 ) || (spa->month > 12 )) return 2;
607  if ((spa->day < 1 ) || (spa->day > 31 )) return 3;
608  if ((spa->hour < 0 ) || (spa->hour > 24 )) return 4;
609  if ((spa->minute < 0 ) || (spa->minute > 59 )) return 5;
610  if ((spa->second < 0 ) || (spa->second >=60 )) return 6;
611  if ((spa->pressure < 0 ) || (spa->pressure > 5000)) return 12;
612  if ((spa->temperature <= -273) || (spa->temperature > 6000)) return 13;
613  if ((spa->delta_ut1 <= -1 ) || (spa->delta_ut1 >= 1 )) return 17;
614  if ((spa->hour == 24 ) && (spa->minute > 0 )) return 5;
615  if ((spa->hour == 24 ) && (spa->second > 0 )) return 6;
616 
617  if (fabs(spa->delta_t) > 8000 ) return 7;
618  if (fabs(spa->timezone) > 18 ) return 8;
619  if (fabs(spa->longitude) > 180 ) return 9;
620  if (fabs(spa->latitude) > 90 ) return 10;
621  if (fabs(spa->atmos_refract) > 5 ) return 16;
622  if ( spa->elevation < -6500000) return 11;
623 
624  if ((spa->function == SPA_ZA_INC) || (spa->function == SPA_ALL))
625  {
626  if (fabs(spa->slope) > 360) return 14;
627  if (fabs(spa->azm_rotation) > 360) return 15;
628  }
629 
630  return 0;
631 }
double elevation
Definition: spa.h:97
Definition: spa.h:61
int month
Definition: spa.h:69
int hour
Definition: spa.h:71
Definition: spa.h:59
double atmos_refract
Definition: spa.h:113
int year
Definition: spa.h:68
double temperature
Definition: spa.h:103
double latitude
Definition: spa.h:94
int function
Definition: spa.h:116
int day
Definition: spa.h:70
double pressure
Definition: spa.h:100
double longitude
Definition: spa.h:91
double delta_ut1
Definition: spa.h:75
double azm_rotation
Definition: spa.h:109
int minute
Definition: spa.h:72
double delta_t
Definition: spa.h:82
double slope
Definition: spa.h:106
double timezone
Definition: spa.h:88
double second
Definition: spa.h:73

◆ xy_term_summation()

double xy_term_summation ( int  i,
double  x[TERM_X_COUNT] 
)

Definition at line 773 of file spa.c.

774 {
775  int j;
776  double sum=0;
777 
778  for (j = 0; j < TERM_Y_COUNT; j++)
779  sum += x[j]*Y_TERMS[i][j];
780 
781  return sum;
782 }
#define TERM_Y_COUNT
Definition: spa.c:142
FTensor::Index< 'j', 2 > j
Definition: ContactOps.hpp:27
const int Y_TERMS[Y_COUNT][TERM_Y_COUNT]
Periodic Terms for the nutation in longitude and obliquity.
Definition: spa.c:388
FTensor::Index< 'i', 2 > i
[Common data]
Definition: ContactOps.hpp:26

Variable Documentation

◆ b_subcount

const int b_subcount[B_COUNT] = {5,2}

Definition at line 145 of file spa.c.

◆ B_TERMS

Initial value:
=
{
{
{280.0,3.199,84334.662},
{102.0,5.422,5507.553},
{80,3.88,5223.69},
{44,3.7,2352.87},
{32,4,1577.34}
},
{
{9,3.9,5507.55},
{6,1.73,5223.69}
}
}

Definition at line 296 of file spa.c.

◆ l_subcount

const int l_subcount[L_COUNT] = {64,34,20,7,3,1}

Definition at line 144 of file spa.c.

◆ L_TERMS

Initial value:
=
{
{
{175347046.0,0,0},
{3341656.0,4.6692568,6283.07585},
{34894.0,4.6261,12566.1517},
{3497.0,2.7441,5753.3849},
{3418.0,2.8289,3.5231},
{3136.0,3.6277,77713.7715},
{2676.0,4.4181,7860.4194},
{2343.0,6.1352,3930.2097},
{1324.0,0.7425,11506.7698},
{1273.0,2.0371,529.691},
{1199.0,1.1096,1577.3435},
{990,5.233,5884.927},
{902,2.045,26.298},
{857,3.508,398.149},
{780,1.179,5223.694},
{753,2.533,5507.553},
{505,4.583,18849.228},
{492,4.205,775.523},
{357,2.92,0.067},
{317,5.849,11790.629},
{284,1.899,796.298},
{271,0.315,10977.079},
{243,0.345,5486.778},
{206,4.806,2544.314},
{205,1.869,5573.143},
{202,2.458,6069.777},
{156,0.833,213.299},
{132,3.411,2942.463},
{126,1.083,20.775},
{115,0.645,0.98},
{103,0.636,4694.003},
{102,0.976,15720.839},
{102,4.267,7.114},
{99,6.21,2146.17},
{98,0.68,155.42},
{86,5.98,161000.69},
{85,1.3,6275.96},
{85,3.67,71430.7},
{80,1.81,17260.15},
{79,3.04,12036.46},
{75,1.76,5088.63},
{74,3.5,3154.69},
{74,4.68,801.82},
{70,0.83,9437.76},
{62,3.98,8827.39},
{61,1.82,7084.9},
{57,2.78,6286.6},
{56,4.39,14143.5},
{56,3.47,6279.55},
{52,0.19,12139.55},
{52,1.33,1748.02},
{51,0.28,5856.48},
{49,0.49,1194.45},
{41,5.37,8429.24},
{41,2.4,19651.05},
{39,6.17,10447.39},
{37,6.04,10213.29},
{37,2.57,1059.38},
{36,1.71,2352.87},
{36,1.78,6812.77},
{33,0.59,17789.85},
{30,0.44,83996.85},
{30,2.74,1349.87},
{25,3.16,4690.48}
},
{
{628331966747.0,0,0},
{206059.0,2.678235,6283.07585},
{4303.0,2.6351,12566.1517},
{425.0,1.59,3.523},
{119.0,5.796,26.298},
{109.0,2.966,1577.344},
{93,2.59,18849.23},
{72,1.14,529.69},
{68,1.87,398.15},
{67,4.41,5507.55},
{59,2.89,5223.69},
{56,2.17,155.42},
{45,0.4,796.3},
{36,0.47,775.52},
{29,2.65,7.11},
{21,5.34,0.98},
{19,1.85,5486.78},
{19,4.97,213.3},
{17,2.99,6275.96},
{16,0.03,2544.31},
{16,1.43,2146.17},
{15,1.21,10977.08},
{12,2.83,1748.02},
{12,3.26,5088.63},
{12,5.27,1194.45},
{12,2.08,4694},
{11,0.77,553.57},
{10,1.3,6286.6},
{10,4.24,1349.87},
{9,2.7,242.73},
{9,5.64,951.72},
{8,5.3,2352.87},
{6,2.65,9437.76},
{6,4.67,4690.48}
},
{
{52919.0,0,0},
{8720.0,1.0721,6283.0758},
{309.0,0.867,12566.152},
{27,0.05,3.52},
{16,5.19,26.3},
{16,3.68,155.42},
{10,0.76,18849.23},
{9,2.06,77713.77},
{7,0.83,775.52},
{5,4.66,1577.34},
{4,1.03,7.11},
{4,3.44,5573.14},
{3,5.14,796.3},
{3,6.05,5507.55},
{3,1.19,242.73},
{3,6.12,529.69},
{3,0.31,398.15},
{3,2.28,553.57},
{2,4.38,5223.69},
{2,3.75,0.98}
},
{
{289.0,5.844,6283.076},
{35,0,0},
{17,5.49,12566.15},
{3,5.2,155.42},
{1,4.72,3.52},
{1,5.3,18849.23},
{1,5.97,242.73}
},
{
{114.0,3.142,0},
{8,4.13,6283.08},
{1,3.84,12566.15}
},
{
{1,3.14,0}
}
}

Earth Periodic Terms.

Definition at line 151 of file spa.c.

◆ PE_TERMS

const double PE_TERMS[Y_COUNT][TERM_PE_COUNT]
Initial value:
={
{-171996,-174.2,92025,8.9},
{-13187,-1.6,5736,-3.1},
{-2274,-0.2,977,-0.5},
{2062,0.2,-895,0.5},
{1426,-3.4,54,-0.1},
{712,0.1,-7,0},
{-517,1.2,224,-0.6},
{-386,-0.4,200,0},
{-301,0,129,-0.1},
{217,-0.5,-95,0.3},
{-158,0,0,0},
{129,0.1,-70,0},
{123,0,-53,0},
{63,0,0,0},
{63,0.1,-33,0},
{-59,0,26,0},
{-58,-0.1,32,0},
{-51,0,27,0},
{48,0,0,0},
{46,0,-24,0},
{-38,0,16,0},
{-31,0,13,0},
{29,0,0,0},
{29,0,-12,0},
{26,0,0,0},
{-22,0,0,0},
{21,0,-10,0},
{17,-0.1,0,0},
{16,0,-8,0},
{-16,0.1,7,0},
{-15,0,9,0},
{-13,0,7,0},
{-12,0,6,0},
{11,0,0,0},
{-10,0,5,0},
{-8,0,3,0},
{7,0,-3,0},
{-7,0,0,0},
{-7,0,3,0},
{-7,0,3,0},
{6,0,0,0},
{6,0,-3,0},
{6,0,-3,0},
{-6,0,3,0},
{-6,0,3,0},
{5,0,0,0},
{-5,0,3,0},
{-5,0,3,0},
{-5,0,3,0},
{4,0,0,0},
{4,0,0,0},
{4,0,0,0},
{-4,0,0,0},
{-4,0,0,0},
{-4,0,0,0},
{3,0,0,0},
{-3,0,0,0},
{-3,0,0,0},
{-3,0,0,0},
{-3,0,0,0},
{-3,0,0,0},
{-3,0,0,0},
{-3,0,0,0},
}

Definition at line 455 of file spa.c.

◆ r_subcount

const int r_subcount[R_COUNT] = {40,10,6,2,1}

Definition at line 146 of file spa.c.

◆ R_TERMS

Initial value:
=
{
{
{100013989.0,0,0},
{1670700.0,3.0984635,6283.07585},
{13956.0,3.05525,12566.1517},
{3084.0,5.1985,77713.7715},
{1628.0,1.1739,5753.3849},
{1576.0,2.8469,7860.4194},
{925.0,5.453,11506.77},
{542.0,4.564,3930.21},
{472.0,3.661,5884.927},
{346.0,0.964,5507.553},
{329.0,5.9,5223.694},
{307.0,0.299,5573.143},
{243.0,4.273,11790.629},
{212.0,5.847,1577.344},
{186.0,5.022,10977.079},
{175.0,3.012,18849.228},
{110.0,5.055,5486.778},
{98,0.89,6069.78},
{86,5.69,15720.84},
{86,1.27,161000.69},
{65,0.27,17260.15},
{63,0.92,529.69},
{57,2.01,83996.85},
{56,5.24,71430.7},
{49,3.25,2544.31},
{47,2.58,775.52},
{45,5.54,9437.76},
{43,6.01,6275.96},
{39,5.36,4694},
{38,2.39,8827.39},
{37,0.83,19651.05},
{37,4.9,12139.55},
{36,1.67,12036.46},
{35,1.84,2942.46},
{33,0.24,7084.9},
{32,0.18,5088.63},
{32,1.78,398.15},
{28,1.21,6286.6},
{28,1.9,6279.55},
{26,4.59,10447.39}
},
{
{103019.0,1.10749,6283.07585},
{1721.0,1.0644,12566.1517},
{702.0,3.142,0},
{32,1.02,18849.23},
{31,2.84,5507.55},
{25,1.32,5223.69},
{18,1.42,1577.34},
{10,5.91,10977.08},
{9,1.42,6275.96},
{9,0.27,5486.78}
},
{
{4359.0,5.7846,6283.0758},
{124.0,5.579,12566.152},
{12,3.14,0},
{9,3.63,77713.77},
{6,1.87,5573.14},
{3,5.47,18849.23}
},
{
{145.0,4.273,6283.076},
{7,3.92,12566.15}
},
{
{4,2.56,6283.08}
}
}

Definition at line 311 of file spa.c.

◆ Y_TERMS

const int Y_TERMS[Y_COUNT][TERM_Y_COUNT]
Initial value:
=
{
{0,0,0,0,1},
{-2,0,0,2,2},
{0,0,0,2,2},
{0,0,0,0,2},
{0,1,0,0,0},
{0,0,1,0,0},
{-2,1,0,2,2},
{0,0,0,2,1},
{0,0,1,2,2},
{-2,-1,0,2,2},
{-2,0,1,0,0},
{-2,0,0,2,1},
{0,0,-1,2,2},
{2,0,0,0,0},
{0,0,1,0,1},
{2,0,-1,2,2},
{0,0,-1,0,1},
{0,0,1,2,1},
{-2,0,2,0,0},
{0,0,-2,2,1},
{2,0,0,2,2},
{0,0,2,2,2},
{0,0,2,0,0},
{-2,0,1,2,2},
{0,0,0,2,0},
{-2,0,0,2,0},
{0,0,-1,2,1},
{0,2,0,0,0},
{2,0,-1,0,1},
{-2,2,0,2,2},
{0,1,0,0,1},
{-2,0,1,0,1},
{0,-1,0,0,1},
{0,0,2,-2,0},
{2,0,-1,2,1},
{2,0,1,2,2},
{0,1,0,2,2},
{-2,1,1,0,0},
{0,-1,0,2,2},
{2,0,0,2,1},
{2,0,1,0,0},
{-2,0,2,2,2},
{-2,0,1,2,1},
{2,0,-2,0,1},
{2,0,0,0,1},
{0,-1,1,0,0},
{-2,-1,0,2,1},
{-2,0,0,0,1},
{0,0,2,2,1},
{-2,0,2,0,1},
{-2,1,0,2,1},
{0,0,1,-2,0},
{-1,0,1,0,0},
{-2,1,0,0,0},
{1,0,0,0,0},
{0,0,1,2,0},
{0,0,-2,2,2},
{-1,-1,1,0,0},
{0,1,1,0,0},
{0,-1,1,2,2},
{2,-1,-1,2,2},
{0,0,3,2,2},
{2,-1,0,2,2},
}

Periodic Terms for the nutation in longitude and obliquity.

Definition at line 388 of file spa.c.