cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Craige_Hales
Super User
Lunar Eclipse - Blood Moon - pylunar

Lunar eclipse last night.

Best the camera can do.Best the camera can do.

 

info5048.png

Midnight. The color is pretty accurate. Not enough light for the camera to focus.Midnight. The color is pretty accurate. Not enough light for the camera to focus.

8 sec exposure8 sec exposure

 

Python code called from JMP for lunar phase calculations.

// python -m pip install pylunar

Python Init(); // one-time startup...

// 0: startup 

xrc = Python Execute( {}, 
                      {rc},
"\[
try:
    import pylunar,datetime

    def timeFromRST(rst):
    #    print(rst,isinstance(rst,str))
        if isinstance(rst,str):
            rst = (1,1,1,1,1,1)
        return datetime.datetime(*rst)
        
    rc = "ok"
except Exception as e:
    rc = repr(e)
]\"
);

If( xrc != 0 | rc != "ok", Throw( "start up pylunar failed" || Try( ": " || Char( rc ), "" ) ) );

xrc = Python Execute( {}, 
                      {rc,line1,line2,line3},
"\[
try:
    localnow = datetime.datetime.now()
    mi = pylunar.MoonInfo((35, 45, 0), (-78, 40, 0)) # about my location degrees/minutes/seconds
    utc = datetime.datetime.utcnow()
    mi.update(utc) # find the answer for right now
    todayRST = mi.rise_set_times('America/New_York') 
    mi.update(utc + datetime.timedelta(days=1)) # find the answer 24 hours from now
    tomorrowRST = mi.rise_set_times('America/New_York')
    mi.update(utc) # put it back, not finished with today yet

    moonTransit=-1
    moonSet=-1
    moonRise=-1

    for earlyRST in todayRST:
        if earlyRST[0]=="transit":
            moonTransit = timeFromRST(earlyRST[1])
        elif earlyRST[0]=="rise":
            moonRise = timeFromRST(earlyRST[1])
        elif earlyRST[0]=="set":
            moonSet = timeFromRST(earlyRST[1])
        else:
            print("BUMMER 1*********************")
            stop()
    for lateRST in tomorrowRST:
        if lateRST[0]=="transit":
            if moonTransit < localnow:
                moonTransit = timeFromRST(lateRST[1])
        elif lateRST[0]=="rise":
            if moonRise < localnow:
                moonRise = timeFromRST(lateRST[1])
        elif lateRST[0]=="set":
            if  moonSet < localnow:
                moonSet = timeFromRST(lateRST[1])
        else:
            print("BUMMER 2*********************")
            stop()

    if moonRise.day==localnow.day:
        riseday="later today"
    else:
        riseday="tomorrow"

    if moonSet.day==localnow.day:
        setday="later today"
    else:
        setday="tomorrow"

    if moonRise < moonSet :
        line1="The Moon rises "+riseday+" at "+moonRise.strftime("%I:%M %p")+" and"
        line2="sets "+setday+" at "+moonSet.strftime("%I:%M %p")
    else:
        line1="The Moon sets "+setday+" at "+moonSet.strftime("%I:%M %p")+" and"
        line2="rises "+riseday+" at "+moonRise.strftime("%I:%M %p")

    line3=mi.phase_name().replace("_"," ").title()

    rc = "ok"
except Exception as e:
    rc = repr(e)
]\"
);
    
    show(rc,line1,line2,line3);

That code was ripped out of another project that needed a text description of the moon's phase:

line1 = "The Moon sets later today at 06:21 AM and";
line2 = "rises later today at 09:13 PM";
line3 = "Full Moon";

If you use it, test carefully...that project was never finished. I'm working late...it looks like the moon sets soon.

 

Cell phone is worse.

Scattered clouds at the start of the eclipse. It is already dark.Scattered clouds at the start of the eclipse. It is already dark.

Last Modified: May 16, 2022 1:55 AM