Wednesday, March 25, 2015

DGVM and LSM

很高兴在这个时刻读到了Anne Quillet的综述文章。
1. The modules representing the interactions between biosphere and climate in GCM are SVAT.
Until 1980, land surface parameterizations were introduced in GCM computations. However, all the SVAT are static and didn't include dynamical component of vegetation.
SVAT is a scheme developed specially for GCM.
But DGVM can be directly coupled to GCM.

关于数据,观测手段等文章,一直觉得没有兴趣去了解。我觉得必须要有硬性的标准,像上课一样。

Sunday, March 22, 2015

泪流以后是坚持

无聊中打开油管首页推荐的李健在央视《夜话》的访谈。

大学的时候我对李健已经很了解了。对我来言他不是一种现象,而是一种音乐习惯,习惯了人淡如菊的他,习惯有他那种宁静隽永的力量注入生活。是以,我其实很少对李健的人生,乃至我自己的人生做过刻意的思考。

没想到,在节目中间,李健的高中、清华同学高鹏说了一番话,把我触动了。高鹏曾是清华合唱团团长,目前是金融家,在外人眼里有着非常体面的生活和工作。他和李健有着完全相似的校园轨迹,却有着完全不同的人生轨迹。

我能完全理解这种表面的相似,主要是校园里选择相对局限的这种客观因素造成的。无论升学、保研、出国、找工作,高中大学校园里最重要的社会衡量标准,无非还是高考成绩、绩点、寄托成绩和文章数量此类。然而清华北大里,哪个人不是三头六臂,才艺加身,远的不说吧,我的三位室友就分别会弹古筝,拉小提琴,弹钢琴。可是仔细想想,有多少人是出自真心对艺术的喜爱,出自和李健相似的对音乐的痴迷。如今坚持音乐理想的人凤毛麟角,在李健那个年代(2000)还算正常,但在今天,却显得那么的不合时宜。

Sunday, March 8, 2015

[Review] Surface energy fluxes

Surface energy fluxes are the exchanges of energy, water and other atmospheric constituents on the surface, such as water molecule.
Surface energy fluxes mainly occur in the form of radiant energy, latent heat, sensible heat, and soil heat. The residue term of the heat fluxes is the heat that diffuses into the ground and be stored. The heat storage include physical energy storage, biochemical energy storage (2% of the incoming solar energy, which is amazingly small) , and the advected energy (which is important at the heterogeneous surface, such as oasis).

Some typical numbers (w/m2),
Downward shortwave radiation, 350
Longwave net radiation, Nighttime net radiation, -75

Terrestrial surfaces with different land cover types substantially alter the amount of the solar radiation. And the partitioning into latent and sensible heat changes from day to night.
(1) From albedo perspective:
dark color and rougher surface reflects less solar radiation, so therefore higher net radiation. Forest, wet soil have higher incoming energy.

(2) From partitioning in latent and sensible heat perspective: 
(a) For soil, wet soil is latent heat dominant, while dry soil is sensible heat dominant. 
(b) For forest, latent heat is slightly greater than sensible heat.
(c) For crop, latent heat is dominant. Why no sensible heat?


(3) From daytime and nighttime perspective: 
Wet soil have better thermal conductivity and store more heat at night.

Tuesday, February 10, 2015

[Python] Plot

# Set the colorbar

(1)
plt.imshow(data, vmin=0, vmax=10, cmap='jet', aspect='auto')
(2)
plt.pcolor(X, Y, v, cmap=cm)
plt.clim(-4,4)
plt.show()

(3) Change the range of a colormap for a certain values
import matplotlib.colors as colors
(a)
cmap = cm.get_cmap('jet', 20)
cvals = cmap(arange(5, 20, 1))
ncmap = colors.ListerdColormap(mcolors)
(b)
mcolors = plt.cm.jet(linspace(0.3, 1, 256))
ncmap = colors.ListedColormap(mcolors)

(3)Remove the top and bottom axis
 def simpleaxis(ax):
  ax.spines['top'].set_visible(False) 
  ax.spines['right'].set_visible(False) 
  ax.get_xaxis().tick_bottom()
  ax.get_yaxis().tick_left()

(4) Draw the x=y line
plot([xmin, xmax],[ymin, ymax])


Tuesday, February 3, 2015

以此贴为证!

太被动了,这学期第一天要进入绝对的奋斗阶段!!!
三个月,看你搞出个什么来!!!

Saturday, January 31, 2015

[Python] Files I/O

1. Binary file: Use pylab to simply read and write files

Array.fromfile (pylab) is a  intrinsic package to load the binary file in the local disk, eg. *.bin file.
What it does is read machine data into arrays.

(1) read file
Before you read your binary file, you should figure out what format it is.
I am not an expert at data types (check it out: Numpy Data Types). There are many ways you can go and test the format.
In my case, I directly open the file (matlab, python, or any fast program) and check the machine values. The first thing to look at is whether it is string, interger, or float (double, single). After that, I can estimate whether it is 8, 16, 32, or 64 bit according to the range of the data, or file size.

(A) It becomes rather easy as long as you know the format. Say it is float32,
> from pylab import *
> file = fromfile("filename.bin", dtype = 'float32')
# the extension doesn't matter, it can be bin, dat, whatever, even no extenstion. 

(B) You can also do some list comprehension to process your data simpler and nicer.
In: file = [fromfile("filename_%s_%s.bin" %("tas", str(year)), dtype = 'uint16').reshape(12,180,360)[3:5,:,:] for year in xrange(1900,2001)]
Out: [array([...],dtype=float32), ..., 101 of them]

The example shows how to read the global temperature data from 1900-2000 among the period of April to June. So this becomes a list of arrays, maybe it is not what you want.
> df = np.hstack(file)
which can simply do the combination of all the arrays in the list into a multi-dimensional arrays.

(C) We can still use traditional loop to read the data.
for var in forcing:
      for year in xrange(styr, edyr+1):
           input = fromfile('%s_%s.bin' % (var, str(year)), 'float32').reshape(-1, 180, 360)
input = input[::-1]
           # use concatenate, or append
   data = np.concatenate((data, input))  
           # append
           data = np.append(data, input)


(2) write file


2. NetCDF file: use netcdf4 package
(1) Install
Use anaconda to install package for netcdf4: 
$ conda install netcdf4
(2) read file
> file = Dataset("path/filename.nc").variables["variable_name"][:]
This method will automatically fill out the missing values. 
So far, I use the numpy method, "file.data" to get the original data, and then set the original missing value to np.nan.
> file = Dataset("path/filename.nc").variables["variable_name"][:].data
> file[file==-9999] = np.nan


3. String TXT file: 
3.1 readlines

3.2 pandas read_csv


Thursday, January 29, 2015

粮食生产大问题

从今天开始推出这个专题,食品粮食安全问题。
我感兴趣的几个大问题:
(1)如今的粮食生产的浪费环节
(2)如今的粮食生产的能源消耗到底有多少,是不是真的
(3)转基因食品到底给发展中国家带来多大利弊