---
# System prepended metadata

title: 'Week 3: OLR Data Analysis'
tags: [111 Summer Research]

---

## Data Info.
1. Data name: olr_from1979.nc
2. Format:
    * Time 
        * Start: **Jan 01, 1979**
        * End: **Apr 30, 2022**
        * Length: **15826**
    * Longitude
        * Area: **Global (0~359)**
        * Grid: **$2.5^\circ$**
        * Length: **144**
    * Latitude
        * Area: **Global (-90~90)**
        * Grid: **$2.5^\circ$**
        * Length: **73**
    * OLR
        * Area: **Global (0~359; -90~90)**
        * Grid: $2.5^\circ \times 2.5^\circ$
        * Type: **Daily global observation**
        * Shape: **(15826, 73, 144)**

## Analysis Method
Using the same method as Week 2.
By using the concept of Forier transform, conducting spectrum analysis.
And using the result of DFT to compute power spectrum of the OLR data.
Detail code can read:
https://colab.research.google.com/drive/1fc2y7X8jYpj66FSUmE_CtcXAjtyZgyMM?usp=sharing
as a reference.

## Pre-processing of the OLR Data
### CDO method
CDO (Climate Data Operator) is a system of command to process climate data.
To pre-process the OLR data, there are three command required:

1. **ydaymean**
    Computing the mean on time series.
2. **lowpass**
    Forming the first n harmonics.
3. **ydaysub**
    Minus raw data with harmonics.
    
Detailed code:
https://drive.google.com/file/d/1Q5_bp0EOi5yireYW3g06OyUwQ_gt2iLz/view?usp=sharing

