Plot A Cube Diagram Using Matlab

This article discusses how to plot a cube using Matlab.

Here is a final effect displayed as following.

We use the function ‘patch’ to draw the cube.

‘Faces’ represents all faces defined by faceLevel that we want to draw, it is composed of the relationship of the points mapped in the vertices set cubeLevel.

‘Vertices’ is an array with the dimension of  \(m \times 3\), where m is the number of vertices and each raw denote its coordinate [x,y,z].

For example, we have four points cubeLevel=[0 0 0; 1 0 0; 1 0 1; 0 0 1], we could draw a rectangle on x-z plain by setting faceLevel = [1 2 3 4] .

‘FaceVertexCData’ define the color we want to draw for the face. See more details in the Matlab official document.

Plot a nice figure using Matlab (1)

From today I will present a series of examples to show how to plot nice figures using Matlab.

Today’s topic will address on sharing some skills on how to easily plot tight subplots and how to export nice figures with high-quality.
 
This is the example we want to obtain:
 
 
To plot a tight subplot, I recommend using the package tight_subplot.
 
To export a nice figure with a transparent background and edge-cut, I recommend using the package export_fig.

To use an alternative colormap except for defaults, I strongly recommend looking for your favorite colormaps from NCL website and download the .rgb file. After deleting the first few descriptive lines in the .rgb file, it could be loaded easily in Matlab:

To plot a nice contour map, first, plot pcolor and then hold on the figure and then plot contour for the same data with no line.

And here are some normal configurations to control axes.

Use wget to download multiple ocean data from NASA

This article talks about how to download ocean data from NASA using wget.

The contents mainly refer to NASA’s official website here: https://disc.gsfc.nasa.gov/data-access.

First, please refer to the official website to apply an Earthdata account.  Here I describe an example to download multiple ocean data only.

Second, configure wget following instructions provided by formal website as well. Here is a short summary (for Linux/Mac only):

  • Create a .netrc  file in your home directory with following contents: machine urs.earthdata.nasa.gov login <uid> password <password>(without <>)
  • Give permission to this file: chmod 0600 .netrc
  • Create a blank cookie file in home directory named .urs_cookies

Third, taking downloading “Aquarius Official Release Level 3 Rain-flagged Sea Surface Salinity Standard Mapped Image Descending Daily Data V5.0” data for the whole 2012 for example.

To start, find the “Data Access” section and go to ‘OPENDAP’ method to reach the data location. Select ‘2012’ and further go to ‘001’ directory, we’ll see several different files that in this folder, actually they are different data but have the same logical data structure, so they are arranged in the same directory. What we are looking for is “RAIN_MASK_SSS” data, so we click the corresponding link and reach the location of this file.

Just copy the content in DATA URL line and we will obtain the url for this file.

You can of course download this file directly via clicking “Get as NetCDF-4” button, but you can also use a cooler method to download it using this url in a command terminal by typing:

This cooler method makes it possible for us to download multiple files at once.

So the next question is how to obtain the multiple url for files we’re interested in. By observing the naming rules of the file, we can use a MATLAB script to make it. Here is a sample MATLAB script to make it.

Finally, it cannot be easier for us any more, just type following command in the terminal in your preferred directory:

Done.

Data Visualization Using ParaView on Supercomputer

This article just shows a quick glance for what we can expect from ParaView for data visualization on Supercomputer.

Before beginning, you should have prepared your data well for visualization.

Let’s start now.

First, you need to have access to GPU resources in one supercomputer and login to set everthing to work fine.

Then, this is most basic things that you can expected from ParaView:

Of course, it is quite easy to obtain corresponding amazing animation effect!

Click it to view the animation.

Enjoy it!

Draw an animation with NCL

This article tells about how to draw an animation with NCL.

Similarly to Matlab, to obtain an animation, first we need plot  time-series figures with all plot configuration the same except for the data. Then using convert command to convert these independent figures into an animation.

And then run following command in the terminal

Then we obtain the animation.

Draw a 3D-animation with Matlab

This article tells how to draw a 3D figure from 3D data with Matlab, and by the way how to generate an animation for such 3D data with convert  command in Linux terminal.

