Below is the script I'm stuck with.
Keep getting the error:
terminate called after throwing an instance of 'libdap::Error'
Abort
I've checked all the paths so don't thinks its that.
It ran fine on another pc so it probably has something to do with the way
NCL is set up on this PC, just not sure where to look?
;program to pair up observed variables from station files with wrf data.
;currently set for a short period from the george station with no header
;wrf data files are daily 48 hour projections which I split into first and
second day forecasts and plot as time series
;this domain misses george so im pretending its in the domain since the
bigger domain only has 3hourly data
;this programme finds the nearest gridpoint to george
;produces arrays for observed, 24hforecast and 48hforecast windspeed and a
timestamp
load "$NCARG_ROOT/share/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/share/ncarg/nclscripts/csm/gsn_code.ncl"
;loads the necessary functions
load "$NCARG_ROOT/share/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/share/ncarg/nclscripts/wrf/WRFUserARW.ncl"
begin
;******Read in station data***********
datas = asciiread("/media/My
Passport/NCDC/688280",(/5012,1/),"string") ;open station
data
dataf = asciiread("/media/My Passport/NCDC/688280",(/5012,14/),"float")
;******Recode the time stamp**********
timestamp =new((/5012,1/),"string")
do d=0,5011
time = stringtocharacter(datas(d,0))
year = charactertostring(time(0:3))
month = charactertostring(time(4:5))
day = charactertostring(time(6:7))
hour = charactertostring(time(8:9))
name = year+"-"+month+"-"+day+"_"+hour
;print(name)
timestamp(d,:) = name
end do
;******Store the variable***********
stationid = (dataf(0,1))
latitude = (dataf(0,2))
longitude = (dataf(0,3))
elevation = (dataf(0,4))
ppt = (dataf(:,5))
P= (dataf(:,6))
T= (dataf(:,7))
Td= (dataf(:,8))
wspd= (dataf(:,9))
direction= (dataf(:,10))
u= (dataf(:,11))
v= (dataf(:,12))
;do n=0,10
;print (timestamp(n,0)+" "+wspd(n))
;print (timestamp(0:71,0))
;end do
;******Find the closest point in WRF**
opt = True
opt@MAP_PROJ = 1
opt@TRUELAT1 = -30.0
opt@TRUELAT2 = -60.0
opt@STAND_LON = 20.0
opt@REF_LAT = -36.7366
opt@REF_LON = 14.477
opt@KNOWNJ = 0
opt@KNOWNI = 0
opt@DX = 7500.
opt@DY = 7500.
loc = wrf_ll_to_ij( longitude, latitude, opt )
ni =floattointeger(loc(0))
nj =floattointeger(loc(1))
;print (ni + " "+ nj)
;******Loop through the WRF files*****
File = "/media/My Passport/SAfrica/wrfout_d03_" ;get data
periods=5012
firstdayforecast =new((/periods,1/),"float")
seconddayforecast =new((/periods,1/),"float")
d = -1
years = 2009
do months = 9,10
if (months .gt. 12) then
months = months-12
end if
do days=1,5
d = d+1
hours = 12
FName =
File+sprinti("%0.4i",years)+"-"+sprinti("%0.2i",months)+"-"+sprinti("%0.2i",days)+"_"+sprinti("%0.2i",hours)
;check we are getting it
right
if (isfilepresent(FName)) then ;chceks if
file exists
ff = addfile(FName+".nc","r") ;ff is now
the files
Time = -1 ;takes all times
ua = wrf_user_getvar(ff,"ua",Time) ; u on mass points
va = wrf_user_getvar(ff,"va",Time) ; v on mass points
Wwspd = sqrt(ua*ua + va*va)
copy_VarMeta (ua,Wwspd) ;replaces
metadata
Wwspd@description = "wind speed" ;corrects
the variable name
;printVarSummary(Wwspd)
;printMinMax(Wwspd,True) ;a useful data
check
if (days.eq.1) then ;if statement
lat = ff->XLAT ;quick way to grab
a variable
lon = ff->XLONG
Wwspd@lat2d = lat ;assigns
coordinates
Wwspd@lon2d = lon
end if
firstday = Wwspd(0:24,0,ni,nj)
secondday = Wwspd(24:48,0,ni,nj)
do t =0,24
firstdayforecast(24*d+t,:) = firstday(t)
seconddayforecast(24+24*d+t,:) = secondday(t)
end do
end if
end do
end do
;******Print Pairs to a file*******
datamatrix =new((/5012,4/),"string")
print ("Timestamp"+ " "+"obs wspd"+" "+ "24hf wspd"+" " +"48hf wsdp")
do n=0,5011
print(timestamp(n,0)+" "+wspd(n)+" "+firstdayforecast(n,0)+"
"+seconddayforecast(n,0))
datamatrix(n,0)= timestamp(n,0)
datamatrix(n,1) = wspd(n)
datamatrix(n,2) = flt2string(firstdayforecast(n,0))
datamatrix(n,3) = flt2string(seconddayforecast(n,0))
end do
opt = True
opt@fout = "Pairs.dat"
write_matrix (datamatrix(1:3,:), "f3.2" , opt)
end
On Fri, Jul 16, 2010 at 9:37 PM, Rick Brownrigg <brownrig@ucar.edu> wrote:
> Hi Brendan,
>
> It sounds like perhaps you are trying to open a remote file via OPeNDAP,
> and the read of that file is failing? Its likely not the copy_VarMeta
> function per se. It might be useful if you can post your script.
>
> By the way, not that it should make a difference in the libdap:Error
> outcome, but in your attempt to replace
>
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> with
>
>
> load "./usr/share/ncarg/nclscripts/csm/contributed.ncl"
>
>>
>> Note that the leading "." makes that a relative path, not the absolute
> path I think you intended.
>
> FWIW...
> Rick
>
>
> On Jul 16, 2010, at 3:37 AM, Brendan Argent wrote:
>
> Hey all
>> I'm quite a rookie with NCL so any help would be welcome.
>> I've been working on a script on a computer overseas and brought it back
>> with me only to find a bunch of error messages I wasn't getting before.
>> Specifically:
>>
>> terminate called after throwing an instance of 'libdap::Error'
>> Abort
>>
>> I think it has to do with the libraries being in a different place but I'm
>> not sure how to tell NCL where to find the functions I need.
>>
>> One of the functions I am using is copy_VarMeta. This requires the line
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>>
>> If I comment this line out then I get the error:
>>
>> fatal:syntax error: line 95 in file
>> Pairs3.ncl before or near ;replaces metadata
>>
>> copy_VarMeta (ua,Wwspd)
>> ;replaces metadata
>> ^
>>
>> fatal:syntax error: possibly an
>> undefined procedure
>> fatal:Syntax Error in block, block not
>> executed
>> fatal:error at line 136 in file
>> Pairs3.ncl
>>
>> SO then the program actually runs which makes me think the problem is with
>> loading the function.
>>
>> I've checked the path to the contributed.ncl function
>> (/usr/share/ncarg/nclscripts/csm/contributed.ncl)
>> but if I change the suggested line to :
>> load "./usr/share/ncarg/nclscripts/csm/contributed.ncl"
>>
>> I get the error:
>> fatal:Could not open
>> (./usr/share/ncarg/nclscripts/csm/contributed.ncl)
>> fatal:error at line 9 in file Pairs3.ncl
>>
>> As I said I'm quite new to this so maybe I'm missing something obvious.
>> Any help would be appreciated.
>> Thanks
>> Brendan
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jul 19 02:59:06 2010
This archive was generated by hypermail 2.1.8 : Mon Jul 19 2010 - 09:39:01 MDT