### Check the Correctness of These Pre-processing
#### Check the first 3 Harmonics in Different Latitude
![](https://hackmd.io/_uploads/BkPwFPL9n.png)
In this image, it is obvious that all the harmonics in tropic area, the harmonics is smooth.
Therefore, the harmonics is formed successfully.
#### Compare the First 3 Harmonics with Raw Data
![](https://hackmd.io/_uploads/Syqe9vU53.png)
Harmonics is components of total OLR data.
Since the data is constructed by many different harmonics, the line of first 3 harmonics need to be included in the line of raw data.
This image shows this property, therefore it is success.
#### Plot the Raw Data with Filted Data
Since the data of filted data has minus the first 3 harmonics, therefore the filted data can be regarded as anomaly of the harmonics.
Thus, the region of its value with more close to 0, compared with raw data.
![](https://hackmd.io/_uploads/r1Ja2vL52.png)
This image shows the property discussed above, therefore the processing the success.

By the three examination above, the pre-processing done on the raw OLR data is successfully completed.

## Formating the OLR Data
Since the OLR data, or even other features, can be constructed by symmetry part and anti-symmetry part.
The symmetry and anti-symmetry axis is the equator.
Follow is the way to form symmetry and anti-symmetry part of data:
### Symmetry Data
Similar to weighting average, the weight the data product with is $cos(lat)$.
the process like:
```
# do cosine function on lat
sym_lat = np.cos(np.deg2rad(lat_fil))
lat_sum = np.sum(sym_lat)

#weighting the OLR Data
weight_sym_olr = olr_fil * sym_lat[None, :, None]
avg_sym_olr    = np.sum(weight_sym_olr, axis = 1) / lat_sum
```
### Anti-symmetry Data
Similar to weighting average, the weight the data product with is $cos(lat)$ at northern semisphere, and $-cos(lat)$ at southern semisphere.
the process like:
```
# do cosine function on lat
asy_lat = np.empty(13)
asy_lat[:6] = -np.cos(np.deg2rad(lat_fil[:6]))
asy_lat[6:] =  np.cos(np.deg2rad(lat_fil[6:]))

#weighting the OLR Data
weight_asy_olr = olr_fil * asy_lat[None, :, None]
avg_asy_olr    = np.sum(weight_asy_olr, axis = 1) / lat_sum
```

## Split Data
Since the properties is quite different at winter and summer, we thus need to split the data.
In this file, I choose winter (DJF) data to analyze.
There is the way to do the process of split data:
```
monthly_range = pd.date_range(start = '1979-01-01', end = '2022-04-30', freq = 'D')
original_data = pd.DataFrame(avg_sym_olr, index = monthly_range)

monthly_data = []
for _, month_data in original_data.resample('M'):
    monthly_data.append(month_data.values)

for i in range(1979, 2023):
  if (i<2022):
    globals()['sym_Dec_' + str(i)] = monthly_data[11 + 12*(i-1979)]
  if (i>1979):
    globals()['sym_Jan_' + str(i)] = monthly_data[0 + 12*(i-1979)]
    globals()['sym_Feb_' + str(i)] = monthly_data[1 + 12*(i-1979)]

for i in range(1979, 2022):
  if (globals()['sym_Feb_' + str(i+1)].shape[0] == 29):
    globals()['sym_olr_DJF_' + str(i) + '_' + str(i+1)] = np.concatenate((globals()['sym_Dec_' + str(i)], globals()['sym_Jan_' + str(i+1)], globals()['sym_Feb_' + str(i+1)][:-1, :]), axis = 0)
  else :
    globals()['sym_olr_DJF_' + str(i) + '_' + str(i+1)] = np.concatenate((globals()['sym_Dec_' + str(i)], globals()['sym_Jan_' + str(i+1)], globals()['sym_Feb_' + str(i+1)]), axis = 0)
```
Using `pandas` package to split the data along time (#0) axis into monthly data.
And reconstructing the data into the form of DJF form.

## Spectrum Analysis
Using the same method as Week 2, conducting DFT function on the OLR data, to compute the power spectrum of OLR data.
And there is the result of analysis:
### Symmetry Data
![](https://hackmd.io/_uploads/rkEEHGY92.png)

### Anti-symmetry Data
![](https://hackmd.io/_uploads/H1sVBzK9h.png)

The contour doesn't show the real value of the power, it is done logarithm with exponential-base.

## Background OLR data
Since there is many periodic phenomenon presented in the power spectrum above, it will affect us to determine the signal of non-periodic (random) signal.
In this case, the signal of periodic phenomenon must be removed.
The method used in this report is using 1-2-1 filter to computing smoothen OLR diagram in $\omega - k$ diagram.
Being more detailed, the filter is to do weighting average on the value and its neighbors, this can make the signal of random phenomenon be removed.
And the diagram will only exist the signal of periodic signal.
This data have combine the symmetry data and anti-symmetry data of this OLR file, since the strength of the two types have difference.
The way to process the data is to average the two types, and conducting 1-2-1 filter on the average OLR profile.
However, the problem will exist when the condition is the first or the last element of the data array.
Therefore, in order to solve the edge problem, the data is expanded by the axis applied.
Left to the original 0 element, will be expanded with the 1 element.
Righter to the original last element, will be expanded with the last 2 element.
In signal processing, this is called **mirrored**.
By this method, its background OLR data looks like:
![](https://hackmd.io/_uploads/HylDdzY5n.png)

## Statically Significant Spectral Peaks in OLR
In the discussion in the section above, the phenomenon we wanna observe is the non-linear and random phenomenon.
Therefore, the background signal needs to be removed.
The method to do so is to divide the symmetry data and anti-symmetry data with background data to show the statically significant spectral peaks in OLR.
By applying this method, there is the $\omega - k$ diagram:
### Symmetry Form
![](https://hackmd.io/_uploads/Bkpv9zYc2.png)
There are some special signal in the diagram.
Firstly, at wavenumber = 2, frequency < 0.5, there is a area super "red", this is the signal of **MJO** (Madden-Julia Oscillation).
Secondly, at wavenumber = -2~-6, frequency = 0~0.1, there is a super strong signal which is **n = 1 ER wave**.
Last, at wavenumber = 4~10, frequency = 0.1~0.3, the super strong signal is **Kelvin wave**.
### Anti-Symmetry Form
![](https://hackmd.io/_uploads/HJzO5zFch.png)
In this diagram, there is a signal, wavenumber = -4~8, frequency = 0.2~0.4, this is the signal of **MRG wave**.


## Detailed Code
https://drive.google.com/file/d/1vzbm81mTft3P2X_1ZTexWhwb_HKJphr1/view?usp=drive_link