In [1]:
%pylab inline
import numpy as np
import pandas as pd
import rasterio
from charistools.modelEnv import ModelEnv
from netCDF4 import Dataset


Populating the interactive namespace from numpy and matplotlib

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]:
'/projects/CHARIS/charistools_test_data/MODSCAG_GF/MODSCAG_GF_Snow.v0.4.h23v05_2001.h5'

In [5]:
f = Dataset(modscag_filename, 'r', 'HDF5')
d = f.groups['500m'].variables['fsca']

In [6]:
f


Out[6]:
<type 'netCDF4._netCDF4.Dataset'>
root group (NETCDF4 data model, file format HDF5):
    dimensions(sizes): 
    variables(dimensions): 
    groups: 500m

In [7]:
np.shape(d)


Out[7]:
(365, 2400, 2400)

In [8]:
(days, rows, cols) = np.shape(d)
data = np.zeros((rows,cols))
data.dtype


Out[8]:
dtype('float64')

In [9]:
d.dtype


Out[9]:
dtype('uint8')

In [10]:
data = d[0, :, :].T
print data.shape
print np.amin(data), np.amax(data)


(2400, 2400)
0 100

In [11]:
new = np.zeros((rows,cols))
new.shape


Out[11]:
(2400, 2400)

In [12]:
new[data > 0] = 255

In [16]:
new[255 if k > 0 else k for k in data]


  File "<ipython-input-16-33575f1cc0e0>", line 1
    new[255 if k > 0 else k for k in data]
                              ^
SyntaxError: invalid syntax

In [13]:
plt.imshow(new, cmap=plt.cm.gray, vmin=0, vmax=255 )


Out[13]:
<matplotlib.image.AxesImage at 0x7f035cfece90>

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 [ ]: