[ncl-talk] Derivatives in NCL

Dennis Shea shea at ucar.edu
Mon Feb 6 10:59:03 MST 2017


The is no need for a function. Re is a scalar

f = addfile("foo.grb","r")
h = f->GEOHGT ;[lv_ISBL0 | 37] x [ygrid_0 | 113] x [xgrid_0 | 151]

 Re = 6356766.0
  Z = (h*Re)/(Re-h)
                            ; assign appropriate attributes
 Z at long_name = "Geometric Height"
 Z at units = "m"
                            ; copy selected attributes
  Z at coordinates = "gridlat_0 gridlon_0"
 Z at forecast_time     = h at forecast_time
 Z at forecast_time_units = h at forecast_time_units
 Z at initial_time        = h at initial_time
              ; copy any coordinate variables
  copy_VarCoords(h,Z)
  printVarSummary(Z)

=============================
You may wish to create your own function

undef("geometric_height")
function geometric_height(h:numeric)
local Re, Z
begin
   Re = 6356766.0
   Z = (h*Re)/(Re-h)
                            ; assign appropriate attributes
   Z at long_name = "Geometric Height"
   Z at units = "m"
                            ; copy selected attributes
   Z at coordinates = "gridlat_0 gridlon_0"
 Z at forecast_time     = h at forecast_time
 Z at forecast_time_units = h at forecast_time_units
 Z at initial_time        = h at initial_time
              ; copy any coordinate variables
  copy_VarCoords(h,Z)
  return(Z)
end

=============

As an experiment, add

*setfileoption*("grb","SingleElementDimensions","Initial_time")

before

f = addfile("foo.grb","r")
h = f->GEOHGT
print(h)

===============
If you are new to NCL, please see the DKRXZ tutorials at:

https://www.ncl.ucar.edu/Document/Manuals/


On Mon, Feb 6, 2017 at 9:04 AM, Black, Forrest (LARC-D318)[UNIVERSITIES
SPACE RESEARCH ASSOCIATION] <forrest.black at nasa.gov> wrote:

> Hello all,
>
>
>
> I am trying to solve the following equation in NCL:
>
>
>
> Z = (h*Re)/(Re-h)’
>
>
>
> Z: Geometric Height
>
> h: Geopotential height (3D Array)
>
> Re: Radius of Earth, assumed constant (6356766m)
>
>
>
> I have looked at some old threads, but am still unsure of what functions I
> would use to calculate (Re-h)’.
>
>
>
> Can anyone give me some suggestions on how to tackle this?
>
>
>
> This is the Attribute data for Geopotential Height:
>
>
>
> Variable: Geopotential Height
>
> Type: float
>
> Total Size: 2525324 bytes
>
>             631331 values
>
> Number of Dimensions: 3
>
> Dimensions and sizes:   [lv_ISBL0 | 37] x [ygrid_0 | 113] x [xgrid_0 | 151]
>
> Coordinates:
>
>             lv_ISBL0: [10000..100000]
>
> Number Of Attributes: 13
>
>   center :      US National Weather Service - NCEP (WMC)
>
>   production_status :   Operational products
>
>   long_name :   Geopotential height
>
>   units :       gpm
>
>   _FillValue :  1e+20
>
>   coordinates : gridlat_0 gridlon_0
>
>   grid_type :   Lambert Conformal can be secant or tangent, conical or
> bipolar
>
>   parameter_discipline_and_category :   Meteorological products, Mass
>
>   parameter_template_discipline_category_number :       ( 0, 0, 3, 5 )
>
>   level_type :  Isobaric surface (Pa)
>
>   forecast_time :       0
>
>   forecast_time_units : hours
>
>   initial_time :        01/31/2017 (00:00)
>
>
>
>
>
> Thanks for any help.
>
>
>
> -        Forrest
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170206/64c53329/attachment.html 


More information about the ncl-talk mailing list