Adv2
====
This package provides a 'reader' for .adv (AstroDigitalVideo) Version 2 files.
It is the result of a collaborative effort involving Bob Anderson and Hristo Pavlov.
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 (these give the image size and number of images in the file):
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):
# status is a Dict[str, str]
err, image, frameInfo, status = rdr.getMainImageAndStatusData(frameNumber=frame)
# To get frames from a CALIBRATION stream, use rdr.getCalibImageAndStatusData()
if not err:
# If timestamp info was not present in the file (highly unlikely),
# the timestamp string returned will be empty (== '')
if frameInfo.StartOfExposureTimestampString:
print(frameInfo.DateString, frameInfo.StartOfExposureTimestampString)
print(f'\nframe: {frame} STATUS:')
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.
Raw data
{
"_id": null,
"home_page": "https://github.com/bob-anderson-ok/adv2reader",
"name": "Adv2",
"maintainer": "Bob Anderson",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "bob.anderson.ok@gmail.com",
"keywords": "ADV file reader,Astro Digital Video version 2 file reader",
"author": "Bob Anderson",
"author_email": "bob.anderson.ok@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/69/8a/e4658e2cf77a7723c02070135b2df71388a3bb9a2f788671ca397e79608f/Adv2-1.2.0.tar.gz",
"platform": "",
"description": "Adv2\n====\n\nThis package provides a 'reader' for .adv (AstroDigitalVideo) Version 2 files.\n\nIt is the result of a collaborative effort involving Bob Anderson and Hristo Pavlov.\n\nThe specification for Astro Digital Video files can be \nfound at: <http://www.astrodigitalvideoformat.org/spec.html>\n\nTo install this package on your system:\n\n pip install Adv2\n\nThen, sample usage from within your Python code is:\n\n from pathlib import Path\n\n from Adv2.Adv2File import Adv2reader\n\n try:\n # Create a platform agnostic path to your .adv file (use forward slashes)\n file_path = str(Path('path/to/your/file.adv')) # Python will make Windows version as needed\n\n # Create a 'reader' for the given file\n rdr = Adv2reader(file_path)\n\n except AdvLibException as adverr:\n print(repr(adverr))\n exit()\n\n except IOError as ioerr:\n print(repr(ioerr))\n exit()\n\nNow that the file has been opened and a 'reader' (rdr) created for it, \nthere are instance variables available that will be useful.\nHere is how to print some of those out (these give the image size and number of images in the file):\n\n print(f'Width: {rdr.Width} Height: {rdr.Height} NumMainFrames: {rdr.CountMainFrames}')\n\nThere is also an composite instance variable called `FileInfo` which gives access to all\nof the values defined in the structure `AdvFileInfo` (there are 20 of them).\n\nFor example:\n\n print(rdr.FileInfo.UtcTimestampAccuracyInNanoseconds)\n\nTo get (and show) the file metadata (returned as a Dict[str, str]):\n\n print(f'\\nADV_FILE_META_DATA:')\n meta_data = rdr.getAdvFileMetaData()\n for key in meta_data:\n print(f' {key}: {meta_data[key]}')\n\nThe main thing that one will want to do is read image data, timestamps, and frame status information\nfrom image frames.\n\nContinuing with the example and assuming that the adv file contains a MAIN stream (it\nmight also contain a CALIBRATION stream):\n\n\n for frame in range(rdr.CountMainFrames):\n\n # status is a Dict[str, str]\n err, image, frameInfo, status = rdr.getMainImageAndStatusData(frameNumber=frame)\n # To get frames from a CALIBRATION stream, use rdr.getCalibImageAndStatusData()\n\n if not err:\n # If timestamp info was not present in the file (highly unlikely),\n # the timestamp string returned will be empty (== '')\n if frameInfo.StartOfExposureTimestampString:\n print(frameInfo.DateString, frameInfo.StartOfExposureTimestampString)\n print(f'\\nframe: {frame} STATUS:')\n for entry in status:\n print(f' {entry}: {status[entry]}')\n else:\n print(err)\n\n`err` is a string that will be empty if image bytes and metadata where successfully extracted.\nIn that case, `image` will contain a numpy array of uint16 values. If `err` is not empty, it will contain\na human-readable description of the error encountered.\n\nThe 'shape' of image will be `image[Height, Width]` for grayscale images. Color video\nfiles are not yet supported.\n\nFinally, the file should closed as in the example below:\n\n print(f'closeFile returned: {rdr.closeFile()}')\n rdr = None\n\nThe value returned will be the version number (2) of the file closed or 0, which indicates an attempt to close a file that was\nalready closed.\n\n\n",
"bugtrack_url": null,
"license": "License :: OSI Approved :: MIT License",
"summary": "Adv2reader reads version 2 Astro Digital Video files.",
"version": "1.2.0",
"split_keywords": [
"adv file reader",
"astro digital video version 2 file reader"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5a536afa0afe1c2699fc1009b6e8905ab463559453c2cb0c386784307f1a74aa",
"md5": "6024a4614699002554aa20c42b32a102",
"sha256": "af732ef1e6a1a5324facadcbe8a628cdadfca53d4783617e65f010b450d363b3"
},
"downloads": -1,
"filename": "Adv2-1.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6024a4614699002554aa20c42b32a102",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 1979558,
"upload_time": "2020-04-06T20:54:55",
"upload_time_iso_8601": "2020-04-06T20:54:55.038782Z",
"url": "https://files.pythonhosted.org/packages/5a/53/6afa0afe1c2699fc1009b6e8905ab463559453c2cb0c386784307f1a74aa/Adv2-1.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "698ae4658e2cf77a7723c02070135b2df71388a3bb9a2f788671ca397e79608f",
"md5": "d29fe5313a575693a10e47cc22b00722",
"sha256": "2f09159b3637582ec90c6ff4aa33cfc3f1988103b0e55fb274d3bf18a85a931a"
},
"downloads": -1,
"filename": "Adv2-1.2.0.tar.gz",
"has_sig": false,
"md5_digest": "d29fe5313a575693a10e47cc22b00722",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 1961232,
"upload_time": "2020-04-06T20:55:00",
"upload_time_iso_8601": "2020-04-06T20:55:00.153827Z",
"url": "https://files.pythonhosted.org/packages/69/8a/e4658e2cf77a7723c02070135b2df71388a3bb9a2f788671ca397e79608f/Adv2-1.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2020-04-06 20:55:00",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "bob-anderson-ok",
"github_project": "adv2reader",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "adv2"
}