Skip to main content

Sas Data Loader application

Project description

Sasdata

A package for importing and exporting reduced small angle scattering data.

The data loaders provided are usable as a standalone package, or in conjunction with the sasview analysis package.

Citing and Acknowledging SasData

If you found this software useful to your work please cite and/or acknowledge its use in your publications. The latest instructions for citing and acknowledging are available on our website.

Citing SasData Acknowledging SasData

Install

The easiest way to use sasdata is by using SasView.

View the latest release on the sasdata pypi page and install using pip install sasdata.

To run sasdata from the source, create a python environment using python 3.10 or higher and install all dependencies

  • Using a python virtual environment::

    $ python -m venv sasdata
    $ .\sasdata\Scripts\activate (Windows) -or- source sasdata/bin/activate (Mac/Linux)
    (sasdata) $ python -m pip install -e .
    
  • Using any anaconda distribution::

    $ conda create -n sasdata
    $ conda activate sasdata
    (sasdata) $ python -m pip install -e .
    

Data Formats

The Loader() class is directly callable so a transient call can be made to the class or, for cases where repeated calls are necessary, the Loader() instance can be assigned to a python variable.

The Loader.load() method accepts a string or list of strings to load a single or multiple data sets simultaneously. The strings passed to load() can be any combination of file path representations, or URIs. A list of Data1D/Data2D objects is returned. An optional format parameter can be passed to specify the expected file extension associated with a reader. If format is passed, it must either be a single value, or a list of values of the same length as the file path list.

  • Load format options include:
    • .xml: canSAS XML format
    • .h5, .hdf, .hdf5, .nxs: NXcanSAS format
    • .txt: Multi-column ascii format
    • .csv: Comma delimited text format
    • .ses, .sesans: Multi-column SESANS data
    • .dat: 2D NIST format
    • .abs, .cor: 1D NIST format for SAS and USAS
    • .pdh: Anton Paar reduced SAXS format

The save() method accepts 3 arguments; the file path to save the file as, a Data1D or Data2D object, and, optionally, a file extension. If an extension is passed to save, any file extension in the file path will be superseded. If no file extension is given in the filename or format, a ValueError will be thrown.

  • Save format options include:
    • .xml: for the canSAS XML format
    • .h5: for the NXcanSAS format
    • .txt: for the multi-column ascii format
    • .csv: for a comma delimited text format

Save argument examples and data output:

filename format saved file name saved file format
'mydata' '.csv' mydata.csv CSV format
'mydata.xml' None mydata.xml canSAS XML format
'mydata.xml' '.csv' mydata.xml.csv CSV format
'mydata' None - raise ValueError

More information on the recognized data formats is available on the sasview website.

Example Data

A number of data files are included with this package available in sasdata.example_data.

  • Each subdirectory has a specific type of data.
    • 1d_data: 1-dimensional SAS data. A few examples are apoferritin.txt which is SANS from apoferritin, 3 files starting with AOT_ that are contrast variations for a mircroemulsion, and latex_smeared.xml with SANS and USANS data for spherical latex particles.
    • 2d_data: 2-dimensional SAS data. Examples include 3 P123_....dat files for a polymer concentration series.
    • convertibles_files: A series of data sets that can be converted via the data conversion tool in the sasdata.file_converter package.
    • dls_data: NOTE Not loadable by sasdata. Two example DLS data sets that will be loadable in a future release.
    • image_data: Image file loadable from sasdata.dataloader.readers.tiff_reader. The files are all the same image, but in different image formats.
    • sesans_data: SESANS data sets. sphere_isis.ses is spin-echo SANS from a sample with spherical particles.
  • To directly access this data via a python prompt, import data_path from sasdata returns the absolute path to sasdata.example_data

Usage

Accessing example data

(sasdata) $ python
>>> from sasdata import data_path
>>> data = Loader().load(os.path.join(data_path, '1d_data', 'apoferritin.txt'))

Loading and saving data sets using a fixed Loader instance:

(sasdata) $ python
>>> from sasdata.dataloader.loader import Loader
>>> loader_module = Loader()
>>> loaded_data_sets = loader_module.load(path="/path/to/file.ext")
>>> loaded_data_set = loaded_data_sets[0]
>>> loader_module.save(path='/path/to/new/file.ext', data=loaded_data_set, format=None)

Loading and saving data sets using a transient Loader instance (more scriptable):

(sasdata) $ python
>>> from sasdata.dataloader.loader import Loader
>>> loaded_data_sets = Loader().load(path="/path/to/file.ext")
>>> Loader().save(path='/path/to/new/file.ext', data=loaded_data_sets[0], format=None)

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

sasdata-0.12.0a1.tar.gz (29.6 MB view details)

Uploaded Source

Built Distribution

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

sasdata-0.12.0a1-py3-none-any.whl (21.8 MB view details)

Uploaded Python 3

File details

Details for the file sasdata-0.12.0a1.tar.gz.

File metadata

  • Download URL: sasdata-0.12.0a1.tar.gz
  • Upload date:
  • Size: 29.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for sasdata-0.12.0a1.tar.gz
Algorithm Hash digest
SHA256 c00265bc5d2342d6b0f8e9d3644c34935cae3435d83d2eedfc0d337d5fd8776a
MD5 a04f8020567e4be503704c1e28d68b69
BLAKE2b-256 2f4ae5bb47da015710bfb89ff5790c0a7d31d5c73a09b0f157bda4236c32144b

See more details on using hashes here.

File details

Details for the file sasdata-0.12.0a1-py3-none-any.whl.

File metadata

  • Download URL: sasdata-0.12.0a1-py3-none-any.whl
  • Upload date:
  • Size: 21.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for sasdata-0.12.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 853931105036e3c1d7f51f46b5bdebcd5f780d22dca59cc060d9715edd7e6353
MD5 2b5cd5b049eba96f9c673d591d7204e2
BLAKE2b-256 ddb9d8e5cfa5a4f14ba71132d91dd547a44a102c5d4397d956ee4ea4b3e4725d

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