comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Point Observations from NARR output
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Point Observations from NARR output [message #75752] Thu, 07 April 2011 17:11
B.J. Baule is currently offline  B.J. Baule
Messages: 3
Registered: April 2011
Junior Member
On Apr 7, 5:06 pm, "Kenneth P. Bowman" <k-bow...@null.edu> wrote:
> In article
> < ae2b9885-d9aa-42b6-b3d5-6418072f1...@f11g2000vbx.googlegroup s.com >,
>  "B.J. Baule" <guitarplayer_...@comcast.net> wrote:
>
>> Hello all,
>
>>    This is probably a really simple problem however my inexperience
>> with IDL has left me baffled. I'm relatively new to IDL programming
>> and have a question regarding getting grid point values from NARR
>> reanalysis output. I can get the data to open, read in, and make a
>> map. However, I would like to get point observations from the
>> reanalysis data set (Ex. July Temperature for Barrow, AK Lat:
>> 71.2905556 Lon:-156.7886111).
>
> I suggest that you compute the great circle distance between
> Point Barrow and all of the longitude-latitude points on the
> NARR grid.  Then find the minimum.  You only have to do this once.
> That will tell you which grid point is closest to Barrow.
>
> If you insist on interpolating to Barrow, you will have to
> do that in Cartesian coordinates on the Lambert conformal grid.
> Probably not worth it, in my opinion.
>
> To compute great circle distance use MAP_2POINTS.  (One of my
> nominations for least-intuitive and least-mnemonic routine name
> in IDL.)  You will spend half an hour trying to get all of
> the units and keywords right, but it does work.
>
> Ken Bowman

Thanks Ken. I'll give this a try tomorrow. :)
Re: Point Observations from NARR output [message #75755 is a reply to message #75752] Thu, 07 April 2011 15:06 Go to previous message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article
<ae2b9885-d9aa-42b6-b3d5-6418072f19e6@f11g2000vbx.googlegroups.com>,
"B.J. Baule" <guitarplayer_101@comcast.net> wrote:

> Hello all,
>
> This is probably a really simple problem however my inexperience
> with IDL has left me baffled. I'm relatively new to IDL programming
> and have a question regarding getting grid point values from NARR
> reanalysis output. I can get the data to open, read in, and make a
> map. However, I would like to get point observations from the
> reanalysis data set (Ex. July Temperature for Barrow, AK Lat:
> 71.2905556 Lon:-156.7886111).

I suggest that you compute the great circle distance between
Point Barrow and all of the longitude-latitude points on the
NARR grid. Then find the minimum. You only have to do this once.
That will tell you which grid point is closest to Barrow.

If you insist on interpolating to Barrow, you will have to
do that in Cartesian coordinates on the Lambert conformal grid.
Probably not worth it, in my opinion.

To compute great circle distance use MAP_2POINTS. (One of my
nominations for least-intuitive and least-mnemonic routine name
in IDL.) You will spend half an hour trying to get all of
the units and keywords right, but it does work.

Ken Bowman
Re: Point Observations from NARR output [message #75756 is a reply to message #75755] Thu, 07 April 2011 13:31 Go to previous message
B.J. Baule is currently offline  B.J. Baule
Messages: 3
Registered: April 2011
Junior Member
On Apr 7, 3:25 pm, "B.J. Baule" <guitarplayer_...@comcast.net> wrote:
> Hello all,
>
>    This is probably a really simple problem however my inexperience
> with IDL has left me baffled. I'm relatively new to IDL programming
> and have a question regarding getting grid point values from NARR
> reanalysis output. I can get the data to open, read in, and make a
> map. However, I would like to get point observations from the
> reanalysis data set (Ex. July Temperature for Barrow, AK Lat:
> 71.2905556 Lon:-156.7886111).
>
>     The three variables that I've pulled from the netCDF file file are
> air temp (air), latitude, longitude. With the HELP function in IDL, I
> find that the dimensions of the arrays are: air = ARRAY[349, 277, 12],
> rlats = ARRAY[349,277], rlons = ARRAY[349,277]. As I understand it,
> the Lambert Conformal Conic Grid is a 349x277 grid. It has been
> suggested to me that I should be working in x y coordinates. When I
> try and pull x and y from the netcdf file, I get arrays but they are
> both 277 element single dimension arrays. I'd expected the x array to
> be 349 elements and y to be 277 elements. If I could get a 349 element
> x array and a 277 element y array, then maybe I could use
> MAP_PROJ_INVERSE to get lat lon values for these grid points?
>
>    Sorry if this is an elementary question that has an easy solution
> that I'm overlooking. Does anyone have experience doing this? Any help
> would be greatly appreciated.
>
> Thanks,
> B.J.
>
> (I've attached a copy of the code I've tried to build, sorry about the
> lack of comments):
>
> PRO TRYIT_XY
>
> Compile_Opt defint32
> ;define number of latitudes/longitudes
> nlons=349
> nlats=277
>
> vararray2 = fltarr(nlons,nlats)
> vararray = fltarr(nlons,nlats,12)
> vararryin = fltarr(nlons,nlats)
> rlons  = fltarr(nlons,nlats)
> rlats  = fltarr(nlons,nlats)
>
> ;Open file get variable id's
> infile = '/Users/snr-wbaule/Desktop/Reanalysis_Data/air.2m.mon.ltm.nc '
> nunit = ncdf_open(infile,/nowrite)
> ivarid   = ncdf_varid(nunit,'air')
> ilatid   = ncdf_varid(nunit,'y')
> ilonid   = ncdf_varid(nunit,'x')
>
> ;Get scale and offset attributes from netCDF file
> NCDF_ATTGET,nunit,'air','add_offset', add_offset
> NCDF_ATTGET,nunit,'air','scale_factor',xscale
>
> ; apply offset and scale factor to air temp data for all months
> for itime = 0,11,1 do begin
>   offset   = [0,0,itime]
>   count    = [nlons,nlats,1]
>
>   ncdf_varget,nunit,ivarid,temp, OFFSET=offset
>   vararray[*,*,itime] = vararray2 + (xscale*FLOAT(temp)) + add_offset
>
> endfor
> ; get lat and lon arrays from file
> ncdf_varget,nunit,ilatid,rlats,OFFSET=[0,0],$
>   count = [nlons,nlats]
> ncdf_varget,nunit,ilonid,rlons,OFFSET=[0,0],$
>   count = [nlons,nlats]
>
> HELP, vararray ,rlats, rlons
>
>  ;reproject data with parameters found in netCDF file
> result = MAP_PROJ_INIT(104, CENTER_LATITUDE=0,
> CENTER_LONGITUDE=-107,STANDARD_PAR1=50.0,$
>  STANDARD_PAR2=50.0, DATUM=8, /GCTP, LIMIT=[12.2, -133.5, 54.5, -152.,
> 57.3, -49.4, 14.3,-65.1]); FALSE_EASTING=5632642.22547,
> FALSE_NORTHING=4612545.65137)
> ;convert to x y
> result2 = MAP_PROJ_FORWARD(rlons, rlats, MAP_STRUCTURE=result)
> ;convert x y to lat lon to check values.
> result3 = MAP_PROJ_INVERSE(result2, MAP_STRUCTURE=result)
>
> END

Sorry: ilatid should be ilatid and ilonid should be
ilatid = ncdf_varid(nunit,'lat')
ilonid = ncdf_varid(nunit,'lon')
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Point Observations from NARR output
Next Topic: lmgrd problem

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:31:47 PDT 2025

Total time taken to generate the page: 0.00574 seconds