-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea5688d
commit 77d357e
Showing
2 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env python | ||
|
||
|
||
"""Convert VDIF to NumPy format. | ||
Usage: vdif-convert <vdif> [<npz>] [--chbin <N>] | ||
<vdif> Input VDIF file (*.vdif). | ||
<npz> Output NumPy file (*.npz). | ||
--chbin <N> Number of channels to bin [default: 1]. | ||
-h --help Show this screen and exit. | ||
-v --version Show version and exit. | ||
""" | ||
|
||
|
||
__author__ = "Akio Taniguchi" | ||
__version__ = "0.1.0" | ||
|
||
|
||
# standard library | ||
from pathlib import Path | ||
|
||
|
||
# dependencies | ||
import numpy as np | ||
from docopt import docopt | ||
from vdif_reader import get_all_spectra | ||
|
||
|
||
# main functions | ||
def main() -> None: | ||
args = docopt(__doc__, version=__version__) | ||
|
||
vdif = Path(args["<vdif>"]).resolve() | ||
|
||
try: | ||
npz = Path(args["<npz>"]).resolve() | ||
except TypeError: | ||
npz = vdif.with_suffix(".npz") | ||
|
||
spectra = get_all_spectra(vdif, int(args["--chbin"])) | ||
np.savez(npz, spectra=spectra) | ||
|
||
|
||
# run command line interface | ||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters