Rank: 1818 based on 89 downloads (last 30 days) and 2 files submitted
photo

Andrew Roberts

E-mail
Company/University
Department of Oceanography, Naval Postgraduate School
Lat/Long
36.59000015258789, -121.8499984741211

Personal Profile:

 

Watch this Author's files

 

Files Posted by Andrew Roberts View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
14 Feb 2011 Screenshot ncpolarm Generates polar stereographic maps of the Arctic or Antarctic as a square or rectangular plot. Author: Andrew Roberts oceanography, meteorology, arctic, antarctic, southern ocean, map 20 1
  • 5.0
5.0 | 1 rating
14 Feb 2011 Screenshot ncquiverref Quiver (vector) with a reference vector or color code on a map or Cartesian axes. Author: Andrew Roberts quiver, reference vector, legend, earth sciences, general, color vector 69 16
  • 4.8
4.8 | 11 ratings
Comments and Ratings by Andrew Roberts View all
Updated File Comments Rating
17 Jun 2014 ncquiverref Quiver (vector) with a reference vector or color code on a map or Cartesian axes. Author: Andrew Roberts

Hello "K",

The documentation clearly states that "This version assumes a 2D vector field being plotted using a gridded flow field from numerical models with a regular geometry".

If you set:

lat=[41.1700 -73.1300; 1.0000 1.0000];
lon=[35.2200 -75.6200; 0 1.0000];
u=[30.3800 -84.3500; -1.0000 0];
v=[25.9000 -97.4200; -1.0000 1.0000];

You will find that you get output, and the function works as designed and documented.

If your inputs are not on a grid, then this is not the function for you. Alternatively, if your inputs are on a 2D grid, but are organized into a vector, then you will need to reorganize your data back onto the 2D grid.

- Andrew

27 Jan 2014 ncquiverref Quiver (vector) with a reference vector or color code on a map or Cartesian axes. Author: Andrew Roberts

Hi Nelson,

It's almost impossible to understand what you are doing without an example. Most problems with ncquiverref result from the data not being prepared as specified in the documentation, so check this carefully. If you are unable to resolve the problem, please send me your script and some sample data so that I can check on what you are doing, and then I'll let you know if I can help.

Thanks
Andrew Roberts

01 Sep 2010 ncquiverref Quiver (vector) with a reference vector or color code on a map or Cartesian axes. Author: Andrew Roberts

Hi Hamed,

If you have tested using "max" instead of "median" for reftype, or your color vectors are too long, it is easy to adjust the variable "scalelength" to a fraction of its current value in the code. Change line 186 to:
scalelength=X*min(mean(z1(~isnan(z1))),mean(z2(~isnan(z2))));
where 0<X<1.
The main reason you may have to make this manual adjustment is if your vector magnitudes are strongly negatively skewed.

cheers
Andrew

Comments and Ratings on Andrew Roberts' Files View all
Updated File Comment by Comments Rating
18 Jun 2014 ncquiverref Quiver (vector) with a reference vector or color code on a map or Cartesian axes. Author: Andrew Roberts K

Andrew:

Dang, you are right of course. In my excitement to see something that would plot geographic-coordinate vectors I failed to internalize the very clear statement that the code assumes a gridded field. Guess I'll keep looking and/or work on writing some code to do what I need.

Thanks for your prompt response. It's much appreciated.

17 Jun 2014 ncquiverref Quiver (vector) with a reference vector or color code on a map or Cartesian axes. Author: Andrew Roberts Andrew Roberts

Hello "K",

The documentation clearly states that "This version assumes a 2D vector field being plotted using a gridded flow field from numerical models with a regular geometry".

If you set:

lat=[41.1700 -73.1300; 1.0000 1.0000];
lon=[35.2200 -75.6200; 0 1.0000];
u=[30.3800 -84.3500; -1.0000 0];
v=[25.9000 -97.4200; -1.0000 1.0000];

You will find that you get output, and the function works as designed and documented.

If your inputs are not on a grid, then this is not the function for you. Alternatively, if your inputs are on a 2D grid, but are organized into a vector, then you will need to reorganize your data back onto the 2D grid.

- Andrew

17 Jun 2014 ncquiverref Quiver (vector) with a reference vector or color code on a map or Cartesian axes. Author: Andrew Roberts K

This code looks like it'll do what I want it to do, which is plot vectors (or straight-up direction arrows) in geographic coordinates. Thanks! Unfortunately I'm getting an error at line 151:

[u,v] = pol2cart(th+deg2rad(thproj),z);

The problem is that in my application th is a vector (n rows, one column) but thproj is an array (n rows, n columns). Perhaps I'm just misinterpreting the input variables?

code:
%Clear and close all files, windows, etc.
clc;
close all;
clear;

%Open Excel Data File
filename=input('enter filename: ','s');
[data]=xlsread(filename);
lat=data(:,1); %create latitude vector
lon=data(:,2); %create longitude vector
u=data(:,3); %create u-component vector;
v=data(:,4); %create v-component vector;

%Create a map
ax = usamap('conus');
set(ax, 'Visible', 'off')
latlim = getm(ax, 'MapLatLimit');
lonlim = getm(ax, 'MapLonLimit');
states = shaperead('usastatehi',...
'UseGeoCoords', true, 'BoundingBox', [lonlim', latlim']);
geoshow(ax, states,'FaceColor','white')
grid off;

%Plot arrows
ncquiverref(lat,lon,u,v,'m/s','max','false','k',1);

Here's my test data file (lat, lon, u, v):
41.1700 -73.1300 1.0000 1.0000
35.2200 -75.6200 0 1.0000
30.3800 -84.3500 -1.0000 0
25.9000 -97.4200 -1.0000 1.0000

21 May 2014 ncquiverref Quiver (vector) with a reference vector or color code on a map or Cartesian axes. Author: Andrew Roberts Chad Greene

This function is an incredible improvement over quiverm for two key reasons:

1. quiverm confoundingly thinks insists that u is a meridional component and v is a zonal component, but ncquiverref gets it right.

2. quiverm scales relative to lats and lons, so if you're plotting an absolute field such as surface wind velocity, vectors shrink near the poles using quiverm whereas ncquiverref gets it right.

The only two changes I'd make are 1. switch to a more intuitive name for the function (quite trivial and users can easily do this on their own) and 2. add an option to easily switch between centering arrows over their reference points or starting them at the reference points, because which the user prefers may depend on the data being plotted.

Overall a fantastic, adaptable, and robust script. Thanks for sharing, Andrew.

27 Jan 2014 ncquiverref Quiver (vector) with a reference vector or color code on a map or Cartesian axes. Author: Andrew Roberts Andrew Roberts

Hi Nelson,

It's almost impossible to understand what you are doing without an example. Most problems with ncquiverref result from the data not being prepared as specified in the documentation, so check this carefully. If you are unable to resolve the problem, please send me your script and some sample data so that I can check on what you are doing, and then I'll let you know if I can help.

Thanks
Andrew Roberts

Contact us