Thursday, December 31, 2015

Python: Installing Numpy & Scipy

两个Package 64bit地址,安装方法:CMD切换至Package下载目录,
1
pip install scipy-0.17.0rc1-cp27-none-win_amd64.whl

Wednesday, December 30, 2015

Python: Compile Python Script to Binary Executable

Summary

开贴介绍Python脚本文件转化为.exe的方法。为更好的理解下面的过程,请按照示例步骤操作,准备工作需要安装PyinstallerwxPython

Example

先制作一个演示程序app.py,
1
2
3
4
5
6
#!/usr/bin/env python
import wx
app = wx.App(False)
frame = wx.Frame(None, wx.ID_ANY, "Hello World")
frame.Show(True)
app.MainLoop()
在Python Shell中执行上面这段代码,弹出Fig. 1窗口。
Fig. 1
创建.exe文件
启动Windows之CMD,将当前目录定位至app.py所在文件夹之下,键入
1
pyinstaller.exe --onefile --windowed app.py
稍等片刻,运行结束出现如Fig. 2提示,app.exe文件输出在当前目录之子目录dist。
Fig. 2
下面来解释一下上面命令中的选项:
  • --onefile指定所有相关的文件都打包至一个文件,如果不指定,输出app.exe文件周围会出现很多与之相关的文件
  • --windowed避免运行时出现控制台窗口(Console Window),若这一程序没有图形操作,这个选项可以忽略
  • app.py输出程序的主要源文件,这一文件名称将来会被用来命名.exe文件,或者,也可以另其指定名称,以--name选项命名。
这里注意不需要声明引入很多package,因为代码中已经包含这些声明。
在我的机器上,最终的app.exe文件达到8.61MB。这一文件真的是很大,因为Python解码器、程序代码和所有必需的Packages(命令指定--onefile选项)。尽管这很简单,但你要在输出之前了解这些内容。
After the build, an app.spec file will be created. This file contains all of the options used to run PyInstaller, and can be fed back into PyInstaller for future builds in place of the command line options, if desired.
添加Icon
在IconEden上为刚刚创建的app.exe文件自定义一个Icon,将此Icon置于app.py相同目录,命令稍加修改如下:
1
pyinstaller.exe --onefile --windowed --icon=app.ico app.py
稍等编译,编译完成后出现的app.exe文件如下:
Fig. 3
Matlab调用
正常

References

[3] IconEden.

Python: Installing wxPython Package

在wxPython官网下载页面,选择与安装机器匹配的安装程序,此处安装机器是Win7 64bit和Python 2.7 64bit,对应wxPython3.0-win64-3.0.2.0-py27.exe,下载完成后双击开始安装,安装完成后在Shell中键入import wx,无返回错误即表示安装成功,如Fig. 1。
Fig. 1

References

[1] http://www.wxpython.org.

Python: Install Pyinstaller Package

Summary

PyInstaller is a program that freezes (packages) Python programs into stand-alone executables, under Windows, Linux, Mac OS X, FreeBSD, Solaris and AIX. Its main advantages over similar tools are that PyInstaller works with Python 2.7 and 3.3—3.5, it builds smaller executables thanks to transparent compression, it is fully multi-platform, and use the OS support to load the dynamic libraries, thus ensuring full compatibility.
The main goal of PyInstaller is to be compatible with 3rd-party packages out-of-the-box. This means that, with PyInstaller, all the required tricks to make external packages work are already integrated within PyInstaller itself so that there is no user intervention required. You'll never be required to look for tricks in wikis and apply custom modification to your files or your setup scripts. As an example, libraries like PyQt, Django or matplotlib are fully supported, without having to handle plugins or external data files manually. Check our compatibility list of Supported Packages for details.

Installing

之前已经安装pip,此时需要下载pyinstaller安装包(下载地址见参考文献[2]),Windows之CMD环境中先将当前目录设定在安装文件夹之下,输入pip install pyinstaller,安装完成返回结果如Fig. 1,安装成功。
Fig. 1

References

Thursday, December 17, 2015

Tool: Applications

[1] Lockhunter, unlocking files and folders!
[3] CorelDraw表格文字统一修改:编辑>>全选>>文本, 就可以全部选中文字了,然后改字体和大小.
[4] CorelDRAW图形嵌入文字的调整,主要是图上两处.
[8] 析出水平/垂直线段:选择“表格”工具,在画纸上拉出一个表格;Ctrl+Q将表格转换为曲线;Ctrl+U取消组合对象,此时表格各线段独立.
[9] 任务栏程序图标丢失的解决方法,Solution Answered by Mark Berry.
1
2
3
4
DEAZV-27TFM-BL52D-PVN9L-ADULD <2021-6-11到期>
DEAZW-38TGM-HH52D-XG5WR-FX4QW <2021-6-11到期>
DMAZW-48TGM-LQ52C-G82V6-2JJUC <2021-6-10到期>
DMAZW-4ATGM-QL52D-M6XEM-TCFCS <2021-6-11到期>
[11] CorelDraw插入摄氏度符号(插入字符):
[14] 修改Win7系统字体.
[15] 插入Arial字体%.
[16] 笔记本计算机,若FX键不正常,可以使用组合键Fn+FX.
[18] MathType空心字母,对应文本状态.
[24] Vivaldi Browser, Visual Tabs.

Wednesday, December 16, 2015

Matlab: NetCDF File

What is NetCDF?

NetCDF (Network Common Data Form) is a set of software libraries and self-describing, machine-independent data formats that support the creation, access, and sharing of array-oriented scientific data. The project homepage is hosted by the Unidata program at the University Corporation for Atmospheric Research (UCAR). They are also the chief source of netCDF software, standards development, updates, etc. The format is an open standard. NetCDF Classic and 64-bit Offset Format are an international standard of the Open Geospatial Consortium.
以sst.mon.ltm.1981-2010.nc(details)文件为例,SST(Sea Surface Temperature)在ArcGIS10.2中显示如图 1。
图 1

Matlab操作

以sst.mon.ltm.1981-2010.nc文件为例,Matlab操作读入及输出为GeoTiff文件。
Spatial Coverage:
1.0 degree latitude x 1.0 degree longitude global grid (360x180).
89.5N - 89.5S, 0.5E - 359.5E.
Missing grids are 9.999e+20(ltm).
代码运行生产Jan.~Dec.全球SST,程序运行流畅。

See Also

Monday, December 14, 2015

ArcGIS: Generate Raster Longitude and Latitude

Summary

栅格数据怎样可以得到逐点的经纬度信息,并分别将经度、纬度坐标以二维矩阵形式(影像)输出?
已知mask.tif文件已投影为WGS_1984_UTM_zone_50N,行列分别是411、452,空间分辨率1000m。

Steps

- Convert a raster of the study area to point.
打开ArcToolBox,Conversion--From Raster--Raster to Point,处理结果返回points.shp。
- Create two fields (floating or double) to store x and y.
右键points,Open Attribute Table,在属性表中添加2个域,分别列出经度、纬度,如Fig. 1。
Fig. 1
- Calculate geometry (longitude for x, latitude for y)
在属性名称上右键选择Calculate Geometry ...,经度对应x,纬度对应y,注意单位选择Decimal Degrees,如Fig. 2,计算结果将会存储在属性表中。
Fig. 2
- Convert to raster using x field (longitude raster)
打开ArcToolBox,Conversion--To Raster--Point to Raster,参数配置如Fig.3,像元参数设置与mask.tif一致。
Fig. 3
输出纬度矩阵与mask.tif空间信息完全一致,如Fig. 4。
Fig. 4

References

[2] Specifying the precision and scale allows you to restrict the range of values and number formats a field can accept, giving you greater control. For example, if you specify a float with a precision of 4 and a scale of 2, the field will accept 12.34. If you try to enter 12.345 into the field, an error message would display, as this exceeds the maximum number of digits and decimal places allowed. On the other hand, if you specify a float with a precision of 5 and a scale of 3, the field would let you enter 12.345.