# Assignment 8 : Xarray¶

Due Thursday, Oct. 26

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

I have pre-downloaded and subsetted a portion of this dataset for use in our class. You can download it here: http://ldeo.columbia.edu/~rpa/CERES_EBAF-TOA_Edition4.0_200003-201701.condensed.nc. The size of the data file is 702.53 MB. It will take a minute or two to download.

Considering reviewing the FAQs for this dataset before getting started.

Start by importing xarray, numpy, and matplotlib

## 2.2) From this, make a 2D plot of the the time-mean TOA longwave, shortwave, and solar radiation¶

(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¶

Again, 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¶

We can go beyond a weight factor and actually calculate the area of each pixel of the dataset, using the formula

$$dA = R^2 \cos(\lambda) d\lambda d \varphi$$

where $d\lambda$ and $d\varphi$ are the spacing of the points in latitude and longitude (measured in radians). We can approximate Earth's radius as $R = 6,371$ km.

## 4.1) calculate the pixel area using this formula and create a 2D (lon, lat) DataArray for it¶

(Xarray's ones_like function can help you easily create and broadcast DataArrays.) Verify that the sum of all the pixels equals the Earth's true surface area as evaluated using the formula for the area of a sphere (yes, I know the Earth is not a sphere...it's just a homework problem).

Multiplying the pixel area from above with the radiative flux gives you the total amount of radiation absorbed in each pixel

## 4.2) Calculate and plot the total amount of net radiation in each 1-degree latitude band¶

Label with correct units

## 4.3) Plot the cumulatuve sum in latitude of that quantity¶

Label with correct units. (Hint: check out xarray's cumsum function.)

This curve tells you how much energy must be transported meridionally by the ocean and atmosphere in order to account for the radiative imbalance at the top of the atmosphere.

You should get a curve tht looks something like this ## 5.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.3) Calculate and plot composites of time-mean outgoing shortwave and longwave radiation for low and high cloud area regions¶

Your results should be 2D maps.

Xarray's where function will be helpful.

## 5.4) Using the weight factor from 3.2, calculate the global mean values of shortwave and longwave radiation, composited in high and low cloud regions¶

What is the overall effect of clouds on shortwave and longwave radiation?