Which Format for an ASCII file?
So you have decided to make your own file converter. You know enough programming, you know the organization of your starting data. You ignore the file structure of iNMR files, but have read that iNMR can import ASCII files (ending in “.txt”), so you are just asking: “Which ASCII files?”.
First of all, let us remind you that this is neither the main nor the best route. You should ask for a built-in converter first. Anyway, let's say you have already asked, or you have no time to ask, or you want to create a spectrum from scratch. Now we can tell you: there are four formats, one for time domain data and three for frequency domain data. In all cases, lines are separated by a single Line Feed Character ('\n'), in Unix style. When two values are on the same row, they can be separated by any combination of spaces and tabs.
Time Domain
Write two columns. Real part at left, imaginary part at right. Here is an example:
-3138.000 10254.000
4134.000 9762.000
3954.000 1935.000
-237.000 3534.000
3476.000 6899.000
9030.000 2109.000
Before importing this file, open the Preferences dialog and, into the first panel, insert the value for the spectrometer frequency, because iNMR can't guess it otherwise. After importing the file, with the command “Edit/Metadata”, insert the correct value for the spectral width. This is also the place to set the spectrometer frequency, if you don't like changing your preferences. With the command “Format/Axes & Scales” set the frequency at the middle of the spectrum.
An alternative, more general, format is exemplified here below. It contains an header. In the multidimensional case, the order of the parameters is: x, y and z axes. The x axis corresponds to the direct dimension.
you can add optional comments before and among the header lines, but never after the header
number of dimensions = 2
number of points = 512; 512
carrier frequency = 500.000 MHz; 500.000 MHz
dwell time = 1.600 ms; 1.600 ms
-3138.000 10254.000
4134.000 9762.000
3954.000 1935.000
-237.000 3534.000
3476.000 6899.000
9030.000 2109.000
Frequency Domain
Copy and edit the example/template below. iNMR ignores whatever comes before “first frequency”. Substitute the upper case terms FIRST, LAST, N, STEP and FREQUENCY.
STEP is the distance, in Hz, between two adjacent points:
STEP = FREQUENCY • (LAST - FIRST) / (N - 1).
The spectral width is, therefore:
spectral width = LAST - FIRST + STEP / FREQUENCY.
After the header, enter the intensity values, from left to right (decreasing frequency).
optional comments ...
first frequency = FIRST ppm
last frequency = LAST ppm
number of points = N
step = STEP Hz
carrier frequency = FREQUENCY MHz
22.680
23.818
24.206
22.789
27.823
28.970
32.008
....
Frequency Domain (columnar alternative)
You can use the left column for frequencies and the right column for intensities. iNMR can tell it's a frequency domain spectrum by the small header that starts with “ppm”.
ppm intensity
10.82074 22.680
10.81667 23.818
10.81260 24.206
...... ....
Whatever comes before the header is ignored. iNMR also assumes that the frequency increment between points is constant. As in the case of FIDs, the spectrometer frequency is taken from your preferences. In a variation of this format, the two values are separated by a comma.
Frequency Domain (2-D matrix)
This format describes a 2-D real matrix. The file must start with three empty spaces followed by 0.0000000e+00. The first line will also contain the frequency values of each column of the matrix, in decreasing order. The other lines correspond to the matrix rows, still in decreasing frequency order. Each line begins with the frequency of that row, followed by the intensity values. Each value, including the frequency values, must take exactly 16 characters, including the spaces. The exponential representation is useful, though not required.
0.0000000e+00 9.3321352e+00 9.3260231e+00 9.3199110e+00 9.2832403e+00 9.1487770e+00 9.1426649e+00
9.3321352e+00 1.0000000e+00 9.4436473e-01 8.0598307e-01 8.4845638e-01 9.3396616e-01 9.3008733e-01
9.3260231e+00 9.4436473e-01 1.0000000e+00 8.6518776e-01 8.4607577e-01 9.1791135e-01 9.7206885e-01
9.3199110e+00 8.0598307e-01 8.6518776e-01 1.0000000e+00 7.6705891e-01 7.5179893e-01 8.8539046e-01
9.2832403e+00 8.4845638e-01 8.4607577e-01 7.6705891e-01 1.0000000e+00 8.7568295e-01 8.1265861e-01
9.1487770e+00 9.3396616e-01 9.1791135e-01 7.5179893e-01 8.7568295e-01 1.0000000e+00 8.4121192e-01
9.1426649e+00 9.3008733e-01 9.7206885e-01 8.8539046e-01 8.1265861e-01 8.4121192e-01 1.0000000e+00
9.1365519e+00 9.5754308e-01 9.8643601e-01 8.3838254e-01 8.7181556e-01 9.5935947e-01 9.4047183e-01
9.1304407e+00 8.4107500e-01 9.1353941e-01 8.8544428e-01 7.3014057e-01 7.1563661e-01 9.6498734e-01
9.1059933e+00 7.8522044e-01 7.7718103e-01 7.0723552e-01 9.0135759e-01 8.1878400e-01 7.4643087e-01
Here above you can see a special example, where the intensity of all the diagonal values is 1. The first line and the left column contain the frequency values, in decreasing order.