Skip to main content

parse xy format file of X-ray diffraction

Project description

xrd-xy-parser

xrd-xy-parser is parser of xy file from X-ray diffraction.
Python ver >= 3.10

installation

pip install xrd-xy-parser

or

pip3 install xrd-xy-parser

how to use

from xrd_xy_parser import xy

if __name__ == "__main__":

    try:
        header, body, footer = xy.readstr("examples/example.xy")
        print("header:{}\n" "body:{}\n" "footer:{}\n".format(header, body, footer))
        '''
        header:
        <301.15K> 
        Wavelength = 1.54059 

        body:
        array([[30.  ,  1.  ],
        [30.01,  1.  ],
        [30.02,  3.  ],
        ...,
        [49.97,  3.  ],
        [49.98,  1.  ],
        [49.99,  0.  ]])

        footer:
        ""
        '''
    except xy.ParseError as e:
        print(e)

getting 2θ,Intensity column

    # 2θ column
    print(body[:,0]) # array([30.  , 30.01, 30.02, ..., 49.97, 49.98, 49.99])

    # Intensity column
    print(body[:,1]) # array([1., 1., 3., ..., 3., 1., 0.])

or read2xy

    try:
        xy = read2xy("examples/example.xy")
        print(xy)
        # x:array([30.  , 30.01, 30.02, ..., 49.97, 49.98,])
        # y:array([1., 1., 3., ..., 3., 1., 0.])
    except xy.ParseError as e:
        print(e)
    

function

xy.read(str)

xy.read(Pathlib.Path)

xy.read(TextIOBase)

read xy data from str ,Path or TextIOBase,return tuple (header, body, footer).

xy.read2xy(str)

xy.read2xy(Pathlib.Path)

xy.read2xy(TextIOBase)

read xy data from str ,Path or TextIOBase,return xrdXY object.

class

xrdXY

attribute

  • x: np.ndarray
  • y: np.ndarray

xy file structure

xy file is not explicitly specified.
xy file consists from header,body,footer parts.
header includes some infomation, body is float list. footer is empty or consists from \s ,\t ,\r\n,\n.

<301.15K> \\header
Wavelength = 1.54059 \\header
26.78	11598.00 \\body
26.8	10786.00
26.82	5768.00
26.84	1149.00
26.86	255.00
26.88	74.00
26.9	52.00
26.92	30.00
26.94	19.00 \\body
\\ footer

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

xrd-xy-parser-0.0.4.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

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

xrd_xy_parser-0.0.4-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file xrd-xy-parser-0.0.4.tar.gz.

File metadata

  • Download URL: xrd-xy-parser-0.0.4.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for xrd-xy-parser-0.0.4.tar.gz
Algorithm Hash digest
SHA256 ae0e1c8a20dd360c94693561c70c321f6547015b418ff65f4712fd9882e90892
MD5 caaf666eac7cce358e660e47411183d6
BLAKE2b-256 4c974aa4008f1ea5071a7adbd7754baabd3d9cf188216e1ac6f5aea430233aaa

See more details on using hashes here.

File details

Details for the file xrd_xy_parser-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: xrd_xy_parser-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for xrd_xy_parser-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a42090544e910559b1d9154b94569332876de8285a81c24cdd6695562dd96185
MD5 7a1ab951c21e0e71127d5501fce3feb8
BLAKE2b-256 8b1b31b12c5ad0e24d55cb2dedc2f2d0ece458ba08a1e517dc7437f79b9caae4

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