Reference

spectraplotpy is made up of four decoupled building blocks, the first one is the Dataset, the Importers, the Spectra and the Exporters.

The Importers take data from several different formated files, and populate a Dataset, then the the Dataset can be passed around to the Spectra in order to do some processing and plotting or directly to the Exporters.

Dataset

The dataset module defines the datastructure shared among the spectraplotpy classes, you need to implement a similar interface in order to leverage the class.

The users are encouraged to directly access the data members of this class, and is up to them to keep the data consistently.

import spectrapotpy as spp
import numpy as np

ds = spp.Dataset()
ds.x = np.arrange(0, np.pi, 1000)
ds.y = np.sin(x)

Importers

The importers functionalities to parse input from several file types, it also allows you to easily create new importers for your own formats subclasing the Importer class and overriding some methods.

The library provides several importer for several formats, and the users are encouraged to create their own.

Examples

Importing from an Aviv file,

import spectraplotpy as spp
avii = AvivImporter('filename.cd')
# then you can access the dataset and pass it around
print avii.dataset.x, avii,dataset.y

Creating a custom importer,

import spectraplotpy as spp

class XRDPanalithicalImporter(spp.Importer):
    def parse_metadata(self, metadata_txt):
        # override this function to get the
        pass

    def parse_data(self, data_txt):
        # override this to parse your custom data
        pass

Spectra

The Spectrum class provides some functionalities that allow the users to operate their data in a very intuitive fashion.

Exporters

Much like Importers, exporters provide functionality to export to several file formats, there are text based exporters and plot based exporters.