Visualizing WRF domain

There are many ways to visualize the spatial domain of WRF. I have used several of them in my previous papers, but they turned out to be not so elegant for publications. Therefore, while writing the dissertation recently, I developed some functions that can directly digest WPS namelist (rather than WRF output in some cases) to derive the domain boundaries. Figure 1 is an example plot.

Figure 1. Visualization of WRF domain from home-made Python. Background is the topography from ETOPO1 dataset.

Continue reading

Plotting in Cartopy

I have been using Basemap for years in my Python scripting. Now I would like to slowly switch to Python 3, but Basemap is no longer officially supported there. There seems to be some workaround (such as using customized versions of Basemap), but personally I do not want to try that. So, I guess it is time to find an alternative, such as Cartopy.

In this post, I leave a record of my learning more about Cartopy, as well as some useful tricks (that I found out after hours of experiments..) Continue reading

About packages in Python

I have started my first “big” project in Python: I plan to develop a spatial-temporal analysis toolbox in Python that handles the data often used in geophysics and atmospheric sciences.

The first step is to construct the big structure of the package. So far, I have worked out several obstacles, and I am putting them here to help myself (and probably others).

  1. About importing a folder

In the “__init__.py” file, put a line as “import SAL”.

Home directory in Jupyter

I recently installed Anaconda on my SP3 ( I am switching to Python as my main scripting language). However, by default setup, Jupyter (the successor of Ipython) always starts in my home directory, which is C:\Users\xxxxx. Here are the steps to change this setting.

1. Go to the Jupyter install directory. In my case, it is “D:\Program¬†Files\Anaconda\Scripts”. From here run (in command windows)

jupyter notebook --generate-config

Now we will have a file called “.jupyter/jupyter_notebook_config.py” in the above home directory.

2.¬†Then go to the home directory, and edit the configuration file we just got. Search for ” # c.NotebookApp.notebook_dir = u” “, and put the desired path here. This will result in something like:

# c.NotebookApp.notebook_dir = u’E:\Research\Ipython’

3. Now restart the Jupyter, and it will show the new home directory.