NCL Home > Documentation > Functions > General applied math

get_d2r

Return a constant that converts degrees to radians.

Available in version 6.4.0 and later.

Prototype

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"  ; This library is automatically loaded
                                                             ; from NCL V6.2.0 onward.
                                                             ; No need for user to explicitly load.

	function get_d2r (
		val  : numeric or string   
	)

	return_val [scalar] :  float or double

Arguments

val

If val is type numeric, and val is type "double", the returned constant will be type double; otherwise, it will be type float.

If val is type string, and val="double" or val="d", the returned constant will be type double; otherwise, it will be type float.

It is recommended that the value returned be the same numeric type as the variable(s) with which it will be used.

Return value

The returned scalar will be type double or float.

Description

A constant that is used to convert degrees to radians:

      d2r = PI/180

It is recommended that the value returned by get_d2r (get_r2d and get_pi) be the same numeric type as the variable(s) with which it will be used.

See Also

get_pi, get_r2d

Examples

Example 1: In these examples, the 'd2r' to the left of the assignment can be any name (eg, 'degrees_to_radians', 'deg_ro_rad'). 'd2r'is used for convenience.


  d2r  = get_d2r("double")   ; type double; 0.0174532925199433
  d2r  = get_d2r("float" )   ; type float ; 0.01745329
  d2r  = get_d2r("d")        ; type double; 0.0174532925199433
  d2r  = get_d2r("f")        ; type float ; 0.01745329

  d2r  = get_d2r(1d0)        ; type double
  d2r  = get_d2r(1.0)        ; type float 
  d2r  = get_d2r( 1 )        ; type float 

  xf   = 2.412
  xd   = 2.412d0
  xi   = 100

  d2r  = get_d2r(xd)         ; type double; same type as '
  d2r  = get_d2r(xf)         ; type float
  d2r  = get_d2r(xi)         ; type float