convenience¶
This module’s scope covers tools that make data access more convenient.
-
tuna.io.convenience.
read
(file_name)[source]¶ This function’s goal is to create a tuna can, and attempt to read the specified file_name using the can.read ( ) method.
Parameters:
- file_name : string
Specifies an existing file, containing data in a format Tuna understands.
Returns:
- tuna_can : tuna.io.can
Containing the data read from the input file.
Example:
import tuna tuna.io.read ( "data_file.fits" )
-
tuna.io.convenience.
write
(array=None, file_format=None, file_name=None, metadata=None, photons=None)[source]¶ This method’s goal is to write a file using the specified input.
Parameters:
- array : numpy.ndarray
The data to be saved in the file.
- file_format: string
Specifies one of Tuna’s known write formats (only “fits” is implemented so far).
- file_name: string
Must contain a valid file path and name.
- metadata: dictionary
A structure containing the metadata to be saved as fits headers.
- photons: dictionary
A structure containing photon descriptions, in the same format as specified in tuna.io.can.convert_ndarray_into_table ( ).
Example:
import tuna import numpy zeros_array = numpy.zeros ( shape = ( 2, 3, 3 ) ) tuna.io.write ( array = zeros_array, file_name = "zeros.fits", file_format = "fits" )