Re: 2 variables to ASCII file

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu, 29 Nov 2007 06:49:30 -0700

Try

https://www.ncl.ucar.edu/Document/Functions/Contributed/table_attach_rows.shtml

uv = table_attach_row (u, v, 0)
printVarSummary(uv)

write_matrix (uv, fmtx, opt)
delete(uv)

---
Good luck
Erik Noble wrote:
> Dear NCL,
> My code below currently takes  both zonal and meridional wind from a model
> and intends to write the data out to a file using the matrix ASCII command.
> 
> I have been sucessful writing one variable out as a matrix ascii file. How
> can I write both "sets of variables out to one file so that when I use a
> another program to plot the ascii data, the user "sees" both U and V in the
> file? 
> 
> Thank you,
> Erik
> 
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
> ;load "WRFUserARW.ncl"
> 
> begin
> ;
> ; The WRF ARW input file.
> ; This needs to have a ".nc" appended, so just do it.
> diri1 ="/Volumes/Data_and_Models/Model-Output/Athena/"
> ifile1 ="WRF-SOP3_Athena_3_1_2.nc"
> title  = "U_V_700_r2_"
> a=addfile(diri1+ifile1,"r")
> ; What times and how many time steps are in the data set?
>   times  = wrf_user_list_times(a)  ; get times in the file
>   ntimes = dimsizes(times)         ; number of times in the file
> 
> ; The specific pressure levels that we want the data interpolated to.
>   pressure_levels = (/ 850., 700., 500., 300./)   ; pressure levels to plot
>   nlevels         = dimsizes(pressure_levels)     ; number of pressure
> levels
> 
>   ;do it = 0,ntimes-1             ; TIME LOOP
> do it =248, ntimes-1, 8             ; TIME LOOP
> 
>  ; First get the variables we will need
> 
>         p  = wrf_user_getvar(a, "pressure",it) ; pressure is our vertical
> coordinate
>      v  = wrf_user_getvar(a, "va",it)        ; grid point variable
>      u  = wrf_user_getvar(a, "ua",it)        ; grid point variable
> printVarSummary(v)
>  do level = 0,nlevels-1                 ; LOOP OVER LEVELS
> 
>       pressure = pressure_levels(level)
>       v_plane  = wrf_user_intrp3d( v,p,"h",pressure,0.,False)
>       u_plane  = wrf_user_intrp3d( u,p,"h",pressure,0.,False)
> 
> if ( pressure .eq. 700 ) then
>   N    = 109    ; number of rows
>   M    = 139   ; number of columns
>   fWidth = 10    ; specify the format width
>   fDec   = 3     ; specify the number to the right of decimal point
>   fmtx   = M + "f" + fWidth + "." + fDec              ; fmtx="50f10.3"
> 
>   opt  = True
>   opt_at_fout = title+times(it)
> 
>   write_matrix (v_plane, fmtx, opt)
>                 end if
>         end do
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> 
>   end do        ; END OF TIME LOOP
> 
> end
> 
> 
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Nov 29 2007 - 06:49:30 MST

This archive was generated by hypermail 2.2.0 : Fri Nov 30 2007 - 10:55:48 MST