Assignment 5 : Xarray¶
Part I: Xarray for earth's energy budget¶
In this assignment, we will use Xarray to analyze top-of-atmosphere radiation data from NASA's CERES project.
Public domain, by NASA, from Wikimedia Commons
Start by importing xarray, numpy, and matplotlib
1.1) Open the CERES dataset and display its contents.¶
The CERES dataset has been predownloaded and processed. You can access the dataset here: /scratch/xj103/rcaes/CERES_EBAF-TOA_Edition4.0_200003-201701.condensed.nc
1.2) Print out the long_name
attribute of each variable¶
2.1) Calculate the time-mean of the entire dataset¶
2.2) From this, make a 2D plot of the the time-mean TOA longwave, shortwave, and incoming solar radiation flux¶
(All-Sky conditions)
Note the sign conventions on each variable.
2.3) Add up the three variables above and verify (visually) that they are equivalent to the TOA net flux¶
You have to pay attention to and think about the sign conventions for each variable in order to get this to work.
3.1) Calculate the global mean of TOA net radiation directly from the dataset¶
Since the Earth is approximately in radiative balance, the net TOA radiation should be zero. But taking the naive mean from this dataset, you should find a number far from zero. Why?
The answer is that each "pixel" or "grid point" of this dataset does not represent an equal area of Earth's surface. So naively taking the mean, i.e. giving equal weight to each point, gives the wrong answer.
On a lat / lon grid, the relative area of each grid point is proportional to $\cos(\lambda)$. ($\lambda$ is latitude)
3.2) Create a weight
array proportional to $\cos(\lambda)$ with a mean value of 1¶
Verify its mean is 1 and plot it. Be careful about radians vs. degrees.
3.3) Redo your global mean TOA net radiation calculation with this weight factor¶
Remember Xarray's handling of broadcasting. Don't make this harder than it needs to be.
This time around, you should have found something much closer to zero. Ask a climate scientist what the net energy imbalance of Earth due to global warming is estimate to be. Do you think our calculation is precise enough to detect this?
3.4) Now that you have a weight
factor, verify that the TOA incoming solar, outgoing longwave, and outgoing shortwave approximately match up with the cartoon above¶
4.1) Plot the time-mean cloud area fraction (day and night)¶
4.2) Define boolean masks for low cloud area ($\le$ 25%) and high cloud area ($\ge$ 75%)¶
Use the whole dataset, not the time mean.
5.1) Make a figure of 4 subplots that show the seasonal mean TOA outgoing shortwave and another figure for TOA longwave radiation¶
5.2) Subset the dataset for NJ region (74˚W - 75.6˚W, 38.8˚N - 41.5˚N) and calculate the monthly climatology of cloud visible optical depth and cloud area fraction¶