-
Notifications
You must be signed in to change notification settings - Fork 29
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
Showing
2 changed files
with
57 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
numpy==1.11.1 | ||
numpy>=1.11.1 | ||
Click==6.6 |
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,55 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
""" Command line utilities for package Seabird | ||
""" | ||
|
||
import click | ||
|
||
from seabird.exceptions import CNVError | ||
from .cnv import fCNV | ||
from .netcdf import cnv2nc | ||
|
||
@click.group() | ||
def cli(): | ||
""" Utilities for seabird files | ||
""" | ||
pass | ||
|
||
@cli.command(name='cnvdump') | ||
@click.argument('inputfilename', type=click.Path(exists=True)) | ||
def dump(inputfilename): | ||
""" Dump the contents of a CNV file | ||
""" | ||
|
||
try: | ||
data = fCNV(inputfilename) | ||
except CNVError as e: | ||
print("\033[91m%s\033[0m" % e.msg) | ||
import sys; sys.exit() | ||
except: | ||
raise | ||
|
||
print("file: %s" % inputfilename) | ||
print("Global attributes") | ||
for a in sorted(data.attributes.keys()): | ||
print("\t\033[93m%s\033[0m: %s" % (a, data.attributes[a])) | ||
|
||
print("\nVariabes") | ||
for k in data.keys(): | ||
print("\033[91m%s\033[0m" % k) | ||
for a in data[k].attributes.keys(): | ||
print("\t\033[93m%s\033[0m: %s" % (a, data[k].attributes[a])) | ||
|
||
@cli.command(name='cnv2nc') | ||
@click.option('--outputfilename', default=None, | ||
help='The output netCDF filename.') | ||
@click.argument('inputfilename', type=click.Path(exists=True)) | ||
def nc(inputfilename, outputfilename): | ||
""" Export a CNV file as a netCDF | ||
""" | ||
if outputfilename is None: | ||
outputfilename = inputfilename.replace('.cnv','.nc') | ||
click.echo('Saving on %s' % outputfilename) | ||
data = fCNV(inputfilename) | ||
cnv2nc(data, outputfilename) |