Skip to main content

Adv2reader reads version 2 Astro Digital Video files.

Project description

Adv2reader

This package provides a 'reader' for .adv (AstroDigitalVideo) files.

The specification for Astro Digital Video files can be found at: http://www.astrodigitalvideoformat.org/spec.html

To install this package on your system:

pip install Adv2

Then, sample usage from within your Python code is:

from pathlib import Path

from Adv2.Adv2File import Adv2reader

try:
    # Create a platform agnostic path to your .adv file (use forward slashes)
    file_path = str(Path('path/to/your/file.adv'))  # Python will make Windows version as needed

    # Create a 'reader' for the given file
    rdr = Adv2reader(file_path)

except AdvLibException as adverr:
    print(repr(adverr))
    exit()

except IOError as ioerr:
    print(repr(ioerr))
    exit()

Now that the file has been opened and a 'reader' (rdr) created for it, there are instance variables available that will be useful. Here is how to print some of those out:

print(f'Width: {rdr.Width}  Height: {rdr.Height}  NumMainFrames: {rdr.CountMainFrames}')

There is also an composite instance variable called FileInfo which gives access to all of the values defined in the structure AdvFileInfo (there are 20 of them).

For example:

print(rdr.FileInfo.UtcTimestampAccuracyInNanoseconds)

To get (and show) the file metadata (returned as a Dict[str, str]):

print(f'\nADV_FILE_META_DATA:')
meta_data = rdr.getAdvFileMetaData()
for key in meta_data:
    print(f'    {key}: {meta_data[key]}')

The main thing that one will want to do is read image data, timestamps, and frame status information from image frames.

Continuing with the example and assuming that the adv file contains a MAIN stream (it might also contain a CALIBRATION stream):

for frame in range(rdr.CountMainFrames):
    # To get frames from a CALIBRATION stream, use rdr.getCalibImageAndStatusData()
    # status is a Dict[str, str]

    err, image, frameInfo, status = rdr.getMainImageAndStatusData(frameNumber=frame)

    if not err:
        print(f'\nframe: {frame} STATUS:')
        print(frameInfo.DateString, frameInfo.StartOfExposureTimestampString)
        for entry in status:
            print(f'    {entry}: {status[entry]}')
    else:
        print(err)

err is a string that will be empty if image bytes and metadata where successfully extracted. In that case, image will contain a numpy array of uint16 values. If err is not empty, it will contain a human-readable description of the error encountered.

The 'shape' of image will be image[Height, Width] for grayscale images. Color video files are not yet supported.

Finally, the file should closed as in the example below:

print(f'closeFile returned: {rdr.closeFile()}')
rdr = None

The value returned will be the version number (2) of the file closed or 0, which indicates an attempt to close a file that was already closed.

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

Adv2-0.3.4.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

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

Adv2-0.3.4-py3-none-any.whl (2.0 MB view details)

Uploaded Python 3

File details

Details for the file Adv2-0.3.4.tar.gz.

File metadata

  • Download URL: Adv2-0.3.4.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.4

File hashes

Hashes for Adv2-0.3.4.tar.gz
Algorithm Hash digest
SHA256 ec7a34b62d852777465659cf60dac5175a72467cbe5553d55c5bf7f36fda6f86
MD5 45378c607ff5d6610afcc610345dfa2a
BLAKE2b-256 0ed61f95b59e57c15873f08c3e362ff07856a526ea2c71a2e4b40ab19ee72c98

See more details on using hashes here.

File details

Details for the file Adv2-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: Adv2-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.4

File hashes

Hashes for Adv2-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 40c38e519ce268e9e46e95ff03ef083d3748a6233e6565d5076ee4e7ca680140
MD5 4556293579e64a0e5b25774c771d02a1
BLAKE2b-256 42ad1747ef365c294009fba9853e6c38b96dae68eed4267863a33a16d8a91c00

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