Author Topic: getriseset()  (Read 1400 times)

0 Members and 1 Guest are viewing this topic.

ABer

  • Administrator
  • Hero Member
  • *****
  • Posts: 1260
    • View Profile
getriseset()
« on: May 27, 2024, 07:31:19 PM »
Hi Jean - can you let me know if the getriseset() function looks always for the preceding rise based on the julian date, or whether it depends on the placement of the body above or below the horizon. I wonder if a body that is placed below the horizon is defined as rising at the next rise, and a body that is above the horizon is defined as rising at the preceding rise, within the getriseset() function.

Thanks. Ed

Jean

  • Administrator
  • Hero Member
  • *****
  • Posts: 1316
    • View Profile
Re: getriseset()
« Reply #1 on: May 27, 2024, 07:41:38 PM »
The getriseset() function calls pd's internal setrise() function, see below.
You can see there's a 'flag' set for the swiss ephemeris function swe_rise_trans() that determines body placement and refraction. These can be set in Options Settings Extra.
Hope this helps.
Happy coding. ;D

Code: [Select]
double setrise(int p, double jd, double lon, double lat, char *star, bool rise)
{
double geopos[3] = { lon, lat, 0}, tret[10];
char err[256];
int flag = 0; // barycenter
if (disctype == 1)
  flag = SE_BIT_DISC_BOTTOM;
if (disctype == 2)
  flag = SE_BIT_DISC_CENTER;
if (refrac)
  flag |= SE_BIT_NO_REFRACTION;
while (incalculate) Sleep(100);
incalculate = true;
swe_rise_trans(jd, planetmap[p], star, SEFLG_SWIEPH, (rise ? SE_CALC_RISE : SE_CALC_SET) | flag, geopos, 0, 0, &tret[0], err);
incalculate = false;
return tret[0];
}
Greetings from Groningen Netherlands.

ABer

  • Administrator
  • Hero Member
  • *****
  • Posts: 1260
    • View Profile
Re: getriseset()
« Reply #2 on: May 27, 2024, 08:02:36 PM »
Thanks Jean - this is from the programmer's guide:


8.12.    swe_rise_trans() and swe_rise_trans_true_hor() (risings, settings, meridian transits)

The function swe_rise_trans() computes the times of rising, setting and meridian transits for all planets, asteroids, the moon, and the fixed stars. The function swe_rise_trans_true_hor() does the same for a local horizon that has an altitude != 0.

The function returns a rising time of an object:

·     if at t0 the object is below the horizon and a rising takes place before the next culmination of the object;

·     if at t0 the object is above the horizon and a rising takes place between the next lower and upper culminations of the object.

And it returns a setting time of an object,

·     if at t0 the object is above the horizon and a setting takes place before the next lower culmination of the object;

·     if at t0 the object is below the horizon and a setting takes place between the next upper and lower culminations.

Function definitions are as follows:

