Commit dd7995fb authored by Marco Kurzynski's avatar Marco Kurzynski
Browse files

changed bbcal to take a directory

parent b2e33b9c
......@@ -365,7 +365,7 @@ Options:
### Shell Example
```console
$ docker run --rm -it -v <data_dir>:/nli -w /nli aeri_armory nli.py -o /nli/output -a --plotall AEYYMMDD
$ docker run --rm -it -v <data_dir>:/nli aeri_armory nli.py -o /nli/output -a --plotall /nli/AEYYMMDD
```
# DMV to netCDF converter
......@@ -438,7 +438,7 @@ You can skip tests by assigning the variables below with any non-empty values re
### Shell Example
```bash
$ docker run --rm -w /tests -it -v <test_dir>:/tests aeri_armory test_suite.sh
$ docker run --rm -it -v <test_dir>:/tests aeri_armory test_suite.sh /tests
running aeri qc...
running quick vis...
running nc diff...
......@@ -459,7 +459,7 @@ SUCCESS: dmv_to_ncdf
To skip aeri_qc and cal_val:
```bash
$ docker run --rm -w /tests -e SKIP_AERI_QC=foo -e SKIP_CAL_VAL=bar -it -v <test_dir>:/tests aeri_armory test_suite.sh
$ docker run --rm -e SKIP_AERI_QC=foo -e SKIP_CAL_VAL=bar -it -v <test_dir>:/tests aeri_armory test_suite.sh /tests
running nli...
running diff...
SUCCESS: nli
......
......@@ -48,7 +48,7 @@ def interpolate(xin, yin, xout):
return val
def process(c1_file, c2_file, records, abb_breakout=None, output_path=''):
def process(directory, records, abb_breakout=None, output_path=''):
try:
NBBtemp = float(str.strip(os.environ.get('NBBTEMP')))
except TypeError:
......@@ -57,9 +57,9 @@ def process(c1_file, c2_file, records, abb_breakout=None, output_path=''):
IBBtemp = float(str.strip(os.environ.get('IBBTEMP')))
except TypeError:
IBBtemp = None
return process_helper(1, c1_file, records, NBBtemp, IBBtemp, abb_breakout, output_path), process_helper(2, c2_file, records, NBBtemp, IBBtemp, abb_breakout, output_path)
return process_helper(1, directory, records, NBBtemp, IBBtemp, abb_breakout, output_path), process_helper(2, directory, records, NBBtemp, IBBtemp, abb_breakout, output_path)
def process_helper(channel_number, channel_file, records, NBBtemp=None, IBBtemp=None, abb_breakout=None, output_path=''):
def process_helper(channel_number, directory, records, NBBtemp=None, IBBtemp=None, abb_breakout=None, output_path=''):
if isinstance(records, numbers.Number):
records = [records]
......@@ -76,7 +76,7 @@ def process_helper(channel_number, channel_file, records, NBBtemp=None, IBBtemp
try:
LOGFILE = str.strip(os.environ.get(f'C{channel_number}_LOGFILE'))
except TypeError:
LOGFILE = f'bbcal3p_{os.path.basename(channel_file)[:6]}.lo{channel_number}'
LOGFILE = f'bbcal3p_{os.path.basename(directory)[2:]}.lo{channel_number}'
LOGFILE = os.path.join(output_path, LOGFILE)
# Open logfile
......@@ -85,7 +85,7 @@ def process_helper(channel_number, channel_file, records, NBBtemp=None, IBBtemp
lf.write(" -----------------------------------------------------\n")
# Input File
INFILE = channel_file
INFILE = os.path.join(directory, f"{os.path.basename(directory)[2:8]}C{channel_number}.RNC")
lf.write("INPUT FILE: %s\n" % INFILE)
lf.write("INPUT RECORD RANGE: {0}\n".format(records))
......@@ -170,7 +170,7 @@ def process_helper(channel_number, channel_file, records, NBBtemp=None, IBBtemp
try:
MLTFILE = str.strip(os.environ.get(f'C{channel_number}_MLTFILE'))
except TypeError:
MLTFILE = f'bbcal_{os.path.basename(channel_file)[:6]}.mlt{channel_number}'
MLTFILE = f'bbcal_{os.path.basename(directory)[2:]}.mlt{channel_number}'
MLTFILE = os.path.join(output_path, MLTFILE)
# Write MLT file to Log file
......@@ -180,7 +180,7 @@ def process_helper(channel_number, channel_file, records, NBBtemp=None, IBBtemp
try:
SUMFILE = str.strip(os.environ.get(f'C{channel_number}_SUMFILE'))
except TypeError:
SUMFILE = f'bbcal_{os.path.basename(channel_file)[:6]}.sum{channel_number}'
SUMFILE = f'bbcal_{os.path.basename(directory)[2:]}.sum{channel_number}'
SUMFILE = os.path.join(output_path, SUMFILE)
lf.write("TEXT OUTPUT (SUMMARY) file: %s\n" % SUMFILE)
......@@ -507,7 +507,7 @@ def process_helper(channel_number, channel_file, records, NBBtemp=None, IBBtemp
jhms = format_time(TIME2)
# jhms=ihms
dateYYMMDD = channel_file[-12:-6]
dateYYMMDD = os.path.basename(directory)[2:8]
with open(SUMFILE, 'w') as sf:
sf.write("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n")
sf.write("Mean and Standard deviation of Observed minus Predicted BT\n\n\n")
......
......@@ -5,6 +5,7 @@ from cal_val import bbcal
import matplotlib
matplotlib.use('Agg')
import faulthandler
import matplotlib.pylab as plt
import numpy as np
import argparse
......@@ -12,7 +13,7 @@ import os, logging, math, numbers
from textwrap import wrap
from datetime import datetime
from utils import file_finder
faulthandler.enable()
matplotlib_logger = logging.getLogger('matplotlib')
# set WARNING for Matplotlib.
......@@ -583,7 +584,7 @@ def main(directory, output_dir=None, record_range=None, excluded_records=None, s
logger.info('Record {0} scene mirror position = {1}'.format(record, sceneMirrorPositions[record - 1]))
# Returns wavenumbers, obs_ice, pred_ice, obs_3body, pred_3body
logger.debug('Running bbcal')
lw,sw = bbcal.process(str(c1_file), str(c2_file), record, output_path=output_path)
lw,sw = bbcal.process(directory, record, output_path=output_path)
if sceneMirrorPositions[record - 1] == 83:
NBB.append((record, times[record - 1], lw[5], sw[5]))
......@@ -612,7 +613,7 @@ def main(directory, output_dir=None, record_range=None, excluded_records=None, s
logger.info('Record {0} scene mirror position = {1}'.format(records[-1],
sceneMirrorPositions[records[-1] - 1]))
# Returns wavenumbers, obs_ice, pred_ice, obs_3body, pred_3body
lw,sw = bbcal.process(str(c1_file), str(c2_file), records, output_path=output_path)
lw,sw = bbcal.process(directory, records, output_path=output_path)
make_NBB_plot(str(c1_file), lw, sw, records, output_path)
make_IBB_plot(str(c1_file), lw, sw, records, output_path)
......
#!/bin/bash
set -o pipefail
TEST_DIR=${TEST_DIR:-$PWD}
TEST_DIR=${1:-$PWD}
num_fails=0
result () {
......
#!/usr/bin/env python3.8
from os.path import basename, join, dirname, isdir, realpath
from os.path import basename, join, dirname, isdir, isfile, realpath
from os import mkdir, getenv
from sys import stderr
import subprocess
import argparse
import shutil
from utils import file_finder
def process(input_file, output_dir, args):
def process(input_file, output_dir, verbose):
exe = '/usr/bin/dmv-ncdf'
output_file = join(dirname(input_file), f'{basename(input_file)[:-4]}_{str.lower(basename(input_file)[-3:])}.nc')
logfile = join(dirname(input_file), f'{basename(input_file)[:-4]}_{str.lower(basename(input_file)[-3:])}.log')
dmv_input = '%s\n1\n99999\n0\n%s\n\n\n%s\n' % (input_file, output_file, logfile)
if args.verbose:
if verbose:
p = subprocess.Popen( [exe], stdin=subprocess.PIPE )
else:
p = subprocess.Popen( [exe], stdout=subprocess.PIPE, stdin=subprocess.PIPE )
......@@ -48,6 +49,9 @@ if __name__=='__main__':
ae_dirs = file_finder.getFiles(args.input_file, extensions=args.extensions)
for d, files in ae_dirs.items():
for f in files:
process(join(d,f), args.output_dir, args)
process(join(d,f), args.output_dir, args.verbose)
elif not isfile(args.input_file):
print("invalid input", file=stderr)
exit(1)
else:
process(realpath(args.input_file), args.output_dir, args)
process(realpath(args.input_file), args.output_dir, args.verbose)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment