[Thread Prev][Thread Next][Index]

Re: how to read the lon&lat from the dat file and use them to plotgraph?



Hi Lily,
	You say that your extra file has values of lon, lat, xdis, and
ydis which might suggest that you are dealing with a curvilinear grid
where xlon is not the same for all points in the netCDF file with a
given value of xdis.  This might require a different approach than what
follows which is for the case where both the xdis/ydis and lon/lat
grids are rectangular (but not necessarily eveny spaced).

Converting between rectangular grids

Step 1: From your lon,lat,xdis,ydis file extract the NX points on your
        longitude axis (NX is the same as the number of xdis values)
	I'll assume these longitudes are in east longitude convention
	so the file "longitudes.d" might contain NX records
		170.0   <- 170E
		172.5
		177.0
		185.0
		...
		207.0   <- 207E or 153W
	of regularly or irregularly-spaced monotonically increasing
	values.
Step 2: Do the same for latitude so that you get another file "latitude.d"
	with NY values, for example
		-10.0   <- 10S
		 -5.0
		 -2.0
		  0.0
		  2.0
		  5.0
		 10.0   <- 10N

Step 3: Open a ferret session
	! open the longitude file ...
	file/form=free/var=lon/units=longitude longitude.d
	! ... and define an x-axis based on the values there
	def axis/x/from_data/name=xax lon[d=1]
	! do the same to create a y-axis
	file/form=free/var=lat/units=latitude latitude.d
	def axis/y/from_data/name=yax lat[d=2]

	! now open your netcdf data file which has an NX by NY
	! grid in the horizontal, but perhaps depth and time axes
	! which don't need to be changed.

	use myNetcdfFile.nc

	! Suppose this data file has a variable V. We now make
	! a new grid based on V but with new x and y-axes xax and yax

	def grid/like=V[d=3]/x=xax/y=yax gnew

	! now make a new version of V on the longitude-latitude grid

	let Vnew = V[d=3,g=gnew,gx=@asn,gy=@asn]

Step 4: Now if you plot or shade Vnew the x and y axes will be in
	longitude and latitude units.

Apologies if the answer above does not correspond to your situation
(perhaps you are in a non-rectangular axis situation). If you are
then there are ways to handle that too - you may find help in the
archives under curvilinear mapping, or rephrase your question.

Good luck,
Mick

|____Mick.Spillane@noaa.gov____|
|__Room 2070 Bldg#3 NOAA/PMEL__|
|____Phone_:_(206)526-6780_____|




[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement