Creating image or surface plot with proper waves and matrix

Hi all,

I am trying to create a image or surface plot, but my x wave (date_s), y wave (Dp), and z matrix (DDlogDp) are problematic. I would want replace rows of z matrix with x wave and columns of z matrix with y wave. Otherwise, I want to use a x wave, a y wave and multiple z waves (the multiple z waves are separates of a z matrix) for the plots. Please find my igor table.

Any comment would be very helpful. Thank you.

 

toIgorExchange.pxp

I am having trouble understanding what you want, but you can make an image plot using x and y waves, see below. For further analysis it might be useful to convert your DDlogDp wave to waveform format (uniformly spaced data points).

Keep in mind that when you plot an image using x and y waves. The x and y waves refer to the edges of the pixels, not the centers, and therefore need to have one additional data point.

Function Test()
//  Test Function

    Wave DataWave=DnDlogDp
    Wave Dp
   
    Variable MaxY=NumPnts(Dp)
    Make/O/N=(MaxY+1) YWave
    YWave[0]=2*Dp[0]-Dp[1]
    YWave[1,MaxY-1]=(Dp[p-1]+Dp[p])/2
    YWave[MaxY]=2*Dp[MaxY-1]-Dp[MaxY-2]
   
    //  Since your time steps are uniform this was easier than trying to read your date time format
    Make/O/N=(DimSize(DataWave,0)+1) XWave=-15+p*30

    DoWindow /K RawDataWindow
    Display /W=(5, 40, 370, 340) /K=1 /N=RawDataWindow
    AppendImage/W=RawDataWindow DataWave
    ModifyImage/W=RawDataWindow '' ctab= {*,*,ColdWarm,0}, ctabAutoscale=1, lookup= $""
   
    DoWindow /K DataWindow
    Display /W=(405, 40, 770, 340) /K=1 /N=DataWindow
    AppendImage/W=DataWindow DataWave vs {XWave, YWave}
    ModifyImage/W=DataWindow '' ctab= {*,*,ColdWarm,0}, ctabAutoscale=1, lookup= $""
end

 

Your x wave "date_s" loaded as text instead of date numbers (seconds since Jan 1, 1904). I see that they are in 30 minute increments, starting at hour 0. You don't need this wave: setting the 2D matrix's X scaling to start at 05/01/2016 00:00 can be done with:

SetScale/P x 3544905600,1800,"dat", DnDlogDp

The Y "dp" wave, on the other hand isn't a linear series: it is exponential (taking the log results in a linear dp)

As oleytken pointed out, to use an auxiliary wave to provide image coordinates you need to provide coordinates of the edges, not the centers.

For that, I wrote this little routine to compute N+1 coordinates given an N point exponential y wave:

 

Function/WAVE ImageCoordinates4Exponential(exponentialWave, outputWaveName)
    Wave exponentialWave
    String outputWaveName
   
    // algorithm, compute log(exponentialWave) to get a linear result.
    // Add one point, shift the X by 0.5, compute a linear fit,
    // convert back to exponential.
   
    Duplicate/O/FREE exponentialWave, logWave
    logWave= ln(exponentialWave)

    CurveFit/Q line logWave
    WAVE W_coef
   
    Make/O/D/N=(numpnts(exponentialWave)+1) $outputWaveName/WAVE=out
    // shift x by -0.5 to keep the center of the pixel at the coordinate
    Variable dx = DimDelta(exponentialWave,0)
    Variable x0 = DimOffset(exponentialWave,0) - dx/2
    SetScale/P x, x0, dx, out
    out = exp(W_coef[0] + W_coef[1]*x)
   
    return out
End

(not completely sure about the math there) and then ran it using:

ImageCoordinates4Exponential(dp,"dpPlus1")

I created an image plot using X scaling and a Y auxiliary wave, and used log (Z) colors to enhance contrast.

Display;AppendImage DnDlogDp vs {*,dpPlus1}
ModifyImage DnDlogDp log=1, ctab= {1,*,Geo,0}
ModifyGraph nticks(bottom)=20,minor(bottom)=1

See the attachments for the result and for the experiment I used to create it.

 

olelytken, Jim, thanks for your help! I am almost there, excepting treating irregular datetime on the graph. Please find 'NewDataset" folder in the attachment. Now I have "dat" at 30-min interval with breaks, "DnDlogDp", and "dpPlus1" in the NewDataset folder. Could you provide a way to creat image plot with this dataset?

toIgorExchange.pxp

You need to decide what representation you want for the gaps in the dates.

You could linearly interpolate the data values for intermediate dates.

You could generate an X date wave with an extra point, but you'd need to choose its duration.

Using an X date wave you'd end up with some stripes of wide pixels.