The 3D figure may looks like this:

Click the figure to see the animation.

The Matlab code:

After running this Matlab script, we will obtain many figures with time going forward. Then we run following command in Linux terminal in figure directory:

Then we obtain the animation.

 

ISDA2018纪实

09.03.2018更新
终于,到了ISDA2018最后一天。总结起这五天的收获,最大的就是意识到了差距,打了几剂强效鸡血。做科研果然不能闭门造车,而是要经常出来透透气,了解下领域内的牛人在做什么,领域内的同龄人在做什么,重新审视下自己在做什么,自己还能做什么。幸运的话还能发现新的问题,找到解决已有问题的办法。

总的来说,经过这次学术会议之后,学术层面我总结出来以下几点短期内要完成的事情:一是尽快把手头的课题推进,二是抓紧提高英语读写水平,三是提高文献管理能力。

其他方面,就是要赶快学德语、锻炼减肥!

这次ISDA2018给了我一次全新的学术会议体验,安排地满当当的学术报告和海报展示无缝衔接,真是痛快!非常感谢慕尼黑大学的组织者们,尤其是Martin。会议期间上认识了不少领域内的前辈和同辈,也游览了慕尼黑老城,品尝了慕尼黑最负盛名的啤酒和猪肘子,会议间隙见了德语班同桌Frau刘夫妇,逛了安联球场,在慕尼黑市中心久负盛名的玛利亚大街的拜仁慕尼黑粉丝商店给龙哥买了17/18赛季主场球衣,并亲眼见证了在它背面印上他的姓(wo的ming)。

至此,完美慕尼黑之行,期待下次慕尼黑之旅!

Before I die

玛丽亚广场-市政厅

———————————————————-08.03.2018——————————————–

今天是ISDA2018的第四天,会议明显开始进入了尾声,每日的报告安排实在是太满了,一天下来能有十五六个,真是有点吃不消。与其在会场昏昏欲睡,索性翘掉了下午四点以后的五场报告,去外面浪了一圈,品尝了一河南哥们自制的捞面,味道很足。

今天听报告似乎有了一个新的收获,就是我越来越能听懂他们的语言了——内容还是比较难懂。这大概是近几日的一个小收获吧。

晚上吃完捞面出来,正巧发现安联球场就在三站地铁外,听说球场的夜景还可以,于是就果断掉头奔向安联球场。

从地铁站出来,远远就望到安联球场孤独地矗立在一座小坡上,周身律动着红色的光芒,好像夜空中闪亮的一颗巨大红宝石。从地铁站到球场入口的路是漫长阴冷的,一路上几乎碰不到任何人。对一个连伪球迷都称不上的我来说,这段长达1.4km的旅程似乎也有那么一丝“朝圣”的味道。一步,一步,又一步,“红宝石”在视野中越来越大,最终完全占据了我的整个眼球,倒映出那个名动地球的名字:Allianz Arena。

安联球场

———————————————————-07.03.2018——————————————–

今天是ISDA2018的第三天,下午展示完海报之后感觉不虚此行,获取了两种相关问题的解决方法,给几个科学家介绍了我的工作,此行的学术目的目标基本达成。

随着会议进入中段,气氛变得越来越友好和丰富了。下午的报告结束后,按照预定计划,我们开启了慕尼黑观光游。专业的导游带领我们穿梭在慕尼黑古城的各种气派建筑间,声情并茂地讲述它们曾经的风云变幻,有令人唏嘘的革命者的悲壮经历,也有令人捧腹的皇室的如烟往事。古朴的建筑就这样静静地矗立在大街上,无言地诉说着或波澜不惊、或平淡如水的过往,只留下在傍晚寒风中瑟瑟发抖的人群以及某一只要风度不要温度的中二青年。

皇帝像?

摸了就会好运来的东西

只要风度的中二青年

晚上七点钟,诙谐的导游把我们带到了晚餐的目的地:Hofbräuhaus,在这里我一晚上就达成了来德国的三大成就:白肠、啤酒和猪肘子!德国的有特色的食物恐怕就这几样了吧,至此,清单上的事项就只剩下去趟安联球场拍个照,买件拜仁慕尼黑的球衣了。

话不多说,直接上图。

HB

Beer Dark

Beer Original

德国大肘子

———————————————————-06.03.2018——————————————–

今天是ISDA2018的第二天,一天下来十五六个报告实在是太累。中午去昨天打探到的打印店打印了海报,本来以为预算挺高了,交付文件之后甩手过了半个小时过来取,结果被账单吓了一大跳,体会了一把被贫穷限制了想象力的感觉。做完展示之后,我一定把它好好带回去供起来贴在家里做装饰,也算是警醒自己以后办事前一定要先问价。

今天听报告最大的感受就是语言水平亟需提高。说、听的能力目前是重点,写作也即将成为重点。除此之外,德语也该认真开始有计划地学习了,学好了不仅方便自己的生活,也算是给自己增添一点乐趣,再想得美一点,以后回国后万一有一天用得上呢。语言的学习在返回汉堡之后要开始规划起来了。

晚上和几个中国人吃饭,几位年长的老师们一言不合就吐槽起北京的房价,房价真是阻碍人才流入的绝佳手段啊。我则和一个来自中国香港的小伙子相谈甚欢,谈到了香港的薪资水平,真是另内地望尘莫及。不过意料到香港和内地的关系时,言语间彼此的误解还是挺深的。香港的政治现状并不像内地媒体描述的那样波澜不惊,不过是几只小蚂蚱在蹦跶;而内地也并不是像香港本地人想象中的那样各种压迫自己。在这种问题上,恐怕也只有多沟通,多交流才能消除彼此的误会,加深彼此的情感吧。

对了,今天吃的牛排,味道还可以,medium。

牛排-薯条

———————————————————-05.03.2018——————————————–

今天是ISDA2018的第一天,收获还挺多。在反复挣扎要不要做Poster之后我终于决定还是展示一下,以免留下遗憾。

这算是第一次在国外参加国际学术会议。和在国内参加过的学术会议相比,ISDA2018简约而不简单。没有什么注册费,主办方提供的是一个纯粹的学术交流的机会。为期五天的会程安排得满满的,看起来十分充实。主办方在活动前期的沟通交流中做的很贴心,会议的最新信息在网站上更新地很及时。在繁忙的会议间隙,主办方还专门挤出时间来安排游览慕尼黑和体验正宗的巴伐利亚啤酒,可以说是非常尽心了。今天报告结束后第一次体验了ICEBREAKER,新奇又有趣,顺便还解决了一顿晚饭。

从口头报告和海报展示来看,ISDA2018主要针对的是大气各方面的同化问题,针对海洋的同化研究几乎没有出现,可能我算是独一份儿吧。这也算是给了增加了一点展示的勇气。我的展示在周三和周四,提前祝福下自己一切顺利。

从今天的大会报告可以看出华人的影响力在资料同化界还是不小的。不过来自本土的科学家还是比较少,出彩的是在美国、丹麦工作的华人科学家。在ICEBREAKER期间和丹麦气象局的杨老师聊到中国资料同化的水平目前怎么样,他保守地说估计落后至少十年。当他们已经把分辨率做到2.5公里的时候,国内的气象局领导还在把目标定为争取2025年做到10公里的分辨率。这个目标太没有野心了。不过听说国内的卫星资料同化近年来势头很猛,已经有了国际领先水平的趋势。但总的来讲,还是任重道远。

中午在会场周边觅食,吃到了10块钱一个的汉堡,牛肉很扎实,非常美味,可以说是贵的有道理。

Hamburg in Munich

Various fraction expression ways in LaTeX

I tried to input an alternative fraction number by \(\LaTeX\) according to a literature today and finally I made it! Here is a conclusion for several fraction format in  \(\LaTeX\).

 

 

The last expression is exactly the one I am looking for!

In the next article, I will talk about the degree symbol in \(\LaTeX\).

Reference:

[1]  https://tex.stackexchange.com/questions/202325/how-to-make-fractions-in-powers-look-good