OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
color_dtdb.py File Reference

Go to the source code of this file.

Namespaces

 color_dtdb
 

Functions

def rgb2ycbcr (r, g, b)
 
def ycbcr2rgb (y, cb, cr)
 
def rgb2yuv (r, g, b)
 
def yuv2rgb (y, u, v)
 
def rgb2ycbcr2 (r, g, b)
 
def ycbcr2rgb2 (y, pb, pr)
 
def histeq (im, nbr_bins=256)
 
def pseudocolor (val, minval, maxval)
 
def plot_scalar_array (ds_str, title_str, mina, maxa)
 
def plot_rgb ()
 

Variables

int W410 = 0
 
int W445 = 1
 
int W490 = 2
 
int W550 = 3
 
int W670 = 4
 
int W865 = 5
 
int W1240 = 6
 
int W1610 = 7
 
int W2250 = 8
 
int NWL = 9
 
list wlstr = ["410","445","490","550","670","865","1240","1610","2250"]
 
float Kb = 0.114
 
float Kr = 0.299
 
 RGB2YCbCr = np.array([[0.257, 0.504, 0.098],[-0.148, -0.291, 0.439],[0.439, -0.368, -0.071]])
 
 YCbCr2RGB = np.array([[1.0, 0.0, 1.596],[1.0, -0.392, -0.813],[1.0, 2.017, 0.0]])
 
 RGB2YUV = np.array([[0.299, 0.587, 0.114],[-0.14713, -0.28886, 0.436],[0.615, -0.51499, -0.10001]])
 
 YUV2RGB = np.array([[1.0, 0.0, 1.13983],[1.0, -0.39465, -0.58060],[1.0, 2.03211, 0.0]])
 
 args = sys.argv
 
 dtdb_dirpath = args[1]
 
 dataset = args[2]
 
string colors = "123"
 
int bc = np.int(args[3][0])-1
 
int gc = np.int(args[3][1])-1
 
int rc = np.int(args[3][2])-1
 
string logfile = ""
 
string command = "date > " + logfile
 
 result = os.system(command)
 
 dtdb_dircontents = os.listdir(dtdb_dirpath)
 
string filepath = dtdb_dirpath + "/" + x
 
string image_path = dtdb_dirpath + "/IMAGES"
 
string outfilename = x + "_" + dname + ".png"
 
string path = image_path + "_" + dname
 
string outpath = path + "/" + outfilename
 
string title_str = ' Angstrom Exponent'
 
string ds_str = 'ae'
 
float maxa = 2.0
 
float mina = 0.0
 
string image_path1 = image_path + "/histograms"
 
string outfilename1 = x + "_hist_410.png"
 
string outpath1 = image_path1 + "/" + outfilename1
 
string image_path2 = image_path + "/maps"
 
string outfilename2 = x + "_map.png"
 
string outpath2 = image_path2 + "/" + outfilename2
 
list ct = [3200,3200]
 
list st = [0,0]
 
int refwl = W865
 
int refbs = W410
 
int nbins = 100
 
int hmin = 0
 
int hmax = 10
 
float max0 = 0.0
 
float min0 = -2.0
 
float max1 = 2.5
 
float min1 = -0.5
 
 hist = np.zeros((NWL, nbins, nbins))
 
 cmap = cm.get_cmap('turbo')
 
 fig1 = plt.figure(figsize=(16,10))
 
 fig2 = plt.figure(figsize=(16,8))
 
def irgb = plot_rgb()
 
 ax2 = fig2.add_subplot(2,4,1)
 
 rfl0 = xr.load_dataset(filepath,group='/observations')['rhot_'+wlstr[refwl]].values[st[0]:st[0]+ct[0],st[1]:st[1]+ct[1]]
 
 lrfl0 = np.log10(np.clip(rfl0, a_min=0.0001, a_max=1.0))
 
 rflbs = xr.load_dataset(filepath,group='/observations')['rhot_'+wlstr[refbs]].values[st[0]:st[0]+ct[0],st[1]:st[1]+ct[1]]
 
 lrflbs = np.log10(np.clip(rflbs, a_min=0.0001, a_max=1.0))
 
 ml = mpl.cm.ScalarMappable(norm=None, cmap=cmap)
 
 aec = ml.to_rgba(lrfl0, alpha=None)
 
int wl1 = 1
 
int wl2 = 1
 
bool bwl2 = False
 
 rfl1 = xr.load_dataset(filepath,group='/observations')['rhot_'+wlstr[wl]].values[st[0]:st[0]+ct[0],st[1]:st[1]+ct[1]]
 
 lrfl1 = lrflbs - np.log10(np.clip(rfl1, a_min=0.0001, a_max=1.0))
 
 edges
 
 range
 
 bins
 
 density
 
 ax1 = fig1.add_subplot(2,4,wl1)
 
 xpos0
 
 ypos0
 
 cp1 = ax1.contourf(xpos0/2, ypos0/2, np.clip(hist[wl].T, a_min=hmin, a_max=hmax), levels=100, cmap=cmap)
 
bool bticks = True
 
 labelleft
 
 left
 
 b
 
 True
 
 which
 
 color
 
 linestyle
 
 alpha
 
 facecolor
 
 loc = plt.LinearLocator(11)
 
 tvals = loc.tick_values(hmin, hmax)
 
 bottom
 
 top
 
 right
 
 wspace
 
 hspace
 
 cb_ax = fig1.add_axes([0.93, 0.1, 0.02, 0.8])
 
 cax
 
 ticks
 
 bluec = xr.load_dataset(filepath,group='/observations',mask_and_scale=True)['rhot_490'].values
 
 greenc = xr.load_dataset(filepath,group='/observations',mask_and_scale=True)['rhot_550'].values
 
 redc = xr.load_dataset(filepath,group='/observations',mask_and_scale=True)['rhot_670'].values
 
 ocean = xr.load_dataset(filepath,group='/geophysical_data')['AOT_ocean']
 
 land = xr.load_dataset(filepath,group='/geophysical_data')['AOT_land']
 
 cldmsk = xr.load_dataset(filepath,group='/meteorology')['cloud_mask']
 
 cldtst = xr.load_dataset(filepath,group='/quality')['cloud_test']
 
 nomask = np.zeros_like(cldmsk, dtype=np.int16)
 
 ro = np.clip(np.nan_to_num(redc),0,10.0)
 
 go = np.clip(np.nan_to_num(greenc),0,10.0)
 
 bo = np.clip(np.nan_to_num(bluec),0,10.0)
 
 y = y/np.max(y)
 
 u
 
 v
 
 yh
 
 Y_cdf
 
 mino_all = min(np.min(ro), np.min(go), np.min(bo))
 
float maxo_all = max(np.max(ro), np.max(go), np.max(bo)) + 0.001
 
float gamma = 1.0
 
float ga = np.ones_like(ro)*gamma
 
 rg = np.power(ro, ga)
 
 gg = np.power(go, ga)
 
 bg = np.power(bo, ga)
 
 yg = np.power(yh, ga)
 
 ys = np.divide(yg,y)
 
int scale = 255
 
 im_red = im.fromarray(np.uint8(np.clip(rg,0,1.0)*scale))
 
 im_green = im.fromarray(np.uint8(np.clip(gg,0,1.0)*scale))
 
 im_blue = im.fromarray(np.uint8(np.clip(bg,0,1.0)*scale))
 
 im_rgb = im.merge("RGB", (im_red, im_green, im_blue))
 
 set = dataset.partition("/")