[ncl-talk] help to extract data from multiple stations in multiple files

Ramchandra Karki rammetro at hotmail.com
Sat May 7 08:08:05 MDT 2016


   Dear NCL help,I am trying to extract multiple stations time series (ascci output for each stations) from wrfoutput file but i could not succeed in doing so. Would you please kindly guide me to get the solution?regardsRamchandra
 ; --------------  LOAD FUNCTIONS AND PROCEDURES ----------------
    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/wrf/WRFUserARW.ncl"
    ; --------------  BEGINING OF NCL SCRIPT ----------------beginDATADir = "/mnt/gpfs1/data/private/fgvy024/Build_WRF/WRFV6/run/"FILES = systemfunc (" ls -1 " + DATADir + "wrfout_d03* ")numFILES = dimsizes(FILES)a = addfiles(FILES+".nc","r")times = wrf_user_list_times(a)     ; get times in the filentimes = dimsizes(times)           ; number of times in the file or 1584 for domain1 4750
;new parameters namingtemp = new(ntimes,float) rain_expp = new(ntimes,float) rain_conn = new(ntimes,float) rain_tot = new(ntimes,float)wspd = new(ntimes,float)wdir = new(ntimes,float)snoww_eq = new(ntimes,float)snowh_h = new(ntimes,float);rhh = new(ntimes,float)
;******************************* time loopdo it = 0, ntimes-1                 time = it
 ;************************************************do ip = 0, 18             ;loop for number of station locationsip_lats = (/ 27.3081, 27.6331,	27.86,	27.959167, \          27.696667, 27.8024,	27.8953, 27.99,	27.9818, \             27.90506667, 27.89671667, 27.901, 27.8987, \          27.89261111, 27.87828333, 27.85911111, \          27.60111, 27.74661, 27.85722 /)ip_lons = (/ 86.5042, 86.2331, 86.46, 86.81278, 86.721389, 86.7144, \           86.8188, 86.83, 86.7649, 86.37536667, 86.37428333, 86.37625, 86.37911667, \	   86.37594444,	86.43361667, 86.43388889, 86.74028, 86.713, 86.79417 /)res = True      res at returnInt = True point = wrf_user_ll_to_ij(a, ip_lons(ip), ip_lats(ip), True)x = point(0) - 1y = point(1) - 1                   
tc2 = wrf_user_getvar(a,"T2",it)       ; temp extractiontc2 = tc2 -273.16temp(it) = tc2(y,x) ; temperature extraction for station locationrain_exp = wrf_user_getvar(a,"RAINNC",it) rain_con = wrf_user_getvar(a,"RAINC",it) rain_expp(it) = rain_exp(y,x)rain_conn(it) = rain_con(y,x)rain_tot(it) = rain_exp(y,x) + rain_con(y,x)u10 = wrf_user_getvar(a,"U10",it)    ; u at 10 m, mass pointv10 = wrf_user_getvar(a,"V10",it)    ; v at 10 m, mass pointwspd(it) = ndtooned( sqrt(u10(y,x)^2 + v10(y,x)^2) )wdir(it) = ndtooned( atan2(u10(y,x),v10(y,x))/0.01745329 +180. ) snow_eq = wrf_user_getvar(a,"SNOW",it)snow_h = wrf_user_getvar(a,"SNOWH",it)snoww_eq(it) = snow_eq(y,x)snowh_h (it) = snow_h(y,x)
end do    ; end of station loopend do    ; end of time loop
    npts=ntimes    fName = ip+"T2oben_1kmtemp_rainnonc_rainc_raintot_wspd_wdir_snow_snowh.txt"    data  = new( npts, "string")       ;print(" Time temp ")    ip = 0, 18    do it = 0,ntimes-1 ;ntimes-1    data (it)= (sprintf("%5.0f",it)    +" " \          +sprintf("%21.2f", temp(it)) +"  " \          +sprintf("%22.2f", rain_expp(it)) +"  " \          +sprintf("%23.2f", rain_conn(it)) +"  " \          +sprintf("%24.2f", rain_tot(it)) +"  " \          +sprintf("%17.2f", wspd(it)) +"  " \           +sprintf("%25.2f", wdir(it)) +"  " \           +sprintf("%18.2f", snoww_eq(it)) +"  " \          +sprintf("%19.2f", snowh_h(it)) +"  " ) end do                     ; end of time loop asciiwrite (fName , data)end


 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160507/ec0be26e/attachment.html 


More information about the ncl-talk mailing list