Difference between revisions of "Read or write to disk"

From Horace
Jump to: navigation, search
Line 4: Line 4:
  
 
<pre>
 
<pre>
filename='C:\mprogs\myfile_d1d.dat';
+
filename='C:\mprogs\myfile.dat';
w_read=read(sqw,filename);
+
w_read=read_horace(filename);
 
</pre>
 
</pre>
  
In the example shown here <code>w_read</code> is a d1d object, since the data in <code>myfile.dat</code> originated from a d1d. In order to use this method a dummy sqw object must be supplied. You can create this dummy object separately, or just use the above example, since the command <code>sqw</code> with no arguments creates a dummy sqw object anyway.
+
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>
 +
filename='C:\mprogs\myfile.sqw';
 +
w_read=read_sqw(filename);
 +
</pre>
 +
 
 +
In the example shown here <code>w_read</code> is an sqw object, since the data in <code>myfile.sqw</code> originated from a cut created using cut_sqw with option '-pix'.
 +
 
 +
<pre>
 +
filename='C:\mprogs\myfile.d1d';
 +
w_read=read_sqw(filename);
 +
</pre>
 +
 
 +
In the example shown here <code>w_read</code> is an d1d object, since the data in <code>myfile.d1d</code> originated from a cut created using cut_sqw with option '-nopix'.
  
 
==save==
 
==save==

Revision as of 19:02, 16 January 2019

read

Function that reads sqw data from a binary file that was written using save.

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

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 of datasets.

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

This function writes the n-dimensional dataset w_in 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

Display a summary of a file containing sqw/dnd information.

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

The first argument is a dummy sqw/dnd object, as used in the read command. The information contained in the output h is the same as that obtained from an sqw/dnd object when using the command display (see below). The data given are things like original filename, dimensionality of the data, lattice parameters, data ranges, etc. Type

display(sqw)

for a full list for a dummy object.


display

display(w_in)

This function displays header information about the dataset w_in, which can be either a dnd or sqw object.