From 4ea3b35a4c647454a56a58d6eb5a27b0316079fa Mon Sep 17 00:00:00 2001 From: dave <dave@dtu.dk> Date: Sat, 23 Jul 2016 11:10:40 +0200 Subject: [PATCH] prepost: add convenience interface for calculating stats+del per file --- wetb/prepost/statsdel.py | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 wetb/prepost/statsdel.py diff --git a/wetb/prepost/statsdel.py b/wetb/prepost/statsdel.py new file mode 100644 index 00000000..d2f3d49c --- /dev/null +++ b/wetb/prepost/statsdel.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +""" +Created on Thu Jul 21 15:13:38 2016 + +@author: dave +""" + +from __future__ import print_function +from __future__ import division +from __future__ import unicode_literals +from __future__ import absolute_import +#from builtins import dict +#from io import open +#from builtins import zip +#from builtins import range +#from builtins import str +#from builtins import int +from future import standard_library +standard_library.install_aliases() + +import os + +from wetb.prepost import windIO + + +def calc(fpath, no_bins=46, m=[3, 4, 6, 8, 10, 12], neq=None, i0=0, i1=None, + ftype=False, fsave=False): + """ + Should we load m, statchans, delchans from another file? This function + will be called from a PBS script. + """ + + if fpath[-4:] == '.sel' or fpath[-4:] == '.dat': + fpath = fpath[-4:] + + fdir = os.path.dirname(fpath) + fname = os.path.basename(fpath) + + res = windIO.LoadResults(fdir, fname, debug=False, usecols=None, + readdata=True) + statsdel = res.statsdel_df(i0=i0, i1=i1, statchans='all', neq=neq, + no_bins=no_bins, m=m, delchans='all') + + if fsave: + if fsave[-4:] == '.csv': + statsdel.to_csv(fsave) + elif fsave[-3:] == '.h5': + statsdel.to_hdf(fsave, 'table', complib='zlib', complevel=9) + elif ftype == '.csv': + statsdel.to_csv(fpath+ftype) + elif ftype == '.h5': + statsdel.to_hdf(fpath+ftype, 'table', complib='zlib', complevel=9) + + +if __name__ == '__main__': + pass -- GitLab