Skip to main content

Python SDK for Siroquant API V5

Project description

PYSQ - Siroquant SDK for Python

Python SDK for Siroquant V5 API.

Website: https://www.siroquant.com/

Siroquant is a commercial software package designed for quantitative phase analysis using X-ray diffraction (XRD) data, primarily through the Rietveld refinement method. It enables users to determine the composition of crystalline materials—such as minerals, cements, coals, and clays—by fitting full XRD powder patterns without needing physical standards, making it a standardless technique.

Getting Started

# create a virtual environment and activate it
python -m venv venv
source venv\Scripts\activate

# Install the package
pip install pysq

# Update the package (optional)
pip install --upgrade pysq

Usage Examples

Simple Example

from pysq import SQAPI, SQAPIConfig

config = SQAPIConfig(lib_dir=r".\lib", dll_path=r".\lib\sq_api.dll")

with SQAPI(config) as api:
    api.initialize()
    task_info = api.open_task("task.tsk")
    results = api.refine(task_info.job_handle)
    print(f"Results: {results}")

Advanced Example

import os
from pysq import SQAPI, SQAPIConfig, SQAPIError, RefinementParams, ReportResultsFlags, SaveTaskFlags, TaskContext

TASK_FILE = r".\tasks\demo.tsk"
LIB_DIR   = r".\lib"
DLL_PATH  = r".\lib\sq_api.dll"


def main() -> None:
    config = SQAPIConfig(lib_dir=LIB_DIR, dll_path=DLL_PATH)

    try:
        with SQAPI(config) as api:
            api.initialize()

            with TaskContext(api, TASK_FILE) as (job_handle, task_info):
                print(f"Task: {task_info}")

                params = RefinementParams(
                    n_auto_prescale=1,
                    n_refs=1,
                    cutoff=0.5,
                    error_cutoff=1.0,
                    error_pc=0.75,
                    flags=0,
                )
                results = api.refine(job_handle, params=params, report_flags=ReportResultsFlags.CORRECTED)

                print(f"\nResults: {results}")
                if results.phases:
                    print(f"\n{'No.':<4} {'Phase Name':<20} {'Weight (%)':<12} {'Error (%)':<10}")
                    print("-" * 50)
                    for i, phase in enumerate(results.phases, 1):
                        print(f"{i:<4} {phase.phase_name:<20} {phase.weight_pc:<12.2f} {phase.error_of_fit:<10.2f}")

                api.save_task(job_handle)
                print(f"\nTask saved to: {TASK_FILE}")

    except SQAPIError as e:
        print(f"\nSQ API Error: {e}")
        if e.error_code is not None:
            print(f"  Code: {e.error_code}")
    except Exception as e:
        print(f"\nError: {e}")


if __name__ == "__main__":
    main()

Configuration

Set paths via environment variables or code:

  • SQ_LIB_DIR: Library directory path
  • SQ_DLL_PATH: DLL path (optional, auto-detected)

Requirements

  • Python 3.8+
  • Windows (x64)
  • Siroquant V5

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

pysq-0.1.6.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

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

pysq-0.1.6-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file pysq-0.1.6.tar.gz.

File metadata

  • Download URL: pysq-0.1.6.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pysq-0.1.6.tar.gz
Algorithm Hash digest
SHA256 c887c7b52f1079598a24d502823a73d131c2ed66c8945e7d3f07345098ee4098
MD5 8557da2a6df87c716d70f558b6ad1613
BLAKE2b-256 50e0c1655ff6c2a638048176ca8bc5618d2d73526f30e3f359c2eb69119f4967

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysq-0.1.6.tar.gz:

Publisher: publish-pysq.yml on bevolv/sq-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pysq-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: pysq-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pysq-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 180fc1cbcdc1ca21360b5692af6d18bf3be874a2bc6047535e751f739c97c2e8
MD5 c1e4b381d4540f507758f1a46b25f87d
BLAKE2b-256 b698f9533a319302c59c74048c8b75995cfe88de730ea60e6f6e94513b3411a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysq-0.1.6-py3-none-any.whl:

Publisher: publish-pysq.yml on bevolv/sq-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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