Name

c_AVRG — Function to make a selective columnwise average (excluding missing data)

Calling Sequence

MOY = c_AVRG(MissCode,DATA)

Parameters

MissCode

Value attributed to missing data (-9.99 for example)

DATA

Data to average (matrix [NxP] where N is the number of time steps and P the number of element to average)

MOY

Averaged data (matrix [Nx1] where N is the number of time steps)

Description

  • WARNING : This function is written in C language and interfaced with SCILAB (HYDROGR.dll).

  • This function has been designed to realise average over different rainfall stations and produce a catchment rainfall

  • For each line of DATA, the missing data are excluded and the average is performed on the remaining data.

    If no data is available, MissCode is returned

Examples

   P1 = [rand(10,1); -9.99 * ones(5,1) ; rand(5,1)];
   P2 = [rand(6,1); -9.99 * ones(7,1) ; rand(7,1)];   
   Pm = c_AVRG(-9.99,[P1 P2]);
   
   // Graph
   x=(1:size(P1,1))';
   pp=[P1 P2];pp(find(pp<0))=%nan;ppm=Pm;ppm(find(ppm<0))=%nan;
   subplot(2,1,1),plot(x,pp);legend(['Rainfall on Station no1' 'Rainfall on Station no2'],%f);
   xtitle('','Time','Rainfall (mm)');
   subplot(2,1,2),plot(x,ppm,'k');legend(['Mean rainfall'],%f);
   xtitle('','Time','Rainfall (mm)');
  

Authors

Julien Lerat

CEMAGREF Antony, HBAN Unit, julien.lerat@cemagref.fr