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

Export "Inter-photon delay times" graph to .csv file #17

Open
tritemio opened this issue Aug 1, 2018 · 3 comments
Open

Export "Inter-photon delay times" graph to .csv file #17

tritemio opened this issue Aug 1, 2018 · 3 comments

Comments

@tritemio
Copy link

tritemio commented Aug 1, 2018

Migrated from tritemio#68

@ncodina wrote:

Hi,
I want to export the data of the "Inter-photon delay times" to a .csv file. How would I do it?

figure_1

@tritemio
Copy link
Author

tritemio commented Aug 1, 2018

Hi @ncodina,
there is no explicit support for exporting that graph. You can either compute the histogram by yourself using numpy or you can export the coordinates of the datapoints from the matplotlib figure.

In the first case, you need to get the photon streams with Data.get_ph_times(), use np.diff to get the interphoton times and finally call np.histogram to compute the histogram. That's how hist_interphoton_single is implemented.

I the second case, you iterate through the axis children, selecting using isinstance the one representing the data (if I recall it should be Lines2D). Then, each object representing a curve has a get_data method to get x, y coordinates.

@ncodina
Copy link

ncodina commented Aug 6, 2018

Hi @tritemio,

Thanks very much for the information. For now, I exported them by introducing this line of code in the hist_interphoton_single function, after defining counts.

line:
counts.tofile("/Path/To/counts_{}.csv".format(ph_sel), sep='\n')

introduced here:

@tritemio
Copy link
Author

tritemio commented Aug 6, 2018

Good hack.

In the future, we can think about a common API to save plot data . For example all the plot functions could accept a export=True/False, to save to disk. Better, they could accept a single argument export_fname that is None by default and saves to disk only when a file name is specified. The format can be a standard CSV with column names so that files can be directly loaded in a pandas.DataFrame. Each plot function would have its own custom logic to save the data (or raise NotImplemented), but the user API and the way to re-load the data would be the same for all plots.

If you are interested to tackle this issue, I would welcome a Pull Request.

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

No branches or pull requests

2 participants