Sebastiaan Heunis | 24 Jun 00:17

Spectrogram help

Hi

I've sorted all my Qwt issues out and can now compile applications.
Could someone just help me with something?  I've looked at the
spectrogram example, but a few things are unclear.

QwtRasterData(QwtDoubleRect(-1.5, -1.5, 3.0, 3.0))

I understand that this will create an area of -1.5-≥1.5 in both the x
and y directions and that

return QwtDoubleInterval(0.0, 10.0);

for ( double level = 0.5; level < 10.0; level += 1.0 )
        contourLevels += level;
    d_spectrogram->setContourLevels(contourLevels);

sets the contourdata between 0 and 10 with a different colour every
0.5.  What I need to do is to do some processing and and up with an
array (typically [401][501]).  I then want to plot this data from x =
-200 to x = 200 with increments of 1 and from y=0 to y = 0.001 with
increments of 1/500000.  How do I do this?  Can I just call
QwtDoubleRect(-200,400,0,0.001)?  Will that give me a [401][501] grid
to plot in?  Where do I need to store the plotting data?  I'm sorry if
these questions are stupid, but I really do not understand all the
function calls in the spectrogram examples and don't know what
everything does.

Thank you.

(Continue reading)

David Stranz | 24 Jun 03:14

RE: Spectrogram help

Sebastiaan,

Your questions aren't stupid - anyone who has faced the problem
of plotting a 2-D data array using a spectrogram has had to deal
with them.  In the example, it's a nice  continuous mathematical 
function with an infinite resolution raster.  A z-value can be 
computed for every point using the equation.

If you have discrete raster data (and you do - you don't have
a continuous mathematical function, you have an array of
discrete Z values on an X-Y grid), you have to do more work
than the spectrogram example.

Matthias Pospiech posted a solution (with source code) a week
or so ago - look in the list archives on SourceForge.

Basically, you have to create a function that maps from your
real data space onto the pixel space of the screen.  Your data
has 401 x 501 points.  What happens if you want to show this
in a QwtPlot that is 600 x 750 pixels?  The pixels don't line up
with the matrix points.  All those gaps have to be filled with 
some z value that is interpolated between your actual data points.

For every pixel in the plot, the spectrogram will ask the
QwtRasterData instance for a z value, using the method
QwtRasterData::value( double x, double y ).  The x- and y-
ranges are the x- and y-ranges you set in the QwtRasterData
constructor (or setBoundingRect() method), so in your case
you need QwtDoubleRect( -200.0, 0.0, 200, 0.001 ).  The x- and
y-values passed into this method will be the values that correspond
(Continue reading)


Gmane