diff --git a/CODE/VAR/prefs.mat b/CODE/VAR/prefs.mat index b3c67ae..663efed 100644 Binary files a/CODE/VAR/prefs.mat and b/CODE/VAR/prefs.mat differ diff --git a/CODE/dependencies/plot_google_map.m b/CODE/dependencies/plot_google_map.m index 41671b3..19a2c00 100644 --- a/CODE/dependencies/plot_google_map.m +++ b/CODE/dependencies/plot_google_map.m @@ -452,7 +452,7 @@ 'Matlab error was: %s\n\n' ... 'Possible reasons: missing write permissions, no network connection, quota exceeded, or some other error.\n' ... 'Consider using an API key if quota problems persist.\n\n' ... - 'To debug, try pasting the following URL in your browser, which may result in a more informative error:\n%s']); + 'To debug, try pasting the following URL in your browser, which may result in a more informative error:\n%s'], lasterr, url); varargout{1} = []; varargout{2} = []; varargout{3} = []; diff --git a/CODE/dwind/dwind.m b/CODE/dwind/dwind.m index 115025a..e4ec421 100644 --- a/CODE/dwind/dwind.m +++ b/CODE/dwind/dwind.m @@ -53,7 +53,7 @@ function dwind(varargin) % % Optional arguments: % 'intMeth' : Interpolation method, accepts 'Linear' (default), 'Nearest', 'Pchip', 'Cubic', 'Spline' -% 'intExt' : Number of cells (±x, ±y) around vent used for interpolation (default: 2) +% 'intExt' : Number of cells (�x, �y) around vent used for interpolation (default: 2) % 'outDir' : Output folder (default = windName) if nargin==0 @@ -526,6 +526,7 @@ function download(wind) fprintf('Select folder containing the ERA-Interim .nc files\n'); wind.ncDir = uigetdir( ... 'Select folder containing the ERA-Interim .nc files'); + end save(fullfile(wind.folder, 'wind.mat'),'wind') @@ -564,7 +565,7 @@ function download(wind) delete('download_ECMWF.py'); % Offline mode -elseif strcmp(wind.db, 'InterimOff') +elseif strcmp(wind.db, 'InterimOff') || strcmp(wind.db, 'ERA5Off') %% NOAA else diff --git a/CODE/dwind/process_wind.m b/CODE/dwind/process_wind.m index 4bf9f78..c0d04e5 100644 --- a/CODE/dwind/process_wind.m +++ b/CODE/dwind/process_wind.m @@ -128,8 +128,8 @@ function process_wind(varargin) % Case ECMWF ERA-Interim Offline -elseif strcmp(wind.db, 'InterimOff') - in_path = wind.ncDir; +elseif strcmp(wind.db, 'InterimOff') || strcmp(wind.db, 'ERA5Off') + in_path = wind.ncDir; fl = dir(fullfile(in_path, '*.nc')); stor = struct; @@ -141,17 +141,22 @@ function process_wind(varargin) % Find vent coordinates if i==1 - latI(1) = find(stor(i).LAT == wind.lat_min); - latI(2) = find(stor(i).LAT == wind.lat_max); - latI = fliplr(latI); - lonI(1) = find(stor(i).LON == wind.lon_min); - lonI(2) = find(stor(i).LON == wind.lon_max); + if length(stor(i).LAT) == 1 || length(stor(i).LON) == 1 + latI = stor(i).LAT; + lonI = stor(i).LON; + else + latI(1) = find(stor(i).LAT == wind.lat_min); + latI(2) = find(stor(i).LAT == wind.lat_max); + latI = fliplr(latI); + lonI(1) = find(stor(i).LON == wind.lon_min); + lonI(2) = find(stor(i).LON == wind.lon_max); + end end stor(i).HGT = ncread(fullfile(in_path, fl(i).name), 'z')/9.80665; stor(i).UWND = ncread(fullfile(in_path, fl(i).name), 'u'); stor(i).VWND = ncread(fullfile(in_path, fl(i).name), 'v'); - stor(i).time = double(ncread(fullfile(in_path, fl(i).name), 'time'))/24 + datenum(1900,1,1,0,0,0); + stor(i).time = double(ncread(fullfile(in_path, fl(i).name), 'time'))/24 + datenum(1900,1,1,0,0,0); end % Do some tests to see if the timestamp is correct @@ -187,11 +192,18 @@ function process_wind(varargin) fprintf('\tInterpolating and writing ascii files, please wait...\n') for iT = 1:size(UWND,4) % Loop through time for iL = 1:size(UWND,3) % Loop through levels + % No interpolation + if length(stor(i).LAT) == 1 || length(stor(i).LON) == 1 + u = UWND(1,1,iL,iT); + v = VWND(1,1,iL,iT); + z = HGT(1,1,iL,iT); + else % Interpolate to vent coordinates - u = intVent(UWND, stor(i).LON, stor(i).LAT, latI, lonI, wind, iL, iT); - v = intVent(VWND, stor(i).LON, stor(i).LAT, latI, lonI, wind, iL, iT); - z = intVent(HGT, stor(i).LON, stor(i).LAT, latI, lonI, wind, iL, iT); - + u = intVent(UWND, stor(i).LON, stor(i).LAT, latI, lonI, wind, iL, iT); + v = intVent(VWND, stor(i).LON, stor(i).LAT, latI, lonI, wind, iL, iT); + z = intVent(HGT, stor(i).LON, stor(i).LAT, latI, lonI, wind, iL, iT); + end + speed = sqrt(u.^2+v.^2); % Wind speed angle = atan2d(u,v); % Wind direction angle(angle<0) = 360+angle(angle<0); % Get rid of negative value @@ -226,6 +238,8 @@ function process_wind(varargin) fprintf('\tInterpolating and writing ascii files, please wait...\n') for iT = 1:size(UWND,4) % Loop through time for iL = 1:size(UWND,3) % Loop through levels + + % Interpolate to vent coordinates u = intVent(UWND, LON, LAT, [1, length(LAT)], [1, length(LON)], wind, iL, iT); v = intVent(VWND, LON, LAT, [1, length(LAT)], [1, length(LON)], wind, iL, iT); diff --git a/test/wind.mat b/test/wind.mat deleted file mode 100644 index 1696520..0000000 Binary files a/test/wind.mat and /dev/null differ