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

Added some plotting and processing options

parent c9cc3eb3
......@@ -20,6 +20,7 @@
"""
import matplotlib
matplotlib.use('Agg')
import copy
import numpy as np
import glob
from optparse import OptionParser
......@@ -866,7 +867,9 @@ class Scene(object):
Projection='lcc',
edgecolor='none',
verbose=False,
test=None
test=None,
db_ash=3.0,
db_unk=2.0
):
import matplotlib.pyplot as plt
from matplotlib import colors, cm
......@@ -1177,6 +1180,41 @@ class Scene(object):
levels=[-0.5, -0.2]
contour_colors = ['r', 'k']
elif Type=='SEVIRI_dBT_AF':
# Ash flag using SEVIRI dbt
# pdb.set_trace()
data = copy.deepcopy(self.SEVIRI_dBT)
data[:] = 1 # unknmown
data[self.SEVIRI_dBT < -0.5] = 2 # ash
data[self.SEVIRI_dBT > -0.2] = 0 # no ash
levels=[1, 2]
vmin= 0
vmax= 2
step= 1
cblabel='0: No Ash 1: Unknown 2: Ash'
levels=[0.5, 1.5]
contour_colors = ['g', 'r']
elif Type=='IASI_dBT_AF':
# Ash flag using IASI dbt
# We get a lot of false detection near the edges --
# doing a quick and easy path length correction
# import pdb;pdb.set_trace()
data = copy.deepcopy(self.dBT)
data[:] = 1 # unknown
data[self.dBT * np.cos(self.sza/180.*np.pi) > db_ash] = 2 # ash
data[self.dBT * np.cos(self.sza/180.*np.pi) < db_unk] = 0 # no ash
vmin= 0
vmax= 2
step= 1
levels=[.5, 1.5]
cblabel='0: No Ash 1: Unknown 2: Ash'
# levels=[self.SEVIRI_dBTLimit]
contour_colors = ['g', 'r']
elif Type=='SEVIRI_AshML':
data = self.MassLoading[:]
# data = self.AshML[:]*1000 # Convert from g/m**3 to g/m**2 assuming a 1 km thick cloud
......@@ -1217,7 +1255,7 @@ class Scene(object):
#cmap = plt.get_cmap('gist_ncar_r')
ms = cm.ScalarMappable(norm=norm, cmap=cmap)
ip=0
Ntot, = data.shape #self.Nspectra*self.Nscanlines
# Ntot, = data.shape #self.Nspectra*self.Nscanlines
# eso: found a file where len(lons)=2756 but len(data)=2760 ...
Ntot, = self.lons.shape #self.Nspectra*self.Nscanlines
......@@ -1295,6 +1333,7 @@ class Scene(object):
# pdb.set_trace()
cs = m.contour(Xi,Yi,DATA,levels, colors=contour_colors, linewidths=1.5, latlon=True) #, tri=True)
# import pdb; pdb.set_trace()
if not test:
ticks = np.arange(vmin,vmax+0.0001,step)
cb=m.colorbar(im,location='right', pad="5%", ticks=ticks)
......@@ -1346,6 +1385,7 @@ class Scene(object):
self.lons = ncfile.variables['lon'][:]
self.ascan = ncfile.variables['ascan'][:]
self.atrack = ncfile.variables['atrack'][:]
self.sza = ncfile.variables['sza'][:]
try:
self.dBT = ncfile.variables['dBT'][:]
except:
......
......@@ -310,3 +310,5 @@ if __name__ == "__main__":
# Remove lock file
# if os.path.isfile(lock_file):
# os.unlink(lock_file)
print("Processing finished at ", dt.datetime.utcnow().strftime("%Y-%m-%d %H:%M"))
......@@ -21,7 +21,13 @@ import importlib
importlib.reload(IASITools)
def plotCombined(file_name, ignore=False, Type=None):
def plotCombined(file_name,
ignore=False,
Type=None, proj='PS_NE',
verbose=False,
db_ash=None,
db_unk=None,
):
## :TODO: make input arg
# Type='dBT_already_calculated'
if Type is None or Type == "SEVIRI_dBT":
......@@ -33,6 +39,12 @@ def plotCombined(file_name, ignore=False, Type=None):
elif Type == "SEVIRI_AshML":
plotmethod = 'SEVIRI_AshML'
str1 = 'IASI_dBT'
elif Type == "SEVIRI_dBT_AF":
plotmethod = "SEVIRI_dBT_AF"
str1 = 'IASI_dBT'
elif Type == "IASI_dBT_AF":
plotmethod = "IASI_dBT_AF"
str1 = 'IASI_dBT'
else:
print("Invalid plot Type, exiting")
sys.exit(0)
......@@ -61,7 +73,11 @@ def plotCombined(file_name, ignore=False, Type=None):
test=True,
PlotAshContour=True,
PlotFile=fnpng,
Projection='PS_NE')
# Projection='PS_NE')
Projection=proj,
verbose=verbose,
db_ash=db_ash,
db_unk=db_unk)
if __name__ == "__main__":
......@@ -81,12 +97,25 @@ if __name__ == "__main__":
parser.add_argument('-t', '--type',
dest='Type',
default ='SEVIRI_dBT',
help="plot type [IASI_dBT, SEVIRI_dBT, SEVIRI_AshML]")
help="plot type [IASI_dBT, SEVIRI_dBT, SEVIRI_AshML, SEVIRI_dBT_AF, IASI_dBT_AF]")
parser.add_argument('-m', '--map_projection',
dest='map_projection',
default ='PS_NE',
help="map proj [try: PS_NE (=northern europe), lcc(=fit to swath)]")
parser.add_argument('-i', '--ignore_date',
dest='ignore_date', action="store_true",
default=False,
help="Just plot the file, ignoring date and time info from file name")
parser.add_argument('--dba',
dest='dba', default=3.0,
help="IASI dBT ash limit (for IASI ash flag plot only)")
parser.add_argument('--dbu',
dest='dbu', default=2.0,
help="IASI dBT unknown limit")
parser.add_argument('-v',
dest='verbose', action="store_true",
default=False,
help="")
......@@ -95,7 +124,7 @@ if __name__ == "__main__":
# Plot file (skip if size 0)
full_file_name = os.path.join(args.path_name, args.file_name)
if os.stat(full_file_name).st_size > 0:
plotCombined(full_file_name, ignore=args.ignore_date, Type=args.Type)
plotCombined(full_file_name, ignore=args.ignore_date, Type=args.Type, proj=args.map_projection, verbose=args.verbose, db_ash=float(args.dba), db_unk=float(args.dbu))
......
Supports Markdown
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