Skip to content
Snippets Groups Projects
Commit 886650f1 authored by Greg Quinn's avatar Greg Quinn
Browse files

Read in Liam's wavenumber-based VIIRS SRFs

parent 1e5fab38
No related branches found
No related merge requests found
from collections import deque
import sys
import numpy as np
......@@ -16,37 +17,50 @@ def parse_srf_file(filename):
and weights.
"""
# create an SRF object with the channel number and arrays
# to represent the RSR
# this function will return a dict of SRF objects indexed by band
srf_info = {}
with open(filename) as f:
wn_list, resp_list = [], []
for line in f:
if line.startswith('#'):
continue
wl_nm, resp = (float(x) for x in line.split())
wn = 1e7 / wl_nm
resp /= wn**2
wn_list.append(wn)
resp_list.append(resp)
srf = SRF()
srf.channel = filename[17:20]
srf.wavenumbers = np.array(wn_list[::-1])
srf.weights = np.array(resp_list[::-1])
return srf
if len(sys.argv) < 2:
print 'usage: %s <srf_file> ... <output_filename>' % sys.argv[0]
# skip header line
f.readline()
# remainder of file contains records that each have the band
# number, the number of points in the SRF, the first then last
# wavenumber, then the SRF response values
tokens = deque(f.read().split())
while tokens:
band = int(tokens.popleft())
points = int(tokens.popleft())
nu_begin = float(tokens.popleft())
nu_end = float(tokens.popleft())
nu = np.linspace(nu_begin, nu_end, points)
F = np.array([float(tokens.popleft()) for i in range(points)])
srf = SRF()
srf.channel = band
srf.wavenumbers = nu
srf.weights = F
srf_info[band] = srf
return srf_info
if len(sys.argv) != 3:
print 'usage: %s <srf_file> <output_filename>' % sys.argv[0]
sys.exit(1)
srf_filenames = sys.argv[1:-1]
output_filename = sys.argv[-1]
srf_filename = sys.argv[1]
output_filename = sys.argv[2]
# ingest SRF data for the given filenames
srf_info = [parse_srf_file(srf_filename) for srf_filename in srf_filenames]
srf_info = parse_srf_file(srf_filename)
srf_info = [srf_info[band] for band in (13, 15, 16)]
# create an array of the M-band numbers
# FIXME: we'll need to support I-bands too
viirs_bands = np.array([int(srf.channel[1:3]) for srf in srf_info], np.int32)
viirs_bands = np.array([srf.channel for srf in srf_info], np.int32)
# create an array of CrIS wavenumbers
# FIXME: is this right?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment