Re: Confused by coordinate variable

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Mon Aug 05 2013 - 08:44:05 MDT

No.

See attached which is for WRF but you can makes appropriate changes
for the NAM grid.

On 8/5/13 8:26 AM, Means, James wrote:
> Thank you very much Dennis. Am I correct that once I use rcm2points, I would have to follow that with qsort or something like that to make the variable monotonic?
>
> Thanks,
>
> Jim
> ________________________________________
> From: Dennis Shea [shea@ucar.edu]
> Sent: Monday, August 05, 2013 7:09 AM
> To: Means, James
> Cc: ncl-talk@ucar.edu
> Subject: Re: Confused by coordinate variable
>
> Hi Jim
>
> Coordinate variables can be a bit confusing because
> not all arrays that contain grid coordinates are coordinate
> variables. :-) Coordinates variables are a special
> structure.
>
> Unidata definition
> http://www.unidata.ucar.edu/software/netcdf/docs/BestPractices.html
>
> "A coordinate variable is a one-dimensional variable with the same name
> as a dimension, which names the coordinate values of the dimension. It
> must not have any missing data (for example, no _FillValue or
> missing_value attributes) and must be strictly monotonic (values
> increasing or decreasing)."
>
> ===
> Consider a variable with structure: x([time,][lev,],LAT,LON)
>
> Generally, 'time' and 'lev' are one dimensional [*],
> numeric and monotonic: hence, they are coordinate variables.
> For the NAM-218 the 'lv_ISBL2' dimension is a coordinate variable.
>
> For a *rectilinear* grid, the LAT and LON associated with a
> variable are one dimensional [*], numeric and monotonic.
> EG
> double time(time) ;
> time:long_name = "time" ;
> time:calendar = "standard" ;
> time:units = "days since 1979-01-01 00:00:00" ;
> float lat(lat) ;
> lat:long_name = "latitude" ;
> lat:units = "degrees_north" ;
> float lon(lon) ;
> lon:long_name = "longitude" ;
> float PREC(time, lat, lon) ;
> PREC:missing_value = -99999.f ;
> PREC:_FillValue = -99999.f ;
> PREC:units = "mm/day" ;
> PREC:long_name = "precipitation" ;
> In the above the time, lat, lon variables are associated
> with the *named dimensions* of the PREC variable. If you read
> the variable PREC and then do a printVarSummary:
>
> f = addfile("...","r")
> p = f->PREC
> printVarSummary(p)
>
> Variable: p
> [snip]
> Number of Dimensions: 3
> Dimensions and sizes: [time | 384] x [lat | 72] x [lon | 144]
> ---
> Coordinates:
> time: [ 15..11672]
> lat: [-88.75..88.75]
> lon: [1.25..358.75]
> ---
> Number Of Attributes: 4
> [snip
>
> The "Coordinates" lists all 'coordinate variables' associated with
> named dimensions of the parent variable: here, time, lat, lon.
> It also lists the min and max values.
>
> In NCL, the above is imported into a data structure:
> http://www.cgd.ucar.edu/~shea/NclVariableModel.png
> ie: an NCL variable is not just an array of numbers. Rather,
> it is a data structure. Elements of the data structure,
> can be accessed via NCL syntax (& for coordinate variables
> and @ for attributes). Further, coordinate variables
> can be used to easily subset a variable using the {...}
> syntax: p(:,{-20:60},{35:270})
>
> A user could use p&lat ... meaning the 'lat' values associated
> with the variable 'p'... eg
>
> x = linint2_points(p&lon, p&lat, p, ...)
>
>
> ++++++++++++++++++
> The NAM-218 is, in NCL-speak, a *curvilinear* grid. Here, each grid
> point requires 2-dimensional lat/lon arrays to describe the grid.
>
> gridlat_218 ( gridx_218, gridy_218 )
> gridlon_218 ( gridx_218, gridy_218 )
>
> WRF and NARR grids are other examples of curvilinear grids.
> There is no NCL syntax that would allow subsetting. You would have
> to use standard indexing (subscripts).
>
> As indicated by the printVarSummary() below, NCL does tell
> you the variables containing the coordinates that describe
> the grid associated with the variable:
>
> coordinates : gridlat_218 gridlon_218
>
> +++++++++++++++++++
> Finally, the answer to your question!!
>
> I think either of the following can be used:
>
> http://www.ncl.ucar.edu/Document/Functions/Built-in/rcm2points.shtml
>
> http://www.ncl.ucar.edu/Document/Functions/Contributed/rcm2points_Wrap.shtml
>
> These can be a bit slow. There is no simpl, general way to
> isolate the values in a region. Brute force looping is
> used 'under the hood'.
>
> HTH
> D
>
>
> On 8/4/13 11:47 PM, Means, James wrote:
>> Hello NCL-Talk,
>>
>> I'm perpetually confused by coordinate variables. I need to create a cross-section of relative humidity between two points using NAM-218 data. I am trying to borrow code from the transect example, http://www.ncl.ucar.edu/Applications/Scripts/trans_1.ncl, but it uses linint2_points, which I believe requires coordinate variables. When I run ncl_filedump on the NAM-218 grib file, I get information like:
>>
>> float R_H_218_ISBL ( lv_ISBL2, gridx_218, gridy_218 )
>> center : US National Weather Service - NCEP (WMC)
>> long_name : Relative humidity
>> units : %
>> _FillValue : 1e+20
>> coordinates : gridlat_218 gridlon_218
>> level_indicator : 100
>> grid_number : 218
>> parameter_table_version : 2
>> parameter_number : 52
>> model : MESO ETA Model
>> forecast_time : 0
>> forecast_time_units : hours
>> initial_time : 12/11/2008 (12:00)
>>
>> and for gridlat_218:
>>
>> float gridlat_218 ( gridx_218, gridy_218 )
>> corners : ( 12.19, 14.35541, 57.34082, 54.56082 )
>> long_name : latitude
>> grid_description : AWIPS grid over the Contiguous United States (us
>> ed by the 12-km ETA Model) (Lambert Conformal)
>> units : degrees_north
>> mpLambertMeridianF : 265
>> mpLambertParallel2F : 25
>> mpLambertParallel1F : 25
>> mpProjection : LAMBERTCONFORMAL
>> Dy : 12190.58
>> Dx : 12190.58
>> Lov : 265
>> Lo1 : 226.514
>> La1 : 12.19
>>
>> So my question is, what coordinate variables should I use in linint2_points and how do I create them? Sorry for the dumb question.
>>
>> Thanks,
>>
>> Jim
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Mon Aug 5 08:44:15 2013

This archive was generated by hypermail 2.1.8 : Wed Aug 07 2013 - 13:59:00 MDT