In [5]:
%pylab notebook
from charistools.readers import ModisTileCube
from charistools.readers import read_tile
import matplotlib.pyplot as plt
from netCDF4 import Dataset
import numpy as np
In [2]:
%cd /Users/brodzik/projects/CHARIS/albedo/MOD10A1_Collection_005/MOD10A1_005_GF/v06/h23v05
%ls
In [6]:
h23Filev5 = "/Users/brodzik/projects/CHARIS/albedo/MOD10A1_Collection_005/" \
"MOD10A1_005_GF/v05/h23v05/MOD10A1_GF_Albedo_shortwave.v0.5.h23v05_2001.h5"
h23Filev6 = "/Users/brodzik/projects/CHARIS/albedo/MOD10A1_Collection_005/" \
"MOD10A1_005_GF/v06/h23v05/MOD10A1_GF_Albedo_shortwave.v0.6.h23v05_2001.h5"
print(h23Filev5)
print(h23Filev6)
In [9]:
tile5 = ModisTileCube(filename=h23Filev5, varname='albedo_shortwave')
tile6 = ModisTileCube(filename=h23Filev6, varname='albedo_shortwave')
In [10]:
albedo5 = tile5.read(doy=180)
albedo6 = tile6.read(doy=180)
In [11]:
print(type(albedo5))
print(type(albedo6))
In [13]:
#print(albedo5.count())
print(albedo6.count())
In [17]:
print(np.amin(albedo5), np.amax(albedo5))
print(np.amin(albedo5[albedo5 > 0.]), np.amax(albedo5))
print(np.amin(albedo6), np.amax(albedo6))
In [18]:
sub = albedo5[albedo5 > 0.]
len(sub)
Out[18]:
In [32]:
_albedo5 = np.ma.masked_where(np.ma.getmask(albedo6), albedo5)
In [34]:
diff = albedo6 - _albedo5
print(np.amin(diff), np.amax(diff))
In [35]:
test = albedo5[np.ma.getmask(albedo6)]
len(test)
Out[35]:
In [36]:
print(np.amin(test), np.amax(test))
In [47]:
test = np.ma.masked_array(np.arange(5.), mask=[False, True, True, False, False])
print(type(test))
print(test)
In [55]:
new = np.arange(5)
print(new)
print(new[np.logical_and(~np.ma.getmaskarray(test), test > 2)])
print(new[np.logical_and(~np.ma.getmaskarray(test), test <= 2)])
In [54]:
other = np.arange(5)
print(type(other))
print(other)
print(np.ma.getmaskarray(other))
_other = np.ma.masked_where(np.ma.getmask(test), other)
print(type(_other))
print(_other)
print(np.ma.getmaskarray(_other))
In [39]:
myarr = np.arange(5)
_myarr = myarr.copy()
print(myarr)
print(_myarr)
In [40]:
_myarr[3] = 0
print(myarr)
print(_myarr)
In [7]:
plt.imshow(albedo)
Out[7]:
In [8]:
%cd /Users/brodzik/projects/CHARIS/snow_cover/modice.v0.4/min05yr_nc
%ls
In [9]:
modice = read_tile(filename="MODICE.v0.4.h23v05.1strike.min05yr.mask.nc",
varname="modice_min_year_mask")
In [10]:
np.amin(modice), np.amax(modice)
Out[10]:
In [14]:
plt.imshow(modice)
Out[14]:
In [12]:
unclass = np.logical_and(albedo.mask, modice == 2).astype(float)
print(unclass.shape)
print(np.amin(unclass))
print(np.amax(unclass))
In [13]:
plt.imshow(unclass)
Out[13]:
In [ ]:
x = np.arange(5.)
x[2] = 1.e20
x[3] = 1.e20
x
In [ ]:
y = np.ma.masked_values(x,1.e20)
print(type(y))
print(y)
In [ ]:
modice = np.asarray([0, 2, 0, 2, 1])
modice
In [ ]:
print(y.mask)
print(modice == 2)
In [ ]:
np.logical_and(y.mask, modice == 2).astype(float)
In [ ]:
unclass = np.zeros(5)
unclass[np.logical_and(y.mask, modice == 2)] = 1
unclass
#idx = where(y is masked and modice==2)
In [ ]:
[np.logical_and(y.mask, modice == 2)] = 1