sasdata


Namesasdata JSON
Version 0.11.0 PyPI version JSON
download
home_pageNone
SummarySas Data Loader application
upload_time2025-08-19 10:25:14
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseBSD-3-Clause
keywords x-ray data analysis neutron scattering small-angle
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.

## Install
The easiest way to use sasdata is by using [SasView](http://www.sasview.org).

View the latest release on the [sasdata pypi page](https://pypi.org/project/sasdata/) 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](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/)::

       $ python -m venv sasdata
       $ .\sasdata\Scripts\activate (Windows) -or- source sasdata/bin/activate (Mac/Linux)
       (sasdata) $ python -m pip install -e .
 
 - Using any [anaconda](https://www.anaconda.com/) 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](https://www.cansas.org/formats/canSAS1d/1.1/doc/index.html) format
  - `.h5`, `.hdf`, `.hdf5`, `.nxs`: [NXcanSAS](https://manual.nexusformat.org/classes/applications/NXcanSAS.html) format
  - `.txt`: Multi-column ascii format
  - `.csv`: Comma delimited text format
  - `.ses`, `.sesans`: [Multi-column SESANS](https://www.sasview.org/docs/user/qtgui/MainWindow/data_formats_help.html#d-sesans-format) data
  - `.dat`: [2D NIST](https://github.com/sansigormacros/ncnrsansigormacros/wiki/NCNROutput2D_QxQy) 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](https://www.sasview.org/docs/user/qtgui/MainWindow/data_formats_help.html).

## 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)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "sasdata",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "X-ray, data analysis, neutron, scattering, small-angle",
    "author": null,
    "author_email": "SasView Team <developers@sasview.org>",
    "download_url": "https://files.pythonhosted.org/packages/e0/07/8cf6fe0199d86a2ea29e90eab006294741ed9eaa68f1c0af0d78fdc1a57b/sasdata-0.11.0.tar.gz",
    "platform": null,
    "description": "# Sasdata\n\nA package for importing and exporting reduced small angle scattering data.\n\nThe data loaders provided are usable as a standalone package, or in conjunction with the sasview analysis package.\n\n## Install\nThe easiest way to use sasdata is by using [SasView](http://www.sasview.org).\n\nView the latest release on the [sasdata pypi page](https://pypi.org/project/sasdata/) and install using `pip install sasdata`.\n\nTo run sasdata from the source, create a python environment using python 3.10 or higher and install all dependencies\n - Using a [python virtual environment](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/)::\n\n       $ python -m venv sasdata\n       $ .\\sasdata\\Scripts\\activate (Windows) -or- source sasdata/bin/activate (Mac/Linux)\n       (sasdata) $ python -m pip install -e .\n \n - Using any [anaconda](https://www.anaconda.com/) distribution::\n   \n       $ conda create -n sasdata\n       $ conda activate sasdata\n       (sasdata) $ python -m pip install -e .\n\n## Data Formats\n\nThe `Loader()` class is directly callable so a transient call can be made to the class or, for cases where repeated calls\nare necessary, the `Loader()` instance can be assigned to a python variable.\n\nThe `Loader.load()` method accepts a string or list of strings to load a single or multiple data sets simultaneously. The\nstrings passed to `load()` can be any combination of file path representations, or URIs. A list of `Data1D/Data2D`\nobjects is returned. An optional `format` parameter can be passed to specify the expected file extension associated with \na 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.\n\n- Load `format` options include:\n  - `.xml`: [canSAS XML](https://www.cansas.org/formats/canSAS1d/1.1/doc/index.html) format\n  - `.h5`, `.hdf`, `.hdf5`, `.nxs`: [NXcanSAS](https://manual.nexusformat.org/classes/applications/NXcanSAS.html) format\n  - `.txt`: Multi-column ascii format\n  - `.csv`: Comma delimited text format\n  - `.ses`, `.sesans`: [Multi-column SESANS](https://www.sasview.org/docs/user/qtgui/MainWindow/data_formats_help.html#d-sesans-format) data\n  - `.dat`: [2D NIST](https://github.com/sansigormacros/ncnrsansigormacros/wiki/NCNROutput2D_QxQy) format\n  - `.abs`, `.cor`: 1D NIST format for SAS and USAS\n  - `.pdh`: Anton Paar reduced SAXS format\n\nThe `save()` method accepts 3 arguments; the file path to save the file as, a `Data1D` or `Data2D` object, and, optionally, \na file extension. If an extension is passed to `save`, any file extension in the file path will be superseded. If no file\nextension is given in the filename or format, a ValueError will be thrown.\n\n- Save `format` options include:\n  - `.xml`: for the canSAS XML format\n  - `.h5`: for the NXcanSAS format\n  - `.txt`: for the multi-column ascii format\n  - `.csv`: for a comma delimited text format\n\nSave argument examples and data output:\n\n| filename     | format | saved file name | saved file format |\n|--------------|--------|-----------------|-------------------|\n| 'mydata'     | '.csv' | mydata.csv      | CSV format        |\n| 'mydata.xml' | None   | mydata.xml      | canSAS XML format |\n| 'mydata.xml' | '.csv' | mydata.xml.csv  | CSV format        |\n| 'mydata'     | None   | -               | raise ValueError  |\n\nMore information on the recognized data formats is available on the \n[sasview website](https://www.sasview.org/docs/user/qtgui/MainWindow/data_formats_help.html).\n\n## Example Data\n\nA number of data files are included with this package available in `sasdata.example_data`.\n\n- Each subdirectory has a specific type of data.\n  - `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.\n  - `2d_data`: 2-dimensional SAS data. Examples include 3 `P123_....dat` files for a polymer concentration series.\n  - `convertibles_files`: A series of data sets that can be converted via the data conversion tool in the `sasdata.file_converter` package.\n  - `dls_data`: *NOTE* Not loadable by sasdata. Two example DLS data sets that will be loadable in a future release.\n  - `image_data`: Image file loadable from `sasdata.dataloader.readers.tiff_reader`. The files are all the same image, but in different image formats.\n  - `sesans_data`: SESANS data sets. `sphere_isis.ses` is spin-echo SANS from a sample with spherical particles.\n- To directly access this data via a python prompt, `import data_path from sasdata` returns the absolute path to `sasdata.example_data`\n\n## Usage\n\n### Accessing example data\n\n    (sasdata) $ python\n    >>> from sasdata import data_path\n    >>> data = Loader().load(os.path.join(data_path, '1d_data', 'apoferritin.txt'))\n\n### Loading and saving data sets using a fixed Loader instance:\n\n    (sasdata) $ python\n    >>> from sasdata.dataloader.loader import Loader\n    >>> loader_module = Loader()\n    >>> loaded_data_sets = loader_module.load(path=\"/path/to/file.ext\")\n    >>> loaded_data_set = loaded_data_sets[0]\n    >>> loader_module.save(path='/path/to/new/file.ext', data=loaded_data_set, format=None)\n\n### Loading and saving data sets using a transient Loader instance (more scriptable):\n\n    (sasdata) $ python\n    >>> from sasdata.dataloader.loader import Loader\n    >>> loaded_data_sets = Loader().load(path=\"/path/to/file.ext\")\n    >>> Loader().save(path='/path/to/new/file.ext', data=loaded_data_sets[0], format=None)\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "Sas Data Loader application",
    "version": "0.11.0",
    "project_urls": {
        "homepage": "http://sasview.org"
    },
    "split_keywords": [
        "x-ray",
        " data analysis",
        " neutron",
        " scattering",
        " small-angle"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "cc0b8a98ee6196ccf99add9521ce9572092580d609c3b93a5464cc06825f62dd",
                "md5": "8b4949e685733f6897266ef0f5973def",
                "sha256": "620630191deb443bf9ffcdafbff337f925884d3581ecae4a0df1bcc9c965e64a"
            },
            "downloads": -1,
            "filename": "sasdata-0.11.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8b4949e685733f6897266ef0f5973def",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 21489991,
            "upload_time": "2025-08-19T10:25:09",
            "upload_time_iso_8601": "2025-08-19T10:25:09.040985Z",
            "url": "https://files.pythonhosted.org/packages/cc/0b/8a98ee6196ccf99add9521ce9572092580d609c3b93a5464cc06825f62dd/sasdata-0.11.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e0078cf6fe0199d86a2ea29e90eab006294741ed9eaa68f1c0af0d78fdc1a57b",
                "md5": "f3b1ed771d064a710e10ca3aeaa7da76",
                "sha256": "1c8a8414dd18f80e02ea817c35c235a6e06de129b2a0da001686c741c61ea672"
            },
            "downloads": -1,
            "filename": "sasdata-0.11.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f3b1ed771d064a710e10ca3aeaa7da76",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 26036562,
            "upload_time": "2025-08-19T10:25:14",
            "upload_time_iso_8601": "2025-08-19T10:25:14.600029Z",
            "url": "https://files.pythonhosted.org/packages/e0/07/8cf6fe0199d86a2ea29e90eab006294741ed9eaa68f1c0af0d78fdc1a57b/sasdata-0.11.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-19 10:25:14",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "sasdata"
}
        
Elapsed time: 2.64755s