[gradsusr] convert world coordinate distance to real distance (km)

HARVEY, PHILIP O NH-03 USAF AFMC 412 OSS/OSW philip.harvey.1 at us.af.mil
Mon Nov 7 11:24:52 EST 2016


Wendi,

The formula expects input in radians.  You must first convert the input latitudes and longitudes from degrees to radians.  For example, 34.5 * PI / 180 = 0.011294, etc.  Then apply the formula using your example values.  The result of the formula using 34.5 lat 135 lon and 35 lat 135.5 lon is 38.8276 nautical miles or 38.8276 NM * 1.852 = 71.90872 KM.

Phil



-----Original Message-----
From: gradsusr-bounces at gradsusr.org [mailto:gradsusr-bounces at gradsusr.org] On Behalf Of Jeff Duda
Sent: Saturday, November 05, 2016 7:34 AM
To: GrADS Users Forum <gradsusr at gradsusr.org>
Subject: Re: [gradsusr] convert world coordinate distance to real distance (km)

Wendi,
Keep in mind what happens when you alter the geographical bounds in the control file. Those XDEF/YDEF/ZDEF/TDEF lines control the bounds of your dimension environment when running grads. Now that you've set the xdef and ydef to start at 1 and increment by very small values, the maximum x and y values in your dimension environment are now 


max_x = 1 + 319*0.005483962 = 2.749

max_y = 1 + 319*0.00452226 = 2.443


Notice how this math is derived from your control file. This means the maximum values for lat and lon that won't result in an error are 2.749 and 2.443. You set lat and lon to well outside those ranges in your script, which is why you are getting the error. You can instead reset lat and lon so that they're within the bounds above, but I think that's getting away from the problem you're trying to solve. My understanding is that you want to plot a field using linear distance coordinates rather than geographical coordinates. If so, then you don't want to be using lat/lon to set your dimensions. Use 'set x' and 'set y', and also set your initial value in your XDEF and YDEF lines to zero so that the lower left corner of your plots will be at distance coordinate (0,0) and increasing as you go up and right. Is this what you wanted to do?


Jeff Duda


On Sat, Nov 5, 2016 at 1:35 AM, wendi harjupa <wendiharjupa at gmail.com <mailto:wendiharjupa at gmail.com> > wrote:


	Dear Mr. Jeff

	Thank you very much for your advice.
	I have tried it for several times, but it does not work.
	I am very sorry for asking you again.

	I got an error as below
	Data Request Warning:  Request is completely outside file limits
	Cannot contour grid - all undefined values 
	Error in xcbar.gs <http://xcbar.gs> : No shading information


	Here my ctl file and gs file

	try.ctl

	DSET /TAKAYASU/wendi/xband/G000.grads/KINKI/20150808_0900-1700/data/KINKI00001-20150808-1400-G000-EL000000.bin
	UNDEF -999
	  XDEF 319 LINEAR 1 0.005483962
	  YDEF 319 LINEAR  1 0.00452226
	#  ZDEF  81 LINEAR 125 250
	TDEF   120 LINEAR 09:00Z14JUL1500 60yr
	VARS   1
	rr    81 99 rainfall (mm)
	ENDVARS


	try.gs <http://try.gs> 

	  'reinit'
	   'open /TAKAYASU/wendi/overlay_cappi/try.ctl'
	   'setXrain.gs'
	#   'set mproj off'
	#   'setCOMMON.gs'
	   'set lon 134.9 135.4'
	   'set lat 34 34.5'
	   'd  rr'
	   'xcbar  8.6 8.8 0.8 4 -fw 0.11 -fh 0.15 -edge triangle -fstep 1 -line on -lc 1'
	   'set strsiz 0.15 0.15'
	   'draw string 8.5 4.15 mm'

	#   'set xaxis 0 10 1'
	#   'set yaxis 0 10 1'

	   'close 1'

	Thank you very much.
	Best regards,
	wendi







	On Thu, Nov 3, 2016 at 1:37 AM, Jeff Duda <jeffduda319 at gmail.com <mailto:jeffduda319 at gmail.com> > wrote:
	

		Wendi,
		
		You can always change the text of any control file. There should not be anything stopping you from doing that. Please clarify what you mean.
		
		
		Jeff
		

		On Tue, Nov 1, 2016 at 11:53 PM, wendi harjupa <wendiharjupa at gmail.com <mailto:wendiharjupa at gmail.com> > wrote:
		

			Dear Mr Jeff

			Thank you very much for your help.

			I have two different types of data set and I need to make composite data with those data.
			One data is mismatch, then I need to know how far the mismatch.

			One of my data set is binary and another one is netCDF.
			
			I can change my control file in my binary data. But, I cannot do this for my netCDF data.
			Would you mind to suggest me, how to change XDEF and YDEF in netCDF data?

			Thank you very much

			best regards,
			wendi

			On Wed, Nov 2, 2016 at 12:02 AM, Jeff Duda <jeffduda319 at gmail.com <mailto:jeffduda319 at gmail.com> > wrote:
			

				Wendi,
				
				It sounds like you want to draw a plot with geographic coordinates replaced by straight-line/distance coordinates instead. If that is the case, one thing you can try is removing the PDEF line from your control file and resetting your XDEF and YDEF lines to start at 0 (but keep the delta value). That might work. If that doesn't work, you could also try turning off the map projection in grads (set mproj off) and then using 'set xaxis' and 'set yaxis' in clever ways to make it look like the map you draw is in terms of linear distance. Good luck.
				
				
				Jeff Duda
				

				On Tue, Nov 1, 2016 at 9:32 AM, HARVEY, PHILIP O NH-03 USAF AFMC 412 OSS/OSW <philip.harvey.1 at us.af.mil <mailto:philip.harvey.1 at us.af.mil> > wrote:
				

					See Ed Williams' Aviation Formulary at http://williams.best.vwh.net/avform.htm <http://williams.best.vwh.net/avform.htm>  for great circle distance, etc formulas.  The formula you desire is only requires 1 line and can easily be written into a function.
					
					Phil
					


					-----Original Message-----
					From: gradsusr-bounces at gradsusr.org <mailto:gradsusr-bounces at gradsusr.org>  [mailto:gradsusr-bounces at gradsusr.org <mailto:gradsusr-bounces at gradsusr.org> ] On Behalf Of wendi harjupa
					Sent: Tuesday, November 01, 2016 2:01 AM
					To: GrADS Users Forum <gradsusr at gradsusr.org <mailto:gradsusr at gradsusr.org> >
					Subject: [gradsusr] convert world coordinate distance to real distance (km)
					
					Dear every one
					
					I have problem with converting distance in world coordinate to distance,
					
					I have map with
					lon = 135  135.5
					lat = 34.5   35
					
					I want to set lon =135, as 0 km, and lat=34.5 as 0 km.
					as we know that 1 deg is about 110 km.
					
					Is there any function in grads that can directly convert the world coordinat distance to real distance (km)?
					
					Please, any help would be very appreciate.
					
					thank you
					regards,
					wendi
					
					
					_______________________________________________
					gradsusr mailing list
					gradsusr at gradsusr.org <mailto:gradsusr at gradsusr.org> 
					http://gradsusr.org/mailman/listinfo/gradsusr <http://gradsusr.org/mailman/listinfo/gradsusr> 
					



				
				
				-- 
				
				Jeff Duda
				Post-doctoral research associate
				University of Oklahoma School of Meteorology
				
				
				_______________________________________________
				gradsusr mailing list
				gradsusr at gradsusr.org <mailto:gradsusr at gradsusr.org> 
				http://gradsusr.org/mailman/listinfo/gradsusr <http://gradsusr.org/mailman/listinfo/gradsusr> 
				
				



			_______________________________________________
			gradsusr mailing list
			gradsusr at gradsusr.org <mailto:gradsusr at gradsusr.org> 
			http://gradsusr.org/mailman/listinfo/gradsusr <http://gradsusr.org/mailman/listinfo/gradsusr> 
			
			



		
		-- 
		
		Jeff Duda
		Post-doctoral research associate
		University of Oklahoma School of Meteorology
		
		
		
		_______________________________________________
		gradsusr mailing list
		gradsusr at gradsusr.org <mailto:gradsusr at gradsusr.org> 
		http://gradsusr.org/mailman/listinfo/gradsusr <http://gradsusr.org/mailman/listinfo/gradsusr> 
		
		



	_______________________________________________
	gradsusr mailing list
	gradsusr at gradsusr.org <mailto:gradsusr at gradsusr.org> 
	http://gradsusr.org/mailman/listinfo/gradsusr <http://gradsusr.org/mailman/listinfo/gradsusr> 
	
	




-- 

Jeff Duda
Post-doctoral research associate
University of Oklahoma School of Meteorology




More information about the gradsusr mailing list