Re: 2 variables to ASCII file

From: Erik Noble <enoble_at_nyahnyahspammersnyahnyah>
Date: Fri, 7 Dec 2007 13:37:26 -0500

Dear Dr. Shea and NCL world,
I am getting this error now, which does not make sense. My code for
uv = table_attach_rows (u,v, 0) is in the correct syntax, is it not?

Copyright (C) 1995-2007 - All Rights Reserved
 University Corporation for Atmospheric Research
 NCAR Command Language Version 5.0.0
 The use of this software is governed by a License Agreement.
 See http://www.ncl.ucar.edu/ for more details.

Variable: times
Type: string
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
Number Of Attributes: 2
  description : times in file
  _FillValue : missing
(0) 2006-09-10_00:00:00

Variable: v
Type: float
Total Size: 61160 bytes
            15290 values
Number of Dimensions: 3
Dimensions and sizes: [Time | 1] x [south_north_stag | 110] x [west_east | 139]
Coordinates:
Number Of Attributes: 5
  FieldType : 104
  MemoryOrder : XYZ
  units : m s-1
  description : V
  stagger : V
fatal:Number of dimensions in parameter (0) of (table_attach_rows) is
(3), (2) dimensions were expected
fatal:Execute: Error occurred at or near line 42 in file INPUT_ascii.ncl

Erik_at_noble:/Volumes/Data_and_Models/ncl_scripts:

CODE:::

 ; Example script to produce plots for a WRF real-data run,
; with the ARW coordinate dynamics option.
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"
;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/NAMA-SOP3/"
ifile1 ="met_em.d01.2006-09-10_00:00:00.nc"
title = "UV-metGrid_R2-Ascii-"
date = "09-10-00UT"
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

 ; First get the variables we will need

     v = a->VV(:,10,:,:) ; grid point variable
     u = a->UU(:,10,:,:)
 printVarSummary(v)

  N = 120 ; number of rows
  M = 140 ; 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+date
uv = table_attach_rows (u, v, 0)
printVarSummary(uv)

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

end

On Dec 7, 2007 9:50 AM, Dennis Shea <shea_at_ucar.edu> wrote:
> My example
> uv = table_attach_row (u_plane, v_plane, 0)
> neglected to include the 's' at the end of "_row"
> uv = table_attach_rows (u_plane, v_plane, 0)
>
> The documentation URL is correct.
>
>
> Erik Noble wrote:
> > Hi. Thank you for this tip.
> > unfortunately I am still getting an error that says NCL does not
> > recognize "table_attach_row" command.
> > Attached are both my code and my errors (log file) where the problem
> > is on line 52. any suggestions
> >
> > On Nov 29, 2007 8:49 AM, Dennis Shea <shea_at_ucar.edu> wrote:
> >
> >> 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 Fri Dec 07 2007 - 11:37:26 MST

This archive was generated by hypermail 2.2.0 : Tue Dec 11 2007 - 14:19:21 MST