-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun_conversion_batch.py
81 lines (60 loc) · 2.27 KB
/
run_conversion_batch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#! /usr/bin/env python3
# coding=utf-8
import datetime
import os
import re
#import matplotlib
#matplotlib.use('Agg')
#import numpy as np
#import matplotlib.pyplot as plt
import argparse
#import sys, os
import peakTree
import peakTree.helpers as h
import logging
log = logging.getLogger('peakTree')
log.setLevel(logging.INFO)
log.addHandler(logging.StreamHandler())
parser = argparse.ArgumentParser(description='peakTree conversion')
parser.add_argument('--date', help='date in the format YYYYMMDD', required=True)
parser.add_argument('--instrument', help='radar model NMRA, MBR5', default='NMRA')
parser.add_argument('--config', help='config entry to use', default='Lacros_Pun')
args = parser.parse_args()
date = datetime.datetime.strptime(args.date, '%Y%m%d')
#date = datetime.datetime(2019, 2, 3)
path = 'data/{}/{}/'.format(args.instrument, date.strftime('%Y%m%d'))
files = os.listdir(path)
files = [f for f in files if ('.nc' in f or '.cdf' in f)]
print(files)
#files = [f for f in files if int(re.findall("T(\d*)", f)[0]) > 1300]
outpath = 'output/{}/{}/'.format(args.instrument, date.strftime('%Y%m%d'))
if not os.path.isdir(outpath):
print('create output path ', outpath)
os.mkdir(outpath)
pTB = peakTree.peakTreeBuffer(config_file='instrument_config.toml', system=args.config)
# filter for patrics test
#files = [f for f in files if "ldrcorr" in f]
if args.config == 'Lacros_Pun':
#files = [f for f in files if "T1300_" in f]
files = [f for f in files if "v2.0" in f]
print('doing only ', files)
for f in sorted(files)[:]:
print('now doing ', f)
pTB.load(path+f, load_to_ram=True)
pTB.assemble_time_height(outpath)
exit()
pTB = peakTree.peakTreeBuffer(config_file='instrument_config.toml', system='Lacros_Pun')
pTB.load_spec_file('data/D20190317_T0600_0700_Pun_zspc2nc_v1_02_standard.nc4', load_to_ram=True)
pTB.assemble_time_height('output/')
exit()
path = 'data/'
files = os.listdir(path)
valid_time = ['20190711', '20190713']
print('total no files in ', path, ' : ', len(files))
files = [path+f for f in files if f[1:9] >= valid_time[0] and f[1:9] <= valid_time[1]]
files = sorted(files)
print('files selected', len(files))
for f in files:
pTB = peakTree.peakTreeBuffer(system='Lacros_at_ACCEPT')
pTB.load_spec_file(f)
pTB.assemble_time_height('output/')