Skip to content
This repository has been archived by the owner on Jun 16, 2018. It is now read-only.

added method to set coord_type #70

Merged
merged 1 commit into from
Jul 2, 2014

Conversation

anizami
Copy link
Collaborator

@anizami anizami commented Jul 2, 2014

Does this look okay?

def set_coord_type(self, coord_type):
"""
Set the coordinate type for the axis
Parameters
Copy link
Owner

Choose a reason for hiding this comment

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

There should be a full stop after axis and an empty line before Parameters

@astrofrog
Copy link
Owner

@anizami - can you add a small image test? Take for example the MSX test image and change both axes to scalar, and set the format to e.g. x.xxx.

I think you will need to also reset self._formatter_locator. In fact, you could even then call self.set_coord_type from __init__ to avoid duplicating the logic in both. Does this make sense?

@astrofrog astrofrog added this to the 0.1 milestone Jul 2, 2014
@astrofrog
Copy link
Owner

One more comment - can you add an optional coord_wrap argument to this method? (since it is related)

@anizami
Copy link
Collaborator Author

anizami commented Jul 2, 2014

@astrofrog - I've added what you suggested. Can you take a look at the image and see if it makes sense? I'm not sure what the behavior should be like if we change coord_type to 'scalar'. In what situation would someone want to change coord_type?
Also, should coord_wrap be an int or a float? I wasn't sure so I haven't added that in the documentation yet.

if coord_type == 'longitude' and coord_wrap is None:
self.coord_wrap = 360
elif coord_type != 'longitude' and coord_wrap is not None:
raise NotImplementedError('coord_wrap is not yet supported for non-longitude coordinates')
Copy link
Owner

Choose a reason for hiding this comment

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

The logic has changed compared to the original code. Normally, coord_wrap should not be used for scalar coord_type either. Maybe you can try and keep the code more similar to before to keep the same logic?

@astrofrog
Copy link
Owner

@anizami - there are different use cases for this. For example, someone will have a WCS that doesn't say that the coord_type is longitude, which means it will default to scalar, and the user would then change to longitude. Or someone might want to change the coord_wrap from 360. to 180. (to make the longitude go from -180 to 180 instead of 0 to 360). Or maybe the user wants to treat the longitude as if it wasn't an angle. What you have here is good, except for my comment above about the fact the logic is changed. But once that's fixed, this should be good to go :)

@astrofrog
Copy link
Owner

To answer your other question, coord_wrap should be a float (but if an int is passed, it can still work)

@anizami
Copy link
Collaborator Author

anizami commented Jul 2, 2014

@astrofrog - sorry about the changed logic, I've fixed that now :)

@@ -246,3 +246,16 @@ def test_tick_angles_non_square_axes(self, generate):
ax.coords['dec'].set_ticks(color='red', size=20)
self.generate_or_test(generate, fig, 'tick_angles_non_square_axes.png')

# Test for setting coord_type
def test_set_coord_type(self, generate):
fig = plt.figure(figsize=(6, 6))
Copy link
Owner

Choose a reason for hiding this comment

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

Can you make this smaller than 6,6 since it's not needed here? Maybe something like 3,3 would be enough (and you can make the font smaller to fit the labels if needed). Once you do this, make sure you rebase to squash the commits (to avoid having the larger image in the history).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure

@astrofrog
Copy link
Owner

Looks good! Thanks @anizami!

astrofrog added a commit that referenced this pull request Jul 2, 2014
@astrofrog astrofrog merged commit c420a40 into astrofrog:master Jul 2, 2014
@anizami anizami deleted the set-coordinate-type branch July 4, 2014 07:03
astrofrog added a commit that referenced this pull request Nov 28, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants