# Documentation of cosp

Global Index (all files) (short | long) | Local Index (files in subdir) (short | long)

## Function Synopsis

`prod=cosp(x,y,nya,minperc)`

## Help text

``` function prod=cosp(x,y,nya,minperc)

calculates area (cos) weighted projection of two map x and y
onto each other.
X and Y must be linemaps (going from NW to SE).

NYA is the latidue axis of the maps (from top to bottom)
MINPERC (opt) is the minimum percentage of points not missing for the whole
procduct to be not missing (from 0 to 100).
In a projection, the spatial mean is NOT removed from X and Y.
However, the long term mean should be removed from each gridpoint.
```

## Cross-Reference Information

This function is called by

## Listing of function cosp

```function prod=cosp(x,y,nya,minperc)

% make sure maps are 1 down, nulat*nulon across:
if size(x,2) == 1 ;x=x'; end
if size(y,2) == 1 ;y=y'; end

if nargin <4
minperc=0;
else
minperc=minperc/100;
end

if isempty(nya)
error('Latitude axis has to be supplied')
end

nulat=length(nya);
nulon=length(x)/nulat;

w=cos(nya*pi/180);
w=w(:);

if size(x) == size(y)
else
error ('X and Y are not the same size')
end

% wmat is a linemap that contains the weights
% for the data set.
weights=w(:,ones(1,nulon))';
weights=weights(:);
weights=weights';

minpoints=minperc*nulon*nulat;

use=~(isnan(x)|isnan(y));
nupoints=sum(use);
if nupoints < minpoints
prod=NaN;
else
prod=sum(weights(use).*y(use).*x(use))/(sum(weights(use)));
end

```