Topic: Can Graph use date/times for an axis?

I have another application I was considering, thus this new thread...

I have a bunch of pure text data from my solar panels, one file per day, and they look like:
sep=;
Version CSV1|Tool SE|Linebreaks CR/LF|Delimiter semicolon|Decimalpoint dot|Precision 3

;SN: 1234;SN: 1234
;Unknown device;Unknown device
;1234;1234
;Total yield;Power
;Counter;Analog
yyyy-MM-dd hh:mm tt;kWh;kW
2010-09-03 06:45 AM;32.657;0.000
2010-09-03 06:50 AM;32.657;0.000
2010-09-03 06:55 AM;32.657;0.000
2010-09-03 07:00 AM;32.660;0.036
2010-09-03 07:05 AM;32.667;0.084
[etc.]

It would be neat if I could concatenate all the files together (possibly leaving out the headers) and graph them, so I'd have a bunch of scallop-shaped traces. Each line has the date/time, kWh cumulative, and the current kW output (as you can see from the line immediately before the data). Then I'd want to zoom into specific areas.

The problem is that Graph probably wants the X coordinates want to be pure numbers, whereas this application wants date/times for the X axis.

Does Graph have any capability to do this? If not, would you consider adding it?

I have no control over what the inverter writes, but of course I can write a tool to go between this data and whatever Graph would want.

Re: Can Graph use date/times for an axis?

Graph has no support for handling of dates, mostly because dates do not fit very well into Graph.
However it might be a good candidate for a plugin. I have attached a file ImportDates.py. If you place it in the Plugins directory where Graph is installed, you will get a menu item Plugins|Import dates. When selected you need to specify the path to a file in the format you have specified, which will then be imported.

The plugin converts the date and time to days since the first date at midnight. The next thing is to show dates on the x-axis. The only way to do this is to remove the numbers from the axis in the Axes dialog and create text labels with the dates.

I hope you can use it.

Post's attachments

Attachment icon ImportDates.py 1.05 kb, 903 downloads since 2010-09-11 

Re: Can Graph use date/times for an axis?

Sounds like it won't really result in a nice convenient form - I'd really like the dates to be on the axis so I can look for a specific date and don't have to convert to a 'number of days' format, and that's not to mention the time. Changing all the labels sounds impractical because of the quantity involved - traces every 5 minutes for about 10 hours each day.

If I do get to playing with it eventually, how do I get Python to run with Graph? The instructions say to type F11, do I give it the .py filename and then it's executed? Or...?

Lastly, not quite on the subject, but if the axes are out of view, it'd be neat to have the grid lines labeled anyway. The way it is now, I have no idea what grid line I'm looking at when I'm zoomed in. Would you prefer this item be a separate topic?

Re: Can Graph use date/times for an axis?

paulkinzelman wrote:

Sounds like it won't really result in a nice convenient form - I'd really like the dates to be on the axis so I can look for a specific date and don't have to convert to a 'number of days' format, and that's not to mention the time. Changing all the labels sounds impractical because of the quantity involved - traces every 5 minutes for about 10 hours each day.

Unfortunately this seems to be the best that can be done for now. It might be possible to show real dates on the axes in a later version.

paulkinzelman wrote:

If I do get to playing with it eventually, how do I get Python to run with Graph? The instructions say to type F11, do I give it the .py filename and then it's executed? Or...?

If you have Python 3.1 installed Graph will find and use it. A plugin is a .py file that is placed in the Plugins directory. Graph will automatically run it when Graph is started.

As an alternative to writing a plugin file you can press F11 to get a console where you can have commands executed immediately. This is a great way to test things before you write it in a plugin.

paulkinzelman wrote:

Lastly, not quite on the subject, but if the axes are out of view, it'd be neat to have the grid lines labeled anyway. The way it is now, I have no idea what grid line I'm looking at when I'm zoomed in. Would you prefer this item be a separate topic?

If you have a lot to write about it, it might be easier to discuss in a separate topic. smile
Have you tried setting Axes style to Boxed in the Axes dialog?

Re: Can Graph use date/times for an axis?

Yes, I understand that doing times on the axes would be a major change, but I think it could be very useful for some "special needs" people like me. :-) That could be a feature that you'd have and other graph tools wouldn't.

Re: Python
I removed Python so maybe that's why it doesn't work. I punched F11 and nothing happened, is that to be expected if Python is not installed? Might be worth having a pull-down menu item to do the F11 task as well so that people like me fumbling around can find it.

I was able to cheat and change the format of the .H file to be imported to Graph, turns out for the limited number of cases I have to do, that is faster than writing a tool to change the format so I probably won't bother with Python at least for now.

And yes, the Boxed style is *exactly* what I was looking for, thanks! Also, it looks like hovering will show me the X and Y in the lower right I just noticed. Thanks!

Re: Can Graph use date/times for an axis?

To be honest I think a spread sheet would fit your needs better than Graph. They can usually handle dates. Dates do not fit very well into Graph. What is the logarithm to September 1st for example?

You need to have Python installed for Graph to find Python. Then you will also get a menu called Plugins with the menu item Show Python interpreter.

Re: Can Graph use date/times for an axis?

A spreadsheet would work well for some things with dates, but in this case, I really want to see the curve of the power generation as the date and time changes given a set of points. And the number of X points could be quite large.

Just looking at raw numbers is difficult to see trends, peaks, etc. I suppose graphs can be done in Excel, I haven't really experimented with that however. I really think it'd be worth looking at implementing dates on the axis in Graph sometime in the future. I could see a lot of potential applications for that. I realize it'd be complex to do it comprehensively.

I didn't understand your example of "logarithm to Sept 1"?

Re: Python
I see, so you're saying that when Graph starts up, it notices whether Python is installed and modifies its menus accordingly. That's a great way to do it.

Re: Can Graph use date/times for an axis?

paulkinzelman wrote:

Just looking at raw numbers is difficult to see trends, peaks, etc. I suppose graphs can be done in Excel, I haven't really experimented with that however.

I think any spread sheet can plot the data.

paulkinzelman wrote:

I really think it'd be worth looking at implementing dates on the axis in Graph sometime in the future. I could see a lot of potential applications for that. I realize it'd be complex to do it comprehensively.

I will probably add something in a later version, but I am not going to reinvent the spread sheet.

paulkinzelman wrote:

I didn't understand your example of "logarithm to Sept 1"?

In graph you can write log(x). What is the result if x is September 1st? I do not expect an answer. I am just saying that dates do not fit very well.

paulkinzelman wrote:

Re: Python
I see, so you're saying that when Graph starts up, it notices whether Python is installed and modifies its menus accordingly. That's a great way to do it.

Yes, or to be correct, when Graph starts up it will execute the plugins, which then can create menu items.

Re: Can Graph use date/times for an axis?

Yes, any spreadsheet can plot the data to an extent, but I don't know how well they scale up. For instance, if I have a solar output plot for a year, every day, 5 min samples for 8 hrs/day, that makes for 365*8*12 = 35000 datapoints for a year. What happens if I ask a spreadsheet to plot that?

The only reason I can think of for dates is for plotting points, so I think it'd be fine to limit dates to not allow any functions calculating based on dates, or just require a plug-in to work with dates if the user wants to do anything other than label and plot them.

Re: Can Graph use date/times for an axis?

I don't think I ever tried that many data points in a spread sheet, but Graph handles it surprisingly well, so I don't see why a spread sheet shouldn't.

I will probably try to implement support for handling of dates in a plugin. But don't expect anything in the nearest future.