Changeset 15201 for trunk/FACT++
- Timestamp:
- 03/30/13 16:24:09 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/smartfact.cc
r15200 r15201 1 1 #ifdef HAVE_NOVA 2 #include <libnova/solar.h> 3 #include <libnova/lunar.h> 4 #include <libnova/rise_set.h> 5 #include <libnova/transform.h> 2 #include "externals/nova.h" 6 3 #endif 7 4 … … 105 102 // Could be done more efficient: Only recalcuate if 106 103 // the current time exceeds at least on of the stored times 107 Sun( double lon, double lat, const Time &t=Time()) : time(t)104 Sun(const Time &t) : time(t) 108 105 { 109 106 #ifdef HAVE_LIBNOVA 110 ln_lnlat_posn observer;111 observer.lng = lon;112 observer.lat = lat;113 114 107 // get Julian day from local time 115 108 const double JD = time.JD(); 116 109 117 ln_rst_time sun_day;118 ln_rst_time sun_civil;119 ln_rst_time sun_astronomical;120 ln_rst_time sun_dark;121 122 110 // Warning: return code of 1 means circumpolar and is not checked! 123 ln_get_solar_rst (JD-0.5, &observer, &sun_day);124 ln_get_solar_rst_horizon(JD-0.5, &observer, - 6, &sun_civil);125 ln_get_solar_rst_horizon(JD-0.5, &observer, -12, &sun_astronomical);126 ln_get_solar_rst_horizon(JD-0.5, &observer, -18, &sun_dark);111 Nova::RstTime sun_day = Nova::GetSolarRst(JD-0.5); 112 Nova::RstTime sun_civil = Nova::GetSolarRst(JD-0.5, -6); 113 Nova::RstTime sun_astronomical = Nova::GetSolarRst(JD-0.5, -12); 114 Nova::RstTime sun_dark = Nova::GetSolarRst(JD-0.5, -18); 127 115 128 116 fSetDayTime = Time(sun_day.set); … … 139 127 const bool is_night = JD>sun_dark.set; 140 128 141 ln_get_solar_rst (JD+0.5, &observer, &sun_day);142 ln_get_solar_rst_horizon(JD+0.5, &observer, - 6, &sun_civil);143 ln_get_solar_rst_horizon(JD+0.5, &observer, -12, &sun_astronomical);144 ln_get_solar_rst_horizon(JD+0.5, &observer, -18, &sun_dark);129 sun_day = Nova::GetSolarRst(JD+0.5); 130 sun_civil = Nova::GetSolarRst(JD+0.5, -6); 131 sun_astronomical = Nova::GetSolarRst(JD+0.5, -12); 132 sun_dark = Nova::GetSolarRst(JD+0.5, -18); 145 133 146 134 if (is_day) … … 242 230 // Could be done more efficient: Only recalcuate if 243 231 // the current time exceeds at least on of the stored times 244 Moon( double lon, double lat, const Time &t=Time()) : time(t)232 Moon(const Time &t) : time(t) 245 233 { 246 234 #ifdef HAVE_LIBNOVA 247 235 const double JD = time.JD(); 248 236 249 ln_lnlat_posn observer; 250 observer.lng = lon; 251 observer.lat = lat; 252 253 //observer.lng.degrees = -5; 254 //observer.lng.minutes = 36; 255 //observer.lng.seconds = 30; 256 //observer.lat.degrees = 42; 257 //observer.lat.minutes = 35; 258 //observer.lat.seconds = 40; 259 260 ln_rst_time moon; 261 ln_get_lunar_rst(JD-0.5, &observer, &moon); 237 Nova::RstTime moon = Nova::GetLunarRst(JD-0.5); 262 238 263 239 fRise = Time(moon.rise); … … 273 249 const bool is_dn = JD>moon.set; 274 250 275 ln_get_lunar_rst(JD+0.5, &observer, &moon);251 moon = Nova::GetLunarRst(JD+0.5); 276 252 if (is_up) 277 253 fRise = Time(moon.rise); … … 281 257 fSet = Time(moon.set); 282 258 283 ln_equ_posn pos; 284 ln_get_lunar_equ_coords(JD, &pos); 285 286 ln_hrz_posn hrz; 287 ln_get_hrz_from_equ (&pos, &observer, JD, &hrz); 259 const Nova::EquPosn pos = Nova::GetLunarEquCoords(JD); 260 const Nova::HrzPosn hrz = Nova::GetHrzFromEqu(pos, JD); 261 288 262 az = hrz.az; 289 263 zd = 90-hrz.alt; … … 292 266 dec = pos.dec; 293 267 294 disk = ln_get_lunar_disk(JD)*100;268 disk = Nova::GetLunarDisk(JD)*100; 295 269 state = 0; 296 270 if (fRise <fTransit && fRise <fSet) state = 0; // not visible … … 1925 1899 #ifdef HAVE_NOVA 1926 1900 1927 vector<pair< ln_equ_posn, double>> fMoonCoords;1901 vector<pair<Nova::EquPosn, double>> fMoonCoords; 1928 1902 1929 1903 void CalcMoonCoords(double jd) … … 1934 1908 for (double h=0; h<1; h+=1./(24*12)) 1935 1909 { 1936 ln_equ_posn moon; 1937 ln_get_lunar_equ_coords_prec(jd+h, &moon, 0.01); 1938 1939 const double disk = ln_get_lunar_disk(jd+h); 1910 const Nova::EquPosn moon = Nova::GetLunarEquCoords(jd+h,0.01); 1911 1912 const double disk = Nova::GetLunarDisk(jd+h); 1940 1913 1941 1914 fMoonCoords.push_back(make_pair(moon, disk)); … … 1943 1916 } 1944 1917 1945 pair<vector<float>, pair<Time, float>> GetVisibility( ln_equ_posn *src, ln_lnlat_posn *observer, double jd)1918 pair<vector<float>, pair<Time, float>> GetVisibility(Nova::EquPosn *src, double jd) 1946 1919 { 1947 1920 jd = floor(jd); … … 1950 1923 const double jd1 = fmod(fSun.fRiseAstronomical.JD(), 1); 1951 1924 1952 ln_equ_posn moon;1953 ln_equ_posn *pos = src ? src : &moon;1925 Nova::EquPosn moon; 1926 Nova::EquPosn *pos = src ? src : &moon; 1954 1927 1955 1928 double max = 0; … … 1966 1939 moon = fMoonCoords[i].first; //ln_get_lunar_equ_coords_prec(jd+h, &moon, 0.01); 1967 1940 1968 ln_hrz_posn hrz; 1969 ln_get_hrz_from_equ(pos, observer, jd+h, &hrz); 1941 const Nova::HrzPosn hrz = Nova::GetHrzFromEqu(*pos, jd+h); 1970 1942 1971 1943 if (h>jd0 && h<jd1) … … 1988 1960 } 1989 1961 1990 pair<vector<float>, pair<Time, float>> GetLightCondition( ln_equ_posn *src, ln_lnlat_posn *observer, double jd)1962 pair<vector<float>, pair<Time, float>> GetLightCondition(Nova::EquPosn *src, double jd) 1991 1963 { 1992 1964 jd = floor(jd); … … 2008 1980 if (h>jd0 && h<jd1) 2009 1981 { 2010 ln_equ_posn moon = fMoonCoords[i].first;//ln_get_lunar_equ_coords_prec(jd+h, &moon, 0.01); 2011 const double disk = fMoonCoords[i].second;//ln_get_lunar_disk(jd+h); 2012 2013 ln_hrz_posn hrz; 2014 ln_get_hrz_from_equ(&moon, observer, jd+h, &hrz); 1982 Nova::EquPosn moon = fMoonCoords[i].first;//ln_get_lunar_equ_coords_prec(jd+h, &moon, 0.01); 1983 const double disk = fMoonCoords[i].second;//ln_get_lunar_disk(jd+h); 1984 1985 const Nova::HrzPosn hrz = Nova::GetHrzFromEqu(moon, jd+h); 2015 1986 2016 1987 Moon m; … … 2049 2020 void UpdateAstronomy() 2050 2021 { 2051 const double lon = -(17.+53./60+26.525/3600);2052 const double lat = 28.+45./60+42.462/3600;2053 2054 2022 Time now; 2055 2023 2056 2024 CalcMoonCoords(now.JD()); 2057 2025 2058 fSun = Sun ( lon, lat,now);2059 fMoon = Moon( lon, lat,now);2026 fSun = Sun (now); 2027 fMoon = Moon(now); 2060 2028 2061 2029 vector<string> color(8, HTML::kWhite); … … 2144 2112 2145 2113 #ifdef HAVE_NOVA 2146 ln_lnlat_posn observer;2147 observer.lng = lon;2148 observer.lat = lat;2149 2150 2114 int ccol = 0; 2151 2115 int lcol = 0; 2152 2116 2153 /*const*/ pair<vector<float>, pair<Time, float>> vism = GetVisibility(0, &observer,now.JD());2117 /*const*/ pair<vector<float>, pair<Time, float>> vism = GetVisibility(0, now.JD()); 2154 2118 if (vism.first.size()>0) 2155 2119 { … … 2181 2145 const double dec = (*v)[2]; 2182 2146 #ifdef HAVE_NOVA 2183 ln_equ_posn pos;2147 Nova::EquPosn pos; 2184 2148 pos.ra = ra*15; 2185 2149 pos.dec = dec; 2186 2150 2187 ln_hrz_posn hrz; 2188 ln_get_hrz_from_equ(&pos, &observer, now.JD(), &hrz); 2189 2190 /*const*/ pair<vector<float>, pair<Time, float>> vis = GetVisibility(&pos, &observer, now.JD()); 2151 const Nova::HrzPosn hrz = Nova::GetHrzFromEqu(pos, now.JD()); 2152 2153 /*const*/ pair<vector<float>, pair<Time, float>> vis = GetVisibility(&pos, now.JD()); 2191 2154 if (vis.first.size()>0) 2192 2155 { … … 2199 2162 ccol++; 2200 2163 2201 /*const*/ pair<vector<float>, pair<Time, float>> lc = GetLightCondition(&pos, &observer,now.JD());2164 /*const*/ pair<vector<float>, pair<Time, float>> lc = GetLightCondition(&pos, now.JD()); 2202 2165 if (lc.first.size()>0) 2203 2166 {
Note:
See TracChangeset
for help on using the changeset viewer.