polar graph :: scatter to contour

About drawing polar contour based scatter date (radial, Angle, image_z, waves stored in table0).

In igor I convert them into matrix using <XYZtoMatrix>.

I also used origin to plot the same data. the screenshot is "polar_contour_in_origin".

My question si why the two results are different ?

In igor, interpolated results don't seem to be what I want.

 

plot_image2.pxp (10.86 MB)

first create x and y waves from your radius and angle.

Then create an empty polar graph with Igor 9.05.

From the graph menu, choose append contour, but make sure you choose the HorizCrossing and VertCrossing axes.

From the Modify Contour Appearance dialog, choose Fill Contours.

Open the Modify Polar Graph panel, switch to the range tab, and set the radius and angle ranges to match.

 

Thank you for your advice.

       Sorry, I didn't make myself clear.

       What I mean is why do the two programs plot differently based on same data?
       Which one should I trust?

data show (306.21 KB)

In reply to by Qianlix

Qianlix wrote:

       What I mean is why do the two programs plot differently based on same data?
       Which one should I trust?

I don't know anything about Origin, but it looks like the Origin graph has the text "Speed mode is on", which might indicate that it's downsampling your data or otherwise altering the representation of the data in order to make the drawing faster. You might try turning speed mode off before you compare the plots.

I've attached my implementation of what I think you are going for (a polar image not a contour).

After creating the interpolated image, I used the Modify Polar Graph panel's Append Image button (requires Igor 9.05) to select the created image matrix, and then adjusted the polar graph axes ranges and other settings (angle direction and angle 0 location) to match the image's angle direction and angle 0 location specified in the ImageFromPolarCoordinates macro.

See the .png attachment for the result.

For those that don't want to download the revised experiment, I implemented the following code to convert from polar to rectangular followed by ImageInterpolate:

// Argument order is arranged to make missing parameters dialog look organized.
Macro ImageFromPolarCoordinates(wRadiusName, rows, wAngleName, cols, wSpeedName, clockwiseChoice, displayImageChoice, zeroAtChoice)
	String wRadiusName="radial"
	String wAngleName="Angle"
	String wSpeedName="image_z"

	Variable rows=200, cols=200
	Variable clockwiseChoice = 2		// 1=ccw, 2=cw
	Variable zeroAtChoice = 3		// 1 = right, 2 = left, 3 = top, 4 = bottom
	Variable displayImageChoice = 1	// 1 = yes, 2 = no
	
	Prompt wRadiusName,"Radius Wave",popup,WaveList("*",";","DIMS:1")
	Prompt wAngleName,"Angle Wave (degrees)",popup,WaveList("*",";","DIMS:1")
	Prompt wSpeedName,"Speed wave (z)",popup,WaveList("*",";","DIMS:1")
	Prompt rows,"number of rows for matrix"
	Prompt cols,"number of columns for matrix"
	
	Prompt clockwiseChoice,"Angle Direction",popup, "counter-clockwise;Clockwise;"
	Prompt zeroAtChoice,"Zero at",popup, "right;left;top;bottom;"
	Prompt displayImageChoice,"Display Image in New Graph",popup, "yes;no;"

	Variable angleDir = clockwiseChoice == 1 ? 1 : -1
	Variable angle0 = 0		// right
	if( zeroAtChoice == 2 ) // left
		angle0 = 180
	endif
	if( zeroAtChoice == 3 ) // top
		angle0 = -90
	endif
	if( zeroAtChoice == 4 ) // bottom
		angle0 = +90
	endif
	
	String imageName = fImageFromPolarCoordinates($wRadiusName, $wAngleName, $wSpeedName, rows, cols, angleDir, angle0)

	if( displayImageChoice == 1 ) // yes
		Display/K=0;AppendImage $imageName
		ModifyGraph width={Plan,1,bottom,left}
		// Set Axes Symmetrical about zero
		SetAxis/A/E=2 left
		SetAxis/A/E=2 bottom
		ModifyImage ''#0 ctab= {*,*,Turbo,0}
		if( 0 ) // debugging
			String dir = StringFromList(clockwiseChoice-1,"counter-clockwise;Clockwise;")
			String where = StringFromList(zeroAtChoice-1,"right;left;top;bottom;")
			TextBox/C/N=choices dir +" at "+where
		endif
	endif
End

// returns name of image
Function/S fImageFromPolarCoordinates(radius, angle, speed, rows, cols, angleDir, angle0)
    Wave radius, angle, speed // presumed same length 1-D waves, angle in degrees
	Variable rows, cols
	Variable angleDir, angle0

	String prefix= NameOfWave(radius)+NameOfWave(angle)
	String nameX = prefix+"_polarX"
	String nameY = prefix+"_polarY"
	Duplicate/O radius, $nameX,$nameY
	WAVE wx = $nameX
	WAVE wy = $nameY

	wx = radius * cos((angleDir*angle-angle0)*pi/180)
	wy = radius * sin((angleDir*angle-angle0)*pi/180)
	
	// determine the X and Y bounds of the XY data
	WaveStats/M=0/Q wx
	Variable xmin= V_min, xmax = V_max
	Variable dx= (xmax-xmin) / (rows-1)
	if( dx <= 0 )
		DoAlert 0, "max X must be greater than min X!"
		return ""
	endif
	xmax += dx + dx/2	// version 6.38: ImageInterpolate computes nXPoints=floor(abs(xmax-xmin)/dx)
	
	WaveStats/M=0/Q wy
	Variable ymin= V_min, ymax = V_max
	Variable dy= (ymax-ymin) / (cols-1)
	if( dy <= 0 )
		DoAlert 0, "max Y must be greater than min Y!"
		return ""
	endif
	ymax += dy + dy/2
	
 	// ImageInterpolate requires triplet wave
 	String tripletName=prefix+"_temp"
	Concatenate/O/DL {wx,wy,speed},$tripletName
	WAVE wtriplet=$tripletName

	Variable outerValue=NaN	// transparent outside of boundary
	Variable pftl = 1e-5		// overcome perturbation

	String imageName = prefix+"_image"
	ImageInterpolate/DEST=$imageName/PFTL=(pftl)/E=(outerValue)/S={(xmin),(dx),(xmax),(ymin),(dy),(ymax)} Voronoi, wtriplet

	KillWaves/Z wtriplet
	return imageName
End