Tuesday, October 21, 2014

[GrADS] Environment Variables 环境变量设置

Beginning with GrADS version 2.0.a8, there is only one choice for GrADS_executable, a single, fully-featured build, which is good.

GADDIR Points to the directory containing the supplemental font and map files in the GrADS release package. If GADDIR is not set, GrADS will look in the default location, /usr/local/lib/grads/.

GASCRP Points to a list of directories containing GrADS utility scripts and user scripts. If more than one directory is specified, acceptable delimiters are a space, a semi-colon, colon, or a comma.


For example:
example% setenv GADDIR /ford1/local/lib/grads
example% setenv GASHP $HOME/grads/shapefiles
example% setenv GASCRP "$HOME/grads/scripts /opt/local/share/grads/library"
example% setenv GAUDFT $HOME/grads/udf/table

Friday, October 17, 2014

[Python] introducing Python environments

python是一门语言,和IDE实现无关。
王玄:
只是看代码的话,就只看VIM
需要逐行debug,就PTVS或者PyCharm这种重型IDE
需要画图,测试idea,就上ipython
因此,总的来说,有几个实现方法。
(1) vim-python。用vim,kate等编辑器写script,然后在shell prompt 跑。
(2) ipython。python的interactive shell,在terminal打开,就像一个软件一样。
$ ipython --pylab
$ ipython -qtconsole  *弹出来的是一个窗口

(3) ipython-notebook。python的web-based interactive shell,可以作为作业、present的一个交互手段,出文图方便。
(4) pycharm。IDE,就像matlab一样,可以语法纠错,可以debug。

pygrads是一个更加奇怪的东西……
pygrads一方面,是一个grads+ipython的interactive shell,在terminal打开,也是像一个软件一样。
$ pygrads
ln[1]:ga-> open/o file.ctl
ln[2]:ga-> xx ts

然后就可以像在grads的prompt里面输入各种命令。区别在于:
A. 命令很多简写、替代,需要查grads-pygrads对应表。
B. pygrads 可以导入导出grads的数据,然后再用python的功能。

pygrads另一方面,它却是一个python的library!!!
>>from grads import *
>>ga = GrADS("Bin=/path/opengrads")
>>ga.open("file.ctl")
>>ts = ga.exp("ts")
画图请import pylab,不然画不了。注意不是matplotlib。
>>from pylab import title, savefig
>>clf()
>>ga.pcolor('data')
>>savefig('test.png')

Monday, October 13, 2014

反演方法

Inversion and Assimilation
反演、同化总是被同时提起,那么这两者到底分别指的是什么?
以碳循环为例。
反演一般即是通过大气二氧化碳浓度的观测数据来估算陆地生态系统碳源碳汇的分布信息。
同化则是指通过各种直接、间接的测量方式来获得观测数据。

Forward model

Friday, October 10, 2014

重整旗鼓再开张

不要纠结于一些类似于step change的技术细节。
好好学习python,这个没有什么learning curve,本应更加适合我这种人,请把过去的畏难情绪一笔勾销!!!
技术不是根本问题,但它是瓶颈问题,请务必重视、提高热情、打好基础、好好攻克!

Wednesday, October 1, 2014

C语言手札

Tutorial
1. integer division truncates: any fractional part is discarded.
(int): 5/9 = 0
2. printf (a standard function can be called by C, ANSI standard)
\t, tab; \n, new line
%d  print as decimal integer,
%6d  a least 6 characters wide
%f  floating point
%6f  6 characters wide
%.2f  2 characters after decimal point
%6.2f at least 6 wide, 2 after decimal point

Memory
variable in C++ is a name for a piece of memory that can be used to store information. When a variable is declared, a piece of that memory is set aside for that variable. 
First, there is no guarantee that your variables will be assigned the same memory address each time your program is run. The first time you run your program, x may be assigned to memory location 140. The second time, it may be assigned to memory location 168. Second, when a variable is assigned to a memory location, the value in that memory location is undefined (in other words, whatever value was there last is still there). A variable that has not been assigned a value is called an uninitialized variable. Uninitialized variables are very dangerous because they cause intermittent problems (due to having different values each time you run the program).
A good rule is to always assign values to variables when they are declared.

Function
Typically, when learning C++, you will write a lot of programs that involve 3 subtasks:
  1. Reading inputs from the user
  2. Calculating a value from the inputs
  3. Printing the calculated value

Compile
When addressing compile errors in your programs, always resolve the first error produced first.