前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Python处理CMIP数据及3D可视化-基于UVCDAT

Python处理CMIP数据及3D可视化-基于UVCDAT

作者头像
气象学家
发布2020-05-01 18:29:42
1.3K0
发布2020-05-01 18:29:42
举报
文章被收录于专栏:气象学家气象学家

前言介绍

UVCDAT(Ultra-scale Visualization Climate Data Analysis Tools)是美国能源部DOE开发的一种超大规模可视化气候数据分析工具的系统架构,旨在解决气候模式中海量数据的处理、分析以及可视化的问题。其在处理CMIP3/5数据中发挥了很大的作用,为相应的科学报告提供了可靠地支撑。其提供了可视化交互式操作界面也同时具备Python调用接口的方式来使用。目前,UVCDAT已经可以支持全平台了,其中Windows主要还是依赖于内嵌的Linux操作系统(有别于虚拟机和双系统,通常称之为WSL,Windows Subsystem for Linux,推荐为Ubuntu)相比于几年前,UVCDAT的安装改进了很多,功能也越来越通用完备。

气候科学家在理解地球气候系统模式上取得了巨大的进步,特别是在全球的和陆地尺度上。很多前言的气候研究现在集中于理解精细化的时空变化下的气候变化特征(譬如,2-到100-公里分辨率),这将产生超大规模的数据集。在这种规模下,即便是单个数据的快照也将有数TB之大或者更多,而长时间尺度的累计可能产生数以PB的海量数据。

因此,UVCDAT的出现旨在满足以下几种迫切需求:

  • 工作流分析和源头管理;
  • 并行可视化和分析工具(利用并行I / O);
  • 本地和距离可视化和数据访问;
  • 对比可视化和统计分析;
  • 用于格点分辨率重调整,重投影和聚合的强大工具;
  • 用于支撑非结构化网格和非格点化观测数据,包括通常用于观测数据集的地理空间格式。

UVCDAT整体架构

GUI界面

Gallery

仅展示官网的部分示例,后文会给出实操的脚本和数据。 官网样图链接:https://cdat.llnl.gov/gallery.html

安装

安装主要是基于conda命令,导入配置文件即可,一键式安装,轻松省事。但是有两个需要注意的地方:

  1. 网络环境要比较好,可能存在下载依赖库过慢的情况,可以尝试Shadownsocks开全局模式,或者没有F(科学)Q(上网)的条件,不妨多试几次;
  2. 配置文件的路径需要修改为你的anconda3或者miniconda3对应的路径,且需要配置好环境变量(Mac一般为~/.bash_profile或者~/.zshrc,而Linux为~/.bashrc中添加),Mac和Linux设置方式类似,通常miniconda或者anaconda安装完毕都会提醒你的,添加到环境变量中后,记得source ~/.bashrc 或者~/.zshrc 或者~/.bash_profile

自动生成复制添加即可,具体内容如下所示:

代码语言:javascript
复制
 1###################
 2######anaconda#####
 3###################
 4# >>> conda init >>>
 5__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/zhpfu/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
 6if [ $? -eq 0 ]; then
 7    \eval "$__conda_setup"
 8else
 9    if [ -f "/Users/zhpfu/anaconda3/etc/profile.d/conda.sh" ]; then
10        . "/Users/zhpfu/anaconda3/etc/profile.d/conda.sh"
11        CONDA_CHANGEPS1=false conda activate base
12    else
13        \export PATH="/Users/zhpfu/anaconda3/bin:$PATH"
14    fi
15fi
16unset __conda_setup
17# <<< conda init <<<

配置好Python后,就是利用其conda来安装:

官网安装指导链接:https://github.com/CDAT/cdat/wiki/install 推荐使用Python3,在这里面目前支持到Python3.6.7

Linux (and Windows) 8.1 Linux Py36(https://raw.githubusercontent.com/cdat/cdat/master/conda/cdat-v81_py3.6.Linux.yaml) 8.1 Linux Py36 Mesalib(https://raw.githubusercontent.com/cdat/cdat/master/conda/cdat-v81-nox_py3.6.Linux.yaml) Mac OSX 8.1 OSX Py36(https://raw.githubusercontent.com/cdat/cdat/master/conda/cdat-v81_py3.6.Darwin.yaml) 8.1 OSX Py36 Mesalib(https://raw.githubusercontent.com/cdat/cdat/master/conda/cdat-v81-nox_py3.6.Darwin.yaml) Once downloaded simply run:

在这里我选择的是8.1 OSX Py36 Mesalib 下载链接中的cdat-v81-nox_py3.6.Darwin.yaml文件,使以下命令即可:

一键安装:

conda env create -n cdat81 -f cdat-v81-nox_py3.6.Darwin.yaml

激活对应环境:conda activate cdat81

那么在此你就安装完成了!!!

以下是我的安装过程,部分输出内容:

代码语言:javascript
复制
 1 ✘ ⚙  ~/Downloads  conda env create -n cdat81 -f  cdat-v81-nox_py3.6.Darwin.yaml
 2Warning: you have pip-installed dependencies in your environment file, but you do not list pip itself as one of your conda dependencies.  Conda may not use the correct pip to install your packages, and they may end up in the wrong place.  Please add an explicit pip dependency.  I'm adding one for you, but still nagging you.
 3Collecting package metadata: done
 4Solving environment: done
 5
 6
 7==> WARNING: A newer version of conda exists. <==
 8  current version: 4.6.14
 9  latest version: 4.7.11
10
11Please update conda by running
12
13    $ conda update -n base conda
14
15
16
17Downloading and Extracting Packages
18libtiff-4.0.10       | 561 KB    | ######################################################################################################################################### | 100%
19
20忽略显示中间很多依赖的库...
21
22x264-1!152.20180717  | 2.4 MB    | ######################################################################################################################################### | 100%
23kiwisolver-1.0.1     | 56 KB     | ######################################################################################################################################### | 100%
24proj4-5.2.0          | 7.0 MB    | ######################################################################################################################################### | 100%
25docutils-0.14        | 694 KB    | ######################################################################################################################################### | 100%
26Preparing transaction: done
27Verifying transaction: done
28Executing transaction: - b'Enabling nb_conda_kernels...\nStatus: enabled\n'
29\ b'Enabling notebook extension jupyter-js-widgets/extension...\n      - Validating: \x1b[32mOK\x1b[0m\n'
30- b'Enabling notebook extension nb_conda/main...\n      - Validating: \x1b[32mOK\x1b[0m\nEnabling tree extension nb_conda/tree...\n      - Validating: \x1b[32mOK\x1b[0m\nEnabling: nb_conda\n- Writing config: /Users/zhpfu/anaconda3/envs/cdat81/etc/jupyter\n    - Validating...\n      nb_conda 2.2.1 \x1b[32mOK\x1b[0m\n'
31done
32Ran pip subprocess with arguments:
33['/Users/zhpfu/anaconda3/envs/cdat81/bin/python', '-m', 'pip', 'install', '-U', '-r', '/Users/zhpfu/Downloads/condaenv.tsymguo5.requirements.txt']
34Pip subprocess output:
35Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
36Requirement already up-to-date: cdms2==3.0.0 in /Users/zhpfu/anaconda3/envs/cdat81/lib/python3.6/site-packages (from -r /Users/zhpfu/Downloads/condaenv.tsymguo5.requirements.txt (line 1)) (3.0.0)
37Requirement already up-to-date: regrid2==3.0.0 in /Users/zhpfu/anaconda3/envs/cdat81/lib/python3.6/site-packages (from -r /Users/zhpfu/Downloads/condaenv.tsymguo5.requirements.txt (line 2)) (3.0.0)
38
39#
40# To activate this environment, use
41#
42#     $ conda activate cdat81
43#
44# To deactivate an active environment, use
45#
46#     $ conda deactivate
47
48 ⚙  ~/Downloads       conda activate cdat81
49(cdat81)  ⚙  ~/Downloads  python
50Python 3.6.7 | packaged by conda-forge | (default, Feb 28 2019, 02:16:08)
51[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
52Type "help", "copyright", "credits" or "license" for more information.
53>>>
54

出现上面的提示,激活环境,基本就可以使用了。

数据和脚本

运行脚本:

代码语言:javascript
复制
 1(cdat81)  ✘ ⚙  ~/Downloads  python  vcs3D_multiplot.py
 2AREGSL: xyz
 3TYPEEEEEEEEP coastline
 4 build Volume Pipeline: range =  [-45.96063, 76.74686, -45.96063, 0]
 5setVolRenderCfg
 6initCamera: Camera => ((-161.0, -171.0, 279.0), (146.7, 8.5, -28.6), (0.2906693100067274, 0.6715463369120944, 0.6815694165674988))
 7 **************************************** Deleting ImagePlaneWidget module, id = 4657343680  ****************************************
 8 **************************************** Deleting ImagePlaneWidget module, id = 4656729784  ****************************************
 9 **************************************** Deleting ImagePlaneWidget module, id = 4660272992  ****************************************
10(cdat81)  ⚙  ~/Downloads  python vcs3D_uwnd_slice.py
11AREGSL: xyz
12TYPEEEEEEEEP coastline
13initCamera: Camera => ((-161.0, -171.0, 279.0), (146.7, 8.5, -28.6), (0.2906693100067274, 0.6715463369120944, 0.6815694165674988))
14 **************************************** Deleting ImagePlaneWidget module, id = 4584529312  ****************************************
15 **************************************** Deleting ImagePlaneWidget module, id = 4586762480  ****************************************
16 **************************************** Deleting ImagePlaneWidget module, id = 4586765952  ****************************************
17(cdat81)  ⚙  ~/Downloads 

出图:

测试数据和脚本获取方式,打开链接获取: 链接1.https://zenodo.org/record/17633#.XXEDVpMvMWo 链接2.(推荐)https://aims3.llnl.gov/thredds/catalog/esgcet/254/CDAT-sample.v1.html?dataset=CDAT-sample.v1.geos5-sample.nc

参考

1.https://docs.conda.io/projects/conda/en/4.6.0/_downloads/52a95608c49671267e40c689e0bc00ca/conda-cheatsheet.pdf 2.https://cdat.llnl.gov/gallery.html 3.https://ieeexplore.ieee.org/document/6415905 4.https://github.com/CDAT/cdat/wiki/install 5.https://zenodo.org/record/17633#.XXEDVpMvMWo

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-04-25,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 气象学家 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 前言介绍
  • Gallery
  • 安装
  • 数据和脚本
  • 参考
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档