Re: lat2d, lon2d

From: Dennis Shea (shea AT cgd.ucar.edu)
Date: Sun Feb 06 2005 - 12:46:48 MST

  • Next message: Christian Pagé: "Contour line labels: at the boundaries?"

    >Hello,
    >I have 5 years of binary data from MM5. The data has lat2d and lon2d
    >dimensions.
    >I wish to plot the annual cycle of rainfall (xy plot) for a given
    >location (say 40N, 65W). In a normal netcdf file I could have used
    >coordinate subscripting for this.
    >I need some ideas on how I can extract the location of interest. I
    >converted the binary data (Lambert Conformal projection) into
    >netcdf but the dimensions of my rainfall variable is as follows;
    >
    >(0) ==========> printVarInfo: PREC_E
    >
    >
    >Variable: x (parameter)
    >Type: float
    >Total Size: 706560 bytes
    > 176640 values
    > Number of Dimensions: 3
    > Dimensions and sizes: [time | 60] x [MLON | 64] x [NLAT | 46]
    > Coordinates:
    > time: [204101..204512]
    > Number Of Attributes: 2
    > units : mm/day
    > long_name : total precip (perturbed vegetation)
    > (0) Minimum: 0 Maximum: 75.4019
    >
    >This is still not helpful. Maybe, there is a better way to handle this.
    >I should be grateful, if someone can suggest a way to do this.

    The following is not tested. It (hopefully) finds the
    subscript indices of the grid point nearest LAT, LON.
    Given the high resolution of the MM5 grid, it is hardly worth
    interpolating to a specific point.

    function indMinDist(lat2d[*][*]:numeric, lon2d[*][*]:numeric \
                       ,LAT[1]:numeric, LON[1]:numeric)
    ; determine subscript(s) of the nearest grid point to (LAT,LON)
    local lat1d, lon1d, dist, dmin, ijmin, ij2d
    begin
       lat1d = ndtooned(lat2d)
       lon1d = ndtooned(lon2d) ; -180 to 180
                   ; great circle distance is best BUT
                   ; this is close enough in this case
       dist = sqrt( (lat1d-LAT)^2 + (lon1d-LON)^2 )
       dmin = min(dist) ; min distance
       ijmin = ind(dist.eq.dmin) ; index of desire pt in 1d
       
       ij2d = ind_resolve( ijmin, dimsizes(lat2d) )
       return (ij2d)
    end

       prc = .... ; (time,lat2d,lon2d)

       lat2d =
       lon2d =
       LAT = 40.
       LON = -65.
       
       ij = indMinDist(lat2d, lon2d, LAT, LON)
       
       ii = ij(0,0) ; lon2d
       jj = ij(0,1) ; lat2d
       
       prc_timeSeries = prc(:,jj,ii) ; time series of pts at
                                      ; grid pt nearest LAT,LON
                                      
       printVarSummary( prc_timeSeries )
       
    ================

    You can remove the annual cycle from the above time series.

    good luck

    _______________________________________________
    ncl-talk mailing list
    ncl-talk@ucar.edu
    http://mailman.ucar.edu/mailman/listinfo/ncl-talk



    This archive was generated by hypermail 2b29 : Mon Feb 07 2005 - 07:50:42 MST