Loading example_06_SLTAC_adt_lowpass_filered_variance_local.ipynb +3 −3 Original line number Diff line number Diff line %% Cell type:markdown id: tags: # Low-Pass filtered ADT variance %% Cell type:code id: tags: ``` # suppress warnings import warnings warnings.filterwarnings('ignore') ``` %% Cell type:code id: tags: ``` %matplotlib inline import matplotlib.pyplot as plt from pathlib import Path import seaborn as sns import xarray as xr import scipy.signal as signal ``` %% Cell type:code id: tags: ``` plt.rcParams['figure.figsize'] = [15, 9] sns.set_context("notebook", font_scale=1.5, rc={"lines.linewidth": 2.5}) sns.set_style('darkgrid') ``` %% Cell type:markdown id: tags: ## Using a local checkout In `taurus:/data/c2/TMdata/git_geomar_de_data/`, there's a checkout of `SLTAC_GLO_PHY_L4_REP`, `v1.x.x`. Generate a list of all files for the years 1993 and 1994. %% Cell type:code id: tags: ``` data_path = Path("/data/c2/TMdata/git_geomar_de_data/") data_set = "SLTAC_GLO_PHY_L4_REP" ref = "v1.x.x" full_path = data_path / data_set / ref / "data" file_list = [str(fp) for fp in full_path.glob("199[34]/*.nc")] ``` %% Cell type:markdown id: tags: ## Open and select region Select 0°…30°N and 30°W…15°W. %% Cell type:code id: tags: ``` adt = xr.open_mfdataset( file_list, autoclose=True ).sel( latitude=slice(0, 30), longitude=slice(360-30, 360-15) ).adt ``` %% Cell type:code id: tags: ``` print(adt) ``` %% Output <xarray.DataArray 'adt' (time: 365, latitude: 0, longitude: 0)> dask.array<shape=(365, 0, 0), dtype=float64, chunksize=(1, 0, 0)> Coordinates: * latitude (latitude) float32 * longitude (longitude) float32 * time (time) datetime64[ns] 1993-01-01T00:00:21.864513536 ... Attributes: long_name: Absolute dynamic topography standard_name: sea_surface_height_above_geoid units: m comment: The absolute dynamic topography is the sea surface height... grid_mapping: crs %% Cell type:markdown id: tags: ## Build a filter %% Cell type:code id: tags: ``` def butterworth_lowpass_filter(data, order=2, cutoff_freq=1.0/10.0, axis=0): """Filter input data. For unfiltered data, use `cutoff_freq=1`. Currently, this returns a numpy array. """ B, A = signal.butter(order, cutoff_freq, output="ba") return signal.filtfilt(B, A, data, axis=0) ``` %% Cell type:markdown id: tags: ## Calculate filtered fields %% Cell type:code id: tags: ``` # intial filters adt_unfiltered = butterworth_lowpass_filter(adt, cutoff_freq=1) adt_05day_lowpass = butterworth_lowpass_filter(adt, cutoff_freq=1 / 5.0) adt_90day_lowpass = butterworth_lowpass_filter(adt, cutoff_freq=1 / 90.0) # combined filters adt_90day_highpass = adt_unfiltered - adt_90day_lowpass adt_05day_90day_bandpass = adt_05day_lowpass - adt_90day_lowpass ``` %% Cell type:markdown id: tags: # Plot time series %% Cell type:code id: tags: ``` fig, ax = plt.subplots(2, 1, sharex=True) ax[0].plot(adt.coords["time"], adt_unfiltered[:, 0, 0]); ax[0].plot(adt.coords["time"], adt_05day_lowpass[:, 0, 0]); ax[0].plot(adt.coords["time"], adt_90day_lowpass[:, 0, 0]); ax[0].set_ylabel("SSH [m]"); ax[0].legend(["unfiltered", "5day low pass", "90day low pass"], loc=0, ncol=3); ax[1].plot(adt.coords["time"], adt_90day_highpass[:, 0, 0]); ax[1].plot(adt.coords["time"], adt_05day_90day_bandpass[:, 0, 0]); ax[1].set_ylabel("SSH [m]"); ax[1].legend(["90day high pass", "5day-90day band pass"], loc=0, ncol=2); ``` %% Output %% Cell type:markdown id: tags: # Plot fields _ (This still needs work.) _ %% Cell type:code id: tags: ``` plt.contourf(adt_05day_90day_bandpass[0, :, :], cmap="inferno") plt.colorbar() plt.contour(adt_unfiltered[0, :, :], colors=('white',)) plt.contourf(adt_05day_90day_bandpass[0, :, :], cmap="inferno"); plt.colorbar(); plt.contour(adt_unfiltered[0, :, :], colors=('white',)); ``` %% Output <matplotlib.contour.QuadContourSet at 0x7fa648074c18> Loading
example_06_SLTAC_adt_lowpass_filered_variance_local.ipynb +3 −3 Original line number Diff line number Diff line %% Cell type:markdown id: tags: # Low-Pass filtered ADT variance %% Cell type:code id: tags: ``` # suppress warnings import warnings warnings.filterwarnings('ignore') ``` %% Cell type:code id: tags: ``` %matplotlib inline import matplotlib.pyplot as plt from pathlib import Path import seaborn as sns import xarray as xr import scipy.signal as signal ``` %% Cell type:code id: tags: ``` plt.rcParams['figure.figsize'] = [15, 9] sns.set_context("notebook", font_scale=1.5, rc={"lines.linewidth": 2.5}) sns.set_style('darkgrid') ``` %% Cell type:markdown id: tags: ## Using a local checkout In `taurus:/data/c2/TMdata/git_geomar_de_data/`, there's a checkout of `SLTAC_GLO_PHY_L4_REP`, `v1.x.x`. Generate a list of all files for the years 1993 and 1994. %% Cell type:code id: tags: ``` data_path = Path("/data/c2/TMdata/git_geomar_de_data/") data_set = "SLTAC_GLO_PHY_L4_REP" ref = "v1.x.x" full_path = data_path / data_set / ref / "data" file_list = [str(fp) for fp in full_path.glob("199[34]/*.nc")] ``` %% Cell type:markdown id: tags: ## Open and select region Select 0°…30°N and 30°W…15°W. %% Cell type:code id: tags: ``` adt = xr.open_mfdataset( file_list, autoclose=True ).sel( latitude=slice(0, 30), longitude=slice(360-30, 360-15) ).adt ``` %% Cell type:code id: tags: ``` print(adt) ``` %% Output <xarray.DataArray 'adt' (time: 365, latitude: 0, longitude: 0)> dask.array<shape=(365, 0, 0), dtype=float64, chunksize=(1, 0, 0)> Coordinates: * latitude (latitude) float32 * longitude (longitude) float32 * time (time) datetime64[ns] 1993-01-01T00:00:21.864513536 ... Attributes: long_name: Absolute dynamic topography standard_name: sea_surface_height_above_geoid units: m comment: The absolute dynamic topography is the sea surface height... grid_mapping: crs %% Cell type:markdown id: tags: ## Build a filter %% Cell type:code id: tags: ``` def butterworth_lowpass_filter(data, order=2, cutoff_freq=1.0/10.0, axis=0): """Filter input data. For unfiltered data, use `cutoff_freq=1`. Currently, this returns a numpy array. """ B, A = signal.butter(order, cutoff_freq, output="ba") return signal.filtfilt(B, A, data, axis=0) ``` %% Cell type:markdown id: tags: ## Calculate filtered fields %% Cell type:code id: tags: ``` # intial filters adt_unfiltered = butterworth_lowpass_filter(adt, cutoff_freq=1) adt_05day_lowpass = butterworth_lowpass_filter(adt, cutoff_freq=1 / 5.0) adt_90day_lowpass = butterworth_lowpass_filter(adt, cutoff_freq=1 / 90.0) # combined filters adt_90day_highpass = adt_unfiltered - adt_90day_lowpass adt_05day_90day_bandpass = adt_05day_lowpass - adt_90day_lowpass ``` %% Cell type:markdown id: tags: # Plot time series %% Cell type:code id: tags: ``` fig, ax = plt.subplots(2, 1, sharex=True) ax[0].plot(adt.coords["time"], adt_unfiltered[:, 0, 0]); ax[0].plot(adt.coords["time"], adt_05day_lowpass[:, 0, 0]); ax[0].plot(adt.coords["time"], adt_90day_lowpass[:, 0, 0]); ax[0].set_ylabel("SSH [m]"); ax[0].legend(["unfiltered", "5day low pass", "90day low pass"], loc=0, ncol=3); ax[1].plot(adt.coords["time"], adt_90day_highpass[:, 0, 0]); ax[1].plot(adt.coords["time"], adt_05day_90day_bandpass[:, 0, 0]); ax[1].set_ylabel("SSH [m]"); ax[1].legend(["90day high pass", "5day-90day band pass"], loc=0, ncol=2); ``` %% Output %% Cell type:markdown id: tags: # Plot fields _ (This still needs work.) _ %% Cell type:code id: tags: ``` plt.contourf(adt_05day_90day_bandpass[0, :, :], cmap="inferno") plt.colorbar() plt.contour(adt_unfiltered[0, :, :], colors=('white',)) plt.contourf(adt_05day_90day_bandpass[0, :, :], cmap="inferno"); plt.colorbar(); plt.contour(adt_unfiltered[0, :, :], colors=('white',)); ``` %% Output <matplotlib.contour.QuadContourSet at 0x7fa648074c18>