- Timestamp:
- 05/18/12 17:45:26 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/smartfact.cc
r13772 r13778 1 #ifdef HAVE_LIBNOVA 2 #include <libnova/solar.h> 3 #include <libnova/lunar.h> 4 #include <libnova/rise_set.h> 5 #endif 6 1 7 #include "Dim.h" 2 8 #include "Event.h" … … 24 30 25 31 #include "DimDescriptionService.h" 32 33 // ------------------------------------------------------------------------ 34 35 #ifdef HAVE_LIBNOVA 36 37 class Astro 38 { 39 Time fSunRiseDayTime; 40 Time fSunRiseCivil; 41 Time fSunRiseAstronomical; 42 Time fSunRiseDarkTime; 43 44 Time fSunSetDayTime; 45 Time fSunSetCivil; 46 Time fSunSetAstronomical; 47 Time fSunSetDarkTime; 48 49 ln_rst_time moon; 50 51 ln_equ_posn moon_position; 52 double moon_disk; 53 54 string description; 55 56 //observer.lng = -(17.+53./60+26.525/3600); 57 //observer.lat = 28.+45./60+42.462/3600; 58 public: 59 Astro(double lon, double lat, /*const*/ Time/* &*/time=Time()) 60 { 61 // observers location (Edinburgh), used to calc rst 62 struct ln_lnlat_posn observer; 63 observer.lng = -(17.+53./60+26.525/3600); 64 observer.lat = 28.+45./60+42.462/3600; 65 66 time = Time(2012, 5, 18, 23, 30); 67 68 // get Julian day from local time 69 const double JD = time.JD(); 70 71 ln_rst_time sun_day; 72 ln_rst_time sun_civil; 73 ln_rst_time sun_astronomical; 74 ln_rst_time sun_dark; 75 76 // Warning: return code of 1 means circumpolar and is not checked! 77 ln_get_lunar_rst (JD-0.5, &observer, &moon); 78 ln_get_solar_rst (JD-0.5, &observer, &sun_day); 79 ln_get_solar_rst_horizon(JD-0.5, &observer, - 6, &sun_civil); 80 ln_get_solar_rst_horizon(JD-0.5, &observer, -12, &sun_astronomical); 81 ln_get_solar_rst_horizon(JD-0.5, &observer, -18, &sun_dark); 82 83 fSunSetDayTime = Time(sun_day.set); 84 fSunSetCivil = Time(sun_civil.set); 85 fSunSetAstronomical = Time(sun_astronomical.set); 86 fSunSetDarkTime = Time(sun_dark.set); 87 88 fSunRiseDayTime = Time(sun_day.rise); 89 fSunRiseCivil = Time(sun_civil.rise); 90 fSunRiseAstronomical = Time(sun_astronomical.rise); 91 fSunRiseDarkTime = Time(sun_dark.rise); 92 93 const bool is_day = JD>sun_day.rise; 94 const bool is_night = JD>sun_dark.set; 95 96 ln_get_lunar_rst (JD+0.5, &observer, &moon); 97 ln_get_solar_rst (JD+0.5, &observer, &sun_day); 98 ln_get_solar_rst_horizon(JD+0.5, &observer, - 6, &sun_civil); 99 ln_get_solar_rst_horizon(JD+0.5, &observer, -12, &sun_astronomical); 100 ln_get_solar_rst_horizon(JD+0.5, &observer, -18, &sun_dark); 101 102 if (is_day) 103 { 104 fSunRiseDayTime = Time(sun_day.rise); 105 fSunRiseCivil = Time(sun_civil.rise); 106 fSunRiseAstronomical = Time(sun_astronomical.rise); 107 fSunRiseDarkTime = Time(sun_dark.rise); 108 } 109 110 if (is_night) 111 { 112 fSunSetDayTime = Time(sun_day.set); 113 fSunSetCivil = Time(sun_civil.set); 114 fSunSetAstronomical = Time(sun_astronomical.set); 115 fSunSetDarkTime = Time(sun_dark.set); 116 } 117 118 // case 0: midnight to sun-rise | !is_day && !is_night | rise/set 119 // case 1: sun-rise to sun-set | is_day && !is_night | set /rise 120 // case 2: sun-set to midnight | is_day && is_night | rise/set 121 122 if (is_day^is_night) 123 { 124 cout << "SunSet: " << fSunSetDayTime << endl; 125 cout << "SunRise: " << fSunRiseDayTime << endl; 126 } 127 else 128 { 129 cout << "SunRise: " << fSunRiseDayTime << endl; 130 cout << "SunSet: " << fSunSetDayTime << endl; 131 } 132 133 //const double mjd = Time(JD-2400000.5).Mjd(); 134 135 int state = is_day^is_night ? 4 : 0; 136 if (time>fSunSetDayTime) state++; 137 if (time>fSunSetCivil) state++; 138 if (time>fSunSetAstronomical) state++; 139 if (time>fSunSetDarkTime) state++; 140 141 if (time>fSunRiseDarkTime) state++; 142 if (time>fSunRiseAstronomical) state++; 143 if (time>fSunRiseCivil) state++; 144 if (time>fSunRiseDayTime) state++; 145 146 string name[] = 147 { 148 "dark time", 149 "astronomical twilight", 150 "civil twilight", 151 "sunrise", 152 "day time", 153 "sunset", 154 "civil twilight", 155 "astronomical twilight", 156 "dark time" 157 }; 158 159 description = state[name]; 160 161 162 cout << "NOW: " << name[state] << " [" << state << "]" << endl << endl; 163 164 /* 165 // RA, DEC 166 ln_get_lunar_equ_coords(JD, &moon_position); 167 //cout << "MoonRa: " << equ.ra << "\n"; 168 //cout << "MoonDec: " << equ.dec << "\n"; 169 170 // lunar disk, phase and bright limb 171 moon_disk = ln_get_lunar_disk(JD); 172 173 if (JD>sun_dark.set || JD<sun_normal.rise) 174 { 175 cout << "Sunrise will be at:" << endl; 176 cout << "Astronom. TwL: " << Time(sun_dark.rise -2400000.5).GetAsStr() << endl; 177 cout << "Civil TwL: " << Time(sun_astronomical.rise-2400000.5).GetAsStr() << endl; 178 cout << "Sunrise: " << Time(sun_civil.rise -2400000.5).GetAsStr() << endl; 179 cout << "Day time: " << Time(sun_normal.rise -2400000.5).GetAsStr() << endl; 180 } 181 else 182 { 183 cout << "Sunset will be at:" << endl; 184 cout << "Sunset: " << Time(sun_normal.set -2400000.5).GetAsStr() << endl; 185 cout << "Civil TwL: " << Time(sun_civil.set -2400000.5).GetAsStr() << endl; 186 cout << "Astronom. TwL: " << Time(sun_astronomical.set-2400000.5).GetAsStr() << endl; 187 cout << "Dark time: " << Time(sun_dark.set -2400000.5).GetAsStr() << endl; 188 } 189 190 if (JD>moon.rise && JD<moon.set) 191 cout << "Moon: VISIBLE (" << setprecision(2) << moon_disk*100 << "%)" << endl; 192 193 if (JD<moon.rise) 194 cout << "MoonRise: " << Time(moon.rise -2400000.5) << endl; 195 if (JD<moon.transit) 196 cout << "MoonCulm: " << Time(moon.transit-2400000.5) << endl; 197 if (JD<moon.set) 198 cout << "MoonSet: " << Time(moon.set -2400000.5) << endl; 199 */ 200 } 201 202 /* 203 204 Always show the next event: 205 206 What do we have now? 207 time between sunset and civil: sunset 208 time between civial and astronominal: civil 209 time between astronominal and dark: astronomical 210 time above dark: dark 211 212 213 */ 214 215 }; 216 217 #endif 26 218 27 219 // ------------------------------------------------------------------------ … … 408 600 out << "#ffffff\t" << dir[idx] << '\n'; 409 601 602 //Astro a(-(17.+53./60+26.525/3600), 28.+45./60+42.462/3600); 410 603 411 604 ofstream(fPath+"/magicweather.txt") << out.str();
Note:
See TracChangeset
for help on using the changeset viewer.