swisseph icon indicating copy to clipboard operation
swisseph copied to clipboard

Calculation of lunar days

Open damirmur opened this issue 4 years ago • 1 comments

Calculation of lunar days Greetings. I've done this before in Java, here is a piece of code public static double[] moon_Rise(SwissEph sw, SweDate sd, double lat, double lon, double tzOffset) { double[] md; ArrayList<Double> moondays = new ArrayList(); if (sw == null) { sw = new SwissEph("./ephe"); } double date = sd.getJulDay(); sd.makeValidDate(); int fl = SweConst.SEFLG_SWIEPH | SweConst.SEFLG_TRANSIT_LONGITUDE; TransitCalculator tc = new TCPlanetPlanet( sw, SweConst.SE_MOON, SweConst.SE_SUN, fl, 0); boolean backwards = true; double previousTransitUT = sw.getTransitUT(tc, sd.getJulDay(), backwards);//forward double nextTransitUT = sw.getTransitUT(tc, sd.getJulDay(), false);//forward int pl = SweConst.SE_MOON; fl = SweConst.SEFLG_SWIEPH | SweConst.SEFLG_TRANSIT_LONGITUDE | SweConst.SEFLG_TRANSIT_SPEED; int rsmi = 0; double[] geopos = {lon, lat, 0}; DblObj tret = new DblObj(); StringBuffer serr = new StringBuffer(); date = previousTransitUT; moondays.add(previousTransitUT); double monday = sd.getJulDay(); while (date < nextTransitUT) { sw.swe_rise_trans(date, pl, null, fl, SweConst.SE_CALC_RISE, geopos, 0, 0, tret, serr); monday = tret.val + 0.1; if (date > tret.val) { continue; } if (nextTransitUT < tret.val) { break; } moondays.add(tret.val); sw.swe_rise_trans(sd.getJulDay(), pl, null, fl, SweConst.SE_CALC_SET, geopos, 0, 0, tret, serr); date = monday; } moondays.add(nextTransitUT); md = new double[moondays.size()]; for (int i = 0; i < md.length; i++) { md[i] = moondays.get(i); } return md; }

Can you tell me how to do this in Javascript, the same Transit calculator, the previous aspect, the next aspect?

damirmur avatar Sep 03 '20 12:09 damirmur

The objects and methods above make it look like you have used the SwissEph.java code (a Java port of the original C library). Unfortunately those are not part of the original code and are not available in this Javascript binding.

The way forward would be to port the required logic from Java (code is at http://th-mack.de/international/download/) to JS and then use it.

gkostov avatar Feb 16 '21 20:02 gkostov