First wiki version authored by Matthieu Migne's avatar Matthieu Migne
# ReadNexus (python library) # ReadNexus (python library)
The purpose of this python library is to read a file, get specific data and display them with ease. The purpose of this python library is to read a file, get specific data and display them with ease.
## How to use it ## How to use it
First you have to import the library, for exemple you can do in your python interpreter :
import ReadNexus
Then there is two main ways to use the library. The first one is by function: First you have to import the library, for exemple you can do in your python interpreter : _import ReadNexus_
Then there is two main ways to use the library. The first one is by function, you can use them as following:
ReadNexus._NameOfYourFunction_()
### By functions ### By functions
To read data you have to first open a file: To read data you have to first open a file:
| Function name | Description | | Function name | Description |
| ------ | ------ | |---------------|-------------|
| nxSetPath(“directory path”) | Set a working directory so you can open a file using a relative path to this directory | | nxSetPath(“_directory path_”) | Set a working directory so you can open a file using a relative path to this directory |
| nxOpen(“file path”) | Open a file, file path can be either an absolute path or a relative path from the current working directory. One file can be open simultaneously. | | nxOpen(“_file path_”) | Open a file, file path can be either an absolute path or a relative path from the current working directory. One file can be open simultaneously. |
| nxCurrentPath() | Display the current working directory and file open currently if there is one | | nxCurrentPath() | Display the current working directory and file open currently if there is one |
To read data from the file (A file has to be open) To read data from the file (A file has to be open)
| Function name | Description |
|---------------|-------------|
| nxGetInstName() | Returns name of the instrument |
| nxGetInstMode() | Returns mode of the instrument |
| nxGetTypeNexus() | Returns type of the file (scan, ill-classic, ect.) |
| nxGetVersion() | Returns version of the nexus file |
| nxGetCompression() | Returns compression type of the nexus file |
| nxGetScanVariablesDataset() | Returns dataset of scanned variables |
| nxGetScanVarIndex(“_Variable label_”) | Returns the index where a scanned variable can be found in the scanned variables table |
| nxGetScanVarData(“_Variable label_”) | Returns data of a scanned variable |
| nxGetScanVarDim() | Returns dimension of scanned variables table |
| nxGetLabelList() | Returns every label of all scanned variables |
| nxGetDetectorList() | Returns list of detector of the instrument |
| nxGetDetectorNum() | Returns number of detectors of the instrument |
| nxGetDetectorDim(Detector_index) | Argument is optional, returns dimension of a detector. This detector is the first one by default, pass an argument if you want dimensions of a specific one |
| nxGetDetectorData(Detector_index,x,y,z) | Every arguments are optional, returns data of a detector. You can select a slice of data using x,y,z arguments. This detector is the first one by default, pass an argument if you want dimensions of a specific one. |
| nxPlot(\*args) | Plot a curve depending data from every arguments passed |
| nxImage(\*args) | Display an image depending data from every arguments passed |
| nxDict() | Returns dictionary with every variables data and values associate |
### Using objects
You can also use the library using classes method, you have to first initialize an object with the path of your file as following :
_NameOfYourObject_ = ReadNexus.directRead(‘_Path of your file_’)
Now you can call every methods of your object of class directRead. Here is the list of those methods:
| Function name | Description | | Function name | Description |
| ------ | ------ | |---------------|-------------|
| | | | getInstName() | Returns name of the instrument |
| | | | getInstMode() | Returns mode of the instrument |
| | | | getTypeNexus() | Returns type of the file (scan, ill-classic, ect.) |
| | | | getVersion() | Returns version of the nexus file |
| | | | getCompression() | Returns compression type of the nexus file |
| | | | get_scan_variables_data() | Returns dataset of scanned variables |
| | | | getScanVarIndex() | Returns the index where a scanned variable can be found in the scanned variables table |
| | | | getScanVarData(“_Variable label_”) | Returns data of a scanned variable |
| | | | getScanVarDim() | Returns dimension of scanned variables table |
| | | | getLabelList() | Returns every label of all scanned variables |
| | | | getDetectorList() | Returns list of detector of the instrument |
| | | | getDetectorNum() | Returns number of detectors of the instrument |
| | | | getDetectorDim(Detector_index) | Argument is optional, returns dimension of a detector. This detector is the first one by default, pass an argument if you want dimensions of a specific one |
| | | | getDetectorData(Detector_index,x,y,z) | Every arguments are optional, returns data of a detector. You can select a slice of data using x,y,z arguments. This detector is the first one by default, pass an argument if you want dimensions of a specific one. |
| | | | plot(\*args) | Plot a curve depending data from every arguments passed |
| | | | image(\*args) | Display an image depending data from every arguments passed |
| | | | dict | Returns dictionary with every variables data and values associate |
\ No newline at end of file
You can use them by doing: _NameOfYourObject_._NameOfTheMethod_().
3- Installation guide
Download **ReadNexus-0.1.0-py3-none-any.whl**.
Open a terminal and write
pip3 install path/to/ReadNexus-0.1.0-py3-none-any.whl
With _path/to/_ The folder containing **ReadNexus-0.1.0-py3-none-any.whl**.
Now you can use ReadNexus in your Python interpreter.
\ No newline at end of file