public function GetCVofGridFloat(grid, maskReal, maskInteger) result(cv)
compute coefficient of variation of grid_real eventually constrained to a mask
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
type(grid_real),
|
intent(in) |
|
|
:: |
grid |
|
type(grid_real),
|
intent(in), |
optional |
|
:: |
maskReal |
|
type(grid_integer),
|
intent(in), |
optional |
|
:: |
maskInteger |
|
Return Value
real(kind=float)
Variables
Type |
Visibility | Attributes |
|
Name |
| Initial | |
real(kind=float),
|
public |
|
:: |
mean |
|
|
|
real(kind=float),
|
public |
|
:: |
std |
|
|
|
Source Code
FUNCTION GetCVofGridFloat &
!
(grid, maskReal, maskInteger) &
!
RESULT (cv)
IMPLICIT NONE
!Arguments with intent(in):
TYPE (grid_real), INTENT(IN) :: grid
TYPE (grid_real), OPTIONAL, INTENT(IN) :: maskReal
TYPE (grid_integer), OPTIONAL, INTENT(IN) :: maskInteger
!Local declarations:
REAL (KIND = float) :: cv
REAL (KIND = float) :: mean
REAL (KIND = float) :: std
!---------------------------end of declarations--------------------------------
!check that grid and mask have the same coordinate reference system
IF (PRESENT (maskReal)) THEN
IF ( .NOT. CRSisEqual(maskReal,grid) ) THEN
CALL Catch ('error', 'GridStatistics', &
'calculate coefficient of variation: ', argument = &
'coordinate reference system of mask differs from input grid' )
END IF
mean = GetMean (grid, maskReal = maskReal)
std = GetStDev (grid, maskReal = maskReal)
ELSE IF (PRESENT (maskInteger)) THEN
IF ( .NOT. CRSisEqual(maskInteger,grid) ) THEN
CALL Catch ('error', 'GridStatistics', &
'calculate coefficient of variation: ', argument = &
'coordinate reference system of mask differs from input grid' )
END IF
mean = GetMean (grid, maskInteger = maskInteger)
std = GetStDev (grid, maskInteger = maskInteger)
ELSE
mean = GetMean (grid)
std = GetStDev (grid)
END IF
cv = std / mean
RETURN
END FUNCTION GetCVofGridFloat