GithubHelp home page GithubHelp logo

johnson-c / spe2py Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ashirsch/spe2py

0.0 0.0 0.0 6.41 MB

Loads Princeton Instruments LightField (SPE 3.0) files into a python environment.

Python 100.00%

spe2py's Introduction

spe2py

spe2py is a module that imports a Princeton Instruments LightField (SPE 3.x) file into a python environment.

Basic Usage

Loading and accessing data

Use the load() function to load one or more SPE files at a time:

>>> import spe2py as spe
>>> loaded_files = spe.load()

A file selection window will open to allow browsing for source files. The result is an individual SpeFile object, or, in the case where multiple files are loaded at once, a list of SpeFile objects.

Raw data from a file is stored in NumPy arrays and can be accessed directly by

>>> frame_data = loaded_files.data[frame][regionOfInterest]  
>>> frame_data = loaded_files[n].data[frame][regionOfInterest]  # where multiple files are loaded

Alternatively one can load an individual file by passing SpeFile() the source path directly:

file_object = spe.SpeFile(path)
# is equivalent to...
file_object = spe.load()  # and selecting the same file/path
Automatic imaging and plotting

To quickly view an individual frame, region-of-interest, or spectrum, use the image() or specplot() methods. For example,

>>> loaded_file.image()  # images the first frame and region of interest
>>> loaded_file.image(f, r)  # images frame 'f' and region of interest 'r'
>>> loaded_file.specplot()  # plots the loaded spectrum
Accessing metadata

Upon loading, the metadata contained in the file's XML footer is automatically parsed and stored as an untangle object in the footer variable. Elements and attributes can be accessed by calling the different elements and subelements of footer, ending with the attribute as a string:

>>> sensor_height = loaded_file.footer.SpeFormat.Calibrations.SensorInformation['height']

One can print the full element tree by calling the xmltree() method.

Dependencies

  • NumPy - data storage and file reading
  • tkinter - file selection dialog
  • matplotlib - imaging and plotting
  • untangle - XML parsing

Version

1.0.0a - initial upload

License

MIT

spe2py's People

Contributors

ashirsch avatar gh4ag avatar minouhub avatar rashidzia avatar stevejbrown avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.