GithubHelp home page GithubHelp logo

Comments (9)

weaverba137 avatar weaverba137 commented on July 20, 2024

That function is using a custom rotation. Has anyone tried this using astropy.coordinates?

from desisurvey.

weaverba137 avatar weaverba137 commented on July 20, 2024

PS, aren't rotations implemented by symmetric matrices? Because the rotation matrix in that function is not symmetric.

from desisurvey.

sbailey avatar sbailey commented on July 20, 2024

astropy.coordinates seems fast enough in this case:

def radec2lb(ra,dec):
    from astropy.coordinates import SkyCoord
    from astropy import units
    c = SkyCoord(ra*units.deg, dec*units.deg)
    return (c.galactic.l.value, c.galactic.b.value)

n = int(1e6)
ra = np.random.uniform(0,360, size=n)
dec = np.random.uniform(-90,90, size=n)  #- ok not uniform in cos(dec)

%time l,b = radec2lb(ra, dec)
CPU times: user 966 ms, sys: 216 ms, total: 1.18 s
Wall time: 1.19 s

We've had trouble with astropy.coordinates for alt,az calculations for survey planning because it wants to get things accurate to sub-arcsecond precision and it doesn't know about the earths wobble terms into the future. But for equatorial to galactic conversions this seems fine. Any objections?

from desisurvey.

mlandriau avatar mlandriau commented on July 20, 2024

from desisurvey.

weaverba137 avatar weaverba137 commented on July 20, 2024

OK, fair enough, I was just tying to figure out why the function was so completely wrong. Seems like astropy.coordinates is the way to go here.

from desisurvey.

mlandriau avatar mlandriau commented on July 20, 2024

The bug was in the spherical-to-cartesian transform before the rotation was applied (the angles were mixed up). Now gives the same answer as astropy to better than 10^-5 degrees.

P.S. Ben: part of my previous comment wrong. When referring to rotation matrices about a coordinate axis, I should have said that they be decomposed into the sum of a diagonal matrix and an anti-symmetric matrix.

from desisurvey.

sbailey avatar sbailey commented on July 20, 2024

It's reassuring to know the source of the discrepancy, but let's switch to the astropy.coordinates version anyway since that already supports scalar, list, and numpy array inputs. This implementation only supports scalar inputs and thus will be very slow for N>>1 targets.

Please also re-enable the unit test on this to check those cases.

from desisurvey.

weaverba137 avatar weaverba137 commented on July 20, 2024

Note that #29 did not actually implement @sbailey's request to use astropy.coordinates.

from desisurvey.

dkirkby avatar dkirkby commented on July 20, 2024

The only call to equ2gal_J2000() is now in afternoonplan where it is commented out. All new desisurvey code is using astropy.coordinates via helper functions in desisurvey.utils. Closing.

from desisurvey.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.