Jetdsp
JETDSP Homepage
Manual Homepage
Signal Processing Homepage
 
Signal processing
Basic guide
Advanced guide
IBM NEWDSP-syntax
Use your code
Signal slicing
Simple expressions
 
Tutorial
Introduction
Internals
IDL commands
Interpolation
Writing your own code
Adding functions to the Simple dialogue
 
How to...
Read data
Define structure
 
Functions
jetSmooth
jetint
jetsubset
jetmerge
fixgrid
jetwindowpoints
 

Writing your own functions.

It is possible to write your own functions using IDL commands. These can be written using any editor or within the IDL Development Environment (IDLDE). These functions can be called from within the signal processing dialog.

IDL uses files with the extension '.pro' for storing listings of routines. When an unknown function is called, whilst using an interactive IDL session, an attempt is made to find a file. This search is for a file of the same name as the routine and it occurs in the directories specified by IDL_PATH. If the file is found it is compiled.

JETDSP automatically searches the AddIns directory for these files, which makes it a useful place to put them.

Previously it was necessary to create a '.sav' file but these do not need to be created now.

As an example a function to normalise a signal will be written. The code for this is given below, copy it into an editor an save to a file named 'my_normalise.pro' in your AddIns directory. Note that due to a bug in the Linux release of IDL the filename should all be in lowercase.

function my_normalise,data
	min_data=min(data,max=max_data)
	scale=1.0/(max_data-min_data)
	return,(data-min_data)*scale
end
This function can now be called in the same way as any IDL expression.

These functions can take other variables as well, but one function is required for each set of data (signal/time/x) required. For example to perform FFT's two calls are required, the first has the form

function my_fft,data,time
	;put the data onto a uniform time axis using interpolate commands.
	;fft the data
	return, data_fft
end
However 'time' axis values are not returned. These require a second call.
function my_fft_time,time
	; calculate the 'time' points required.
	return, time_fft
end
This then would require the following information to be entered into the dialogue;

This is far from ideal in more complicated cases where the same processing must be done three times to return all the data. To get round this problem a new way of using signal processing function has been introduced. This uses only one function call and must return a specific structure. This is used to create the new signal object and is shown pictorially below.

This is illustrated in the my_truncate function. An example of this is the fixgrid function previously discussed. For further information on using these structures please contact Data and Coding, whose address is linked at the bottom of the page.

Previous page Next page

Top  JETDSP Home Page  Manual  FAQ 
Please send comments to: data-and-coding-support@ccfe.ac.uk