Re: Failed to get index of longitude array

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu May 01 2014 - 20:55:18 MDT

The grid is rectilinear. You can use NCL's 'coordinate subscripting'

Please seen the Mini-Language manual
or the Reference manual

http://www.ncl.ucar.edu/Document/Manuals/
==========

     gribfile="GRMC_GZLM.2014050100000.grb2"
     in = addfile (gribfile,"r")

     centre_lat = 23.84
     centre_lon = 146.4

     u_wind = in->UGRD_P0_L103_GLL0({centre_lat}, {centre_lon})
     v_wind = in->VGRD_P0_L103_GLL0({centre_lat}, {centre_lon})
     print("Wind speed at (" + centre_lat + "," + centre_lon + "): " +
sqrt(u_wind^2+v_wind^2));

On 5/1/14, 8:07 PM, SH WL wrote:
> ncl-talk,
>
> My job was to obtain wind value of a specified grid point from a grib file.
> Before executing, I extracted the lat and lon array from the grib so that I
> know in advance (23.84,146.4) is a valid grid point.
>
> Here is my script
>
> begin
> gribfile="GRMC_GZLM.2014050100000.grb2"
> in = addfile (gribfile,"r")
> raw_lat = in->lat_0
> raw_lon = in->lon_0
> centre_lat = 23.84
> centre_lon = 146.4
> centre_lat_id = ind(raw_lat.eq.centre_lat)
> centre_lon_id = ind(raw_lon.eq.centre_lon)
> print("lat id of " + centre_lat + ": " + centre_lat_id + " | lon id of " +
> centre_lon + ": " + centre_lon_id)
> u_wind = in->UGRD_P0_L103_GLL0(centre_lat_id, centre_lon_id)
> v_wind = in->VGRD_P0_L103_GLL0(centre_lat_id, centre_lon_id)
> print("Wind speed at (" + centre_lat + "," + centre_lon + "): " +
> sqrt(u_wind^2+v_wind^2));
> end
>
> This script got the correct index of lat_0 but not that of lon_0. It is
> always -999 and I had no idea why. Is there anything I overlooked?
>
> I am using NCL v5.1.1, and the grib file to be read can be downloaded at
> http://www.grapes-trams.org.cn/Data/Download/gzlm/GRMC_GZLM_2014050100/GRMC_GZLM.2014050100000.grb2
>
> Thanks a lot.
>
> Regards,
> Samuel Leung
>
>
>
> _______________________________________________
> 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 Thu May 01 20:55:25 2014

This archive was generated by hypermail 2.1.8 : Sun May 04 2014 - 12:38:56 MDT