Extracting Integrals/Intensities

Processing a series of files to obtain intensity or integral values.

Often a user would like to write a macro to process a series of spectra and record the intensity values of specific data points to a file. The following example would be one way to do this:


c**cursor_values.mac
def point1 103
def point2 154
def point3 234
def point4 277
def point5 342
def filename my_filename
def outfile ouput_file_to_use
def temph0 0.0
def temph1 0.0
opn # &outfile 0
for row 1 999
esc out
if &out ne 0 quit
eva exten (&row) 3
re &filename.&exten
if &status ne 0 eof
def phase0 &temph0
def phase1 &temph1
em 2
bft
ph
pol 5
dr
put These are the point values for file=&filename.&exten
for pntnum 1 5
gv &point&pntnum value&pntnum
put Point=&pntnum Value=&value&pntnum
next
next
eof:
if &status ne 0 then
def status 0
ty Problem reading row=&row
eif
quit:
cl
cls
ret
end


This macro will read and process a series of filenames like this:

my_filename.001
my_filename.002
...
my_filename.010
my_filename.011
my_filename.012
...
my_filename.999


Note that you don't need separate macros to process each range of filename extensions. This works by using an as yet undocumented feature of the eva command. The last argument for this command is an optional integer which specifies how many characters are to be used in the definition of the symbol name.
Another common requirement is to process a series of spectra and record the values of a series of integrals in each spectra to a file. The following sort of macro could be used to do this:


c**integral_values.mac
def filename my_filename
def outfile ouput_file_to_use
def temph0 0.0
def temph1 0.0
def segint 2
dba list range 3 seg:segments item 1 99 numseg
opn # &outfile 0
for row 1 999
esc out
if &out ne 0 quit
eva exten (&row) 3
re &filename.&exten
if &status ne 0 eof
def phase0 &temph0
def phase1 &temph1
em 2
bft
ph
pol 5
dr
put These are the integral values for file=&filename.&exten
for loop 1 &numseg
dba list load 3 &loop segitm
dba element load seg:segments.&segitm.lo_pt loval
dba element load seg:segments.&segitm.hi_pt hival
dba element load seg:segments.&segitm.volume intval
put Segment=&loop Lo Point= &loval Hi Point= &hival Integral=&intval
next
next
eof:
if &status ne 0 then
def status 0
ty Problem reading row=&row
eif
quit:
def segint 0
cl
cls
ret
end


To use this macro you would need to first setup the integral segments that you want. To do this you would read in and process a sample file by hand and then add in the segments you want by using the Measure/Integral/Volume/Add Segments command. This will create an entity called seg:segments in your dba file. You could also create and add the segments from within the macro if you wish. When you run the macro it will look at the seg:segments entity and determine how many segments are present then load the integral value for each segment into a symbol. This value is then placed into the output text file using put.
Use these macros as a guide to help produce your own custom macros.

 
   
   • 
 Back to FAQ's
   •   Contact us
 
        www.FelixNMR.com © 2007