Skip to content

Commit

Permalink
all files added
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Henry Colligan IV committed Mar 9, 2020
1 parent 152800f commit 12e00de
Show file tree
Hide file tree
Showing 22 changed files with 1,051 additions and 126 deletions.
12 changes: 10 additions & 2 deletions WaveletTransform.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
tempWavelet;
coi;
alt;
sig95;
end

methods
Expand All @@ -37,13 +38,19 @@
obj.dj = dj;
obj.dt = dt;
[obj.uWavelet, ~, obj.waveletScales, ~] = wavelet(u_wind_component, dt, pad, dj, s0); % wave, period, scale, COI
lag1 = acf(u_wind_component', 1);
[sigU, ~] = wave_signif(u_wind_component, dt, obj.waveletScales, 0, lag1);
[obj.vWavelet, ~, ~, obj.coi] = wavelet(v_wind_component, dt, pad, dj, s0); % coi is the same for all transforms of the same data.
lag1 = acf(v_wind_component', 1);
[obj.tempWavelet, ~, ~, ~] = wavelet(temperature, dt, pad, dj, s0);
[sigV, ~] = wave_signif(v_wind_component, dt, obj.waveletScales, 0, lag1);
obj.sig95 = (sigU + sigV)'*(ones(1,size(u_wind_component, 2)));
obj.powerSurface = abs(obj.uWavelet).^2 + abs(obj.vWavelet).^2;
obj.sig95 = obj.powerSurface ./ obj.sig95;
obj.fourierWavelength = 1.03 * obj.waveletScales; % magic number from Torrence and Compo.
end

function [u_wind_reconstructed, v_wind_reconstructed, tempReconstructed, meanVerticalWavelength] = invertWindowedTransform(obj, windowedWaveletTransform)
function [u_wind_reconstructed, v_wind_reconstructed, tempReconstructed, meanVerticalWavelength, windVariance] = invertWindowedTransform(obj, windowedWaveletTransform)
% Reconstruct the wave packet at altitudes of interest and
% scales of interest by adding up the wavelet coefficients at
% the scales of interest. This is an implementation of equation
Expand All @@ -65,7 +72,8 @@
v_wind_reconstructed = constant_coef*sum(windowed_v_wavelet ./ sqrt(windowed_scales)', 1);
meanVerticalWavelength = mean(obj.fourierWavelength(scale_index_1:scale_index_2)); % the dominant wavelength is taken
% to be the mean of the wavelengths over the scale range of
% interest.
% interest. Same as in Murphy, 2014.
windVariance = abs(u_wind_reconstructed).^2 + abs(v_wind_reconstructed).^2;
end

function [uWindInverted, vWindInverted] = invertWaveletTransform(obj)
Expand Down
23 changes: 23 additions & 0 deletions calcParams.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function [intrinsicHorizPhaseSpeed, lambda_h] = calcParams(lambda_z, axialRatio, theta, bvFreqSquared)
%CALCPARAMS This function calculates g-wave parameters from
% hodograph data.
latitude = -30.250; % Latitude of launch location.
coriolisFreq = coriolisFrequency(latitude);
intrinsicFreq = coriolisFreq*axialRatio;
fprintf("%f %f\n", axialRatio, 2*pi/(intrinsicFreq*3600));
bvMean = abs(mean(bvFreqSquared)); % Get the mean squared Brunt-Vaisala frequency over the height range of the gravity wave packet
m = 2*pi / lambda_z; % vertical wavelength (1 / meters)
k_h = sqrt(((coriolisFreq^2*m^2)/(bvMean))*(intrinsicFreq^2/coriolisFreq^2 - 1)); % horizontal wavenumber (1 / meters)
%intrinsicVerticalGroupVel = -(1 / (intrinsicFreq*m))*(intrinsicFreq^2 - coriolisFreq^2); % m/s
zonalWaveNumber = k_h*sin(theta);% 1/m
meridionalWaveNumber = k_h*cos(theta); % 1 / m
%intrinsicVerticalPhaseSpeed = intrinsicFreq / m; % m/s
intrinsicHorizPhaseSpeed = intrinsicFreq / k_h; % m/s
intrinsicZonalGroupVel = zonalWaveNumber * bvMean / (intrinsicFreq * m^2); % m/s
intrinsicMeridionalGroupVel = meridionalWaveNumber * bvMean / (intrinsicFreq * m^2); % m/s
%intrinsicHorizGroupVel = sqrt(intrinsicZonalGroupVel^2 + intrinsicMeridionalGroupVel^2); % m/s
lambda_h = 2*pi / k_h; % horizontal wavelength (m)


end

Binary file modified collaborativeApp.mlapp
Binary file not shown.
106 changes: 106 additions & 0 deletions dnsfnu/ds2nfu.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
function varargout = ds2nfu(varargin)
% DS2NFU Convert data space units into normalized figure units.
%
% [Xf, Yf] = DS2NFU(X, Y) converts X,Y coordinates from
% data space to normalized figure units, using the current axes. This is
% useful as input for ANNOTATION.
%
% POSf = DS2NFU(POS) converts 4-element position vector, POS from
% data space to normalized figure units, using the current axes. The
% position vector has the form [Xo Yo Width Height], as defined here:
%
% web(['jar:file:D:/Applications/MATLAB/R2006a/help/techdoc/' ...
% 'help.jar!/creating_plots/axes_pr4.html'], '-helpbrowser')
%
% [Xf, Yf] = DS2NFU(HAX, X, Y) converts X,Y coordinates from
% data space to normalized figure units, on specified axes HAX.
%
% POSf = DS2NFU(HAX, POS) converts 4-element position vector, POS from
% data space to normalized figure units, using the current axes.
%
% Ex.
% % Create some data
% t = 0:.1:4*pi;
% s = sin(t);
%
% % Add an annotation requiring (x,y) coordinate vectors
% plot(t,s);ylim([-1.2 1.2])
% xa = [1.6 2]*pi;
% ya = [0 0];
% [xaf,yaf] = ds2nfu(xa,ya);
% annotation('arrow',xaf,yaf)
%
% % Add an annotation requiring a position vector
% pose = [4*pi/2 .9 pi .2];
% posef = ds2nfu(pose);
% annotation('ellipse',posef)
%
% % Add annotations on a figure with multiple axes
% figure;
% hAx1 = subplot(211);
% plot(t,s);ylim([-1.2 1.2])
% hAx2 = subplot(212);
% plot(t,-s);ylim([-1.2 1.2])
% [xaf,yaf] = ds2nfu(hAx1,xa,ya);
% annotation('arrow',xaf,yaf)
% pose = [4*pi/2 -1.1 pi .2];
% posef = ds2nfu(hAx2,pose);
% annotation('ellipse',posef)

% Michelle Hirsch
% [email protected]
% Copyright 2006-2014 The MathWorks, Inc

%% Process inputs
error(nargchk(1, 3, nargin))

% Determine if axes handle is specified
if length(varargin{1})== 1 && ishandle(varargin{1}) && strcmp(get(varargin{1},'type'),'axes')
hAx = varargin{1};
varargin = varargin(2:end);
else
hAx = gca;
end;

errmsg = ['Invalid input. Coordinates must be specified as 1 four-element \n' ...
'position vector or 2 equal length (x,y) vectors.'];

% Proceed with remaining inputs
if length(varargin)==1 % Must be 4 elt POS vector
pos = varargin{1};
if length(pos) ~=4,
error(errmsg);
end;
else
[x,y] = deal(varargin{:});
if length(x) ~= length(y)
error(errmsg)
end
end


%% Get limits
axun = get(hAx,'Units');
set(hAx,'Units','normalized');
axpos = get(hAx,'Position');
axlim = axis(hAx);
axwidth = diff(axlim(1:2));
axheight = diff(axlim(3:4));


%% Transform data
if exist('x','var')
varargout{1} = (x-axlim(1))*axpos(3)/axwidth + axpos(1);
varargout{2} = (y-axlim(3))*axpos(4)/axheight + axpos(2);
else
pos(1) = (pos(1)-axlim(1))/axwidth*axpos(3) + axpos(1);
pos(2) = (pos(2)-axlim(3))/axheight*axpos(4) + axpos(2);
pos(3) = pos(3)*axpos(3)/axwidth;
pos(4) = pos(4)*axpos(4)/axheight;
varargout{1} = pos;
end


%% Restore axes units
set(hAx,'Units',axun)

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# =========================
# Operating System Files
# =========================

# OSX
# =========================

.DS_Store
.AppleDouble
.LSOverride

# Icon must ends with two \r.
Icon

# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# MATLAB-Dataspace-to-Figure-Units
Convert from dataspace to figure units to make it easier to add annotations pointing to data in a MATLAB figure window.

The annotation function, which allows you to programmatically add a wide range of annotations to your figure, requires coordinates to be specified in normalized figure units. I have found that I almost always want to specify my annotations in data space (i.e., based on the values of data displayed in an axes).
This utility function converts coordinates in data space into normalized figure coordinates, for input to annotation. Some annotations require you to specify (x,y) pairs, while others require a 4 element position vector. This function supports both syntaxes.

Here's a simple example:

```matlab
% Create some data
t = 0:.1:4*pi;
s = sin(t);
% Add an annotation requiring (x,y) coordinate vectors
plot(t,s);ylim([-1.2 1.2])
xa = [1.6 2]*pi; % X-Coordinates in data space
ya = [0 0]; % Y-Coordinates in data space
[xaf,yaf] = ds2nfu(xa,ya); % Convert to normalized figure units
annotation('arrow',xaf,yaf) % Add annotation
```

Note: I believe annotation was introduced in MATLAB 7.

[![View Data space to figure units conversion on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/10656-data-space-to-figure-units-conversion)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Copyright (c) 2006, The MathWorks, Inc.
Copyright (c) 1997, Christophe COUVREUR
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution
* Neither the name of the The MathWorks, Inc. nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Loading

0 comments on commit 12e00de

Please sign in to comment.