Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centring on Planets from Astropy coords #247

Open
swaterfall opened this issue May 15, 2023 · 4 comments
Open

Centring on Planets from Astropy coords #247

swaterfall opened this issue May 15, 2023 · 4 comments

Comments

@swaterfall
Copy link

swaterfall commented May 15, 2023

I'm trying to centre the view on the planets but can't seem to get them centred correctly. I'm using Astropy to get the ra/dec in degrees. I've tried adjusting timezones and changing the solar_system_ephemeris options in Astropy, nothing seems to work.:

        t = Time.now()
        loc = EarthLocation.of_site("Royal Observatory Greenwich")
        body = get_body("moon", t, loc)
        return body.ra.degree, body.dec.degree

        >>> (1.732172921343838, -3.0447182746037487)

Then I set WWT to same location:

        wwt.settings.set_locationLat(51.4778);
        wwt.settings.set_locationLng(0.00);
        wwt.settings.set_locationAltitude(46);

But all the planets are off centred:
Jupiter:
jupiter
moon
sun

@pkgw
Copy link
Contributor

pkgw commented May 18, 2023

Possibly this has to do with the different coordinates that are calculated relative to a specific observatory, or the Earth's center? That is:

>>> t = Time.now()
>>> b1 = get_body("moon", t)
>>> b1.obsgeoloc
<<< <CartesianRepresentation (x, y, z) in m (0., 0., 0.)>
>>> b1.ra.degree, b1.dec.degree
<<< (45.39946675152052, 18.527480135150867)

>>> loc = EarthLocation.of_site("Royal Observatory Greenwich")
>>> b2 = get_body("moon", t, loc)
>>> b2.obsgeoloc
<<< <CartesianRepresentation (x, y, z) in m (-3636157.00114706, -1594241.3489031, 4975109.54005981)>
>>> b2.ra.degree, b2.dec.degree
<<< (45.17052170200746, 17.653262424718967)

At first I was thinking that the coordinate differences you are seeing might be about about the scale of the differences in the two versions above ... but you're not a whole degree of declination off, are you? (edit: based on the angular size of the Sun, the error looks like it's about 0.1°?) Also it is worth saying that, after checking the code, I am pretty sure that WWT should indeed be correcting the apparent planet positions based on the observing location, so what you're doing should be yielding the correct answers.

Another thing to check would be whether WWT's internal clock matches with the time that you're feeding to Astropy. If I'm remembering correctly, WWT's clock should default to tracking the system time, so it should line up well, but perhaps there's some kind of issue there. It is also possible that there's a timezone component coming into play. You could try playing with the internal clock and seeing if there's an adjustment that lines up the solar system bodies with your crosshairs.

One last thing to try might be selecting a time for the spring equinox such that the Sun's geocentric RA and Dec are 0, and seeing what you're getting out of WWT, after setting its internal clock to match what you're using in Astropy. That might help with quantifying the offset and seeing how it changes with various factors.

@swaterfall
Copy link
Author

I've tried comparing/adjusting the clocks and changing timezones and nothing seems to 'fit'. I'll give the equinox suggestion a try. All the deep sky objects line up correctly so for now I might just have to stick with those.

@swaterfall
Copy link
Author

@pkgw Is there any function in WWT to go to an object? like goTo("moon"). The engine obviously has the position of the moon that its rendering so if I could just go to that I could make it work.

@pkgw
Copy link
Contributor

pkgw commented May 23, 2023

Yes, there is! It's not currently documented, though.

The key is that you need to create a "place" object with some special settings. Using the low-level JavaScript API, you'd do:

var pl = new wwtlib.Place();
pl.set_names(["Moon"]);
pl.set_target(wwtlib.SolarSystemObjects.moon); // both `names` and `target` must agree
pl.set_classification(wwtlib.Classification.solarSystem);
pl.set_type(wwtlib.ImageSetType.sky);

Then you can use gotoTarget:

wwtlib.WWTControl.singleton.gotoTarget(pl, false, false, true);

In the recommended TypeScript interfaces, you should be able to do everything as well. The Place class is exposed, as are the Classification, ImageSetType, and SolarSystemObjects enums (in the @wwtelescope/engine-types package). The slightly higher-level WWInstance class in @wwtelescope/engine-helpers has a gotoTarget method of its own, which is also available in the Vue/Pinia API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants