Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions custom_scripts/AutomateEntireSoft.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
% This is an example to automate entire Eddy detection and tracking software
% and also to visualize outputs. Each section elucidates different aspect
% of automatization.
clc; clear
% =====Input arguments for set_up_data_regional=====%
NetCDF_files_path = '~/Desktop/Satellite_data/MADT-SLA/';
ssh_NetCDF_name = 'sla';
lat_NetCDF_name = 'lat';
lon_NetCDF_name = 'lon';
lonlimit = [100, 175];
latlimit = [-35, -70];
ssh_save_path = '~/Documents/MATLAB/OceanEddies-master/Myssh';
%=======
% Preprocessing data for complete run
set_up_NRTdata_regional(NetCDF_files_path, ssh_NetCDF_name, lat_NetCDF_name, lon_NetCDF_name, ...
lonlimit, latlimit, ssh_save_path)

%% Detection and tracking of eddies
clear;
% =====Input arguments for complete_run=====%
% My SLA data archived in \textbf{Myssh} directory
ssh_path = '~/Documents/MATLAB/OceanEddies-master/Myssh/';
% I save my outputs at \textbf{MyRuns/MyEddies} and \textbf{MyTracks} directories.
% Note: Both directory will be generated by script if not exist at provided location.
% Furthermore, it will also generate directories for modified eddies and track if you
% had allowed eddy to unassociate. i.e 'yes' at fake eddy argument.
eddies_save_path = '~/Documents/MATLAB/OceanEddies-master/MyRuns/MyEddies/eddies';
tracks_save_path = '~/Documents/MATLAB/OceanEddies-master/MyRuns/MyTracks/tracks';
% These are extra outputs more detail please follow up text in section 3
viewer_data_save_path = '~/Documents/MATLAB/OceanEddies-master/MyRuns/';
viewer_path = '~/Documents/MATLAB/OceanEddies-master/MyRuns/Extra_viewer/';
%========
% running software
complete_run(ssh_path, eddies_save_path, tracks_save_path, 'yes', viewer_data_save_path, viewer_path)

%% Visualization of eddies track after filtering by lifespan
clear;
% =====Input arguments for plotTrack=====%
path = '~/Documents/MATLAB/OceanEddies-master/MyRuns/modified_tracks';
cycfilename = 'cyclonic_tracks_processed.mat';
acycfilename = 'anticyc_tracks_processed.mat';
load([path, cycfilename])
load([path, acyfilename])
% I would filter eddies whose lifespan is \geq 28days
filter_day = 28;
% global_coastline.txt file contains global longitudes and latitude
coast = load('global_coastline.txt');
xtick = 100:10:175;
ytick = -70:5:-35;
%======
% Filtering and plotting
plotTrack(cyclonic_tracks, anticyc_tracks, filter_day, coast, xtick, ytick)
98 changes: 98 additions & 0 deletions custom_scripts/EddyAnimation.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
% This script generates an Animation to identify desired edd(y)ies for
% further analysis
%
% NOTE: SLA overlaid by contours of 0.1 0.4 and 0 m
% - with center position obtained from the Algorithms
% NOTE: This is only for cyclonic eddies, for anticyclonic eddies make
% changes, suggested below
%===============
% Ramkrushn Patel, IMAS/UTAS
%===============

% CONTENTS:
% 1) Loading Sea Surface Height data
% 2) Loading Eddies locations
% 3) Preparing Movie

%% 1) Loading Sea Surface Height data
clear; clc;

old_path = pwd;
ssh_path = '~/Desktop/Satellite_data/JoanModelRun/';
cd(ssh_path)
%
filenames = dir('ssh_*.mat');
nfiles = length(filenames);
%
load lon.mat
load lat.mat
load dates.mat
%
cd(old_path)

%% 2) Loading Eddies location

eddy_path = '~/Documents/MATLAB/OceanEddies-master/MyRuns/JoanEddy/';
fname = 'chelton_structured_tracks.mat';
load([eddy_path, fname])

