引言
ccplot是一个开源的用于绘制 CloudSat, CALIPSO and Aqua MODIS数据产品:廓线、层、地球可视化数据的命令行程序。因为笔者的研究领域,需要使用CALIPSO、CloudSat等卫星的地球观测数据,今天抽出时间来编译构建ccplot,用于A-Train的对地观测数据分析与作图,并将过程下来共该领域同仁交流学习。
下面的安装适用于ccplot 1.5.2对于高版本(1.5.4版)的安装见博文最后部分。
MacPorts安装
在官网下载MacPorts安装包pkg,一路安装。
安装ccplot
将Python27设置为MacPorts的默认Python
在终端输入命令:
sudo port select --set python python27
出现错误:
Selecting 'python27' for 'python' failed: The specified group 'python' does not exist.
解决方法:
终端输入命令,安装Python27
sudo port install py27-pip
在终端输入命令
sudo port select --list python
Available versions for python:
none
python26-apple
python27 (active)
python27-apple
从MacPorts 安装附加包
键入命令,约20分钟可以安装结束。
sudo port install hdf4 hdfeos py27-cython py27-numpy py27-matplotlib py27-matplotlib-basemap
构建和安装ccplot
依次在终端中键入如下命令,即可完成ccplot的构建和安装。
tar xzf ccplot-1.5.1.tar.gz
cd ccplot-1.5.1
python setup.py build
sudo python setup.py install
上述命令分别是:ccplot-1.5.1.tar.gz进行解压、指定目录、构建和安装。
注意:ccplot官网提供的版本为1.5.2,注意和上述命令中的区别。解压时候使用绝对路径即可。
测试ccplot
在终端中键入下面命令进行测试。
ccplot -V
如果不成功,就运行下面命令。
export PATH="$PATH:/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin"
对CALIPSO、CloudSat和MODIS数据可视化
ccplot支持的产品
Spacecraft | Instrument | Product | Data set |
---|---|---|---|
CALIPSO | CALIOP | Lidar L1B Profiles | Total Attenuated Backscatter 532nm; Attenuated Backscatter 1064nm; Perpendicular Attenuated Backscatter 532nm; Attenuated Color Ratio 1064nm/532nm; Depolarization Ratio |
Lidar L2 Cloud Layer Products (333m, 1km, 5km) | Integrated Attenuated Backscatter 532nm; Integrated Attenuated Backscatter 1064nm; Integrated Attenuated Total Color Ratio 1064nm/532nm; Integrated Volume Depolarization Ratio; Midlayer Temperature | ||
CloudSat | CPR | 2B-GEOPROF | Radar Reflectivity Factor |
Aqua | MODIS | MYD02QKM | Bands 1, 2 |
MYD02HKM | Bands 1-7 | ||
MYD021KM | Bands 1-12, 13lo, 13hi, 14lo, 14hi, 15-36 |
Functions | Data set |
---|---|
cloudsat-reflec | Cloud Reflectivity Factor |
calipso532 | CALIPSO L1B Total Attenuated Backscatter 532nm |
calipso532p | CALIPSO L1B Perpendicular Attenuated Backscatter 532nm |
calipso1064 | CALIPSO L1B Attenuated Backscatter 1064nm |
calipso-cratio | CALIPSO L1B Attenuated Color Ratio 1064nm/532nm |
calipso-dratio | CALIPSO L1B Depolarization Ratio |
calipso532-layer | CALIPSO L2 Integrated Attenuated Backscatter 532nm |
calipso1064-layer | CALIPSO L2 Integrated Attenuated Backscatter 1064nm |
calipso-cratio-layer | CALIPSO L2 Integrated Attenuated Total Color Ratio 1064nm/532nm |
calipso-dratio-layer | CALIPSO L2 Integrated Volume Depolarization Ratio |
calipso-temperature-layer | CALIPSO L2 Midlayer Temperature |
orbit | map projection of CALIPSO and CloudSat tractor, and Aqua MODIS radiance or reflectance swath depending on files supplied |
orbit-clipped | MODIS-region-clipped map projection of CALIPSO and CloudSat trajectory, and Aqua MODIS radiance or reflectance swath depending on files supplied |
Colormap
这里使用ccplot自带的colormap,当然也可以自己创建colormap。ccplot自带的colormap文件名列表如下:
calipso-backscatter.cmap
calipso-cratio.cmap
calipso-dratio.cmap
calipso-temperature.cmap
cloudsat-reflectivity.cmap
modis-reflectance.cmap
modis-temperature.cmap
根据colormap的命名就应该知道在代码中如何使用了。
CALIPSO profile and layer plots
ccplot -o calipso532.png -c calipso-backscatter.cmap -a 30 -x 4:16:20..4:21:50 -y 0..30000 calipso532 CAL_LID_L1-ValStage1-V3-01.2007-06-12T03-42-18ZN.hdf
CloudSat profile plots
ccplot -o cloudsat-reflec.pdf -c cloudsat-reflectivity.cmap -a 15 -x 24.60S..31S,50W..60W -y -1000..18000 cloudsat-reflec 2009037050924_14779_CS_2B-GEOPROF_GRANULE_P_R04_E02.hdf
CloudSat profile plots
CloudSat and CALIPSO trajectories on top of MODIS swath
ccplot -o orbit-modis_x31+cloudsat.pdf -m x31 -c modis-temperature.cmap -p tmerc orbit-clipped MYD021KM.A2009037.0515.005.2009332033315.hdf 2009037050924_14779_CS_2B-GEOPROF_GRANULE_P_R04_E02.hdf
ccplot -o orbit-modis_x31+calipso_spstere.pdf -m x31 -c modis-temperature.cmap -p spstere:boundinglat=60S orbit-clipped MYD021KM.A2007163.0415.005.2009290181256.hdf CAL_LID_L1-ValStage1-V3-01.2007-06-12T03-42-18ZN.hdf
CloudSat and CALIPSO trajectories on top of MODIS swath
Perpendicular Attenuated Backscatter 532nm
ccplot -o calipsop.pdf -c calipso-backscatter.cmap -a 30 -x 4:16:20..4:21:50 -y 0..30000 calipso532p CAL_LID_L1-ValStage1-V3-01.2007-06-12T03-42-18ZN.hdf
Perpendicular Attenuated Backscatter 532nm
Attenuated Backscatter 1064nm
ccplot -o calipso1064.pdf -c calipso-backscatter.cmap -a 30 -x 4:16:20..4:21:50 -y 0..30000 calipso1064 CAL_LID_L1-ValStage1-V3-01.2007-06-12T03-42-18ZN.hdf
Attenuated Backscatter 1064nm
Attenuated Color Ratio 1064nm/532nm
ccplot -o calipso-cratio.pdf -c calipso-cratio.cmap -a 30 -x 4:16:20..4:21:50 -y 0..30000 calipso-cratio CAL_LID_L1-ValStage1-V3-01.2007-06-12T03-42-18ZN.hdf
Attenuated Color Ratio 1064nm/532nm
Depolarization Ratio
ccplot -o calipso-dratio.pdf -c calipso-dratio.cmap -a 30 -x 4:16:20..4:21:50 -y 0..30000 calipso-dratio CAL_LID_L1-ValStage1-V3-01.2007-06-12T03-42-18ZN.hdf
Depolarization Ratio
Integrated Attenuated Backscatter 532nm
ccplot -o calipso532-layer.pdf -c calipso-backscatter.cmap -a 30 -x 20:00:00..20:05:00 -y 0..30000 calipso532-layer CAL_LID_L2_01kmCLay_Exp-Prov-V3-40.2017-10-25T19-30-00Z.hdf
Integrated Attenuated Backscatter 532nm
Integrated Attenuated Backscatter 1064nm
ccplot -o calipso1064-layer.pdf -c calipso-backscatter.cmap -a 30 -x 20:00:00..20:05:00 -y 0..30000 calipso1064-layer CAL_LID_L2_01kmCLay_Exp-Prov-V3-40.2017-10-25T19-30-00Z.hdf
Integrated Attenuated Backscatter 1064nm
Integrated Attenuated Total Color Ratio 1064nm/532nm
ccplot -o calipso-cratio-layer.pdf -c calipso-cratio.cmap -a 30 -x 20:00:00..20:05:00 -y 0..30000 calipso-cratio-layer CAL_LID_L2_01kmCLay_Exp-Prov-V3-40.2017-10-25T19-30-00Z.hdf
Integrated Attenuated Total Color Ratio 1064nm/532nm
Integrated Volume Depolarization Ratio
ccplot -o calipso-dratio-layer.pdf -c calipso-dratio.cmap -a 30 -x 20:00:00..20:05:00 -y 0..30000 calipso-dratio-layer CAL_LID_L2_01kmCLay_Exp-Prov-V3-40.2017-10-25T19-30-00Z.hdf
Integrated Volume Depolarization Ratio
Midlayer Temperature
ccplot -o calipso-temperature-layer.pdf -c calipso-temperature.cmap -a 30 -x 20:00:00..20:05:00 -y 0..30000 calipso-temperature-layer CAL_LID_L2_01kmCLay_Exp-Prov-V3-40.2017-10-25T19-30-00Z.hdf
Midlayer Temperature
ccplot 1.5.4版本安装
第一步:Install Anaconda 64-bit.
第二步:Install MacPorts.这里可能需要安装Xcode,如果不安装Xcode是否可以成功并未测试。
第三步:Install required MacPorts packages. In the macOS Terminal:
这里可能需要半个小时。
sudo port install hdf4 hdfeos
Last login: Thu Nov 26 10:09:19 on ttys000
(base) MacBook-Pro:~ $ port version
Version: 2.6.4
(base) MacBook-Pro:~ $ sudo port install hdf4 hdfeos
Password:
---> Computing dependencies for hdf4
The following dependencies will be installed:
gettext
gperf
jpeg
libiconv
ncurses
xz
zlib
Continue? [Y/n]: y
---> Fetching archive for jpeg
---> Attempting to fetch jpeg-9d_0.darwin_18.x86_64.tbz2 from https://packages.macports.org/jpeg
---> Attempting to fetch jpeg-9d_0.darwin_18.x86_64.tbz2 from http://atl.us.packages.macports.org/jpeg
---> Attempting to fetch jpeg-9d_0.darwin_18.x86_64.tbz2 from https://cph.dk.packages.macports.org/jpeg
---> Attempting to fetch jpeg-9d_0.darwin_18.x86_64.tbz2.rmd160 from https://cph.dk.packages.macports.org/jpeg
---> Installing jpeg @9d_0
---> Activating jpeg @9d_0
---> Cleaning jpeg
---> Fetching archive for gperf
---> Attempting to fetch gperf-3.1_0.darwin_18.x86_64.tbz2 from https://packages.macports.org/gperf
---> Attempting to fetch gperf-3.1_0.darwin_18.x86_64.tbz2 from http://atl.us.packages.macports.org/gperf
---> Attempting to fetch gperf-3.1_0.darwin_18.x86_64.tbz2 from https://cph.dk.packages.macports.org/gperf
---> Attempting to fetch gperf-3.1_0.darwin_18.x86_64.tbz2.rmd160 from https://cph.dk.packages.macports.org/gperf
---> Installing gperf @3.1_0
---> Activating gperf @3.1_0
---> Cleaning gperf
---> Fetching archive for libiconv
---> Attempting to fetch libiconv-1.16_1.darwin_18.x86_64.tbz2 from https://packages.macports.org/libiconv
---> Attempting to fetch libiconv-1.16_1.darwin_18.x86_64.tbz2 from http://atl.us.packages.macports.org/libiconv
---> Attempting to fetch libiconv-1.16_1.darwin_18.x86_64.tbz2 from https://cph.dk.packages.macports.org/libiconv
---> Attempting to fetch libiconv-1.16_1.darwin_18.x86_64.tbz2.rmd160 from https://cph.dk.packages.macports.org/libiconv
---> Installing libiconv @1.16_1
---> Activating libiconv @1.16_1
---> Cleaning libiconv
---> Fetching archive for ncurses
---> Attempting to fetch ncurses-6.2_0.darwin_18.x86_64.tbz2 from https://packages.macports.org/ncurses
---> Attempting to fetch ncurses-6.2_0.darwin_18.x86_64.tbz2 from http://atl.us.packages.macports.org/ncurses
---> Attempting to fetch ncurses-6.2_0.darwin_18.x86_64.tbz2 from https://cph.dk.packages.macports.org/ncurses
---> Attempting to fetch ncurses-6.2_0.darwin_18.x86_64.tbz2.rmd160 from https://cph.dk.packages.macports.org/ncurses
---> Installing ncurses @6.2_0
---> Activating ncurses @6.2_0
---> Cleaning ncurses
---> Fetching archive for gettext
---> Attempting to fetch gettext-0.19.8.1_2.darwin_18.x86_64.tbz2 from https://packages.macports.org/gettext
---> Attempting to fetch gettext-0.19.8.1_2.darwin_18.x86_64.tbz2 from http://atl.us.packages.macports.org/gettext
---> Attempting to fetch gettext-0.19.8.1_2.darwin_18.x86_64.tbz2 from https://cph.dk.packages.macports.org/gettext
---> Attempting to fetch gettext-0.19.8.1_2.darwin_18.x86_64.tbz2.rmd160 from https://cph.dk.packages.macports.org/gettext
---> Installing gettext @0.19.8.1_2
---> Activating gettext @0.19.8.1_2
---> Cleaning gettext
---> Fetching archive for xz
---> Attempting to fetch xz-5.2.5_0.darwin_18.x86_64.tbz2 from https://packages.macports.org/xz
---> Attempting to fetch xz-5.2.5_0.darwin_18.x86_64.tbz2 from http://atl.us.packages.macports.org/xz
---> Attempting to fetch xz-5.2.5_0.darwin_18.x86_64.tbz2 from https://cph.dk.packages.macports.org/xz
---> Attempting to fetch xz-5.2.5_0.darwin_18.x86_64.tbz2.rmd160 from https://cph.dk.packages.macports.org/xz
---> Installing xz @5.2.5_0
---> Activating xz @5.2.5_0
---> Cleaning xz
---> Fetching archive for zlib
---> Attempting to fetch zlib-1.2.11_0.darwin_18.x86_64.tbz2 from https://packages.macports.org/zlib
---> Attempting to fetch zlib-1.2.11_0.darwin_18.x86_64.tbz2 from http://atl.us.packages.macports.org/zlib
---> Attempting to fetch zlib-1.2.11_0.darwin_18.x86_64.tbz2 from https://cph.dk.packages.macports.org/zlib
---> Attempting to fetch zlib-1.2.11_0.darwin_18.x86_64.tbz2.rmd160 from https://cph.dk.packages.macports.org/zlib
---> Installing zlib @1.2.11_0
---> Activating zlib @1.2.11_0
---> Cleaning zlib
---> Fetching archive for hdf4
---> Attempting to fetch hdf4-4.2.15_0.darwin_18.x86_64.tbz2 from https://packages.macports.org/hdf4
---> Attempting to fetch hdf4-4.2.15_0.darwin_18.x86_64.tbz2 from http://atl.us.packages.macports.org/hdf4
---> Attempting to fetch hdf4-4.2.15_0.darwin_18.x86_64.tbz2 from https://cph.dk.packages.macports.org/hdf4
---> Attempting to fetch hdf4-4.2.15_0.darwin_18.x86_64.tbz2.rmd160 from https://cph.dk.packages.macports.org/hdf4
---> Installing hdf4 @4.2.15_0
---> Activating hdf4 @4.2.15_0
---> Cleaning hdf4
---> Computing dependencies for hdfeos
---> Fetching archive for hdfeos
---> Attempting to fetch hdfeos-2.20_0.darwin_18.x86_64.tbz2 from https://packages.macports.org/hdfeos
---> Attempting to fetch hdfeos-2.20_0.darwin_18.x86_64.tbz2 from http://atl.us.packages.macports.org/hdfeos
---> Attempting to fetch hdfeos-2.20_0.darwin_18.x86_64.tbz2 from https://cph.dk.packages.macports.org/hdfeos
---> Attempting to fetch hdfeos-2.20_0.darwin_18.x86_64.tbz2.rmd160 from https://cph.dk.packages.macports.org/hdfeos
---> Installing hdfeos @2.20_0
---> Activating hdfeos @2.20_0
---> Cleaning hdfeos
---> Updating database of binaries
---> Scanning binaries for linking errors
---> No broken files found.
---> No broken ports found.
(base) shizhenweideMacBook-Pro:~ shizhenwei$
第四步:Build and install ccplot:
这里的x.y.z是对应的版本号,如ccplot-1.4.4.tar.gz
tar xzf ccplot-x.y.z.tar.gz
cd ccplot-x.y.z
python setup.py install
测试:You should now be able to run ccplot in the macOS Terminal:
ccplot -V
结语
博文里从如何在Mac OS下编译安装ccplot做了完整记录。在例子部分对MODIS、CloudSat、CALIPSO卫星数据进行了可视化,并附上了完整代码。希望能够对大家的学习研究起到帮助作用。
参考:
https://www.macports.org/install.php
http://ccplot.org
http://www.it165.net/os/html/201404/7932.html