Difference between revisions of "Read or write to disk"

From Horace
Jump to: navigation, search
 
Line 1: Line 1:
==read==
+
==read_horace, read_sqw, read_dnd==
  
Function that reads sqw data from a binary file that was written using <code>save</code>.
+
There are three functions that can be used to read sqw or d1d,d2d,...d4d data from a binary file that was written using <code>save</code>.
  
 
<pre>
 
<pre>
Line 8: Line 8:
 
</pre>
 
</pre>
  
In the example shown here <code>w_read</code> will contain an sqw object or d1d,d2d,...d4d object depending on the contents of the file. (Here the example data file has deliberately been chosen to have an ambiguous extension. Normally you would save an object to a file with the conventional extension for the object in question: .sqw, .d1d, .d2d, .d3d, .d4d.)
+
This is the most general function, and the one that is recommended for general use. In the example shown here <code>w_read</code> will contain an sqw object or d1d,d2d,...d4d object depending on the contents of the file. (Here the example data file has deliberately been chosen to have an ambiguous extension. Normally you would save an object to a file with the conventional extension for the object in question: .sqw, .d1d, .d2d, .d3d, .d4d.)
  
 
<pre>
 
<pre>
Line 26: Line 26:
 
==save==
 
==save==
  
Function that applies to all dimensionalities of datasets.
+
Function that applies to all dimensionalities and types of datasets.
  
 
<pre>
 
<pre>
Line 33: Line 33:
 
</pre>
 
</pre>
  
This function writes the n-dimensional dataset <code>w_in</code> to a file specified by the string <code>filename</code>.
+
This function writes the n-dimensional dataset <code>w_in</code> (sqw type or d1d etc type) to a file specified by the string <code>filename</code>.
  
  
Line 48: Line 48:
  
  
==head==
+
==head_horace, head_sqw, head_dnd==
  
Display a summary of a file containing sqw/dnd information.
+
These functions return a Matlab structure containing with the header information in an sqw or dnd file.
  
 
<pre>
 
<pre>
 
filename='C:\mprogs\myfile.sqw'
 
filename='C:\mprogs\myfile.sqw'
h=head(sqw,filename)
+
h=head_horace(filename)
 +
hfull=head_horace(filename,'-full')
 
</pre>
 
</pre>
  
The first argument is a dummy sqw/dnd object, as used in the <code>read</code> command. The information contained in the output <code>h</code> is the same as that obtained from an sqw/dnd object when using the command <code>display</code> (see below). The data given are things like original filename, dimensionality of the data, lattice parameters, data ranges, etc. Type
+
The header information is read from a binary file containing an sqw object or dnd object.  
  
 
<pre>
 
<pre>
display(sqw)
+
filename='C:\mprogs\myfile.sqw'
 +
h=head_sqw(filename)
 +
hfull=head_sqw(filename,'-full')
 
</pre>
 
</pre>
  
for a full list for a dummy object.
+
The header information is read from a binary file containing an sqw object.  
 
+
 
+
==display==
+
  
 
<pre>
 
<pre>
display(w_in)
+
filename='C:\mprogs\myfile.sqw'
 +
h=head_dnd(filename)
 
</pre>
 
</pre>
  
This function displays header information about the dataset <code>w_in</code>, which can be either a dnd or sqw object.
+
The header information is read from a binary file containing a dnd object. If the file contains an sqw object, then the header information that is returned is that if there was an implicit conversion of the sqw onject to a dnd object.

Latest revision as of 19:15, 16 January 2019

read_horace, read_sqw, read_dnd

There are three functions that can be used to read sqw or d1d,d2d,...d4d data from a binary file that was written using save.

filename='C:\mprogs\myfile.dat';
w_read=read_horace(filename);

This is the most general function, and the one that is recommended for general use. In the example shown here w_read will contain an sqw object or d1d,d2d,...d4d object depending on the contents of the file. (Here the example data file has deliberately been chosen to have an ambiguous extension. Normally you would save an object to a file with the conventional extension for the object in question: .sqw, .d1d, .d2d, .d3d, .d4d.)

filename='C:\mprogs\myfile.sqw';
w_read=read_sqw(filename);

In the example shown here w_read is an sqw object, since the data in myfile.sqw originated from a cut created using cut_sqw with option '-pix'.

filename='C:\mprogs\myfile.d1d';
w_read=read_sqw(filename);

In the example shown here w_read is an d1d object, since the data in myfile.d1d originated from a cut created using cut_sqw with option '-nopix'.

save

Function that applies to all dimensionalities and types of datasets.

filename='C:\mprogs\myfile.dat';
save(w_in,filename);

This function writes the n-dimensional dataset w_in (sqw type or d1d etc type) to a file specified by the string filename.


save_xye

Save data in an sqw or dnd dataset to an ascii file.

filename='C:\mprogs\my_ascii_file.txt';
save_xye(w_in,filename);

The format of the ascii file for an n-dimensional dataset is n columns of co-ordinates along each of the axes, plus one column of signal and another column of error (variance).


head_horace, head_sqw, head_dnd

These functions return a Matlab structure containing with the header information in an sqw or dnd file.

filename='C:\mprogs\myfile.sqw'
h=head_horace(filename)
hfull=head_horace(filename,'-full')

The header information is read from a binary file containing an sqw object or dnd object.

filename='C:\mprogs\myfile.sqw'
h=head_sqw(filename)
hfull=head_sqw(filename,'-full')

The header information is read from a binary file containing an sqw object.

filename='C:\mprogs\myfile.sqw'
h=head_dnd(filename)

The header information is read from a binary file containing a dnd object. If the file contains an sqw object, then the header information that is returned is that if there was an implicit conversion of the sqw onject to a dnd object.