File commands Ferdi Franceschini Introduction Filenames SICS provides methods to create and save files. You can create a single file, and save either a single dataset, or multiple datasets to the one file. You can also create and manage collections of files, and save single or multiple datasets to files in the collection SICS automatically creates the filename. The filenames have the form xxxnnnnnnn.nx.hdf where xxx is a 3 letter abbreviation of the instrument QKK - quokka ECH - echidna WOM - wombat KOW - kowari PLA - platypus TPN - taipan nnnnnnn is a 7 numeral sequence number, starting at 0000000 when the facility commenced operation, and is automatically incremented by SICS. The file /usr/local/sics/DataNumber is used to keep track of the number. DO NOT edit this file. .nx denotes that the file is a NeXus file. .hdf denotes the file is an hdf5 (binary) file. e.g. QKK0001234.nx.hdf File Format. NeXus Files are saved using the ANSTO interpretation of the NeXus standard. SICS support both the xml and hdf5 form. For performance of reading and writing, by default we write hdf5 binary. SICS can also be configured to write xml. This is set in nxscripts_common_1.tcl. Set the file,format element of the state array to "xml" File Content This section will give only a very brief overview of NeXus. Further reading can be found at the NeXus webite, www.nexusformat.org NeXus is a hierachical data format; data is saved in groups and these groups live under entries. It a similar structure to directories on a file system. We have made a policy decision at the Bragg Institute to have only one entry per file. This entry may contain a variable parameter or scan, where e.g. temperature is varied. If you use the runscan command, histogram data is taken at discrete temperatures. Temperature will be a vector in the file, and the histogram data may be a data cube of 2 dimensional x,y or 3 dimensional x,y,t histogram arrays. There are 4 groups in NeXus. User, Sample, Instrument and Data. SICS will write the data it acquires to one of these groups. The content that is saved, and where in the file it is saved to is controlled by configuration files. /usr/local/sics/server/config/nexus contains *.dic dictionary files. These files tell SICS how to map a SICS object to a location in a NeXus file, and what type the data will be, and its attributes e.g units. Below is an example from nexus.dic samphi = /entry1,NXentry/sample,NXsample/SDS sample_phi -type NX_FLOAT32 -rank 1 -dim {-1} -attr {units,degrees} -attr {long_name,sample_phi} Changes to configurations are done by the facility. Dictionaries can be checked with check_instdict.tcl and check_sicsobj_attributes.tcl. By default, if the SICS object exists and there is an entry in the dictionary, then it will be saved to the data file. There is a second hierarchy of SICS objects which is used by Gumtree for control. This is called hipadaba. We won't go into detail about hipadaba in this manual, but it is important for this discussion to know how hipadaba controls saving of SICS objects. Hipadaba has the same structure as NeXus. The hipadaba tree when initially created by SICS is a complete NeXus tree, which is then pruned to contain only those nodes that exist for that instrument. This allows any node to be added to nexus.dic for an instrument without having to change hipadaba. There are dictionary files for hipadaba found at /usr/local/sics/server/config/hipadaba/. In general, there is no instrument specific information in these files. Every node in hipadaba has data and nxsave attributes. By default, nxsave is set to true, and if the node contains data, data is set to true. If either of these is set to false, then the data will not be saved. File Locations A mutable (read-write) copy of the file is made a few minutes after the experiment, and is available at e.g. /experiments/wombat/data/proposal/01234 where 01234 is the proposal number for the current experiment. An archive of the file is made to the cycle directory e.g. /experiments/wombat/data/cycle/040 where 040 is the reactor cycle number. File are written to /usr/local/sics/data of the ics1-australian_fauna computer. This path is configured in server_config.tcl by setting the SicsDataPath variable. Posix symbolic links are used to link the directory to the appropriate directory on filer.nbi.ansto.gov.au, under the /experiments mount point e.g /experiments/wombat/data/current. You can mount this directory on the MS Windows machine dav1-australian_fauna. Files in this location are read-only. The facility requires an immutable version of the data. File Commands. Single Files newfile command newfile file_type scratch creates a new file of type file_type ready to write to. The command does write any information to disk. To save data, use the save command. You can only hold a reference to one file. If you need to reference a number of files, then use newfile_collection. Only use the optional scratch if you want to write data to a scratch file. The file will be overwritten with the next invocation of this option file_type may have the following values: Saves data from the configured beam monitors, histogram memory data is not saved. Saves histogram total time data and beam monitor data. Saves histogram x data and beam monitor data. Saves histogram x,t data and beam monitor data. Saves histogram y data and beam monitor data. Saves histogram y,t data and beam monitor data. Saves histogram x,y data and beam monitor data. Saves histogram total x,y,t data and beam monitor data. save command save index saves data to disk. index is the index of data to be saved, starting with 0. To save your first slice of data you would save 0. This provides you with a complete NeXus file. You may be doing After you acquire you next slice of data, you would save 1, then save 2 etc. Other single file commands killfile decrements the data number used for SICS file writing and thus consequently overwrites the last datafile. This is useful when useless data files have been created during tests. As this is critical command in normal user operations, this command requires managers privilege. File Collection Commands newfile_collection command newfile_collection {sample1 sample2} file_type save_type Whereas newfile creates one file, newfile_collection will create as many files as there are labels. The command does write any information to disk. To save data, use the save_collection command Example: You have a multi-sample changer or robot. You want to do a measurement on each sample at multiple temperatures. Your experimental sequence has the sample changer as the fastest varying parameter (inner loop), and temperature change as the slowest varying parameter (outer loop). You want to record all temperature data for a sample in one file. save_type may have the following values: writes to a normal data file writes to a scratch file. The file will be overwritten with the next invocation of this option. Used mainly for testing. file_type may have the following values: Saves data from the configured beam monitors, histogram memory data is not saved. Saves histogram total time data and beam monitor data. Saves histogram x data and beam monitor data. Saves histogram x,t data and beam monitor data. Saves histogram y data and beam monitor data. Saves histogram y,t data and beam monitor data. Saves histogram x,y data and beam monitor data. Saves histogram total x,y,t data and beam monitor data. save_collection command save_collection val -labels sample1 saves data to disk within a collection (multiple files) -indexval is the index of data to be saved, starting with 0. To save your first slice of data you would save 0. This provides you with a complete NeXus file. You may be doing After you acquire you next slice of data, you would save 1, then save 2 etc. -labels sample1 will save to the file referenced by the label sample1. You would put all data relating to a sample into this one file.