<div dir="ltr"><div><div>Hello All,<br><br></div>I have gridded satellite estimated
rainfall and a file of precipitation measurements from gauges. I would
like to Interpolate the gridded data to the gauge locations for
comparison. I figured the function linint2_points might work for this
process, but thus far I've had no luck. I get no error message but the
return value is just an array of missing values (-999). My best guess
is that my "rain" array isn't set up correctly for the function when it
is read in from binary.<br><br></div><div>The 2 files have been placed on the FTP<br></div><div><br></div><div>I am running ncl version 6.0.0<br><br></div><div>thanks,<br></div><div>Steven Fuhrman<br><br></div>CODE:<br><br>begin<br><br> load "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/contributed.<wbr>ncl" <br><br>;*****************************<wbr>******************************<br>; read in station data file <br>;*****************************<wbr>****************************** <br> filename = "guatamala_mon_rain.txt"<br> rows = numAsciiRow(filename)<br> colls = numAsciiCol(filename)<br> f = asciiread(filename,(/rows,<wbr>colls/),"float")<br><br>;*****************************<wbr>******************************<br>; read in gridded estimated precip file <br>;*****************************<wbr>****************************** <br> <br> diri = "/cpc/fews/production/ARC/<wbr>MONTHLY/" ; input directory<br> fili = "arc2_monthly_200010" ; DSET<br> fName = diri+fili <wbr> ; path<br><br> nlat = 801 <wbr> ; YDEF<br> nlon = 751 ; XDEF<br> nvars = 1 <wbr> ; vars<br><br> year = 2000 <wbr> ; TDEF<br> ntim = 1 ; time steps<br> nmos = 1<br> <br> <wbr> ;create an array to contain data<br> UNDEF = -999.0 <wbr> ; UNDEF<br> rain = new ( (/ntim,nlat,nlon/), float, UNDEF) ;switched!<br><br> rain@long_name = "precipitation" ; VARS<br> rain@units = "mm" <br> <br> <wbr> <br> do nt=0,ntim-1 <wbr> ; read each record: store in x<br> rain(nt,:,:) = fbindirread(fName, nt, (/nlat,nlon/), "float") <br> end do<br><br> rain!0 = "time"<br> rain!1 = "lat"<br> rain!2 = "lon"<br> printVarSummary(rain)<br> print ("min(rain)="+min(rain))<br> print ("max(rain)="+max(rain))<br><br>;*****************************<wbr>******************************<wbr>*<br>; Generate lat/lon that pairs with gridded data<br>;*****************************<wbr>******************************<wbr>*<br> lon = fspan(-20,55,751)<br> lon!0 = "lon"<br> lon@long_name = "longitude"<br> lon@units = "degrees_east"<br><br> lat = fspan(-40,40,801)<br> lat!0 = "lat"<br> lat@long_name = "latitude"<br> lat@units = "degrees_north"<br> <br>;*****************************<wbr>******************************<wbr>*<br>; count number of stations<br>;*****************************<wbr>******************************<wbr>*<br>count = 0<br>previous = f(0,0)<br>do i=1,rows-2<br> if(f(i,0) .ne. previous)<br> count = count + 1<br>; print(f(i,0)+" i am counting!"+i)<br> end if<br> previous = f(i,0) <br>end do<br>print("count = "+count) <br><br>;*****************************<wbr>******************************<wbr>*<br>; make subset -an array with only a single date (year/month) for each station. <br>;*****************************<wbr>******************************<wbr>*<br>subset =new((/count,colls/),float,-<wbr>999) <br>year = 2000<br>month = 1<br>line = 0<br> do i=0,rows-1<br> if ((f(i,1) .eq. year) .and. (f(i,2) .eq. month))<br> subset(line,0) = f(i,0)<br> subset(line,1) = f(i,1)<br> subset(line,2) = f(i,2)<br> subset(line,3) = f(i,3)<br> subset(line,4) = f(i,4)<br> subset(line,5) = f(i,5)<br> line = line + 1<br> end if<br> end do<br><br>;*****************************<wbr>******************************<br>; perform interpolation with subset<br>;*****************************<wbr>******************************<br>interpolation = linint2_points(lon,lat,rain,<wbr>False,subset(:,4),subset(:,5),<wbr>0) ; subset was formally x<br><br>print (interpolation)<br>end<br clear="all"><br>-- <br>
</div>