distance My City - Moon

52 views
Skip to first unread message

An Rodriguez

unread,
May 12, 2024, 11:53:57 AMMay 12
to Stellarium
Hi,
I use Stellaium's API () to get the field distance. I thought it would be the distance from the point of view to the object. However, plotting first two days I get a plot which suggest it is the distance from the center of the two objects instead of an oscillating distance due to Earth's rotation? (see attaches image)
Can Stellarium give the distance from the viewpoint to the object?

Code i'm using to obtain the coordinates is:

map=core.getObjectInfo(object_info)

//...

core.output(date + ",Az,Alt," + map["azimuth-geometric"] + "," + map["altitude-geometric"] + ",dkm," + map["distance-km"])

//...

°

Thanks,
An

figure distance new york - moon.png

Georg Zotti

unread,
May 12, 2024, 8:10:35 PMMay 12
to Stellarium
Have you activated Topocentric correction? I.e., does the Moon show distance variation in just the on-screen text when you are stepping through the hours?

An Rodriguez

unread,
May 12, 2024, 10:56:46 PMMay 12
to Stellarium
After reading your message, I tried using `setUseTopocentricCoordinates` with the API like among other attempts

core.setUseTopocentricCoordinates (true)


but got

script error: 'Type' @ line 46: TypeError: Property 'setUseTopocentricCoordinates' of object StelMainScriptAPI(0x1ec1ee18fb0) is not a function



Here's the plot of the 'geometric altitude' from the same data. Altitude oscillates as expected:

figure geometic altitude my city  - moon.png

Please advise,

Thanks.


pd the Moon shows distance variation when stepping through the hour, just now as much as expected due to Earth's rotation.

An Rodriguez

unread,
May 12, 2024, 10:56:51 PMMay 12
to Stellarium
Hi,
I tried turning the topocentric coordinates in the API without avail doing


core.setUseTopocentricCoordinates (true)


which gives error

script error: 'Type' @ line 46: TypeError: Property 'setUseTopocentricCoordinates' of object StelMainScriptAPI(0x1ec1ee18fb0) is not a function


Then I found this: https://answers.launchpad.net/stellarium/+question/670846, which seems to say it is not possible.

altitude-geometic seems to be as expected
figure geometic altitude my city  - moon.png

Could Stellarium provide the topocentric distance?

Please advise.

Regards

pd this might be a double post

On Sunday, May 12, 2024 at 8:10:35 PM UTC-4 Georg Zotti wrote:

Georg Zotti

unread,
May 13, 2024, 3:38:13 AMMay 13
to Stellarium
I asked:
> Have you activated Topocentric correction? I.e., does the Moon show distance variation in just the on-screen text when you are stepping through the hours?

I must apparently reformulate with even more words:
Have you activated Topocentric correction in the checkbox which you can click in the Graphical User Interface (GUI)? 
I.e., does the Moon show distance variation in just the on-screen text in the top-left area of the display when you are manually stepping through the hours using the time panel?

Once you have checked this, you may find another scripting function useful: core.setPlanetocentricCalculations(bool)
It has inverse logic to a function  that you may have attempted to use from the non-scriptable StelCore. Note that JavaScript's core object is not a StelCore, as described in that thread you have found.

An Rodriguez

unread,
May 14, 2024, 1:29:01 PMMay 14
to Stellarium
Hi, inline

I asked:
> Have you activated Topocentric correction? I.e., does the Moon show distance variation in just the on-screen text when you are stepping through the hours?

I must apparently reformulate with even more words:
Have you activated Topocentric correction in the checkbox which you can click in the Graphical User Interface (GUI)? 

I tried to find where to activate in GUI, but failed.

However during the search I found an option I didn't know about, is exporting the positions of objects.

This provides an oscillating distance as expected.
oscillating distance.png7positions export.png

 
I.e., does the Moon show distance variation in just the on-screen text in the top-left area of the display when you are manually stepping through the hours using the time panel?
I thought I replied that the distance to the moon changes, but does seem to oscillate daily. 

Once you have checked this, you may find another scripting function useful: core.setPlanetocentricCalculations(bool)
It has inverse logic to a function  that you may have attempted to use from the non-scriptable StelCore. Note that JavaScript's core object is not a StelCore, as described in that thread you have found.

Modified my script with the `core.setPlanetocentricCalculations(bool) `, but the distance doesn't show the oscillation...

Please advise 

Georg Zotti

unread,
May 14, 2024, 5:31:16 PMMay 14
to Stellarium
In our scripting examples, we always show a little wait in the loops, to allow the system performing the necessary computations before retrieving the infoMap. Did you include that?

My minimal working code to find distances:

core.setTimeRate(0);

jd=core.getJDay();

for (h=0; h<24; ++h)

{

   core.setJDay(jd+h/24);

   core.wait(0.1)


   map=core.getSelectedObjectInfo()

   core.output(map["distance-km"])

}



An Rodriguez

unread,
May 14, 2024, 9:26:18 PMMay 14
to Stellarium
It has a wait of 0.1. I also testes increasing to 0.5 to no avail.

The script is:

year = "2020"

month = "02"

local_output_path = "D:\\Users\\x\\"

dir_name = "height-star"

output_path = local_output_path + "\\" + dir_name + "\\"

// star name

object_info = "HIP54589"

object_info = "Sun"

object_info = "Moon"

//object_info = "Earth"

observer_location = "Caracas, Venezuela"

// how many points per file ; test

ciclos = 240


///////////////////////// don't modify below this line


core.setPlanetocentricCalculations(true)

output_fname = output_path + "heightstar-"+object_info+"-"+year + "-" + month + ".csv"

core.selectObjectByName(object_info, true);

map=core.getObjectInfo(object_info)

core.resetOutput()

core.setObserverLocation(observer_location)

core.setDate(year + "-" + month + "-01T00:00:00", "UTC")


for (i=0; i<ciclos; i++)

{

map=core.getObjectInfo(object_info)

date = core.getDate()

core.output(date + ",Az,Alt," + map["azimuth-geometric"] + "," + map["altitude-geometric"] + ",dkm," + map["distance-km"])

core.setDate("+"+minutos_medida+" minutes", "UTC")

core.wait(0.1);


}

core.saveOutputAs(output_fname)

core.debug("fin")



Regards

An Rodriguez

unread,
May 14, 2024, 9:52:31 PMMay 14
to stell...@googlegroups.com
I deleted a necessary line:

minutos_medida = 20


An Rodriguez


--
You received this message because you are subscribed to the Google Groups "Stellarium" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stellarium+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/stellarium/ce16b6da-8531-446c-9f76-df9a899d4b21n%40googlegroups.com.

Georg Zotti

unread,
May 15, 2024, 8:28:10 AMMay 15
to Stellarium
If you want topocentric data, you should necessarily delete or invert this line instead:
core.setPlanetocentricCalculations(true)

An Rodriguez

unread,
May 15, 2024, 1:17:47 PMMay 15
to Stellarium
Yes, that was it.
Thank you for helping me notice.
Now the distance oscillates as expected.
oscillating distance.png
Regards!
Reply all
Reply to author
Forward
0 new messages