Skip to content

WCS should accept / return coordinates objects #812 - #2210

Closed
QuanTakeuchi wants to merge 2 commits into
astropy:masterfrom
QuanTakeuchi:wcs_coor
Closed

QuanTakeuchi wants to merge 2 commits into
astropy:masterfrom
QuanTakeuchi:wcs_coor

Conversation

@QuanTakeuchi

Copy link
Copy Markdown
Contributor

In response to Issue #812

@QuanTakeuchi

Copy link
Copy Markdown
Contributor Author

Is this approach fine?

Comment thread astropy/wcs/wcs.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you converting the angles to strings and back again?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to get a float value from the angle object. And parse_angle takes string as an input. Besides dms_to_degrees needed each value seperately. That's the reason I did it that way

Is there a better way to do this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just do xy.lonangle.degrees.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be careful also -- add update your test accordingly -- that SphericalCoordinates objects can contain/be an array of coordinates, not just a single coordinate.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did try .degrees in the beginning, but it didn't work so I assumed that the object has no such attribute. Anyways after your suggestion I looked into it and found that there is no 's' in degree. Thanks for pointing out though.

And sure I will see to it that the it takes a list of coordinates as input.

@mdboom

mdboom commented Mar 18, 2014

Copy link
Copy Markdown
Contributor

There's a couple of problems here:

  1. This will accept coordinates as inputs even to functions where the input is in pixels (such as wcs_pix2world). This should only happen for functions where the input is in world coordinates.
  2. The ordering of the arguments is not always (lon, lat). Depending on the WCS, they could latitude and longitude could be in any of the axes. You should use self.wcs.lat and self.wcs.lng to determine which are the latitude and longitude axes and only deal with those. See:

http://docs.astropy.org/en/stable/api/astropy.wcs.Wcsprm.html#astropy.wcs.Wcsprm.lat

@QuanTakeuchi

Copy link
Copy Markdown
Contributor Author

Ok I will modify it to take this into consideration.

@QuanTakeuchi

Copy link
Copy Markdown
Contributor Author

@mdboom Tried to include all the suggestions you gave. What all problems can arise from this implementation?

@astrofrog

Copy link
Copy Markdown
Member

@QuanTakeuchi - just a side comment. It looks like you are merging the master branch into the feature branch you are using here, but this causes many 'merge' commits to appear in the list of commits. You can avoid this by rebasing the feature branch on master instead of merging master into the feature branch. You can also get rid of those commits now by rebasing on the latest upstream master, then force pushing to the remote branch.

@QuanTakeuchi

Copy link
Copy Markdown
Contributor Author

@astrofrog I tried to rebase. I was expecting that now it would show just the commits I made on this feature branch, but it includes the commits on the upstream master branch as well. Is this how it should work, or I have done the rebasing incorrectly?

@astrofrog

Copy link
Copy Markdown
Member

@QuanTakeuchi - you should rebase with:

git fetch upstream
git rebase -i upstream/master

Does this work? Once you do this the latest upstream commits will appear in your history, but should not appear in the pull request.

@QuanTakeuchi

Copy link
Copy Markdown
Contributor Author

@astrofrog Thanks. It worked.

But what about the changes that I made in this pull request? Are they fine?

@astrofrog

Copy link
Copy Markdown
Member

@QuanTakeuchi - I think we will need to discuss this a little with other developers before merging this - the issue is that for example if the WCS has a specific coordinate system (for example ICRS) and Galactic coordinates are passed, we need to intelligently understand how to convert these.

@QuanTakeuchi

Copy link
Copy Markdown
Contributor Author

@astrofrog Okay, got it. We can compare both the input coordinate system and WCS coordinate system and convert the input value to the latter. Is there any problem in doing it this way?

@astrofrog

Copy link
Copy Markdown
Member

@QuanTakeuchi - I don't know if there's an easy way to figure out the relation between the WCS coordinate system and the coordinate system from astropy.wcs at the moment. Maybe @mdboom can comment on this?

Comment thread astropy/wcs/wcs.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The world coordinates can be more than two-dimensional -- for example, (lat, lon, spec), or it could even be (lat, spec). So the correct solution might be to create a zeroed array for all of the dimensions, fill in xy.lonangle.degree in index self.wcs.lng and xy.latangle.degree in index self.wcs.lat. Alternatively, you could check that the world coordinate dimensions are 2 (self.wcs.naxis == 2) and that the wcs.lat and wsc.lng are 0 and 1 (in either order), and if not, raise an exception.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Sorry I should have read about world coordinates first, and thought of this possibilty.
Anyways I will correct this.

@mdboom

mdboom commented Mar 23, 2014

Copy link
Copy Markdown
Contributor

As for matching the input coordinate system to the WCS coordinate system: There are a few attributes on self.wcs that might be helpful for determining the coordinate system of the WCS -- radesys, equinox, for example. These keywords are discussed in WCS Paper II:

http://www.atnf.csiro.au/people/mcalabre/WCS/ccs.pdf

I don't think I know enough about coordinate systems to say if that's enough information for what we need, but hopefully that's a good starting point.

@QuanTakeuchi

Copy link
Copy Markdown
Contributor Author

@mdboom I will go through this and see what i can do about it.

@astrofrog astrofrog added this to the v1.0.0 milestone May 3, 2014
@mdboom mdboom added the wcs label May 9, 2014
@astrofrog

Copy link
Copy Markdown
Member

@QuanTakeuchi - just to check, is this still something you are interested in working on? If so, I can provide some updated instructions (there are helper functions now in astropy.wcs that can help with this). If you no longer want to work on it, I can take over and try and submit a new pull request.

@QuanTakeuchi

Copy link
Copy Markdown
Contributor Author

Oh sorry.. I had forgotten about it for to my academics.

@QuanTakeuchi

Copy link
Copy Markdown
Contributor Author

I am still interested though. It's My vacation time now. Sure i would like to resume writing on it. What are those functions?

@astrofrog

Copy link
Copy Markdown
Member

@QuanTakeuchi - I need to add one of those functions to astropy.wcs, but I'll post a comment on here once it's ready.

@astrofrog

Copy link
Copy Markdown
Member

@QuanTakeuchi - I've opened the following pull request: #2885 - with that in hand, it should be easy to then implement this pull request :)

@mdboom

mdboom commented Jan 13, 2015

Copy link
Copy Markdown
Contributor

@QuanTakeuchi: I'm going through and triaging pull requests. I'd still be happy to have this functionality in astropy if we can work out the kinks. For now, though, given the imminent 1.0 release, I am going to remove the 1.0 milestone. Do you still have interest in completing this work?

@mdboom mdboom removed this from the v1.0.0 milestone Jan 13, 2015
@QuanTakeuchi

Copy link
Copy Markdown
Contributor Author

I am sorry. I couldn't get this through. I won't be able to pursue it now. Sorry for the inactivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants