public Placement <Planet> GetPlanetaryPlacement(Planet planet, DateTime?gnomon = null) { gnomon ??= DateTime.UtcNow; var hour = gnomon.Value.Hour + gnomon.Value.Minute / 60.0; var julianDay = swissEphemeris.swe_julday( year: gnomon.Value.Year, mon: gnomon.Value.Month, mday: gnomon.Value.Day, hour: hour, gregflag: SwissEph.SE_GREG_CAL ); double[] placementArray = new double[6]; string error = String.Empty; var result = swissEphemeris.swe_calc_ut( tjd_ut: julianDay, ipl: (int)planet, iflag: SwissEph.SEFLG_SWIEPH, xx: placementArray, serr: ref error ); return(new Placement <Planet>(planet, placementArray[0])); }
public void Test_swe_calc_ut() { using (var swe = new SwissEph()) { double tjd = swe.swe_julday(1974, 8, 16, 0.5, SwissEph.SE_GREG_CAL); double[] geopos = new double[] { 47.853333, 5.333889, 468 }; double[] xx = new double[6]; String serr = null; swe.swe_calc_ut(tjd, SwissEph.SE_SUN, SwissEph.SEFLG_MOSEPH, xx, ref serr); Assert.AreEqual(142.780326430735, xx[0], 0.000000000001); Assert.AreEqual(-1.93227682119264E-05, xx[1], 0.0000000000001); Assert.AreEqual(1.01267244282576, xx[2], 0.0000000000001); Assert.AreEqual(0, xx[3], 0.0000000000001); Assert.AreEqual(0, xx[4], 0.0000000000001); Assert.AreEqual(0, xx[5], 0.0000000000001); } }
public void Test_swe_calc_ut() { using (var swe = new SwissEph()) { double tjd = swe.swe_julday(1974, 8, 16, 0.5, SwissEph.SE_GREG_CAL); double[] geopos = new double[] { 47.853333, 5.333889, 468 }; double[] xx = new double[6]; String serr = null; swe.swe_calc_ut(tjd, SwissEph.SE_SUN, SwissEph.SEFLG_MOSEPH, xx, ref serr); Assert.AreEqual(142.780328315269, xx[0], 0.000000000001); Assert.AreEqual(-1.57808056001826E-05, xx[1], 0.0000000000001); Assert.AreEqual(1.01267244282576, xx[2], 0.0000000000001); Assert.AreEqual(0, xx[3], 0.0000000000001); Assert.AreEqual(0, xx[4], 0.0000000000001); Assert.AreEqual(0, xx[5], 0.0000000000001); } }
public void Test_swe_calc_ut() { using (var swe = new SwissEph()) { double tjd = swe.swe_julday(1974, 8, 16, 0.5, SwissEph.SE_GREG_CAL); double[] geopos = new double[] { 47.853333, 5.333889, 468 }; double[] xx = new double[6]; String serr = null; swe.swe_calc_ut(tjd, SwissEph.SE_SUN, SwissEph.SEFLG_MOSEPH, xx, ref serr); Assert.Equal(142.780328279462, xx[0], 12); Assert.Equal(-1.5780805E-05, xx[1], 12); Assert.Equal(1.012672442833, xx[2], 12); Assert.Equal(0, xx[3], 12); Assert.Equal(0, xx[4], 12); Assert.Equal(0, xx[5], 12); } }
public void LoadAsteroidData() { using (var swe = new SwissEph()) { swe.OnLoadFile += (s, e) => { var asm = this.GetType().GetAssembly(); String sr = e.FileName.Replace("[ephe]", @"SwissEphNet.Tests.files").Replace("/", ".").Replace("\\", "."); e.File = asm.GetManifestResourceStream(sr); }; double tjd = swe.swe_julday(1974, 8, 16, 0.5, SwissEph.SE_GREG_CAL); double[] geopos = new double[] { 47.853333, 5.333889, 468 }; double[] xx = new double[6]; String serr = null; // The issue raised a FormatException swe.swe_calc_ut(tjd, SwissEph.SE_AST_OFFSET + 5, SwissEph.SEFLG_SWIEPH, xx, ref serr); Assert.Equal(130.764380953384, xx[0], 12); Assert.Equal(-1.0445487020471, xx[1], 13); Assert.Equal(3.0793896379558, xx[2], 13); Assert.Equal(0, xx[3], 13); Assert.Equal(0, xx[4], 13); Assert.Equal(0, xx[5], 13); } }
// 天体の位置を計算する public Dictionary <int, PlanetData> PositionCalc(DateTime d, double lat, double lng, int houseKind, int subIndex) { Dictionary <int, PlanetData> planetdata = new Dictionary <int, PlanetData>();; // absolute position double[] x = { 0, 0, 0, 0, 0, 0 }; string serr = ""; int utc_year = 0; int utc_month = 0; int utc_day = 0; int utc_hour = 0; int utc_minute = 0; double utc_second = 0; // [0]:Ephemeris Time [1]:Universal Time double[] dret = { 0.0, 0.0 }; int ii = 0; // utcに変換 // 本来ここにJSTの9.0を入れるのだが・・・ s.swe_utc_time_zone(d.Year, d.Month, d.Day, d.Hour, d.Minute, d.Second, 0.0, ref utc_year, ref utc_month, ref utc_day, ref utc_hour, ref utc_minute, ref utc_second); s.swe_utc_to_jd(utc_year, utc_month, utc_day, utc_hour, utc_minute, utc_second, 1, dret, ref serr); // 10天体ループ // 11(DH/TrueNode)、14(Earth)、15(Chiron)もついでに計算 Enumerable.Range(0, 16).ToList().ForEach(i => { int flag = SwissEph.SEFLG_SWIEPH | SwissEph.SEFLG_SPEED; if (config.centric == ECentric.HELIO_CENTRIC) { flag |= SwissEph.SEFLG_HELCTR; } if (config.sidereal == Esidereal.SIDEREAL) { flag |= SwissEph.SEFLG_SIDEREAL; s.swe_set_sid_mode(SwissEph.SE_SIDM_LAHIRI, 0, 0); // ayanamsa計算 double daya = 0.0; double ut = s.swe_get_ayanamsa_ex_ut(dret[1], SwissEph.SEFLG_SWIEPH, out daya, ref serr); // Ephemeris Timeで計算, 結果はxに入る s.swe_calc_ut(dret[1], i, flag, x, ref serr); } else { // Universal Timeで計算, 結果はxに入る s.swe_calc_ut(dret[1], i, flag, x, ref serr); } PlanetData p = new PlanetData() { no = i, absolute_position = x[0], speed = x[3], aspects = new List <AspectInfo>(), secondAspects = new List <AspectInfo>(), thirdAspects = new List <AspectInfo>(), sensitive = false }; if (i < 10 && subIndex >= 0) { if (main.currentSetting.dispPlanet[subIndex][main.dispListMap[i]]) { p.isDisp = true; } else { p.isDisp = false; } if (main.currentSetting.dispAspectPlanet[subIndex][main.dispListMap[i]]) { p.isAspectDisp = true; } else { p.isAspectDisp = false; } } if (config.centric == ECentric.HELIO_CENTRIC && i == 0) { // ヘリオセントリック太陽 p.isDisp = false; p.isAspectDisp = false; } if (i == 10) { // MEAN NODE p.isDisp = false; p.isAspectDisp = false; } if (i == 11 && subIndex >= 0 && config.centric == ECentric.GEO_CENTRIC) { // TRUE NODE ヘッド if (main.currentSetting.dispPlanet[subIndex][11]) { p.isDisp = true; } else { p.isDisp = false; } if (main.currentSetting.dispAspectPlanet[subIndex][11]) { p.isAspectDisp = true; } else { p.isAspectDisp = false; } } if (i == 12) { // mean apogee、どうでもいい p.isDisp = false; p.isAspectDisp = false; } if (i == 13 && subIndex >= 0) { // true apogee、要はリリス if (main.currentSetting.dispPlanet[subIndex][CommonData.ZODIAC_LILITH]) { p.isDisp = true; } else { p.isDisp = false; } if (main.currentSetting.dispAspectPlanet[subIndex][CommonData.ZODIAC_LILITH]) { p.isAspectDisp = true; } else { p.isAspectDisp = false; } } if (config.centric == ECentric.HELIO_CENTRIC && i == 14 && subIndex >= 0) { // ヘリオセントリック地球 if (main.currentSetting.dispPlanet[subIndex][main.dispListMap[i]]) { p.isDisp = true; } else { p.isDisp = false; } if (main.currentSetting.dispAspectPlanet[subIndex][main.dispListMap[i]]) { p.isAspectDisp = true; } else { p.isAspectDisp = false; } } if (i == 15 && subIndex >= 0) { if (main.currentSetting.dispPlanet[subIndex][CommonData.ZODIAC_CHIRON]) { p.isDisp = true; } else { p.isDisp = false; } if (main.currentSetting.dispAspectPlanet[subIndex][CommonData.ZODIAC_CHIRON]) { p.isAspectDisp = true; } else { p.isAspectDisp = false; } } ii = i; planetdata[i] = p; }); s.swe_close(); // ハウスを後ろにくっつける double[] houses = CuspCalc(d, lat, lng, houseKind); planetdata = setHouse(planetdata, houses, main.currentSetting, subIndex); return(planetdata); }
/// <summary> /// planet position calcurate. /// </summary> /// <param name="timezone">Timezone. JST=9.0</param> public List <PlanetData> PositionCalc(DateTime time, double timezone) { List <PlanetData> planetList = new List <PlanetData>(); s.swe_set_ephe_path(Windows.Storage.ApplicationData.Current.LocalFolder.Path + "/ephe"); s.OnLoadFile += (sender, e) => { if (File.Exists(e.FileName)) { e.File = new FileStream(e.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); } }; int utc_year = 0; int utc_month = 0; int utc_day = 0; int utc_hour = 0; int utc_minute = 0; double utc_second = 0; double[] dret = { 0.0, 0.0 }; double[] x = { 0, 0, 0, 0, 0, 0 }; string serr = ""; s.swe_utc_time_zone(1980, 12, 21, 12, 0, 0, timezone, ref utc_year, ref utc_month, ref utc_day, ref utc_hour, ref utc_minute, ref utc_second); s.swe_utc_to_jd(utc_year, utc_month, utc_day, utc_hour, utc_minute, utc_second, 1, dret, ref serr); int flag = SwissEph.SEFLG_SWIEPH | SwissEph.SEFLG_SPEED; // flag = flag | SwissEph.SEFLG_HELCTR; // display設定で再計算させないようにあらかじめ全て計算しておく foreach (int planet_number in Common.CommonData.target_numbers) { int planet_number2 = 0; s.swe_calc_ut(dret[1], planet_number, flag, x, ref serr); if (planet_number == 100377) { planet_number2 = CommonData.ZODIAC_NUMBER_SEDNA; } else if (planet_number == 146199) { planet_number2 = CommonData.ZODIAC_NUMBER_ERIS; } else if (planet_number == 146108) { planet_number2 = CommonData.ZODIAC_NUMBER_HAUMEA; } else if (planet_number == 146472) { planet_number2 = CommonData.ZODIAC_NUMBER_MAKEMAKE; } else { planet_number2 = planet_number; } PlanetData p = new PlanetData() { no = planet_number2, absolute_position = x[0] }; planetList.Add(p); } return(planetList); }
public void test() { SwissEphNet.SwissEph t = new SwissEph(); double[] house = new double[13]; double[] ascmc = new double[10]; double lt = 6.9; double lg = 79.8612; DateTime d = new DateTime(2012, 8, 1, 7, 31, 0).ToUniversalTime(); double tjd_ut = ToJulianDate(d); t.swe_houses(tjd_ut, lt, lg, 'P', house, ascmc); double start = mod.add(house[12], (mod.sub(house[1], house[12]) / 2)); double ascendant = house[1]; double end = 0.0; Bhava[] housePositions = new Bhava[12]; for (int i = 1; i < house.Length - 1; i++) { end = mod.add(house[i], (mod.sub(house[i + 1], house[i]) / 2)); housePositions[i - 1] = new Bhava(i, start, house[i], end); start = end; } end = mod.add(house[12], (mod.sub(house[1], house[12]) / 2)); housePositions[11] = new Bhava(12, start, house[12], end); t.swe_set_ephe_path("C:\\SWEPH\\EPHE"); char sp; string sdate = DateTime.Now.ToString("dd/mm/yyyy"); char[] snam = new char[40]; string serr = ""; int jday = 1, jmon = 1, jyear = 2000; double jut = 0.0; double te; double[] x2 = new double[6]; int iflag, iflgret; int p; t.swe_set_ephe_path(null); iflag = SwissEphNet.SwissEph.SEFLG_SPEED; while (true) { string returnString = "\nDate (d.m.y) ?"; /* * we have day, month and year and convert to Julian day number */ //tjd_ut = t.swe_julday(jyear, jmon, jday, jut, SwissEphNet.SwissEph.SE_GREG_CAL); /* * compute Ephemeris time from Universal time by adding delta_t * not required for Swisseph versions smaller than 1.60 */ /* te = tjd_ut + swe_deltat(tjd_ut); */ SwissEphNet.C.sprintf("date: %02d.%02d.%d at 0:00 Universal time\n", jday, jmon, jyear); returnString += "planet \tlongitude\tlatitude\tdistance\tspeed long.\n"; /* * a loop over all planets */ for (p = SwissEphNet.SwissEph.SE_SUN; p <= SwissEphNet.SwissEph.SE_CHIRON; p++) { if (p == SwissEphNet.SwissEph.SE_EARTH) { continue; } /* * do the coordinate calculation for this planet p */ iflgret = t.swe_calc_ut(tjd_ut, p, iflag, x2, ref serr); //t.swe_set_sid_mode(SwissEphNet.SwissEph.SE_SIDM_LAHIRI, 0, 0); // t.swe_set_topo(-2.35, 51.5, 0); //t.swe_date_conversion(2016, 4, 20, 7.5 - 5.5, 'g', ref tjd_ut); //t.swe_date_conversion(1975, 7, 2, (12 + (34.00 / 60.00)) - 5.5, 'g',ref tjd_ut); //double ayana = t.swe_get_ayanamsa_ut(tjd_ut); t.swe_houses(tjd_ut, lt, lg, 'P', house, ascmc); double[] pPosition = new double[6]; t.swe_calc_ut(tjd_ut, p, SwissEphNet.SwissEph.SEFLG_SIDEREAL, pPosition, ref serr); /* Swisseph versions older than 1.60 require the following * statement instead */ /* iflgret = swe_calc(te, p, iflag, x2, serr); */ /* * if there is a problem, a negative value is returned and an * error message is in serr. */ if (iflgret < 0) { returnString += "error: " + serr; } /* * get the name of the planet p */ t.swe_get_planet_name(p); /* * print the coordinates */ /*printf("%10s\t%11.7f\t%10.7f\t%10.7f\t%10.7f\n", * snam, x2[0], x2[1], x2[2], x2[3]);*/ } } return; }
/// <summary> /// planet position calcurate. /// </summary> /// <param name="timezone">Timezone. JST=9.0</param> public List <PlanetData> PositionCalc(DateTime date, double timezone) { List <PlanetData> planetList = new List <PlanetData>(); // s.swe_set_ephe_path(path); s.OnLoadFile += (sender, e) => { var path = Path.Combine(NSBundle.MainBundle.BundlePath, "Contents", "Resources", "ephe"); var f = e.FileName.Split('\\'); if (File.Exists(path + "/" + f[1])) { e.File = new FileStream(path + "/" + f[1], FileMode.Open, FileAccess.Read, FileShare.Read); } }; int utc_year = 0; int utc_month = 0; int utc_day = 0; int utc_hour = 0; int utc_minute = 0; double utc_second = 0; double[] dret = { 0.0, 0.0 }; double[] x = { 0, 0, 0, 0, 0, 0 }; string serr = ""; s.swe_utc_time_zone(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, timezone, ref utc_year, ref utc_month, ref utc_day, ref utc_hour, ref utc_minute, ref utc_second); s.swe_utc_to_jd(utc_year, utc_month, utc_day, utc_hour, utc_minute, utc_second, 1, dret, ref serr); int flag = SwissEph.SEFLG_SWIEPH | SwissEph.SEFLG_SPEED; foreach (int planet_number in Common.CommonData.target_numbers) { s.swe_calc_ut(dret[1], planet_number, flag, x, ref serr); int save_number = planet_number; if (planet_number == 100377) { save_number = 90377; } if (planet_number == 146108) { save_number = 136108; } if (planet_number == 146199) { save_number = 136199; } if (planet_number == 146472) { save_number = 136472; } PlanetData p = new PlanetData() { no = save_number, absolute_position = x[0], speed = x[3], // AMATERUでもここ使ってたからたぶん良い aspects0 = new List <AspectInfo>(), aspects1 = new List <AspectInfo>(), aspects2 = new List <AspectInfo>(), aspects3 = new List <AspectInfo>(), aspects4 = new List <AspectInfo>(), aspects5 = new List <AspectInfo>(), aspects6 = new List <AspectInfo>(), }; if (planet_number == CommonData.ZODIAC_NUMBER_ASC || planet_number == CommonData.ZODIAC_NUMBER_MC || planet_number == CommonData.ZODIAC_NUMBER_DH_TRUENODE || planet_number == CommonData.ZODIAC_NUMBER_LILITH || planet_number == CommonData.ZODIAC_NUMBER_VT || planet_number == CommonData.ZODIAC_NUMBER_POF ) { p.sensitive = true; } else { p.sensitive = false; } planetList.Add(p); } s.swe_close(); return(planetList); }
public List <AstroPlanet> CalculatePlanetPosition() { List <AstroPlanet> planets = new List <AstroPlanet>(); NakathEndDateTime = null; double[] cusps = new double[6]; string serr = ""; long iflgret; int planet; swissEph.swe_set_ephe_path(null); DateTime dt = new DateTime(Year, Month, Day, Hour, Minute, Second); TimeData tData = new TimeData(AstroPlace.GetUniversalTime(dt, LocationData.Longitude)); tjd_ut = tData.JulianDateTime; /* * a loop over all planets */ for (planet = SwissEph.SE_SUN; planet <= SwissEph.SE_CHIRON; planet++) { tjd_ut = tData.JulianDateTime; cusps = new double[6]; if (planet == SwissEph.SE_EARTH || planet == SwissEph.SE_MEAN_NODE || planet == SwissEph.SE_MEAN_APOG || planet == SwissEph.SE_OSCU_APOG || planet == SwissEph.SE_CHIRON) { continue; } /* * do the coordinate calculation for this planet p */ swissEph.swe_set_sid_mode(SwissEphNet.SwissEph.SE_SIDM_LAHIRI, 0, 0); AstroPlanet pReturn = null; // Looping to find the next transit time/ reversing time of the planet body iflgret = swissEph.swe_calc_ut(tjd_ut, planet, AstroConsts.iflag, cusps, ref serr); // Longitude // Latitude // Distance in AU // Speed in longitude(deg / day) // Speed in latitude(deg / day) // Speed in distance(AU / day) pReturn = new AstroPlanet(planet, cusps, LocationData); /* * if there is a problem, a negative value is returned and an * error message is in serr. */ if (iflgret < 0) { pReturn.CalculationError = serr; } /* * get the name of the planet p */ pReturn.Name = swissEph.swe_get_planet_name(planet); planets.Add(pReturn); // Add Ketu if (planet == SwissEph.SE_TRUE_NODE) { pReturn.Name = "Rahu"; cusps[0] = (cusps[0] + 180.00) % 360; AstroPlanet ketu = new AstroPlanet(12, cusps, LocationData); ketu.Name = "Kethu"; planets.Add(ketu); } } return(planets); }