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

Option for normalizing data in waterfall plot #31

Merged
merged 4 commits into from
Oct 3, 2016

Conversation

JKThanassi
Copy link
Collaborator

As of right now the button is in place but the graph is not updating. Will finish fixing it tomorrow.

@JKThanassi
Copy link
Collaborator Author

in response to this issue

self.canvas.draw()
if self.is_normalized:
print("normy")
for i in range(0, len(self.key_list)):

Choose a reason for hiding this comment

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

you can just write range(len(...))

Choose a reason for hiding this comment

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

or even better

for i, k in enumerate(self.key_list):
    temp_x = blob[k][0].copy()

Copy link

@CJ-Wright CJ-Wright Aug 23, 2016

Choose a reason for hiding this comment

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

for even more compactness:

blob = your_data # normalized or not
sub_blob = [blob[k] for k in self.key_list]
for i, (x, y) in enumerate(sub_blob):
    self.ax.plot(x + i * offsetx, y + i * offsety)

Copy link

@CJ-Wright CJ-Wright Aug 23, 2016

Choose a reason for hiding this comment

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

Actually, you might not need the sub_blob. Do you allow the number of data sets to not equal the number of keys? If not then just skip the sub_blob line.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, you can only get the data if there is a key for it. There should never be a time there is not a key for the data.

Choose a reason for hiding this comment

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

Great than you can just do a two liner

Copy link

Choose a reason for hiding this comment

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

Also, you don't need 0 in the range call.

@CJ-Wright
Copy link

How does the waterfall plot handle different color maps? Can you change the waterfall's colors?

@cduff4464
Copy link
Collaborator

@CJ-Wright do you mean for the 3d or the 2d waterfall maps?

@CJ-Wright
Copy link

Both? I guess I meant, are the color maps changeable?

self.canvas.draw()
else:
print("4chan")
for i in range(0, len(self.key_list)):
Copy link

Choose a reason for hiding this comment

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

This can just be range(len(self.key_list))

@CJ-Wright
Copy link

In brief I would go with:

self.ax.cla()
title = 'Data not normalized'
if self.is_normalized:
    data = self.normalized_data
    title = 'Data Normalized'
else:
    data = self._data_dict
list_data = (data[k] for k in self.key_list) # you can do a list comp here too
for i, (x, y) in enumerate(list_data):
    self.ax.plot(x + self.x_offset * i, y + self.y_offset * i)
self.ax.title(title)
self.ax.autoscale()
self.canvas.draw()

Also one might go with ordered dicts for the data if you just want to pull it out sequentially

@CJ-Wright
Copy link

I don't know how long/expensive this code is or where the most expensive part is, but you can parallelize the for loop with a map.

@JKThanassi
Copy link
Collaborator Author

its not too expensive, but i can parallelize it for really large datasets

@cduff4464
Copy link
Collaborator

@CJ-Wright to answer the question about the colormaps being changeable, we have not added that in as a feature yet for the three-d waterfall plots, because we just haven't yet. For the 2d plots matplotlib whenever you add a new plot to the graph simply changes the color of the line to show that it is a different plot automatically. In that sense for 2d waterfall you don't choose the color, you just choose the fact that all the lines will be different colors.

@CJ-Wright
Copy link

Would it be possible to set the colormap similar to how I had it set in my graphing scripts?

Basically you know the number of lines then use that as the max for the color map. Then use the colormap to set the line color based on the index of the line.

@JKThanassi
Copy link
Collaborator Author

@CJ-Wright Yeah, that was the way I was thinking of doing it.

@JKThanassi
Copy link
Collaborator Author

also, im having issues with python not recognizing class attributes when running xpdView. I get an error saying that normalized is not an attribute of the Waterfall2D class when it clearly is. When initializing a waterfall 2d object in an ipython session, the normalized attribute is there.

Do any of you have an idea why that would be?

@CJ-Wright
Copy link

@JKThanassi Do you have some .pyc files left over from before? Can you check the path of the object and make certain it is where you think it is? Did you install your code with python setup.py develop?

@JKThanassi
Copy link
Collaborator Author

@CJ-Wright the setup.py develop did the trick. Thanks.

@CJ-Wright
Copy link

I use it so often I have a .bashrc alias for it: psd
Thanks: @ericdill

@cduff4464 cduff4464 merged commit fecb1ed into NSLS-II-XPD:master Oct 3, 2016
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

Successfully merging this pull request may close these issues.

4 participants