Changeset 17953
- Timestamp:
- 08/13/14 12:31:35 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/smartfact.cc
r17940 r17953 1 1 #ifdef HAVE_NOVA 2 #include "externals/ nova.h"2 #include "externals/Prediction.h" 3 3 #endif 4 4 … … 2127 2127 #ifdef HAVE_NOVA 2128 2128 2129 vector<pair<Nova::EquPosn, double>> fMoonCoords; 2130 2131 void CalcMoonCoords(double jd) 2129 //vector<pair<Nova::EquPosn, double>> fMoonCoords; 2130 2131 vector<Nova::SolarObjects> fCoordinates; 2132 2133 void CalcCoordinates(double jd) 2132 2134 { 2133 2135 jd = floor(jd); 2134 2136 2135 f MoonCoords.clear();2137 fCoordinates.clear(); 2136 2138 for (double h=0; h<1; h+=1./(24*12)) 2137 { 2138 const Nova::EquPosn moon = Nova::GetLunarEquCoords(jd+h,0.01); 2139 2140 const double disk = Nova::GetLunarDisk(jd+h); 2141 2142 fMoonCoords.emplace_back(moon, disk); 2143 } 2144 } 2145 2146 pair<vector<float>, pair<Time, float>> GetVisibility(Nova::EquPosn *src, double jd) 2147 { 2148 jd = floor(jd); 2149 2150 const double jd0 = fmod(fSun.fSetAstronomical.JD(), 1); 2151 const double jd1 = fmod(fSun.fRiseAstronomical.JD(), 1); 2139 fCoordinates.emplace_back(jd+h); 2140 } 2141 2142 pair<vector<float>, pair<Time, float>> GetVisibility(Nova::EquPosn *src=0) 2143 { 2144 const double sunset = fSun.fSetAstronomical.JD(); 2145 const double sunrise = fSun.fRiseAstronomical.JD(); 2152 2146 2153 2147 Nova::EquPosn moon; … … 2159 2153 int cnt = 0; 2160 2154 2161 int i=0;2162 2163 2155 vector<float> alt; 2164 for ( double h=0; h<1; h+=1./(24*12), i++)2156 for (auto it=fCoordinates.begin(); it!=fCoordinates.end(); it++) 2165 2157 { 2166 2158 if (src==0) 2167 moon = fMoonCoords[i].first; //ln_get_lunar_equ_coords_prec(jd+h, &moon, 0.01);2168 2169 const Nova::HrzPosn hrz = Nova::GetHrzFromEqu(*pos, jd+h);2170 2171 if ( h>jd0 && h<jd1)2159 moon = it->fMoonEqu; 2160 2161 const Nova::HrzPosn hrz = Nova::GetHrzFromEqu(*pos, it->fJD); 2162 2163 if (it->fJD>sunset && it->fJD<sunrise) 2172 2164 alt.push_back(hrz.alt); 2173 2165 … … 2175 2167 { 2176 2168 max = hrz.alt; 2177 maxjd = jd+h;2169 maxjd = it->fJD; 2178 2170 } 2179 2171 2180 if ( h>jd0 && h<jd1&& hrz.alt>15)2172 if (it->fJD>sunset && it->fJD<sunrise && hrz.alt>15) 2181 2173 cnt++; 2182 2174 } … … 2185 2177 return make_pair(vector<float>(), make_pair(Time(), 0)); 2186 2178 2187 return make_pair(alt, make_pair(maxjd, maxjd>jd+jd0&&maxjd<jd+jd1?max:0)); 2188 } 2189 2190 pair<vector<float>, pair<Time, float>> GetLightCondition(double jd) 2191 { 2192 jd = floor(jd); 2193 2194 const double jd0 = fmod(fSun.fSetAstronomical.JD(), 1); 2195 const double jd1 = fmod(fSun.fRiseAstronomical.JD(), 1); 2179 return make_pair(alt, make_pair(maxjd, maxjd>sunset&&maxjd<sunrise?max:0)); 2180 } 2181 2182 pair<vector<float>, pair<Time, float>> GetLightCondition(const Nova::EquPosn &src_pos) 2183 { 2184 const double sunset = fSun.fSetAstronomical.JD(); 2185 const double sunrise = fSun.fRiseAstronomical.JD(); 2196 2186 2197 2187 double max = -1; … … 2199 2189 2200 2190 int cnt = 0; 2201 int i = 0;2202 2191 2203 2192 vector<float> vec; 2204 for ( double h=0; h<1; h+=1./(24*12), i++)2193 for (auto it=fCoordinates.begin(); it!=fCoordinates.end(); it++) 2205 2194 { 2206 2195 double cur = -1; 2207 2196 2208 if ( h>jd0 && h<jd1)2197 if (it->fJD>sunset && it->fJD<sunrise) 2209 2198 { 2210 Nova::EquPosn moon = fMoonCoords[i].first;//ln_get_lunar_equ_coords_prec(jd+h, &moon, 0.01); 2211 const double disk = fMoonCoords[i].second;//ln_get_lunar_disk(jd+h); 2212 2213 const Nova::HrzPosn hrz = Nova::GetHrzFromEqu(moon, jd+h); 2214 const double dist = Nova::GetLunarEarthDist(jd+h); 2215 2216 // Current prediction 2217 const double calt = sin(hrz.alt*M_PI/180); 2218 2219 const double lc = calt>0 ? calt*pow(disk, 2.2)*pow(dist, -2) : -1; 2220 cur = lc>0 ? 4+103*lc : -1; 2221 2222 vec.push_back(cur); // Covert LC to pixel current in uA 2199 cur = FACT::PredictI(*it, src_pos); 2200 vec.push_back(cur); 2223 2201 } 2224 2202 … … 2226 2204 { 2227 2205 max = cur; 2228 maxjd = jd+h;2206 maxjd = it->fJD; 2229 2207 } 2230 2208 2231 if ( h>jd0 && h<jd1&& cur>0)2209 if (it->fJD>sunset && it->fJD<sunrise && cur>0) 2232 2210 cnt++; 2233 2211 } … … 2236 2214 return make_pair(vector<float>(), make_pair(Time(), 0)); 2237 2215 2238 return make_pair(vec, make_pair(maxjd, maxjd> jd+jd0&&maxjd<jd+jd1?max:-1));2216 return make_pair(vec, make_pair(maxjd, maxjd>sunset&&maxjd<sunrise?max:-1)); 2239 2217 } 2240 2218 #endif … … 2244 2222 Time now; 2245 2223 2246 Calc MoonCoords(now.JD());2224 CalcCoordinates(now.JD()); 2247 2225 2248 2226 fSun = Sun (now); … … 2337 2315 int lcol = 0; 2338 2316 2339 /*const*/ pair<vector<float>, pair<Time, float>> vism = GetVisibility( 0, now.JD());2317 /*const*/ pair<vector<float>, pair<Time, float>> vism = GetVisibility(); 2340 2318 if (!vism.first.empty()) 2341 2319 { … … 2373 2351 const Nova::ZdAzPosn hrz = Nova::GetHrzFromEqu(pos, now.JD()); 2374 2352 2375 /*const*/ pair<vector<float>, pair<Time, float>> vis = GetVisibility(&pos , now.JD());2353 /*const*/ pair<vector<float>, pair<Time, float>> vis = GetVisibility(&pos); 2376 2354 if (!vis.first.empty()) 2377 2355 { … … 2384 2362 ccol++; 2385 2363 2386 /*const*/ pair<vector<float>, pair<Time, float>> lc = GetLightCondition( now.JD());2364 /*const*/ pair<vector<float>, pair<Time, float>> lc = GetLightCondition(pos); 2387 2365 if (!lc.first.empty()) 2388 2366 {
Note:
See TracChangeset
for help on using the changeset viewer.