int32 swe_rise_trans(

double tjd_ut,      /* search after this time (UT) */

Jean

  • Administrator
  • Hero Member
  • *****
  • Posts: 1316
    • View Profile
Re: getriseset()
« Reply #3 on: May 27, 2024, 08:20:51 PM »
Ah you found your answer in the ephemeris docs..
Greetings from Groningen Netherlands.

ABer

  • Administrator
  • Hero Member
  • *****
  • Posts: 1260
    • View Profile
Re: getriseset()
« Reply #4 on: May 28, 2024, 03:53:34 PM »
Hi Jean - I have found this page of python code that relates to swe_rise_trans:

https://python.hotexamples.com/examples/astrology/-/swe_rise_trans/python-swe_rise_trans-function-examples.html

 def __init__(self, lon, lat, altitude, weekday, jd):
        self.risetime = None
        self.settime = None
        self.hrlen = None
        self.daytime = None

        self.weekday = weekday

        #lon, lat, height, atmpress, celsius
        #in GMT, searches after jd!
        ret, risetime, serr = astrology.swe_rise_trans(
            jd, astrology.SE_SUN, '', astrology.SEFLG_SWIEPH,
            astrology.SE_CALC_RISE, lon, lat, float(altitude), 0.0, 10.0)
        #      self.logCalc(risetime)#
        ret, settime, serr = astrology.swe_rise_trans(
            jd, astrology.SE_SUN, '', astrology.SEFLG_SWIEPH,
            astrology.SE_CALC_SET, lon, lat, float(altitude), 0.0, 10.0)
        #      self.logCalc(settime)#

        #swe_rise_trans calculates only forward!!
        offs = lon * 4.0 / 1440.0
        hr = 0
        HOURSPERHALFDAY = 12.0
        if risetime > settime:  # daytime
            self.daytime = True
            #         print 'daytime'#
            ret, self.risetime, serr = astrology.swe_rise_trans(
                jd - 1.0, astrology.SE_SUN, '', astrology.SEFLG_SWIEPH,
                astrology.SE_CALC_RISE, lon, lat, float(altitude), 0.0, 10.0)
            #         self.logCalc(risetime)#
            ret, self.settime, serr = astrology.swe_rise_trans(
                jd, astrology.SE_SUN, '', astrology.SEFLG_SWIEPH,
                astrology.SE_CALC_SET, lon, lat, float(altitude), 0.0, 10.0)

            #From GMT to Local
            self.risetime += offs
            self.settime += offs

            #         self.logCalc(settime)#
            self.hrlen = (self.settime - self.risetime
                          ) / HOURSPERHALFDAY  #hrlen(hour-length) is in days
            for i in range(int(HOURSPERHALFDAY)):
                if jd + offs < self.risetime + self.hrlen * (i + 1):
                    hr = i
                    break
        else:  # nighttime
            self.daytime = False
            #         print 'nightime'#
            ret, self.risetime, serr = astrology.swe_rise_trans(
                jd, astrology.SE_SUN, '', astrology.SEFLG_SWIEPH,
                astrology.SE_CALC_RISE, lon, lat, float(altitude), 0.0, 10.0)
            #         self.logCalc(risetime)#
            ret, self.settime, serr = astrology.swe_rise_trans(
                jd - 1.0, astrology.SE_SUN, '', astrology.SEFLG_SWIEPH,
                astrology.SE_CALC_SET, lon, lat, float(altitude), 0.0, 10.0)
            #         self.logCalc(settime)#

            #From GMT to Local
            self.risetime += offs
            self.settime += offs

            #Is the local birthtime greater than midnight? If so => decrement day because a planetary day is from sunrise to sunrise
            if jd + offs > int(jd + offs) + 0.5:
                self.weekday = util.getPrevDay(self.weekday)

            self.hrlen = (self.risetime - self.settime) / HOURSPERHALFDAY
            for i in range(int(HOURSPERHALFDAY)):
                if jd + offs < self.settime + self.hrlen * (i + 1):
                    hr = i + int(HOURSPERHALFDAY)
                    break

        self.planetaryhour = PlanetaryHours.PHs[self.weekday][
            hr]  #planetary day begins from sunrise(not from 0 hour and Planetary hours are not equal!!)

ABer

  • Administrator
  • Hero Member
  • *****
  • Posts: 1260
    • View Profile
Re: getriseset()
« Reply #5 on: May 28, 2024, 04:04:45 PM »
Hi Jean - this code is from Morinus, which is a well-respected freeware, used for traditional astrology.

The code suggests the following:

swe_rise_trans always calculates/searches forwards.

If the original rise time > set time, calculated using jd, the rise time needs to be recalculated using jd-1 day. The code seems to imply that the chart is a day chart in this case.

If the original rise time !> set time, the set time needs to be recalculated using jd-1 day. The code seems to imply that the chart, in this case is a night chart.

Lastly if the local time is greater than midnight, use the previous day, as planetary days run from sunrise to sunrise.

Let's see how we get on with this. Ed


Jean

  • Administrator
  • Hero Member
  • *****
  • Posts: 1316
    • View Profile
Re: getriseset()
« Reply #6 on: May 28, 2024, 04:08:47 PM »
Ed, i compared Time - Rise / Set with Petr's astroseek, it's identical.
Also pd's planetaryhour() uses setrise(), also identical with Petr's.
So i don't think i want to change them.

Btw, planetaryhour() uses jd-1 a lot to get to the previous day. And i see that code you posted is also about planetaryhour, i thought this was about getriseset?

I'm mailing you my planetaryhour code, maybe you can make something from it.
Greetings from Groningen Netherlands.

ABer

  • Administrator
  • Hero Member
  • *****
  • Posts: 1260
    • View Profile
Re: getriseset()
« Reply #7 on: May 29, 2024, 12:50:50 PM »
Hi Jean - I think I've still got problems in the medieval scripts with identifying the correct planetary day ruler. I'm trying to work out how to fix it.

Ed

ABer

  • Administrator
  • Hero Member
  • *****
  • Posts: 1260
    • View Profile
Re: getriseset()
« Reply #8 on: May 30, 2024, 08:20:47 PM »
Thanks for your help today Jean. I feel we are on the verge of getting this worked out. Ed

Jean

  • Administrator
  • Hero Member
  • *****
  • Posts: 1316
    • View Profile
Re: getriseset()
« Reply #9 on: May 30, 2024, 09:49:35 PM »
About time Ed, hope i finally have it right.
Greetings from Groningen Netherlands.