results_slp_sst_Adam

One cycle per T will give the lowest possible frequency (the fundamental). f= 1/T = 1/240 months 2. **What is the //bandwidth// or spectral resolution (Δf) of the spectrum you will create from it?** f= 1/T = 1/240 months The Nyquist frequency is given by cycle/2(deltaT). In this case that is 1 cycle every 2 months. f=2*pi.*[-0.5+1/240:1/240:0.5];
 * 1. Load in your data again, and extract 240-month time series ts1(t) and ts2(t) at some longitude ( the central Pacific, longitude index 80 = 200E = 160W will have a lot of ENSO signal, or pick your own). Take these series from array x and y, not anomx and anomy -- we'll keep the annual cycle in here to help make sure the frequency axis is right (there should be a distinctive peak there). The mean of your time series will appear in the real (cosine) zero frequency bin if you don't remove it.**
 * 1) **What is the fundamental (lowest) frequency possible in this time series?****﻿**
 * 3. What is the Nyquist (highest resolvable) frequency in this time series?**
 * 4. Based on the above, make a 1D frequency array f to use as the x axis on your plots in part 2.**

> ^^Had trouble with this > Above the spectrum is halved.
 * 2. Make the 1D power spectrum of your first field time series:**
 * 1) **Plot the spectrum** as a power spectral density PSD = Δ(variance)/Δf = Pow//Δf vs. frequency f. Label the axes with the right values and units. Area under the curve should be proportional to total power (total variance). Since it's variance in discrete bins, you should ideally use a bar plot or plotting symbols, not just a line plot connecting the "points".
 * You may want to center it on 0 frequency (by shifting the array) to show a symmetric spectrum with positive and negative frequencies.
 * Or you may prefer to just half the spectrum (PSD vs. the absolute value of f -- remember to double the positive frequency part of Pow so area = variance).

The first plot is rebinned over 2 points, the second plot is rebinned over 3 points:
 * You may also choose to rebin f and PSD to coarser spectral bands, if the plot is too noisy.




 * 2. Plot the spectrum** as an indefinite integral (cumulative power) vs. period or log period.


 * 3. Plot the spectrum** as f*power vs. log(f). Area under the curve should still be proportional to total power (variance).[[image:ac_hw4_23.jpg]]


 * 4. Plot the spectrum** as f*power vs. log(period). Area under the curve should still be proportional to total power (variance).[[image:ac_hw4_24.jpg]]


 * 5. Plot the spectrum** as log(Pow) vs. log(f).
 * Why this way? Area under the curve is no longer meaningful. The reason to plot a spectrum this way is to see if it looks like a straight line. If the slope is -1, you have Pink Noise [] aka [|Flicker noise] aka []. If the slope is -2, you have [|Brownian noise (hear an acoustic sample here!)]. Slopes of -3 or -5/3 are predicted for KE (velocity variance) by 3D and 2D turbulence theory (based solely on scaling arguments). No matter what the slope, a straight line implies a power law, although the [|implications of finding a power law may be less profound than they appear].[[image:ac_hw4_25.jpg]]


 * 6. Plot the spectrum in your favorite format, after rebinning** f and Pow to coarser frequency bins. [[image:ac_hw4_26.jpg]]


 * 7. Plot the spectrum in your favorite format,****overplotting** the PSD you get //when you **pad the ends of the time series with zeroes**//. This will highlight the errors associated with making your time series as if it were periodic.
 * to do this part, just make a new data array tspad = [ts*0, ts-mean(ts), ts*0] (IDL) or [ts*0 ts-mean(ts) ts*0]; (Matlab)[[image:ac_hw4_27.jpg width="504" height="378"]]


 * Adjust the variance of the padded time series spectrum so that it overlays the unpadded spectrum well.


 * 1) **Extra** credit on 1D spectra: explore end explain some of the virtues of one of the MANY special built-in functions or packages for spectral analysis (periodogram or other special functions in Matlab, IDL wavelet GUI, spectraworks.com package for Mac, etc etc.).


 * 3. Significance testing of peaks: Overplot a red noise spectrum and its 95% significance level (the F test).**
 * 1) **Estimate** your lag-1 autocorrelation value r1 for your field1.

