In [1]:
%cd /vagrant/source/charistools/test/test_files
%ls


/vagrant/source/charistools/test/test_files
Kta_hypso_100m.3col.csv
Kta_hypso_100m.csv
test.3x4.bin
test_basin.500.ALBEDO_MCD.0035.ablation.dat
test_basin.500.ALBEDO_MCD.0035.ablation.dat~
test_basin.500.ALBEDO_MCD.0035.snow_off_ice.dat
test_basin.500.ALBEDO_MCD.0035.snow_off_ice.dat~
test_basin.500.ALBEDO_MCD.0035.snow_on_ice.dat
test_basin.500.ALBEDO_MCD.0035.snow_on_ice.dat~
test_basin.500.temperature.dat
test_basin.500.temperature.dat~
test.sca_by_elev.txt

In [2]:
from charistools.hypsometry import Hypsometry
import numpy as np
import pandas as pd

In [3]:
sol_hyps = Hypsometry('test_basin.500.ALBEDO_MCD.0035.snow_off_ice.dat')
t_hyps = Hypsometry('test_basin.500.temperature.dat')

In [4]:
sol = sol_hyps.data.copy()
t = t_hyps.data.copy()

In [5]:
sol, t


Out[5]:
(            3000.  3500.  4000.  4500.  5000.
 Date                                         
 2001-04-01   3605   9002  17390      0   1000
 2001-05-01   1130   5689  14800  23382   1000
 2001-06-01    100   1507   9089  18394  21466
 2001-07-01      9    255   2514  10954  14766
 2001-08-01     12     92    175   3324   9067
 2001-09-01     28    270   3275  12291  19570,
               3000.    3500.   4000.   4500.   5000.
 Date                                                
 2001-04-01   2.9000   1.6000  0.3000  0.0000  0.0000
 2001-05-01   6.7097   4.4839  1.9032  0.3548 -1.0000
 2001-06-01   9.8667   7.6000  4.5667  1.8667  0.4000
 2001-07-01  13.0000  10.5806  7.4839  4.3226  1.4516
 2001-08-01  13.3871  10.9355  7.7742  4.5484  1.3871
 2001-09-01   9.6000   7.2333  4.2000  1.6000  0.2333)

In [14]:
t[['4000.','5000.']]


Out[14]:
4000. 5000.
Date
2001-04-01 0.3000 0.0000
2001-05-01 1.9032 -1.0000
2001-06-01 4.5667 0.4000
2001-07-01 7.4839 1.4516
2001-08-01 7.7742 1.3871
2001-09-01 4.2000 0.2333

In [18]:
#melt = sol.multiply(t[['4000.','5000.']],fill_value=0.)
melt = sol * t[['4000.','5000.']]
melt


Out[18]:
3000. 3500. 4000. 4500. 5000.
Date
2001-04-01 NaN NaN 5217.0000 NaN 0.0000
2001-05-01 NaN NaN 28167.3600 NaN -1000.0000
2001-06-01 NaN NaN 41506.7363 NaN 8586.4000
2001-07-01 NaN NaN 18814.5246 NaN 21434.3256
2001-08-01 NaN NaN 1360.4850 NaN 12576.8357
2001-09-01 NaN NaN 13755.0000 NaN 4565.6810

In [6]:
sol.index


Out[6]:
DatetimeIndex(['2001-04-01', '2001-05-01', '2001-06-01', '2001-07-01',
               '2001-08-01', '2001-09-01'],
              dtype='datetime64[ns]', name=u'Date', freq=None)

In [ ]:
ddfs = np.arange(len(sol.index))
ddf_series = pd.Series(data=ddfs, index=sol.index, name="Snow_DDF_mm_pday_pdegC")
ddf_series

In [ ]:
sol.multiply(ddf_series, axis=0)

In [21]:
sol


Out[21]:
3000. 3500. 4000. 4500. 5000.
Date
2001-04-01 3605 9002 17390 0 1000
2001-05-01 1130 5689 14800 23382 1000
2001-06-01 100 1507 9089 18394 21466
2001-07-01 9 255 2514 10954 14766
2001-08-01 12 92 175 3324 9067
2001-09-01 28 270 3275 12291 19570

In [22]:
sol * 10


Out[22]:
3000. 3500. 4000. 4500. 5000.
Date
2001-04-01 36050 90020 173900 0 10000
2001-05-01 11300 56890 148000 233820 10000
2001-06-01 1000 15070 90890 183940 214660
2001-07-01 90 2550 25140 109540 147660
2001-08-01 120 920 1750 33240 90670
2001-09-01 280 2700 32750 122910 195700

In [ ]:
doy = sol.index.dayofyear

In [ ]:
doy

In [ ]:
type(sol.index)

In [ ]:
tmp = sol.index
tmp

In [ ]:
test = tmp[0].replace(year=2000)
test
new = [test]
new

In [ ]:
import calendar

In [ ]:
leaptest = [calendar.isleap(year) for year in sol.index.year]
leaptest

In [ ]:
leaptest[0] = True
leaptest

In [ ]:
daysinyear = [366 if x else 365 for x in leaptest]

In [ ]:
print(isleap)
print(daysinyear)

In [ ]:
for x in isleap:
    print x

In [ ]:
[1 if isleap[x] else 365 for x in isleap]

In [33]:
pow(10.,-4)


Out[33]:
0.0001

In [ ]: