Daily Archives: May 1, 2010

一生的资本

在聊书的时候,有位年轻的朋友推荐说,有本叫“一生的资本”的书不错,可以学到不少为人处事的道理。一检索,发现是个叫马登的外国人写的,有中文网页说是什么《成功》杂志的创始人之说。Google是个好东西,大概检索了一下,有网页说,其英文标题叫Lifelong Captial。于是再检索这个标题,外加作者名Marden。很奇怪的发现Google只返回几十条,且都是中文网页,大概是宣传这本书的。

于是找到这位Marden的全名,叫Orison Swett Marden,是位美国的励志作家(1850-1924)。检索了Wikipedia,又翻到http://orisonswettmarden.wwwhubs.com/,有很多作品,但没有这本“一生的资本”。敢情是Marden先生在上帝家做客,感受到国人的好客,专门为大家创作的。

有哪位朋友有其它材料能证实Marden真有这种本,请告诉我。

Google检索链接:http://www.google.com/search?q=marden+%22lifelong+capital%22&btnG=Search&hl=en&client=firefox-a&hs=NVU&rls=org.mozilla%3Aen-US%3Aofficial&channel=s&sa=2

Using ArcGIS to prepare Sub catchment file for TopMODEL

Zhuotong Nan ([email protected]), CAREERI/CAS

TopMODEL is a conceptual hydrological model which was initially released in 1979 but is still widely used today especially in a watershed simulation with sparse observations.  TopMODEL uses topographic index (TI) to calculate water flow. There are already some tools developed for TI computation. Here I want to present a method using ArcGIS.

There is a similar work at http://soilandwater.bee.cornell.edu/Courses/GIS/TI.ppt. What I will present will be more than it.

1. We have  a DEM which is large enough to cover our study area. The DEM “Heihe_SRTM.img” is subset from the SRTM 90m data which is in lat/lon coordinates (WGS84).

image

2. Open ArcToolbox, go to Data Management Tools > Projections and Transformations > Raster > Project Raster.

image

Here use bilinear to interpolate the input raster to a 90m resolution grid in the Albers equal area projection.  The resulted raster is “heihe_albers”.

image 

3. In ArcToolbox, Spatial Analyst Tools > Hydrology > Fill, to fill up the possible sinks, resulting “hh_up_filled”.

image

4. In ArcToolbox, go to Data Management Tools >Raster > Raster Processing > Clip, to make the filled DEM smaller, because the next steps are very computation intensive. “dem_up_fil” is created.

image image

5. Hydrology > Flow direction. Note, use the filled DEM. flow direction file is “hh_fdir_clp”.

image

6. Hydrology > Flow Accumulation to compute “hh_accum”

image

7. open hydrosta.shp. this is a hydrological station location shapefile. We use the red line surrounded site as the watershed outlet.

image

8. use the “select feature” to select the desired site

image image

9. export to a separate file. the exported ylx.shp now is in same projection as hydrosta.shp which is lat/lon.

image image

10. Data Management Tools > Projections and Transformations > Feature > Project. save as “ylx_alb.shp”.

image

the output coordinates can be imported from the heihe_albers raster.

11. Hydrology > Snap Pour point. Carefully select the snap distance which is in map units. The result is “ylx_pour1” grid.

image

12. Hydrology > Watershed to delineate the watershed. Now we have “hh_ws1”.

image

13. ArcToolbox > Conversion Tools > Raster to Polygon to create “hhupws.shp”

image image

14. Open Spatial analyst toolbar (right click on the blank space of menu bar, select Spatial Analyst), set Spatial Analyst > Options > Analysis mask to hhupws (the watershed boundary polygon)

image

15. Spatial Analyst > Raster Calculator, double click hh_fdir_clp, and then click Evaluate. This will make the hh_fdir_clp masked by the watershed boundary.

image

Make the generated Calculation layer permanent (right click the item in the TOC, Data > Make Permanent…). Save as “hh_fdir_up1”.

Do same to dem_up_fil; dem is clipped to “dem_upstr1”.

Do same to hh_accum to generate “hh_accum_clp”

image image image
hh_fdir_up1 (left), dem_upstr1 (middle) and hh_accum_clp (right)

16. Hydrology > Flow Length

image

the flow length raster “hh_flowlen” is used to calculate channel levels in the SUBCAT file.

17. Spatial Analyst > surface analysis > Slope

image

save the slope file as “Slope_filldem”

18. Spatial Analyst > Raster Calculator

image

use “Tan(([Slope_filldem] * 1.570796) / 90) ” to calculate tangent of slope radians

save to “tan_slope1”

19. Same in Raster Calculator

Calculate TI by typing “Ln((([[hh_accum_clp]] + 1) * 90) / [[slope_filldem]] )”

image

save to “ti1”

Now we have data ready. What we do next is to classify data and make data formatted to fit what Topmodel requires.

20. Select ti1, then click Spatial Analyst > Reclassify … In the window, click Classify, select Equal Interval as the method, set 29 as the classes, click Ok to accept it. Other classification methods also can be used for your cases. You also can set more classes. but keep in mind that the TopModel version might be have limitation on classes.

image

click “Save…” , save the classification schema to “ti_table” as info table

Click ok to classify the continuous TI grid. a new layer “Reclass of ti1” is added to TOC. select it and right click to bring up the context menu. Open Attribute Table, and then Options > Export all records to “ti_export.txt”.

image

Note, the Save as type should be selected as “Text File”. It might not work if you only specify an “.txt” extension.

Do same to the hh_flowlen. classify it to 9 classes. and export the data to “flowlen_export.txt” in a text format. The classification schema is saved to “flowlen_table”.

21. In ArcGIS, click Add data to adding flowlen_table and ti_table to the ArcGIS session.  Right click on each item, open the table, and export all data to text files, here, “flowlength_clas_table.txt” and “ti_clas_table.txt”, respectively.

image

22. Open Excel. drag “flowlength_clas_table.txt”, "ti_clas_table.txt”, "ti_export.txt”, and “flowlen_export.txt” to Excel.

In each Excel workbook, select the first column, click “Text to Columns” in the data tab of Excel 2007. in the earlier version, there is also similar commands.

select comma as the delimiter, click finish.

Copy “From_”, “To_”, “Out” columns in class schema files, append to ti and flowlen export data workbooks respectively. This step is to combine the schema to actual data. after appending, close the two class table files (“flowlength_clas_table.txt”, "ti_clas_table.txt”) without saving changes. Now we have something like that,

image image
The combined ti_export.txt workbook(left) and the combined flowlen_export.txt workbook (right)

23. In the ti_export.txt workbook, select the “OUT” cell, click reverse order command image .

Right to the “OUT” column, add “Area”, and then “TI”. 

In the cell below the title “Area”, type: =c2/sum($c$2:$c$30).  this will calculate the fractional area. Note, $c$30 indicates the last low of the data. You might change it accordingly when you have different classes. Copy this cell to propagate through the Area column.

In the cell below the title “TI”, type: =D2. Copy this cell to propagate through the Area column.

Insert a new row right below the header row where we set area to 0, and ti to “=E3” (the largest TI). like below in this time,

image

Save the result to a new Excel file, say, “ti_ready.xlsx”.

24. In the flowlen_export.txt workbook, right to the “OUT” col, add “area”, “accum_area”, and “dis” in the next two cells.

use “=C2/SUM($C$2:$C$10)” to calculate the area column; note, $c$10 is the last data line. change it accordingly.

use “=SUM($G$2:G2)” to calculate accumulative area for the accum_area column;

use “=e2” to calculate the dis column.

copy those formula to other rows.

insert a new line immediately below the header line. type 0 and 0 for accu_area and dis.  if this is a subcatchment, set the distance from the outlet of the entire catchment to dis here.

looks like as below,

image

save the excel to “flowlen_ready.xlsx”

close ti_export.txt and flowlen_export.txt, no need to save changes.

Note, we do not need to reversely sorting data which is different from the ti case described above.

25. copy “area” and “ti” in the ti_ready.xlsx (without header) to the proper section of the SUBCAT file.

copy “accum_area” and “dis” in the flowlen_ready.xlsx (without header) to the proper section of the SUBCAT file.

in this case, the total ti increments are 30; the total channel levels are 10. looks as below,

image

For the demonstration purpose, we abbreviate 30 ti increments.

ThinkPad x200 更换硬盘及数据迁移

Zhuotong Nan ([email protected])

原硬盘250G,因最近工作产生大量数据,已经只有10G空间了。在决定换硬盘前,通读了一些网上相关的文档,大致评估了风险。硬盘是肯定可以换的,但我更关心:

  1. 原硬盘上的系统和数据要原原本本迁移拷贝到新硬盘,否则安装系统和各种应用程序、专业程序,调整系统就太麻烦了。
  2. 因操作系统是正版的,不想因为变换了硬盘,导致操作系统要重新激活。
  3. 一定保证数据安全,不丢失。

购买7200转的500G Seagate硬盘,USB 2.0硬盘盒。准备一个4G U盘(不一定4G,有100M空间就够),一把十字螺丝刀。

1. 安装Acronis True Image Home 2010,主要用于创建启动U盘,和磁盘对拷。我是安装在另一台Vista机器,如果没有额外机器,也可以安装在笔记本上。2010版本支持在Windows 7上运行,如果系统是Vista(象my case),可以安装旧版本。Acronis得是full version,可以购买或者从网上找序列号。

安装后,插入U盘,打开Arconis,注意,创建启动U盘需要管理员权限。选择创建可启动的应急盘。按指示进行,在指定目标时,选择对应的U盘。注意U盘上的内容会被清除,注意将U盘有用的内容事先备份。创建后的U盘只花了几十MB的空间。

要先插入U盘,Acronis才有在U盘上创建应急盘的选项,否则只有光盘等可选项。

2. 关闭ThinkPad X200笔记本。将启动U盘插入X200对应USB口上。将新硬盘安装到USB硬盘盒,连接USB线到X200。我没有将新硬盘直接换到X200上,是为了防止有可能的系统迁移失败,当然后来的事情很顺利。但建议大家也是按这个次序,并不显得麻烦太多。

按F12不放,按电源键开机,按F12不放,直到在屏幕上看到preparing boot list,放开。这是ThinkPad提供的一个临时改变启动次序的方法。出来的启动次序,选择U盘。

请注意,因为以后的拷贝操作会消耗比较长的时间,一定要接外接电源。

3. 系统很快从U盘上启动,进入Acronis图形界面,这时是支持鼠标的。点击Arconis帐号(在2010上只有一个可用帐号)进去。在Tools and Utilities下选择 disk clone,可以看到两个disk,一个是x200上的原硬盘,和连接到USB上的新硬盘。

我的X200是安装Windows 7系统,有100M的系统保留分区,如果是原装的X200 Vista,还有保留应急分区。不管如何,在disk clone时,选择manual (手动),如果选择自动,会将各分区按比例自动扩大,这不是我们想要的。进去Manual选择后,选As is。这样在新盘上将创建与原盘上一样大的分区,多余的空间作为未分配空间,可通过widnows 7磁盘管理里的扩展卷功能,将未分配空间重新并入。与As Is下仍然有Manual允许指定大小,但为了免除误操作,建议选As is选项。

首先要指定源盘,请确认选择了x200上的盘,再指定目标盘,即新盘。务请不要搞反了,否则就悲惨了。

克隆开始。进展对话框,有一选项是完成后关闭电脑。我是在晚上睡觉前执行上面工作,所以将这个选项选择上,然后安心睡觉去了。克隆的过程大概需要4小时左右,各人电脑需时不一。耐心等候,Arconis能完美地完成任务。

另外,无须担心x200上的源盘数据受损,Arconis只是从源盘读数据,不会进行任何写操作,我的机器上有最近的工作都没有备份,也十分放心的做以上操作。但一定要遵从我上面的步骤要点。尤其是源,目标盘不能搞反了。

4. 拷贝/克隆完成后。退出acronis,关闭x200电源。拔掉电线和外设。反转电脑,拧开一枚螺丝,将盖打开。硬盘两边有橡胶保护。有一黑色塑料片(是固定在硬盘架上的),可以捏住这个向外拉。拉出来后,将橡胶保护去掉,将硬盘从架子上下来,有四个螺丝需要松开。

新硬盘从硬盘盒里取出来。放到硬盘架上,固定4个螺丝,放上橡胶保护,然后塞进去,注意如果塞不倒位,请确认上下没有弄反。我在操作的时候就弄反了。应该很轻松的塞进去。重新固定盖子复原。

将5400转250G的老硬盘放到硬盘盒。可以作它用,或者保管起来以作备份。

5. 打开x200,看是不是成功了,应当能跟以前一样的进去操作系统。在尽情享受更大容量和更高速度带来的乐趣前,执行最后一步。进去磁盘管理(我的电脑右键选管理),在原C盘上,右键,选扩展卷,将未分配的空间全部分配给C盘(或者其它盘,根据你的需要)。