Re: Re: transect plot

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu, 28 Aug 2008 06:41:27 -0600

Hi Lin,

Effectively, LON and LAT are 1D arrays, because they are dimensioned
1 x 3001. However,
the function still sees this as a 2D array, and hence complains.

I'm not sure why you are using a 1 x 3001 array, but is there any
reason you can't just do:

> LAT = lat(:,1 )
> LON = lon(:,1 )

You don't need the "new" statements for LAT and LON either, as the
above statement will
take care of creating these arrays for you.

--Mary

On Aug 27, 2008, at 7:46 PM, Lin Su wrote:

> Dear NCL users,
>
> I got the following error when I run the attached NCL code for my
> transect plot:
>
> fatal:Number of dimensions in parameter (0) of (triple2grid) is
> (2), (1)
> dimensions were expected
> fatal:Execute: Error occurred at or near line 62 in file tran.ncl
>
> What I am thinking is the data (X) can be a multi-dimensional array
> in function
> triple2grid. Any ideas or suggestions for this error?
>
> Thanks a lot,
> -Lin
> ---
> Lin Su
> http://atoc.colorado.edu/~sul/
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> begin
> f = addfile("CAL_LID_L2_05kmALay-Prov-
> V2-01.2007-05-02T16-57-30ZN.hdf", "r")
> lat = f->Latitude ; (3001,3)
> lat_at_units = "degrees_north"
> lon = f->Longitude ; (3001,3)
> lon_at_units = "degrees_east"
> altBase = f->Layer_Base_Altitude ;(3001,8)
> altBase_at_long_name = altBase_at_hdf_name
> altBase@_FillValue = -9999.
> altTop = f->Layer_Top_Altitude ;(3001,8)
> altTop_at_units = "km"
> altTop_at_long_name = altTop_at_hdf_name
> altTop@_FillValue = -9999.
> numlayer = f->Number_Layers_Found ;(3001,1)
> numlayer_at_long_name = numlayer_at_hdf_name
> x = f->Feature_Optical_Depth_532 ; (3001,8)
> x_at_long_name = x_at_hdf_name
> x@_FillValue = -9999.
> ;printVarSummary(x)
>
> ;dimensional issues
> X = new((/8,3001/), float)
> LAT = new((/1,3001/), float)
> LON = new((/1,3001/), float)
> X(0,:) = x(:,0)
> X(1,:) = x(:,1)
> X(2,:) = x(:,2)
> X(3,:) = x(:,3)
> X(4,:) = x(:,4)
> X(5,:) = x(:,5)
> X(6,:) = x(:,6)
> X(7,:) = x(:,7)
> LAT(0,:) = lat(:,1 )
> LON(0,:) = lon(:,1 )
>
> ;res = True
> ;res_at_sfXArray = LON
> ;res_at_sfYArray = LAT
>
> latS = 30.
> latN = 45.
> lonL = 130.
> lonR = 140.
>
> ;delete(res_at_sfXArray)
> ;delete(res_at_sfYArray)
>
> dlat = 0.25 ; create a grid
> dlon = 0.25
> nlat = floattoint( (latN-latS)/dlat ) + 1
> mlon = floattoint( (lonR-lonL)/dlon ) + 1
> lonGrid = fspan(lonL, lonR, mlon)
> lonGrid!0 = "lon"
> lonGrid_at_units = "degrees_east"
> latGrid = fspan(latS, latN, nlat)
> latGrid!0 = "lat"
> latGrid_at_units = "degrees_north"
>
> TGRID = triple2grid(LON,LAT,X,lonGrid,latGrid, False)
> TGRID!0 = "alt"
> TGRID!1 = "lat"
> TGRID!2 = "lon"
> TGRID&alt = alt
> TGRID&lat = latGrid
> TGRID&lon = lonGrid
>
> printVarSummary(TGRID)
> printMinMax(TGRID, True)
> res_at_gsnCenterString = "Feature_Optical_Depth_532"
>
> ;transect plot
> ;calculate great circle along transect
> ;***************************
> leftlat = 30
> rightlat = 50
> leftlon = 110
> rightlon = 140
> npts = 100
> dist = gc_latlon(leftlat,leftlon,rightlat,rightlon,npts,2)
> points = ispan(0,npts-1,1)*1.0
> ;**************************
> ;interpolate data to great circle
> ;***********************
> trans = linint2_points(TGRID&lon,TGRID&lat,TGRID,True,
> dist_at_gclon,dist_at_gclat,2)
> copy_VarAtts(TGRID,trans)
> trans!0 = "alt"
> trans&alt = TGRID&alt
> ;plot
> wks = gsn_open_wks("x11","trans_os")
> gsn_define_colormap(wks,"BlAqGrYeOrReVi200")
>
> res1 = True
> res1_at_tmXBMode = "Explicit"
> res1_at_tmXBValue = (/points(0),points(npts-1)/)
> res1_at_tmXBLabels = (/leftlat +","+leftlon,rightlat+","+rightlon/)
> res1_at_cnFillOn = True
> res1_at_lbLabelAutoStride = True
> res1_at_gsnSpreadColors = True
> res1_at_cnLinesOn = False
> res1_at_lbOrientation = "vertical"
> res1_at_pmLabelBarOrthogonalPosF = -0.05
>
> plot = gsn_csm_contour(wks,trans,res1)
>
> end
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Aug 28 2008 - 06:41:27 MDT

This archive was generated by hypermail 2.2.0 : Fri Aug 29 2008 - 07:39:21 MDT