// return values are in sun.arunodaya, sun.rise, sun.set, sun.noon, sun.length // if values are less than zero, that means, no sunrise, no sunset in that day // // brahma 1 = calculation at brahma muhurta begining // brahma 0 = calculation at sunrise public void SunCalc(GPGregorianTime vct, GPLocationProvider earth) { if (sunPosMethod == SUNPOSMETHOD_CALCULATOR) { GPSun s_rise = new GPSun(); GPSun s_set = new GPSun(); // first calculation // for 12:00 universal time s_rise.calculateRise(vct, earth); // first calculation // for 12:00 universal time s_set.calculateSet(vct, earth); // calculate times longitude_arun_deg = s_rise.eclipticalLongitude - (24.0 / 365.25); eclipticalLongitude = s_rise.eclipticalLongitude; rightAscession = s_rise.rightAscession; longitude_set_deg = s_set.eclipticalLongitude; sunrise_deg = s_rise.sunrise_deg; sunset_deg = s_set.sunset_deg; } else { calculateRiseSet(vct, earth, 180); double gmt = vct.getJulianGreenwichNoon(); longitude_arun_deg = GPAstroEngine.sunLongitudeMethodM(julianDayRise - 96 / 1440.0); eclipticalLongitude = GPAstroEngine.sunLongitudeMethodM(julianDayRise); longitude_set_deg = GPAstroEngine.sunLongitudeMethodM(julianDaySet); } updateSunriseTimes(vct, earth); updateNoonTimes(vct, earth); updateSetTimes(vct, earth); List <GPLocationChange> chr = earth.getChangesForJulianDay(arunodaya.getJulianGreenwichNoon()); processTravellingChanges(chr); // finally calculate length of the daylight DayLength = (set.getJulianGreenwichTime() - rise.getJulianGreenwichTime()) * 24.0; }
private void button1_Click(object sender, EventArgs e) { GPLocation loc; content.findLocations("Bratislava"); loc = content.getLocation(0); GPLocationProvider provider = new GPLocationProvider(loc); int nCount = 365; GPGregorianTime startDateA = new GPGregorianTime(loc); GPCalendarResults calA = new GPCalendarResults(); GPCalendarResults calB = new GPCalendarResults(); calA.progressReport = this; calB.progressReport = this; if (startDateA != null) { GPSun.sunPosMethod = GPSun.SUNPOSMETHOD_CALCULATOR; calA.CalculateCalendar(startDateA, nCount); GPSun.sunPosMethod = GPSun.SUNPOSMETHOD_CALCULATOREX; calB.CalculateCalendar(startDateA, nCount); } GPSun.sunPosMethod = GPSun.SUNPOSMETHOD_CALCULATOR; StringBuilder sb = new StringBuilder(); GPCalendarTwoLocResults cals = new GPCalendarTwoLocResults(); cals.CalendarA = calA; cals.CalendarB = calB; FormaterHtml.WriteCompareCalendarHTML(cals, sb); string HtmlText = sb.ToString(); webBrowser1.DocumentText = HtmlText; GPObserver obs = new GPObserver(); obs = loc; GPStrings.pushRich(false); StringBuilder sba = new StringBuilder(); GPJulianTime sunRise, sunNoon, sunSet; for (int i = 0; i < calA.getCount(); i++) { GPCalendarDay cd = calA.get(i); GPCalendarDay cd2 = calB.get(i); GPAstroEngine.CalculateTimeSun(cd.date, loc, out sunRise, out sunNoon, out sunSet); GPGregorianTime gt = new GPGregorianTime(loc); GPCelestialBodyCoordinates pos = GPAstroEngine.sun_coordinate(GPDynamicTime.getUniversalTimeFromDynamicTime(2457012.82313)); GPAstroEngine.calcHorizontal(pos, loc); sunRise.setLocalTimezoneOffset(loc.getTimeZoneOffsetHours()); sba.AppendFormat("{0} {1} {2} \n", cd.date.ToString(), cd.getSunriseTime().getLongTimeString(), cd2.getSunriseTime().getLongTimeString()); gt.setDate(1992, 10, 13); //cd.astrodata.sun.calculateCoordinatesMethodM(gt, 360/24.0); } GPStrings.popRich(); richTextBox1.Text = sba.ToString(); GPGregorianTime t1 = new GPGregorianTime(loc); t1.setDate(2015, 4, 4); double jd = t1.getJulianLocalNoon(); sba.Clear(); for (double d = 0.3; d < 1.0; d += 0.01) { double ml = GPAstroEngine.moon_coordinate(jd + d).eclipticalLongitude; double sl1 = GPAstroEngine.sun_coordinate(jd + d).eclipticalLongitude; double sl2 = GPAstroEngine.sunLongitudeMethodM(jd + d); sba.AppendFormat("{0} : {1} {2} {3}\n", jd + d, ml, sl1, sl2); } richTextBox2.Text = sba.ToString(); }