% Extracting variables
e_sign = eddies_t.cyc;
% get only cyclonic eddies/anticyclonic eddies
cyc = e_sign == 1; % -1 for cyclonic % ---------- Change here for type of eddies
%
e_lon = eddies_t.x(cyc); % eddies center longitude
e_lat = eddies_t.y(cyc); % eddies center latitude
e_trackday = eddies_t.track_day(cyc); % tracked date
e_id = eddies_t.id(cyc); % eddies id

% Loading coastlines
c = load('~/Documents/MATLAB/Construction_Site/global_coastline.txt'); % Coast Line

%% 3) Preparing movie
close all
h = figure(11);
set(h, 'Position', [100 678 560 420])
% ==Prepare Video file==
vidObj = VideoWriter('EddyAnimationACyc.avi'); %==== Change file name if you re-run the script
fps = 7;
vidObj.FrameRate = fps;
vidObj.Quality = 100;
open(vidObj)
%
for fInd = 1:nfiles
disp(['Current File: ', int2str(fInd)])
%
load([ssh_path, filenames(fInd).name]) % SLA data
time = num2str(dates(fInd));
time = datestr(datenum(time,'yyyymmdd'));
%
% Getting eddies for the day
da_id = dates(fInd);
ind = find(e_trackday == da_id);

% Plotting
% Background MSLA
pcolor(lon, lat, data); shading interp
caxis([-0.5, 0.5])
colormap(redblue(length(-0.5:0.02:0.5) - 1))
colorbar
hold on
% Plotting eddies
plot(e_lon(ind), e_lat(ind), '.m', 'MarkerSize', 20)
text(e_lon(ind), e_lat(ind), num2str(e_id(ind)),'color','k','fontsize', 14, 'fontweigh','bold') % numbering eddies
% Ensuring closed contours
contour(lon, lat, data, [-0.1, -0.1], '-', 'linewidth', 1, 'color', 'b');
contour(lon, lat, data, [0.1, 0.1], '-', 'linewidth', 1, 'color', 'r');

% ======
plot(c(:,1), c(:,2), 'k-', 'LineWidth', 3);
s1 = sprintf('Day %d Date: %s', fInd, time);
title(s1, 'fontsize', 14, 'fontweigh', 'bold')
M(fInd) = getframe(h); %#ok
clf
clear data time s1 ind da_id
end
writeVideo(vidObj, M)
close(vidObj)
clear M h
37 changes: 37 additions & 0 deletions custom_scripts/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Custom Scripts to extend functionality of OceanEddies software
*This ReadMe.md belongs to **custom_scripts** directory*

## Author
Ramkrushnbhai S. Patel $^{1,2}$

1: [Institute for Marine and Antarctic Studies](https://www.imas.utas.edu.au), [University of Tasmania](https://www.utas.edu.au), Hobart, Tasmania, Australia

2: [Australian Research Council Centre of Excellence for Climate Extremes](https://climateextremes.org.au), University of Tasmania, Hobart, Tasmania, Australia

## ABOUT
The *custom_scripts* directory provides the scripts that automatise the detection and tracking of eddies using Faghmous et al. 2015 software.
## CONTENTS
Directory | Description
--------- | ----------
custom_scripts | Collection of preprossing, post-processing and analyses scripts
txt file | global coastline data
ReadMe | -

### Example scripts
*AutomateEntireSoft.m* : demonstrates how to automate the software from altimetry data\
*idealizedmodelautomate.m* : demonstrates how to automate the software from idealised model output data\
*EddyAnimation.m* : makes movie to identify specific types of eddies\


### Preprocessing functions
*set_up_NRTdata_regional.m* : prepares near-real-time daily SLA maps for the software\
*set_up_DTdata_regional.m* : prepares delay-mode daily SLA maps for the software with modified area-map algorithm\
*set_up_data_3D2daily.m* : converts 3D.mat file to daily to conform complete_run.m function input\
*set_up_data_3D2dailyModel.m* : flexible compare to 3D2daily function\
**

### Supporting functions
*plotTrack.m* : visualise eddies track redily after the detection for the quick summary

### Contact
If you have any question or feedback, please raise an issue in [OceanEddiesToolbox](https://github.com/rampatels/OceanEddiesToolbox.git) repository.
Loading