[r,lags]=xcorr(ts1, 'coeff' );

r1=r(241); > r1=0.9958 2. Use r1 to **create and** power spectrum of an autoregressive (AR(1)) or "red noise" process with the same r1 and same variance as your series. 3. Use the [|F test] to **overplot** a line indicating the 99% significance level for spectral peaks.



==**4. Cross-spectrum of your 2 variables. (see section 3.1.2 of Hsieh handout).** ==
 * 1) **Compute the 2 FFTs** of your 2 time series. xhat = fft(ts1); yhat = fft(ts2); **and plot the spectrum of your field 2** in your favorite depiction from Part 2.6 above, if you didn't already.
 * 2. Compute the cross-spectrum** by complex multiplication: Cross = xhat .* conj(yhat)
 * 3. Separate** the cross spectrum into its real and imaginary parts.

R and I in Hsieh (handout) section 4. often see them called P(f) and Q(f) (the "in-phase" and "quadrature" parts). Quadrature means 90 degrees out of phase: sin and cos components. **Plot a cumulative spectrum of the in-phase part P (or R) as in 2.2 above.** Show that it ends up at the covariance of ts1 and ts2, mean( (ts1-mean(ts1)) * (ts2-mean(ts2)) ). What timescales contribute the most to the overall correlation (or covariance) of your 2 time series, according to this plot?
 * 5. Plot the squared coherency spectrum** (or just "coherence" in lazy language you will often hear). It is (P 2 +Q 2 ) /(xPow 2 ) /(yPow 2 ). Why is it always 1?? (Hsieh 3.33-3.36)


 * 6. Plot the squared coherency spectrum after rebinning** P, Q, xPow and yPow to coarser frequency bins.

Reasoning: For physically real phenomena operating in a general, broad frequency band (like ENSO), the variables x and y will have the same phase relationship for all frequencies since they are physically linked, so averaging (rebinning) won't decrease coherency much. For random, non physically linked fluctuations of x and y, the in-phase and quadrature components will both be random (positive at one frequency, negative at the next), so the averaging will weaken the coherency when the phase relationship is random. See Hsieh handout, (3.37).




 * 7. Plot the phase spectrum** arctan(Q/P), and interpret the phase relationship between your variables in a frequency band where there is strong coherence (like ENSO) by showing this phase relationship using time series plots zoomed in to one dominant case of this strong oscillation (like an ENSO event).



**5. 2D FFT**

 * 1) **Compute the 2D FFT (xhat) of your primary field's time-longitude section (fft2 in Matlab, fft in IDL).**
 * 2) **Display this 2D fft** as an image or contour plot, as a function of frequency f and zonal wavenumber k.
 * You have an f array: you just need to make a k array, following the logic in question 1 above in the x direction.
 * Shift the Power array (with fftshift in Matlab, or the shifting keyword in IDL8's FFT routine) to put low frequencies in the middle of the image.
 * You may want to display the log or square root of power, so the lowest frequencies don't dominate so strongly and you see more structure.
 * You should probably zoom in on the lowest frequency region.
 * 1) Can you interpret this spectrum directly in terms of the size and orientation of stripes seen in the time-longitude section image? >>
 * 2) Can you interpret this spectrum in terms of the rebinned variance diagram from HW3, problem 4?




 * 3. Show a filtered data image**: Multiply the xhat 2-dimensional array by zero (mask it out) in some spectral region. Maybe low pass (exclude wavenumbers and frequencies > 10 times the fundamental). Or try band pass: can you find and zero out the El Nino peak? Anything that interests you. Explore, then teach us what you learned. Transform back to x-t space with ifft in Matlab or fft(xhat, /inverse) and display filtered and unfiltered data.