In [1]:
%pylab inline
import numpy as np
import pandas as pd
import rasterio
from charistools.modelEnv import ModelEnv
from netCDF4 import Dataset
In [2]:
configFile = "/vagrant/source/charistools/test/modis_tiles_config.ini"
In [3]:
myEnv = ModelEnv(tileConfigFile=configFile, topDir='/projects/CHARIS/charistools_test_data')
In [4]:
modscag_filename = myEnv.forcing_filename(type='modscag_gf', tileID="h23v05", yyyy=2001,verbose=True)
modscag_filename
Out[4]:
In [5]:
f = Dataset(modscag_filename, 'r', 'HDF5')
d = f.groups['500m'].variables['fsca']
In [6]:
f
Out[6]:
In [7]:
np.shape(d)
Out[7]:
In [8]:
(days, rows, cols) = np.shape(d)
data = np.zeros((rows,cols))
data.dtype
Out[8]:
In [9]:
d.dtype
Out[9]:
In [10]:
data = d[0, :, :].T
print data.shape
print np.amin(data), np.amax(data)
In [11]:
new = np.zeros((rows,cols))
new.shape
Out[11]:
In [12]:
new[data > 0] = 255
In [16]:
new[255 if k > 0 else k for k in data]
In [13]:
plt.imshow(new, cmap=plt.cm.gray, vmin=0, vmax=255 )
Out[13]:
In [ ]:
print testf
print testb
In [ ]:
testb = testf
testb.dtype
In [ ]:
print np.amin(mask), np.amax(mask)
In [ ]:
test = np.reshape(np.arange(12),(3,4))
test
In [ ]:
target = np.reshape(np.zeros(12),(3,4))
target
In [ ]:
target[test != 5] = 1
target
In [ ]:
mask.dtype
In [ ]:
len(test[test > 5.])
In [ ]:
for i in (np.arange(77-29+1)+29)*100:
print i
In [ ]:
import datetime
str(str(datetime.datetime.now()))
In [ ]:
test = np.arange(10.)
In [ ]:
test
In [ ]:
' '.join(str(test)) + '\n'
In [ ]:
test
In [ ]:
[str(x) for x in test]
In [ ]:
test.shape
In [ ]: