diff options
author | Mattias Andrée <m@maandree.se> | 2025-03-07 21:35:04 +0100 |
---|---|---|
committer | Mattias Andrée <m@maandree.se> | 2025-03-07 21:35:04 +0100 |
commit | ac2dd9331d2d3cf2559bf47f4285995f9e329624 (patch) | |
tree | 0a289b8a3812b8d202c5ccb9d136793267bf5e80 /src/solar.c | |
parent | misc minor improvements (diff) | |
download | redshift-ng-ac2dd9331d2d3cf2559bf47f4285995f9e329624.tar.gz redshift-ng-ac2dd9331d2d3cf2559bf47f4285995f9e329624.tar.bz2 redshift-ng-ac2dd9331d2d3cf2559bf47f4285995f9e329624.tar.xz |
Remove unused code
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'src/solar.c')
-rw-r--r-- | src/solar.c | 113 |
1 files changed, 0 insertions, 113 deletions
diff --git a/src/solar.c b/src/solar.c index 784a293..d8ece88 100644 --- a/src/solar.c +++ b/src/solar.c @@ -30,28 +30,6 @@ #define DEG(x) ((x)*(180/M_PI)) -/* Angels of various times of day. */ -static const double time_angle[] = { - [SOLAR_TIME_ASTRO_DAWN] = RAD(-90.0 + SOLAR_ASTRO_TWILIGHT_ELEV), - [SOLAR_TIME_NAUT_DAWN] = RAD(-90.0 + SOLAR_NAUT_TWILIGHT_ELEV), - [SOLAR_TIME_CIVIL_DAWN] = RAD(-90.0 + SOLAR_CIVIL_TWILIGHT_ELEV), - [SOLAR_TIME_SUNRISE] = RAD(-90.0 + SOLAR_DAYTIME_ELEV), - [SOLAR_TIME_NOON] = RAD(0.0), - [SOLAR_TIME_SUNSET] = RAD(90.0 - SOLAR_DAYTIME_ELEV), - [SOLAR_TIME_CIVIL_DUSK] = RAD(90.0 - SOLAR_CIVIL_TWILIGHT_ELEV), - [SOLAR_TIME_NAUT_DUSK] = RAD(90.0 - SOLAR_NAUT_TWILIGHT_ELEV), - [SOLAR_TIME_ASTRO_DUSK] = RAD(90.0 - SOLAR_ASTRO_TWILIGHT_ELEV) -}; - - -/* Unix epoch from Julian day */ -static double -epoch_from_jd(double jd) -{ - return 86400.0*(jd - 2440587.5); -} - - /* Julian day from unix epoch */ static double @@ -188,19 +166,6 @@ equation_of_time(double t) return 4*DEG(eq_time); } -/* Hour angle at the location for the given angular elevation. - lat: Latitude of location in degrees - decl: Declination in radians - elev: Angular elevation angle in radians - Return: Hour angle in radians */ -static double -hour_angle_from_elevation(double lat, double decl, double elev) -{ - double omega = acos((cos(fabs(elev)) - sin(RAD(lat))*sin(decl))/ - (cos(RAD(lat))*cos(decl))); - return copysign(omega, -elev); -} - /* Angular elevation at the location for the given hour angle. lat: Latitude of location in degrees decl: Declination in radians @@ -213,57 +178,6 @@ elevation_from_hour_angle(double lat, double decl, double ha) sin(RAD(lat))*sin(decl)); } -/* Time of apparent solar noon of location on earth. - t: Julian centuries since J2000.0 - lon: Longitude of location in degrees - Return: Time difference from mean solar midnigth in minutes */ -static double -time_of_solar_noon(double t, double lon) -{ - /* First pass uses approximate solar noon to - calculate equation of time. */ - double t_noon = jcent_from_jd(jd_from_jcent(t) - lon/360.0); - double eq_time = equation_of_time(t_noon); - double sol_noon = 720 - 4*lon - eq_time; - - /* Recalculate using new solar noon. */ - t_noon = jcent_from_jd(jd_from_jcent(t) - 0.5 + sol_noon/1440.0); - eq_time = equation_of_time(t_noon); - sol_noon = 720 - 4*lon - eq_time; - - /* No need to do more iterations */ - return sol_noon; -} - -/* Time of given apparent solar angular elevation of location on earth. - t: Julian centuries since J2000.0 - t_noon: Apparent solar noon in Julian centuries since J2000.0 - lat: Latitude of location in degrees - lon: Longtitude of location in degrees - elev: Solar angular elevation in radians - Return: Time difference from mean solar midnight in minutes */ -static double -time_of_solar_elevation(double t, double t_noon, - double lat, double lon, double elev) -{ - /* First pass uses approximate sunrise to - calculate equation of time. */ - double eq_time = equation_of_time(t_noon); - double sol_decl = solar_declination(t_noon); - double ha = hour_angle_from_elevation(lat, sol_decl, elev); - double sol_offset = 720 - 4*(lon + DEG(ha)) - eq_time; - - /* Recalculate using new sunrise. */ - double t_rise = jcent_from_jd(jd_from_jcent(t) + sol_offset/1440.0); - eq_time = equation_of_time(t_rise); - sol_decl = solar_declination(t_rise); - ha = hour_angle_from_elevation(lat, sol_decl, elev); - sol_offset = 720 - 4*(lon + DEG(ha)) - eq_time; - - /* No need to do more iterations */ - return sol_offset; -} - /* Solar angular elevation at the given location and time. t: Julian centuries since J2000.0 lat: Latitude of location @@ -293,30 +207,3 @@ solar_elevation(double date, double lat, double lon) double jd = jd_from_epoch(date); return DEG(solar_elevation_from_time(jcent_from_jd(jd), lat, lon)); } - -void -solar_table_fill(double date, double lat, double lon, double *table) -{ - /* Calculate Julian day */ - double jd = jd_from_epoch(date); - - /* Calculate Julian day number */ - double jdn = round(jd); - double t = jcent_from_jd(jdn); - - /* Calculate apparent solar noon */ - double sol_noon = time_of_solar_noon(t, lon); - double j_noon = jdn - 0.5 + sol_noon/1440.0; - double t_noon = jcent_from_jd(j_noon); - table[SOLAR_TIME_NOON] = epoch_from_jd(j_noon); - - /* Calculate solar midnight */ - table[SOLAR_TIME_MIDNIGHT] = epoch_from_jd(j_noon + 0.5); - - /* Calulate absolute time of other phenomena */ - for (int i = 2; i < SOLAR_TIME_MAX; i++) { - double angle = time_angle[i]; - double offset = time_of_solar_elevation(t, t_noon, lat, lon, angle); - table[i] = epoch_from_jd(jdn - 0.5 + offset/1440.0); - } -} |