Skip to main content

Renishaw spectroscopy data file accessor classes

Project description

This package provides Python support for using Renishaw Wdf data files. These files are used to hold spectroscopic data from the line of Raman microscopes manufactured by Renishaw plc.

This package requires Python 3.8 or later.

See the accompanying file LICENSE for license details.

Documentation

The package is documented using python docstrings which yield assistance in most editors. Documentation can be generated using pydoc:

$ python -m pydoc *Entity name*

For instance:

$ python -m pydoc wdf.Wdf

Basic usage

Use the Wdf class to open data files. For instance, to print the values for the first spectrum in a file to two columns:

from wdf import Wdf
with Wdf(filename) as data:
    for x, i in zip(data.xlist(), data[0]):
        print(f"{x}\t{i}")

Or using matplotlib to plot the spectral data graphically:

import matplotlib.pyplot as plt
from wdf import Wdf
with Wdf(filename) as data:
    plt.plot(data.xlist(), data[0])
    plt.show()

The Wdf class is iterable and supports indexing to obtain spectra. The result of Wdf[] or Wdf.spectrum() is a non-mutable sequence of floating point values.

A Wdf file is divided into sections, many of which store a collection of named properties. Known section identifiers are provided by constants in the WdfBlockId module and sections are identified by an ID (defining a type of section) and a unique ID (defining a specific instance). To obtain the properties for a the first map section stored in a file the get_section_properties method can be used as shown below.

from wdf import WdfBlockId
props = data.get_section_properties(WdfBlockId.MAP, -1)
print(props["Title"].value)

Spectra often have additional information stored about the collection environment such as the time collected or the X and Y position of the spectrum if part of an area map, or the temperature for a member of a temperature series. These values are stored as data origins and are accessed using the origins property with the data type as a key to obtain the sequence of values that can then be indexed by the spectrum index.

from wdf import Wdf, WdfDataType
index = 1  # spectrum index
with Wdf(filename) as data:
    # the spectrum timestamp (as a datetime)
    timestamp = data.origins[WdfDataType.Time][index]
    # Print all data origin values:
    for origin in data.origins:
        print(origin, data.origins[origin][index], sep="\t")

Map information

If the file contains maps generated from the collected data these can be plotted using numpy and matplotlib.

import numpy as np
import matplotlib.pyplot as plt
from wdf import Wdf, WdfBlockId
mapindex = -1  # first available map
with Wdf(filename) as data:
    shape = data.map_area.count.x, data.map_area.count.y
    mapinfo = data.get_section_properties(WdfBlockId.MAP, mapindex)
    mapdata = np.array(data.get_map_data(mapindex), dtype=float)

    fig = plt.figure()
    ax = fig.add_subplot(1, 1, 1)
    ax.set_title(mapinfo["Label"].value)
    ax.imshow(mapdata.reshape(shape))
    fig.show()

Example files

There are some examples of using the library in the demos/ folder.

The installation will also register wdfbrowser as an executable application. This is implemented from the wdf.browser module and provides a view of all the sections and properties provided in a Wdf file.

The wdfbrowser utility depends on additional packages: numpy, matplotlib and Pillow. These can be installed using pip or any other package management tool.

$ pip install numpy matplotlib Pillow

The wdf package does not have any package dependencies beyond the python standard library.

Installation from source

$ python setup.py install

Bugs and issues

Bug reports should be e-mailed to the support contact for the package.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

renishaw_wdf-1.2.0.tar.gz (262.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

renishaw_wdf-1.2.0-py3-none-any.whl (33.0 kB view details)

Uploaded Python 3

File details

Details for the file renishaw_wdf-1.2.0.tar.gz.

File metadata

  • Download URL: renishaw_wdf-1.2.0.tar.gz
  • Upload date:
  • Size: 262.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for renishaw_wdf-1.2.0.tar.gz
Algorithm Hash digest
SHA256 af560360d4a3d47825d617587eb7b7f7b35edaa49a0b143ce4847248aa21ccbd
MD5 0a87563cc8316b90068038147fdac4fb
BLAKE2b-256 2e280337b9965c7130019fed8856a87b97a384e1d94ee107bf36011f4dc4ff70

See more details on using hashes here.

File details

Details for the file renishaw_wdf-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: renishaw_wdf-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 33.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for renishaw_wdf-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3017f2b666e761deb388f56066e0876ca54a5cd057de0881ab45d80099d965d
MD5 e2a64d14b8fea7f8e3f70faae8896b73
BLAKE2b-256 efda0b0921a3bd167a240f0f25b86c1eaa5414d9efdde72f1cd447800c155ff3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page