[ncl-talk] fatal:No coordinate variable exists for dimension (lat) in variable (modvar_pd_elnino)
Jesús Garcia Rosales
jesus21gr at gmail.com
Sun Sep 27 15:51:56 MDT 2015
I hope that you help me, because it's important for my research.
Jesus
2015-09-26 22:51 GMT-05:00 Jesús Garcia Rosales <jesus21gr at gmail.com>:
> Hi users I have a problem. This is my script:
>
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
> ;*****************************************************
> begin
>
> inidx = 0
> inloc = "Huayao"
> inlat = -12.04
> inlon = -75.32
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ; Now open station data (observations) and read in
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
>
> delim = "," ; these are csv files
>
> ; El Nino
> ; open the files and read in the data
> obs_data_pd_elnino =
> asciiread("/media/jesus/TOSHIBA/ncl_alan/datos/estacion_diaria.csv",-1,"string")
> obs_strs_pd_elnino = str_split_csv (obs_data_pd_elnino, ",", 0)
> obs_pointdata_pd_elnino=tofloat(obs_strs_pd_elnino(1:27,2::))
>
> ; Now compute the length(0) and width(1) of the data matrix
> obsdims_pd_elnino = dimsizes(obs_pointdata_pd_elnino)
>
> ; Find the data column that corresponds to your station of interest
> obs_pointdata_1stn_pd_elnino = obs_pointdata_pd_elnino(:,inidx)
>
> ; now compute a daily climatology from the time series (i.e., average
> all days together)
> obs_pointdata_1stn_90d_multiyear_pd_elnino =
> onedtond(obs_pointdata_1stn_pd_elnino,(/(obsdims_pd_elnino(0)/3),3/))
> obs_pointdata_1stn_dayclm_pd_elnino =
> dim_avg_n(obs_pointdata_1stn_90d_multiyear_pd_elnino,1)
>
>
>
>
>
>
> fname =
> ("/media/jesus/TOSHIBA/WRF_alan/9km/wrfout_d01_2003-01-29_00:00:00") ;
> input precip data
> fin = addfile (fname,"r")
> ; prc = fin->pr ; (time,yc, xc) 3 hrly
> lat = fin->XLAT
> lon = fin->XLONG
>
> time = fin->Times
> ntimes = dimsizes(time)
>
>
> rain_exp = wrf_user_getvar(fin,"RAINNC",-1)
> rain_con = wrf_user_getvar(fin,"RAINC",-1)
>
> ;rain_exp=fin->RAINNC(:,:,:)
> ;rain_con=fin->RAINC(:,:,:)
>
> rain_tot = rain_exp + rain_con
>
> rain=rain_tot(0:743,:,:)
>
> do it=1,743,1
>
> rain(it,:,:)=rain_tot(it,:,:)-rain_tot(it-1,:,:)
>
> end do
>
> ;x(time,lev,lat,lon)
>
> dimx = dimsizes(rain)
> ntim = dimx(0) ; number of time steps
> ; printVarSummary(rain)
>
> ;nlat = dimx(2)
> ; mlon = dimx(3)
>
> nday = ntim/24
>
>
> ; print("nday="+nday)
> ; print("ntim="+ntim)
>
> xday = rain(::24,:,:) ; 'trick' to allocate memory + retain meta
> data
> ; printVarSummary(xday)
>
> do nt=0,ntim-1,24
> xday(nt/24,:,:) = dim_avg_n_Wrap(rain(nt:nt+23,:,:),0) ;
>
> end do
>
>
> modvar_pd_elnino = xday(3:29,:,:)
>
> modvar_pd_elnino!0="time"
> modvar_pd_elnino!1="lat"
> modvar_pd_elnino!2="lon"
>
> ; Find latitudes and longitudes so that you can interpolate data to
> specified station
> lat = modvar_pd_elnino&lat
> lon = modvar_pd_elnino&lon
>
>
> ; El Nino
> mod_pointdata_1stn_dayclm_pd_elnino_2d =
> linint2_points(lon,lat,modvar_pd_elnino,False,inlon,inlat,0)
> mod_pointdata_1stn_dayclm_pd_elnino =
> mod_pointdata_1stn_dayclm_pd_elnino_2d(:,0)
>
> ; now create a single data variable that holds all six
> ; data arrays that you would like to plot
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> data = new((/2,27/),"float")
>
> ; rank order all of the data so you can compute percentiles
> data(0,:) = obs_pointdata_1stn_dayclm_pd_elnino
> data(1,:) = mod_pointdata_1stn_dayclm_pd_elnino
>
> ;create a dummy time variable (integer days: 1 = Dec 1, 90 = Feb 28)
> intday = ispan(1,27,1)
>
> ;**************************************
> ; Create plot
> ;***************************************
> ;open the image. Note you can choose pdf, ps, png, ncgm or x11 format.
> (x11 prints to screen)
> wks = gsn_open_wks ("x11","xy_"+inloc+"_tas") ; open
> workstation
>
> ;Set the resources for the plot Text
> res = True ; plot mods desired
>
> ;Text strings for title and axes
> res at tiMainString = inloc+": DJF El Nino vs La Nina: tas" ; Title
> at top of plot
> res at tiYAxisString = "tas (deg_C)" ; Y-axis title
> res at tiXAxisString ="Day of DJF"
>
> ;Line colors/types
> res at xyLineThicknesses = (/3.,2./) ; make 2nd lines thicker
> res at xyLineColors = (/"red","blue"/) ; change line color
> res at xyDashPatterns = (/0,5/) ; Make curves all solid
>
> ;Make the plot
> plot = gsn_csm_xy (wks,intday,data,res) ; create plot
>
>
> end
>
>
> And when I want to run it, this message appear:
>
> fatal:No coordinate variable exists for dimension (lat) in variable
> (modvar_pd_elnino)
> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 131 in
> file serie_tiempo.ncl
>
> would you please give me some advices for this problem?, thank for your
> time.
>
> Jesus
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150927/16f4d300/attachment.html
More information about the ncl-talk
mailing list