|
From: Jon G. <jo...@th...> - 2014-01-30 22:24:08
|
> > The patch only implements unwrapping for datasets, and not for
> > continuous functions (I'm not entirely sure why it has no effect for
> > functions; it is not an intentional limitation from my side).
>
> To use smoothing with a function you need to modify your plot command
> so that the function is treated as sampled data:
>
> plot 'phase.log' using 1:(atan2($3,$2)) w lines ls 1 t 'Wrapped' \
> ,'phase.log' using 1:(atan2($3,$2)) w lines ls 3 t 'Unwrapped' smooth unwrap \
> ,'+' using 1:(x-(floor(x/6.28)*6.28)-3.14) ls 4 t 'Wrapped func' \
> ,'+' using 1:(x-(floor(x/6.28)*6.28)-3.14) ls 5 t 'Unwrapped func' smooth unwrap \
s/x/$1/
Well, the good news is that it wraps the values correctly.
The bad news is that, as you expected, the plot jumps around when you
zoom and pan.
To be honest, I don't quite know what would be expected behavior for
unwrap for continuous function though. When you change the xrange, the
unwrapping *should* change as the first point changes; that's kind of
the point of unwrap.
I can think of a couple of ways of dealing with this, but none of them
are really ideal:
- Always unwrap from x=0, but unwrap in both directions:
Tricky to implement correctly.
Problematic when the xrange is far from zero.
Could be a massive problem for functions that have branch cuts
around the origin.
- Disallow unwrapping for sampled functions:
I'm not even sure if this would be possible?
Users might want the ability to unwrap functions...
- Make no special arrangements for sampled functions:
Very odd behavior for the user if they don't know what to expect.
Simple to implement, and does "what the user asked" even though
that may not be what they expected.
- Add a "start unwrap at" parameter to the unwrap smoothing operation:
Even trickier to implement.
Complicates syntax.
Adds another source for plotting confusion for users.
Personally, I think what makes most sense is to not deal with plotting
sampled functions as a special case. Unwrap will work "as advertised",
and users who know what unwrap is supposed to do are likely to
understand what is going on when they zoom/pan.
You could also argue that unwrap doesn't even really make sense for
functions, because in many cases you could just rewrite the function so
that it doesn't wrap. I think it is relatively rare in practice for
people to write functions that *do* wrap; it is usually a phenomenon
seen in sampled data.
One separate note about the patch is that the line:
lasty = M_PI;
should possibly be changed to
lasty = 0;
The former makes sense for a signal that usually varies from 0 to 2*pi,
whereas the latter makes more sense for signals that vary from -pi to
pi. In practice it will make little difference beyond the y-intercept of
the unwrapped line.
|