Verified Commit 5397ca23 authored by Marco Kurzynski's avatar Marco Kurzynski
Browse files

moved mlt, sum, log, and wn into bbcal

parent d9fe81ba
import os
def set_env():
# Chan 1
os.environ.setdefault('C1_IDNBB', 'S')
os.environ.setdefault('C1_IDIBB', 'T')
os.environ.setdefault('C1_NBEMFL', 'nbb-emis.asc')
os.environ.setdefault('C1_IBEMFL', 'ibb-emis.asc')
os.environ.setdefault('C1_CAVFAC2', '39.0')
os.environ.setdefault('C1_WTNB', '0.811 0.189 0.0')
os.environ.setdefault('C1_TOSNB', '0.0 0.0 0.0')
os.environ.setdefault('C1_WTIB', '0.811 0.0945 0.0945')
os.environ.setdefault('C1_TOSIB', '0.0 0.0 0.0')
os.environ.setdefault('C1_NRNGS', '1')
# Chan 1 redeclared for Chan 2
os.environ.setdefault('C2_IDNBB', 'S')
os.environ.setdefault('C2_IDIBB', 'T')
os.environ.setdefault('C2_NBEMFL', 'nbb-emis.asc')
os.environ.setdefault('C2_IBEMFL', 'ibb-emis.asc')
os.environ.setdefault('C2_CAVFAC2', '39.0')
os.environ.setdefault('C2_WTNB', '0.811 0.189 0.0')
os.environ.setdefault('C2_TOSNB', '0.0 0.0 0.0')
os.environ.setdefault('C2_WTIB', '0.811 0.0945 0.0945')
os.environ.setdefault('C2_TOSIB', '0.0 0.0 0.0')
os.environ.setdefault('C2_NRNGS', '1')
# Unique Chan 1
os.environ.setdefault('C1_LOGFIL', 'bbcal3p.lo1')
os.environ.setdefault('C1_MLTFILE', 'bbcal.mlt1')
os.environ.setdefault('C1_SUMFILE', 'bbcal.sum1')
os.environ.setdefault('C1_WN', '900 1100')
# Unique Chan 2
os.environ.setdefault('C2_LOGFIL', 'bbcal3p.lo2')
os.environ.setdefault('C2_MLTFILE', 'bbcal.mlt2')
os.environ.setdefault('C2_SUMFILE', 'bbcal.sum2')
os.environ.setdefault('C2_WN', '2100 2200')
os.environ.setdefault('IDNBB', 'S')
os.environ.setdefault('IDIBB', 'T')
os.environ.setdefault('NBEMFL', 'nbb-emis.asc')
os.environ.setdefault('IBEMFL', 'ibb-emis.asc')
os.environ.setdefault('CAVFAC2', '39.0')
os.environ.setdefault('WTNB', '0.811 0.189 0.0')
os.environ.setdefault('TOSNB', '0.0 0.0 0.0')
os.environ.setdefault('WTIB', '0.811 0.0945 0.0945')
os.environ.setdefault('TOSIB', '0.0 0.0 0.0')
os.environ.setdefault('NRNGS', '1')
set_env()
......@@ -61,21 +61,18 @@ def process_helper(channel_number, channel_file, records, NBBtemp=None, IBBtemp
# Maximum number of ranges
MAXRNGS = 10
if channel_number == 1:
prefix = 'C1_'
elif channel_number == 2:
prefix = 'C2_'
else:
prefix = ''
if channel_number != 1 and channel_number != 2:
logger.error("Invalid channel_number, must be 1 or 2")
exit(1)
# line[5] Log file
LOGFIL = os.path.join(output_path, str.strip(os.environ.get(prefix+'LOGFIL')))
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 = os.path.join(output_path, LOGFILE)
# Open logfile
lf = open(LOGFIL, 'w')
lf = open(LOGFILE, 'w')
lf.write(" ---------------- bbcal3p.py -----------------------\n")
lf.write(" -----------------------------------------------------\n")
......@@ -86,15 +83,15 @@ def process_helper(channel_number, channel_file, records, NBBtemp=None, IBBtemp
lf.write("INPUT RECORD RANGE: {0}\n".format(records))
# NBB & IBB Scene IDs
IDNBB = str.strip(os.environ.get(prefix+'IDNBB'))
IDNBB = str.strip(os.environ.get('IDNBB'))
lf.write("NBB identifier: %s\n" % IDNBB)
IDIBB = str.strip(os.environ.get(prefix+'IDIBB'))
IDIBB = str.strip(os.environ.get('IDIBB'))
lf.write("IBB identifier: %s\n" % IDIBB)
# NBB & IBB Emissivity Files
NBEMFL = str.strip(os.environ.get(prefix+'NBEMFL'))
NBEMFL = str.strip(os.environ.get('NBEMFL'))
lf.write("NBB EMISSIVITY FILE: %s\n" % NBEMFL)
IBEMFL = str.strip(os.environ.get(prefix+'IBEMFL'))
IBEMFL = str.strip(os.environ.get('IBEMFL'))
lf.write("IBB EMISSIVITY FILE: %s\n" % IBEMFL)
# Read NBB & IBB Emissivity Files
......@@ -125,50 +122,58 @@ def process_helper(channel_number, channel_file, records, NBBtemp=None, IBBtemp
imfp.close()
# BB Cavity Factor
CAVFAC2 = float(str.strip(os.environ.get(prefix+'CAVFAC2')))
CAVFAC2 = float(str.strip(os.environ.get('CAVFAC2')))
lf.write("BB CAVITY FACTOR: %f\n" % CAVFAC2)
RCF = 1.0 / CAVFAC2
# NBB Apex, Bottom and Top weightings
WTNBA = float(str.split(str.strip(os.environ.get(prefix+'WTNB')))[0])
WTNBB = float(str.split(str.strip(os.environ.get(prefix+'WTNB')))[1])
WTNBT = float(str.split(str.strip(os.environ.get(prefix+'WTNB')))[2])
WTNBA = float(str.split(str.strip(os.environ.get('WTNB')))[0])
WTNBB = float(str.split(str.strip(os.environ.get('WTNB')))[1])
WTNBT = float(str.split(str.strip(os.environ.get('WTNB')))[2])
# Write Weighting to Logfile
lf.write("NBB Weights: %1.5f %1.5f %1.5f\n" % (WTNBA, WTNBB, WTNBT))
# NBB Apex, Bottom and Top offsets
TOSNBA = float(str.split(str.strip(os.environ.get(prefix+'TOSNB')))[0])
TOSNBB = float(str.split(str.strip(os.environ.get(prefix+'TOSNB')))[1])
TOSNBT = float(str.split(str.strip(os.environ.get(prefix+'TOSNB')))[2])
TOSNBA = float(str.split(str.strip(os.environ.get('TOSNB')))[0])
TOSNBB = float(str.split(str.strip(os.environ.get('TOSNB')))[1])
TOSNBT = float(str.split(str.strip(os.environ.get('TOSNB')))[2])
# Write Offsets to Logfile
lf.write("NBB Offsets: %1.5f %1.5f %1.5f\n" % (TOSNBA, TOSNBB, TOSNBT))
# IBB Apex, Bottom and Top weightings
WTIBA = float(str.split(str.strip(os.environ.get(prefix+'WTIB')))[0])
WTIBB = float(str.split(str.strip(os.environ.get(prefix+'WTIB')))[1])
WTIBT = float(str.split(str.strip(os.environ.get(prefix+'WTIB')))[2])
WTIBA = float(str.split(str.strip(os.environ.get('WTIB')))[0])
WTIBB = float(str.split(str.strip(os.environ.get('WTIB')))[1])
WTIBT = float(str.split(str.strip(os.environ.get('WTIB')))[2])
# Write Weighting to Logfile
lf.write("IBB Weights: %1.5f %1.5f %1.5f\n" % (WTIBA, WTIBB, WTIBT))
# IBB Apex, Bottom and Top offsets
TOSIBA = float(str.split(str.strip(os.environ.get(prefix+'TOSIB')))[0])
TOSIBB = float(str.split(str.strip(os.environ.get(prefix+'TOSIB')))[1])
TOSIBT = float(str.split(str.strip(os.environ.get(prefix+'TOSIB')))[2])
TOSIBA = float(str.split(str.strip(os.environ.get('TOSIB')))[0])
TOSIBB = float(str.split(str.strip(os.environ.get('TOSIB')))[1])
TOSIBT = float(str.split(str.strip(os.environ.get('TOSIB')))[2])
# Write Offsets to Logfile
lf.write("IBB Offsets: %1.5f %1.5f %1.5f\n" % (TOSIBA, TOSIBB, TOSIBT))
# MLT file
MLTFILE = os.path.join(output_path, str.strip(os.environ.get(prefix+'MLTFILE')))
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 = os.path.join(output_path, MLTFILE)
# Write MLT file to Log file
lf.write("ASCII Output (MLT) file: % s\n" % MLTFILE)
# Summary File
SUMFILE = os.path.join(output_path, str.strip(os.environ.get(prefix+'SUMFILE')))
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 = os.path.join(output_path, SUMFILE)
lf.write("TEXT OUTPUT (SUMMARY) file: %s\n" % SUMFILE)
# Array of Metadata required
......@@ -449,17 +454,25 @@ def process_helper(channel_number, channel_file, records, NBBtemp=None, IBBtemp
mlt.close()
# Read number of ranges
NRNGS = int(str.strip(os.environ.get(prefix+'NRNGS')))
NRNGS = int(str.strip(os.environ.get('NRNGS')))
# FIXME: Do something in the future if there is more then 1 range
if NRNGS >= 2:
logger.error("Add more code :)")
try:
WN = str.strip(os.environ.get(f'C{channel_number}_WN'))
except TypeError:
if channel_number == 1:
WN = '900 1100'
else:
WN = '2100 2200'
# Lower bound of spectral range
WNLO = int(str.split(str.strip(os.environ.get(prefix+'WN')))[0])
WNLO = int(str.split(WN)[0])
# Higher bound of spectral range
WNHI = int(str.split(str.strip(os.environ.get(prefix+'WN')))[1])
WNHI = int(str.split(WN)[1])
XMIN = interx[0]
XMAX = interx[len(interx) - 1]
......
......@@ -631,7 +631,27 @@ if __name__ == '__main__':
#
######################################################################
# Argument Parsing
parser = argparse.ArgumentParser(description='Generate cal val plots for IBB and NBB. The first record is record 1')
parser = argparse.ArgumentParser(description='Generate cal val plots for IBB and NBB. The first record is record 1\n' \
'The following are optional environmental variables you can set:\n' \
'IDNBB - (IDK)\n' \
'IDIBB - (IDK)\n' \
'NBEMFL - (IDK)\n' \
'IBEMFL - (IDK)\n' \
'CAVFAC2 - (IDK)\n' \
'WTNB - (IDK)\n' \
'TOSNB - (IDK)\n' \
'WTIB - (IDK)\n' \
'TOSIB - (IDK)\n' \
'NRNGS - (IDK)\n\n' \
'C1_MLTFILE - MLT output filename for channel 1\n' \
'C1_LOGFILE - Log output filename for channel 1\n' \
'C1_SUMFILE - Sum output filename for channel 1\n' \
'C1_WN - lower and upper wavenumber for channel 1 (ex. default is "900 1100")\n\n' \
'C2_MLTFILE - MLT output filename for channel 2\n' \
'C2_LOGFILE - Log output filename for channel 2\n' \
'C2_SUMFILE - Sum output filename for channel 2\n' \
'C2_WN - lower and upper wavenumber for channel 2 (ex. default is "2100 2200")'
)
parser.add_argument("input", help="Channel 1 input filename in HHMMSSC1.RNC format. Realtive or absolute path")
parser.add_argument("-o", '--output-dir',
......
---------------- bbcal3p.py -----------------------
-----------------------------------------------------
INPUT FILE: /tests/cal_val/input_data/AE170418/170418C1.RNC
INPUT RECORD RANGE: [1, 2, 3, 4]
NBB identifier: S
IBB identifier: T
NBB EMISSIVITY FILE: nbb-emis.asc
IBB EMISSIVITY FILE: ibb-emis.asc
FIRST LINE OF NBB EMISSIVITY-SPECTRUM FILE:
7/96 Sample #5 (Best of Lot #3 of 2.7 inch Aperture BB's)
FIRST LINE OF IBB EMISSIVITY-SPECTRUM FILE:
7/96 Sample #5 (Best of Lot #3 of 2.7 inch Aperture BB's)
BB CAVITY FACTOR: 39.000000
NBB Weights: 0.81100 0.18900 0.00000
NBB Offsets: 0.00000 0.00000 0.00000
IBB Weights: 0.81100 0.09450 0.09450
IBB Offsets: 0.00000 0.00000 0.00000
ASCII Output (MLT) file: /tests/cal_val/user_output/bbcal_170418.mlt1
TEXT OUTPUT (SUMMARY) file: /tests/cal_val/user_output/bbcal_170418.sum1
FROM INPUT RECORD NUMBER: 1
NBB raw temps (apex, bottom, top): 326.763, 326.961, 0.000
NBB AVERAGE temperature: 273.182
IBB raw temps (apex, bottom, top): nan, nan, nan
IBB AVERAGE temperature: 273.182
FROM INPUT RECORD NUMBER: 2
NBB raw temps (apex, bottom, top): 326.765, 326.960, 0.000
NBB AVERAGE temperature: 273.182
IBB raw temps (apex, bottom, top): nan, nan, nan
IBB AVERAGE temperature: 273.182
FROM INPUT RECORD NUMBER: 3
NBB raw temps (apex, bottom, top): 326.766, 326.961, 0.000
NBB AVERAGE temperature: 273.182
IBB raw temps (apex, bottom, top): nan, nan, nan
IBB AVERAGE temperature: 273.182
FROM INPUT RECORD NUMBER: 4
NBB raw temps (apex, bottom, top): 326.768, 326.961, 0.000
NBB AVERAGE temperature: 273.182
IBB raw temps (apex, bottom, top): nan, nan, nan
IBB AVERAGE temperature: 273.182
---------------- bbcal3p.py -----------------------
-----------------------------------------------------
INPUT FILE: /tests/cal_val/input_data/AE170418/170418C2.RNC
INPUT RECORD RANGE: [1, 2, 3, 4]
NBB identifier: S
IBB identifier: T
NBB EMISSIVITY FILE: nbb-emis.asc
IBB EMISSIVITY FILE: ibb-emis.asc
FIRST LINE OF NBB EMISSIVITY-SPECTRUM FILE:
7/96 Sample #5 (Best of Lot #3 of 2.7 inch Aperture BB's)
FIRST LINE OF IBB EMISSIVITY-SPECTRUM FILE:
7/96 Sample #5 (Best of Lot #3 of 2.7 inch Aperture BB's)
BB CAVITY FACTOR: 39.000000
NBB Weights: 0.81100 0.18900 0.00000
NBB Offsets: 0.00000 0.00000 0.00000
IBB Weights: 0.81100 0.09450 0.09450
IBB Offsets: 0.00000 0.00000 0.00000
ASCII Output (MLT) file: /tests/cal_val/user_output/bbcal_170418.mlt2
TEXT OUTPUT (SUMMARY) file: /tests/cal_val/user_output/bbcal_170418.sum2
FROM INPUT RECORD NUMBER: 1
NBB raw temps (apex, bottom, top): 326.763, 326.961, 0.000
NBB AVERAGE temperature: 273.182
IBB raw temps (apex, bottom, top): nan, nan, nan
IBB AVERAGE temperature: 273.182
FROM INPUT RECORD NUMBER: 2
NBB raw temps (apex, bottom, top): 326.765, 326.960, 0.000
NBB AVERAGE temperature: 273.182
IBB raw temps (apex, bottom, top): nan, nan, nan
IBB AVERAGE temperature: 273.182
FROM INPUT RECORD NUMBER: 3
NBB raw temps (apex, bottom, top): 326.766, 326.961, 0.000
NBB AVERAGE temperature: 273.182
IBB raw temps (apex, bottom, top): nan, nan, nan
IBB AVERAGE temperature: 273.182
FROM INPUT RECORD NUMBER: 4
NBB raw temps (apex, bottom, top): 326.768, 326.961, 0.000
NBB AVERAGE temperature: 273.182
IBB raw temps (apex, bottom, top): nan, nan, nan
IBB AVERAGE temperature: 273.182
......@@ -15,8 +15,8 @@ NBB Weights: 0.81100 0.18900 0.00000
NBB Offsets: 0.00000 0.00000 0.00000
IBB Weights: 0.81100 0.09450 0.09450
IBB Offsets: 0.00000 0.00000 0.00000
ASCII Output (MLT) file: /tests/cal_val/user_output/AE191010_output/bbcal.mlt1
TEXT OUTPUT (SUMMARY) file: /tests/cal_val/user_output/AE191010_output/bbcal.sum1
ASCII Output (MLT) file: /tests/cal_val/user_output/bbcal_191010.mlt1
TEXT OUTPUT (SUMMARY) file: /tests/cal_val/user_output/bbcal_191010.sum1
FROM INPUT RECORD NUMBER: 1
NBB raw temps (apex, bottom, top): 318.247, 318.453, 0.000
NBB AVERAGE temperature: 273.182
......
......@@ -15,8 +15,8 @@ NBB Weights: 0.81100 0.18900 0.00000
NBB Offsets: 0.00000 0.00000 0.00000
IBB Weights: 0.81100 0.09450 0.09450
IBB Offsets: 0.00000 0.00000 0.00000
ASCII Output (MLT) file: /tests/cal_val/user_output/AE191010_output/bbcal.mlt2
TEXT OUTPUT (SUMMARY) file: /tests/cal_val/user_output/AE191010_output/bbcal.sum2
ASCII Output (MLT) file: /tests/cal_val/user_output/bbcal_191010.mlt2
TEXT OUTPUT (SUMMARY) file: /tests/cal_val/user_output/bbcal_191010.sum2
FROM INPUT RECORD NUMBER: 1
NBB raw temps (apex, bottom, top): 318.247, 318.453, 0.000
NBB AVERAGE temperature: 273.182
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Mean and Standard deviation of Observed minus Predicted BT
Instrument: AERI-118
Date of measurements: 2017-04-18
Time: 17:02 - 17:35
Input Records: [1, 2, 3, 4]
Vmean DIFFmean RSSmean MeanSigmaObs MeanSigmaPred SigmaWave V1 V2
NBB
1000.00 0.00565 0.01615 0.01612 0.00000 0.00110 900.00 1100.00
Vmean DIFFmean RSSmean MeanSigmaObs MeanSigmaPred SigmaWave V1 V2
IBB
1000.00 nan nan nan 0.00000 nan 900.00 1100.00
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Mean and Standard deviation of Observed minus Predicted BT
Instrument: AERI-118
Date of measurements: 2017-04-18
Time: 17:02 - 17:35
Input Records: [1, 2, 3, 4]
Vmean DIFFmean RSSmean MeanSigmaObs MeanSigmaPred SigmaWave V1 V2
NBB
2150.00 -0.02016 0.02188 0.02176 0.00000 0.00233 2100.00 2200.00
Vmean DIFFmean RSSmean MeanSigmaObs MeanSigmaPred SigmaWave V1 V2
IBB
2150.00 nan nan nan 0.00000 nan 2100.00 2200.00
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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