Extract Error

hegedus
Posts: 288
Joined: 2009-03-21
Location: United States

Hi,

I am trying to do some simple data clean up but I am getting a compile error.

I am getting this error on the first extract line and I have looked at other examples and it seems like the syntax is correct, but obviously something is amiss. Error = Inconsistent type for a wave reference and it highlights the second instance of File_Name

Function LoadQEData()
 
	LoadWave/A/O/J/D/W/K=0/B="N=Count;N=File_Name;N=Material_ID;N=Electric_Field;"
	//Check for missing data in Count
	Wave Count,Electric_Field
	Wave/T File_Name
	Wave/T Material_ID
	Extract/O File_Name, File_Name, numtype(Count)==0  //getting error here
	Extract/O Material_ID, Material_ID, numtype(Count)==0
	Extract/O Electric_Field, Electric_Field, numtype(Count)==0
	//Check for missing data in Electric_Field
	Extract/O File_Name, File_Name, numtype(Electric_Field)==0
	Extract/O Material_ID, Material_ID, numtype(Electric_Field)==0
	Extract/O Count, Count, numtype(Electric_Field)==0
 
End

What is the error in my ways?

Andy


sjr51
Posts: 254
Joined: 2012-12-16
Location: United Kingdom

My reply is that I can't see the error either. Your code compiles if your destwave for the Extract is a Numeric Wave or if you declare your textwave as a numeric wave. But the wave declaration for File_Name has the /T flag so I'm puzzled why this doesn't compile.
The expression itself should work (as you say) because this gives the right result:

make/o/n=3 aaa={0,1,NaN}
make/o/n=3/t ttt={"a","b","c"}
extract/o ttt,ttt,numtype(aaa)==0
print ttt


Posts: 1644
Joined: 2007-06-21
Location: United States

You need the /T flag. This is explained in the discussion of typeFlags in the documentation for Extract. Here is an example:

Function Test()
	Make/O/T/N=10 TestWave = "Row " + num2istr(p)
	WAVE/T TestWave		// This is redundant because Make creates an automatic wave reference in this case
	Extract/O/T TestWave, TestWave, (p&1) == 0
End

Extract creates an automatic wave reference, like Make, and the /T flag causes it to create a WAVE/T wave reference.

Execute this for details:
DisplayHelpTopic "Automatic Creation of WAVE, NVAR and SVAR References"


hegedus
Posts: 288
Joined: 2009-03-21
Location: United States

Hi Howard,

That you for the clarification. Though as an avid reader of the manual, I think the manual could be more clear.

From Manual:
Extract also can use various type flags in user functions to specify the type of destination wave reference variables. These type flags do not need to be used except when it is necessary to match another wave reference variable of the same name or to tell Igor what kind of expression to compile for a wave assignment. See WAVE Reference Types and WAVE Reference Type Flags for a complete list of type flags and further details.

Details
srcWave may be of any type including text.

destWave has the same type as srcWave, but it is always one dimensional. With /INDX, the destWave type is set to unsigned 32-bit integer and the values represent a linear index into srcWave regardless of its dimensionality.

Andy


Back to top