Skip to content
Snippets Groups Projects
Commit 143c1ed7 authored by jml1g18's avatar jml1g18
Browse files

other libraries to make code independent

parent f13ff8ab
No related branches found
No related tags found
No related merge requests found
Showing
with 1002 additions and 1 deletion
......@@ -13,6 +13,10 @@ function batch_execute(job_dir)
hostname= getenv('HOSTNAME');
end
%% add to path
cur_dir = fileparts(mfilename('fullpath'));
addpath(genpath(cur_dir));
%% report
fprintf('--------------------------------------------------------------\n');
fprintf('[%s] %s BATCH PROCESSING BEGIN\n', hostname, datestr(now));
......
......@@ -5,6 +5,7 @@
% j.m.lawson@soton.ac.uk
% Created: 11/09/2019
%
addpath(genpath(fileparts(mfilename('fullpath'))));
%% input parameters: file paths
% where to save jobs
......@@ -29,7 +30,7 @@ vec_pat = '%s/B%05d.mat'; % output vector field file pattern
% processing flags
b_use_mask = true; % use mask file?
b_overwrite = true; % overwrite existing vector fields?
b_execute_now = false; % start processing now?
b_execute_now = true; % start processing now?
% PIV correlation settings
i_frames = {[1 2],[3 4]}; % indices of frame pairs to cross-correlate
......
function clim(lim)
set(gca, 'clim', lim);
end
\ No newline at end of file
function ret = hms(seconds_elapsed)
ret = fix(mod(seconds_elapsed, [0, 3600, 60]) ./ [3600, 60, 1]);
end
\ No newline at end of file
function [dFdx, dFdy] = lsqgradient2d(F, dx, dy)
%% [dFdx, dFdy] = lsqgradient(F, dx, dy)
% computes numerical gradient based on second order,
% least squares approximation as detailed in PIV: A Practical Guide
%
% dF/dx_i ~= 2 f_(i+2) + f_(i+1) - f(i-1) - 2f_(i-2)
% ------------------------------------
% 10 dx_i
%
% F must be a 2D array of size Nx x Ny
% dFdx_i an Nx x Ny array
% at the edges,
% dFdx_i is calculated with either first order central
% differences or at the very edges, forwards/backwards differences
%
%% parse input
if nargin < 2
dx = 1;
dy = 1;
elseif nargin < 3
dy = 1;
end
%% allocate memory for dFdx
Nx = size(F, 1);
Ny = size(F, 2);
dFdx = nan(size(F), class(F));
dFdy = nan(size(F), class(F));
%% forwards and backwards difference at edges
dFdx(1, :) = (F(2,:) - F(1,:) ) / dx;
dFdy(:, 1) = (F(:,2) - F(:,1) ) / dy;
dFdx(end,:) = (F(end,:) - F(end-1,:)) / dx;
dFdy(:,end) = (F(:,end) - F(:,end-1)) / dy;
%% first order central difference near edges
if Nx >= 3
for i = [2 Nx-1]
dFdx(i, :) = (F(i+1,:) - F(i-1,:)) / (2*dx);
end
end
if Ny >= 3
for j = [2 Ny-1]
dFdy(:, j) = (F(:,j+1) - F(:,j-1)) / (2*dy);
end
end
%% second order least squares near middle
% use an expansion of f(x)' which is accurate to O(dx^4)
for i = 3:(Nx-2)
dFdx(i, :) = (2*F(i+2,:) + F(i+1,:) - F(i-1,:) - 2*F(i-2,:)) / (10*dx);
end
for j = 3:(Ny-2)
dFdy(:, j) = (2*F(:,j+2) + F(:,j+1) - F(:,j-1) - 2*F(:,j-2)) / (10*dy);
end
end
function c = redblue(m)
%REDBLUE Shades of red and blue color map
% REDBLUE(M), is an M-by-3 matrix that defines a colormap.
% The colors begin with bright blue, range through shades of
% blue to white, and then through shades of red to bright red.
% REDBLUE, by itself, is the same length as the current figure's
% colormap. If no figure exists, MATLAB creates one.
%
% For example, to reset the colormap of the current figure:
%
% colormap(redblue)
%
% See also HSV, GRAY, HOT, BONE, COPPER, PINK, FLAG,
% COLORMAP, RGBPLOT.
% Adam Auton, 9th October 2009
if nargin < 1, m = size(get(gcf,'colormap'),1); end
if (mod(m,2) == 0)
% From [0 0 1] to [1 1 1], then [1 1 1] to [1 0 0];
m1 = m*0.5;
r = (0:m1-1)'/max(m1-1,1);
g = r;
r = [r; ones(m1,1)];
g = [g; flipud(g)];
b = flipud(r);
else
% From [0 0 1] to [1 1 1] to [1 0 0];
m1 = floor(m*0.5);
r = (0:m1-1)'/max(m1,1);
g = r;
r = [r; ones(m1+1,1)];
g = [g; 1; flipud(g)];
b = flipud(r);
end
c = [r g b];
File added
File added
File added
function [frameInfo]=MakeFrameInfo(Frame)
Names = Frame.ComponentNames;
frameInfo.choices = zeros(12,1);
for i=1:size(Names,1),
if strcmp(Names{i},'U0')==1, frameInfo.choices( 1) = i; end;
if strcmp(Names{i},'V0')==1, frameInfo.choices( 2) = i; end;
if strcmp(Names{i},'W0')==1, frameInfo.choices( 3) = i; end;
if strcmp(Names{i},'U1')==1, frameInfo.choices( 4) = i; end;
if strcmp(Names{i},'V1')==1, frameInfo.choices( 5) = i; end;
if strcmp(Names{i},'W1')==1, frameInfo.choices( 6) = i; end;
if strcmp(Names{i},'U2')==1, frameInfo.choices( 7) = i; end;
if strcmp(Names{i},'V2')==1, frameInfo.choices( 8) = i; end;
if strcmp(Names{i},'W2')==1, frameInfo.choices( 9) = i; end;
if strcmp(Names{i},'U3')==1, frameInfo.choices(10) = i; end;
if strcmp(Names{i},'V3')==1, frameInfo.choices(11) = i; end;
if strcmp(Names{i},'W3')==1, frameInfo.choices(12) = i; end;
if strcmp(Names{i},'ACTIVE_CHOICE')== 1, frameInfo.best = i; end;
if strcmp(Names{i},'ENABLED') == 1, frameInfo.enable = i; end;
if strcmp(Names{i},'MASK') == 1, frameInfo.mask = i; end;
end
frameInfo.Grids = Frame.Grids;
frameInfo.Scales.X = Frame.Scales.X;
frameInfo.Scales.Y = Frame.Scales.Y;
frameInfo.Scales.Z = Frame.Scales.Z;
frameInfo.Scales.I = Frame.Scales.I;
frameInfo.is3D = (frameInfo.choices(3) > 0);
frameInfo.hasChoices = (frameInfo.choices(4) > 0);
\ No newline at end of file
This diff is collapsed.
File added
File added
File added
File added
File added
File added
File added
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment