writing latitude and longitude to ascii

The NCL graphics package.

writing latitude and longitude to ascii

Postby rezars » Tue Mar 01, 2016 10:47 am

Greetings
I want to write the latitude, longitude and cape (at level 1) from a
wrfout nc file in an ascii file. In order to this :
1. I add the nc file
2. then used " wrf_user_ij_to_ll "to extract the lat and long based on
indices.
But I want to extract the lat and lonfg for all of my grid so I wrote a
loop(i and j used as numeric for this function) but It seems that this
function only works with numeric data and not variables (i and j) which
change within loop .
Here it is my code:

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"


a = addfile("c:/cygwin/home/Rezars/wrfout_d03_2016-01-08_18_00_00.nc","r")

cape2d = wrf_user_getvar(a,"cape_2d",18)
cape3d = wrf_user_getvar(a,"cape_3d",18)

; extract the data from the multi-dimensional fields
cape = cape3d(0,:,:,:)

data = new( 9, "string")
fName = "foo.txt"
npt = -1

do i= 1,3
do j=1,3

npt = npt+1
reza = reza+1
loc = wrf_user_ij_to_ll(a, i., j., True)
data(npt) = sprinti("%0.5i", (npt+1) )
data(npt) = data(npt) + sprintf("%10.1f ",loc(0))
data(npt) = data(npt) + sprintf("%10.1f ",loc(1))
data(npt) = data(npt) + sprintf("%10.1f ",cape(1,i,j))
end do
end do
asciiwrite (fName , data)

Best regards
[code][/code]
rezars
 
Posts: 3
Joined: Thu Feb 25, 2016 7:04 pm

Return to NCL

Who is online

Users browsing this forum: No registered users and 3 guests