气象学家公众号 发表于 2024-4-11 23:50:42

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

前言介绍
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命令,导入配置文件即可,一键式安装,轻松省事。但是有两个需要注意的地方:


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

自动生成复制添加即可,具体内容如下所示:
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<img src="static/image/smiley/default/shy.gif" border="0" smilieid="8" alt=":$">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

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

以下是我的安装过程,部分输出内容:
1 ✘ ⚙  ~/Downloads  conda env create -n cdat81 -fcdat-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. <==
8current version: 4.6.14
9latest 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: <a href="https://pypi.tuna.tsinghua.edu.cn/simple" target="_blank">https://pypi.tuna.tsinghua.edu.cn/simple</a>
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 on darwin
52Type "help", "copyright", "credits" or "license" for more information.
53>>>
54出现上面的提示,激活环境,基本就可以使用了。

数据和脚本
运行脚本:
1(cdat81)✘ ⚙  ~/Downloads  pythonvcs3D_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 出图:


测试数据和脚本获取方式,在气象学家公众号后台回复“uvcdat”,
或者打开链接获取:
链接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


文章来源于微信公众号:气象学家


继续宠爱 发表于 2024-4-27 16:44:11

我喜欢你的这种解决方式,非常创新!
页: [1]
查看完整版本: Python处理CMIP数据及3D可视化-基于UVCDAT