Commit c9cc3eb3 authored by Espen Sollum's avatar Espen Sollum
Browse files

bugfix: IASIRAD needs to be cast to 64 bit float. Merge this with branch satdata

parent 3a370266
......@@ -163,8 +163,8 @@ class Scene(object):
for record in bfr:
# One record contains one scan line
if verbose:
print("RECORD", ir)
# if verbose:
# print("RECORD", ir)
for entry in record:
if verbose:
print("ENTRY", entry.name)
......@@ -253,8 +253,8 @@ class Scene(object):
f = open(fn)
while True:
if verbose:
print("message: %s" % cnt)
# if verbose:
# print("message: %s" % cnt)
# The program will usually hang here if bufr file is corrupt
try:
......@@ -340,9 +340,6 @@ class Scene(object):
self.Nscanlines = cnt-1
# import pdb; pdb.set_trace()
#####
swath = np.concatenate(swath)
# sf = np.concatenate(sf)
# SF = np.zeros([self.NwvlsInFile, self.Nspectra]) # Scale factors
......@@ -371,16 +368,10 @@ class Scene(object):
# SF[self.startCh[i]-1:self.endCh[i], :] = sf[0][j]
SF[k,self.startCh[i]-1:self.endCh[i], :] = sf[k][j]
##TEST
# IASIRAD=np.zeros((self.Nscanlines,self.NwvlsInFile,self.Nspectra),
# dtype='float64')
IASIRAD=np.zeros((self.Nscanlines,self.Nwvls,self.Nspectra),
dtype='float64')
# IASIRAD[:,:,:]=np.resize(swath,(self.Nscanlines,self.Nwvls,self.Nspectra))
IASIRAD=np.resize(np.float64(swath),(self.Nscanlines,self.Nwvls,self.Nspectra))
# IASIRAD[:,:,:]=np.resize(swath,(self.Nscanlines,self.NwvlsInFile,self.Nspectra))
## TEST
IASIRAD[:,:,:]=np.resize(swath,(self.Nscanlines,self.Nwvls,self.Nspectra))
# import pdb ; pdb.set_trace()
# ESO mask out invalid, set to mask value
# IASIRAD[IASIRAD == 2147483647] = -2147483648
......@@ -411,8 +402,6 @@ class Scene(object):
isp=isp+1
ind=ind+1
ir=ir+1
#####
self.heights = np.concatenate(height)
self.szas = np.concatenate(sza)
......@@ -420,10 +409,9 @@ class Scene(object):
self.lats = np.concatenate(lat)
# eso test
self.SF = SF
self.sf = sf
self.IASIRAD = IASIRAD
# self.SF = SF
# self.sf = sf
# self.IASIRAD = IASIRAD
if self.lons.shape[0] != self.Nscanlines*self.Nspectra:
print(self.lons.shape, self.Nscanlines*self.Nspectra)
......@@ -1700,8 +1688,8 @@ def GetLatLonRegion(fn,verbose=False):
f = open(fn)
cnt = 1
while True:
if verbose:
print("message: %s" % cnt)
# if verbose:
# print("message: %s" % cnt)
bfr = bufr.codes_bufr_new_from_file(f)
if bfr is None:
break
......
......@@ -154,6 +154,10 @@ if __name__ == "__main__":
default=config.PNG_OUT,
dest='png_dir',
help="Output dir.")
parser.add_argument('--interact_dir',
default=None,
dest='interact_dir',
help="Running in interactive mode, give directory for IASI bufr files.")
args = parser.parse_args()
......@@ -164,8 +168,8 @@ if __name__ == "__main__":
print("Nothing to do (give at least one of -p, -n)")
# sys.exit(0)
# Skip these steps if just processing 1 file
if args.file_name is None:
# Skip these steps if not operational processing
if args.file_name is None and args.interact_dir is None:
# Lock file handling (avoid more than 1 running instance)
pid = str(os.getpid())
......@@ -190,9 +194,27 @@ if __name__ == "__main__":
else:
fs = path+"W_XX-*_eps_o_l1.bin"
# All file names
fns = sorted(glob(fs))
elif args.interact_dir is not None:
"""
Process 1 directory
TODO: can remove this clause and just set path = IASI_PATH above
with minor changes
"""
path = args.interact_dir
if args.old_iasi:
fs = path+"iasi_*bufr"
else:
fs = path+"W_XX-*_eps_o_l1.bin"
# All file names
fns = sorted(glob(fs))
else:
fns = [args.file_name]
......
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