Re: wind_2.ncl script

From: Mittal, Moti <mmittal_at_nyahnyahspammersnyahnyah>
Date: Fri, 10 Apr 2009 16:44:34 -0400

Mary,

Your advice was helpful but now I am getting Latitude Longtitude problem.
Output is:

[mmittal_at_localhost ~/NCL]$ ncl wind_2.ncl
 Copyright (C) 1995-2009 - All Rights Reserved
 University Corporation for Atmospheric Research
 NCAR Command Language Version 5.1.0
 The use of this software is governed by a License Agreement.
 See http://www.ncl.ucar.edu/ for more details.
(0) check_for_y_lat_coord: Warning: Data either does not contain a valid latitude coordinate array or doesn't contain one at all.
(0) A valid latitude coordinate array should have a 'units' attribute equal to one of the following values:
(0) 'degrees_north' 'degrees-north' 'degree_north' 'degrees north' 'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg north'
(0) check_for_lon_coord: Warning: Data either does not contain a valid longitude coordinate array or doesn't contain one at all.
(0) A valid longitude coordinate array should have a 'units' attribute equal to one of the following values:
(0) 'degrees_east' 'degrees-east' 'degree_east' 'degrees east' 'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'
[mmittal_at_localhost ~/NCL]$

Where do I put the lat long attributes?

Thank you for your help.

moti
Professor, Department of Environment and Occupational Health
College of Public Health
University of South Florida
13201 Bruce B. Downs Blvd., MDC56
Tampa, Fl 33612-3805

Tel: (813) 974-9571
Fax: (813) 974-4986
Email: mmittal_at_health.usf.edu
________________________________________
From: Mary Haley [haley_at_ucar.edu]
Sent: Friday, April 10, 2009 3:30 PM
To: Mittal, Moti
Cc: Dennis Shea; ncl-talk_at_ucar.edu
Subject: Re: wind_2.ncl script

On Fri, 10 Apr 2009, Mittal, Moti wrote:

> Dennis,
>
> Thank you for your help. I could fix the earlier error by changing the script in the following way.
> Now I am getting different error in FillValue as:
>
> [mmittal_at_localhost ~/NCL]$ ncl wind_2.ncl
> Copyright (C) 1995-2009 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 5.1.0
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
>
>
> Variable: u
> Type: float
> Total Size: 9604 bytes
> 2401 values
> Number of Dimensions: 2
> Dimensions and sizes: [south_north | 49] x [west_east | 49]
> Coordinates:
> Number Of Attributes: 6
> coordinates : XLONG XLAT
> stagger :
> units : m s-1
> description : U at 10 M
> MemoryOrder : XY
> FieldType : 104
>
>
> Variable: v
> Type: float
> Total Size: 9604 bytes
> 2401 values
> Number of Dimensions: 2
> Dimensions and sizes: [south_north | 49] x [west_east | 49]
> Coordinates:
> Number Of Attributes: 6
> coordinates : XLONG XLAT
> stagger :
> units : m s-1
> description : V at 10 M
> MemoryOrder : XY
> FieldType : 104
> warning:Attempt to reference attribute (_FillValue) which is undefined
> warning:Attempt to reference attribute (_FillValue) which is undefined
> fatal:Number of subscripts do not match number of dimensions of variable,(3) Subscripts used, (2) Subscripts expected
> fatal:Execute: Error occurred at or near line 57 in file wind_2.ncl

Noti,

Your u and v don't appear to have missing values (_FillVaue), so try:

   ur = new ( dimsizes(u), typeof(u) )
   vr = new ( dimsizes(v), typeof(v) )

Also, the error for line 57 is telling you exactly what the problem
is. It says you are trying to subscript a variable as if it
has three dimensions, when it really only has two.

Do this instead:

    plot= gsn_csm_vector_map_ce(wks,ur,vr,res)

--Mary

>
>
> wind_2.ncl script
> 1 ;*************************************************
> 2 ; wind_2.ncl
> 3 ;*************************************************
> 4 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> 5 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> 6 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> 7 load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
> 8 ;*************************************************
> 9 begin
> 10 ;*************************************************
> 11 ; open file and read in data: data are on a gaussian grid
> 12 ;*************************************************
> 13 f = addfile ("wrfout_d01_2007-01-31_12.nc", "r")
> 14 ; u = f->U ; (time,lat,lon)
> 15 ; printVarSummary (u)
> 16 ; v = f->V
> 17 ; printVarSummary (v)
> 18 u = wrf_user_getvar(f,"U10",0) ; 3D U at mass points
> 19 v = wrf_user_getvar(f,"V10",0) ; 3D V at mass points
> 20 printVarSummary (u)
> 21 printVarSummary (v)
> 22 ;*************************************************
> 23 ; calculate vorticity: Wrap version maintains meta data
> 24 ;*************************************************
> 25 vrt = uv2vrG_Wrap(u,v)
> 26
> 27 ;*************************************************
> 28 ; calculate rotational wind component
> 29 ; --
> 30 ; note: the calculation uses a procedure, so memory
> 31 ; must be preallocated.
> 32 ;*************************************************
> 33 ur = new ( dimsizes(u), typeof(u), u@_FillValue )
> 34 vr = new ( dimsizes(v), typeof(v), v@_FillValue )
> 35
> 36 vr2uvg(vrt, ur,vr)
> 37 ur_at_long_name = "Zonal Rotational Wind"
> 38 ur_at_units = u_at_units
> 39 vr_at_long_name = "Meridional Rotational Wind"
> 40 vr_at_units = v_at_units
> 41 copy_VarCoords(u, ur )
> 42 copy_VarCoords(u, vr )
> 43 ;*************************************************
> 44 ; plot results
> 45 ;*************************************************
> 46 wks = gsn_open_wks("x11","wind") ; open workstation
> 47
> 48 res = True
> 49
> 50 res_at_vcRefMagnitudeF = 5. ; make vectors larger
> 51 res_at_vcRefLengthF = 0.050 ; reference vector
> 52 res_at_vcGlyphStyle = "CurlyVector" ; turn on curly vectors
> 53 res_at_vcMinDistanceF = 0.022 ; thin the vectors
> 54 res_at_vcRefAnnoOrthogonalPosF = -1.0 ; move ref vector up
> 55 res_at_gsnLeftString = "Rotational Wind"
> 56 ; plot 1st time step
> 57 plot= gsn_csm_vector_map_ce(wks,ur(0,:,:),vr(0,:,:),res)
> 58
> 59 end
>
>
> Moti
> Professor, Department of Environment and Occupational Health
> College of Public Health
> University of South Florida
> 13201 Bruce B. Downs Blvd., MDC56
> Tampa, Fl 33612-3805
>
> Tel: (813) 974-9571
> Fax: (813) 974-4986
> Email: mmittal_at_health.usf.edu
> ________________________________________
> From: Dennis Shea [shea_at_ucar.edu]
> Sent: Friday, April 10, 2009 12:44 PM
> To: Mittal, Moti
> Cc: ncl-talk_at_ucar.edu
> Subject: Re: wind_2.ncl script
>
> The WRF model has u and v on different grids.
> The arrays are different sizes.
>
> http://www.ncl.ucar.edu/Document/Functions/wrf.shtml
>
> See the WRF WWW. It has a number of examples:
>
> http://www.mmm.ucar.edu/wrf/OnLineTutorial/Graphics/NCL/NCL_examples.htm
>
> The following places the winds on a common grid.
>
>
>
> u = wrf_user_getvar(a,"ua",it) ; 3D U at mass points
> v = wrf_user_getvar(a,"va",it) ; 3D V at mass points
>
>
> Generally, WRF related question should be sent to wrfhelp_at_ucar.edu
>
> Good luck
>
> Mittal, Moti wrote:
>> Hi Dennis,
>>
>> I used printVarSummary for u and v and had the following output.
>> It is showing [south_north | 49] x [west_east_stag | 50] for u
>> and [south_north_stag | 50] x [west_east | 49] for v.
>> My dimensions from wrfout header are as follows:
>>
>> 1 netcdf wrfout_d01_2007-01-31_12 {
>> 2 dimensions:
>> 3 Time = UNLIMITED ; // (6 currently)
>> 4 DateStrLen = 19 ;
>> 5 west_east = 49 ;
>> 6 south_north = 49 ;
>> 7 bottom_top = 27 ;
>> 8 bottom_top_stag = 28 ;
>> 9 soil_layers_stag = 4 ;
>> 10 west_east_stag = 50 ;
>> 11 south_north_stag = 50 ;
>> 12 emissions_zdim = 1 ;
>> 13 klevs_for_dust = 1 ;
>> 14 dust_errosion_dimension = 3 ;
>>
>> What am I doing wrong? I am using polar stereographic projection.
>> I am also attaching the script at the end of this message.
>>
>> Thank you for your help.
>> Moti
>>
>> [mmittal_at_localhost ~/NCL]$ !ncl
>> ncl wind_2.ncl
>> Copyright (C) 1995-2009 - All Rights Reserved
>> University Corporation for Atmospheric Research
>> NCAR Command Language Version 5.1.0
>> The use of this software is governed by a License Agreement.
>> See http://www.ncl.ucar.edu/ for more details.
>>
>>
>> Variable: u
>> Type: float
>> Total Size: 1587600 bytes
>> 396900 values
>> Number of Dimensions: 4
>> Dimensions and sizes: [Time | 6] x [bottom_top | 27] x [south_north | 49] x [west_east_stag | 50]
>> Coordinates:
>> Number Of Attributes: 6
>> FieldType : 104
>> MemoryOrder : XYZ
>> description : x-wind component
>> units : m s-1
>> stagger : X
>> coordinates : XLONG_U XLAT_U
>>
>>
>> Variable: v
>> Type: float
>> Total Size: 1587600 bytes
>> 396900 values
>> Number of Dimensions: 4
>> Dimensions and sizes: [Time | 6] x [bottom_top | 27] x [south_north_stag | 50] x [west_east | 49]
>> Coordinates:
>> Number Of Attributes: 6
>> FieldType : 104
>> MemoryOrder : XYZ
>> description : y-wind component
>> units : m s-1
>> stagger : Y
>> coordinates : XLONG_V XLAT_V
>> fatal:uv2vrF: The input arrays must have the same dimension sizes
>> fatal:Execute: Error occurred at or near line 2277 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl
>>
>> fatal:Execute: Error occurred at or near line 20 in file wind_2.ncl
>>
>> wind_2.ncl: script
>>
>> 1 ;*************************************************
>> 2 ; wind_2.ncl
>> 3 ;*************************************************
>> 4 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>> 5 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>> 6 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>> 7 ;*************************************************
>> 8 begin
>> 9 ;*************************************************
>> 10 ; open file and read in data: data are on a gaussian grid
>> 11 ;*************************************************
>> 12 f = addfile ("wrfout_d01_2007-01-31_12.nc", "r")
>> 13 u = f->U ; (time,lat,lon)
>> 14 printVarSummary (u)
>> 15 v = f->V
>> 16 printVarSummary (v)
>> 17 ;*************************************************
>> 18 ; calculate vorticity: Wrap version maintains meta data
>> 19 ;*************************************************
>> 20 vrt = uv2vrG_Wrap(u,v)
>> 21
>> 22 ;*************************************************
>> 23 ; calculate rotational wind component
>> 24 ; --
>> 25 ; note: the calculation uses a procedure, so memory
>> 26 ; must be preallocated.
>> 27 ;*************************************************
>> 28 ur = new ( dimsizes(u), typeof(u), u@_FillValue )
>> 29 vr = new ( dimsizes(v), typeof(v), v@_FillValue )
>> 30
>> 31 vr2uvg(vrt, ur,vr)
>> 32 ur_at_long_name = "Zonal Rotational Wind"
>> 33 ur_at_units = u_at_units
>> 34 vr_at_long_name = "Meridional Rotational Wind"
>> 35 vr_at_units = v_at_units
>> 36 copy_VarCoords(u, ur )
>> 37 copy_VarCoords(u, vr )
>> 38 ;*************************************************
>> 39 ; plot results
>> 40 ;*************************************************
>> 41 wks = gsn_open_wks("ps","wind") ; open workstation
>> 42
>> 43 res = True
>> 44
>> 45 res_at_vcRefMagnitudeF = 5. ; make vectors larger
>> 46 res_at_vcRefLengthF = 0.050 ; reference vector
>> 47 res_at_vcGlyphStyle = "CurlyVector" ; turn on curly vectors
>> 48 res_at_vcMinDistanceF = 0.022 ; thin the vectors
>> 49 res_at_vcRefAnnoOrthogonalPosF = -1.0 ; move ref vector up
>> 50 res_at_gsnLeftString = "Rotational Wind"
>> 51 ; plot 1st time step
>> 52 plot= gsn_csm_vector_map_ce(wks,ur(0,:,:),vr(0,:,:),res)
>> 53
>> 54 end
>>
>>
>> Professor, Department of Environment and Occupational Health
>> College of Public Health
>> University of South Florida
>> 13201 Bruce B. Downs Blvd., MDC56
>> Tampa, Fl 33612-3805
>>
>> Tel: (813) 974-9571
>> Fax: (813) 974-4986
>> Email: mmittal_at_health.usf.edu
>> ________________________________________
>> From: Dennis Shea [shea_at_ucar.edu]
>> Sent: Tuesday, April 07, 2009 5:59 PM
>> To: Mittal, Moti
>> Cc: ncl-talk_at_ucar.edu
>> Subject: Re: wind_2.ncl script
>>
>> Something tells me that you are not running
>> wind_2.ncl. It uses "uv2vrG_Wrap" and "vr2uvg"
>>
>> So, you have changed something.
>>
>> The eroor message say that you are using two
>> different sized array as input.
>>
>> Please do a 'printVarSummary' on each variable.
>>
>> Good luck
>>
>>
>>
>>
>>
>> Mittal, Moti wrote:
>>> I was trying to run the wind script. I am getting the following error.
>>> I will appreciate the suggestion to circumvent.
>>>
>>> Thank you.
>>> Moti
>>>
>>> Out put message:
>>>
>>> [mmittal_at_localhost ~/NCL]$ ncl wind_2.ncl
>>> Copyright (C) 1995-2009 - All Rights Reserved
>>> University Corporation for Atmospheric Research
>>> NCAR Command Language Version 5.1.0
>>> The use of this software is governed by a License Agreement.
>>> See http://www.ncl.ucar.edu/ for more details.
>>> fatal:uv2vrF: The input arrays must have the same dimension sizes
>>> fatal:Execute: Error occurred at or near line 2277 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl
>>>
>>> fatal:Execute: Error occurred at or near line 18 in file wind_2.ncl
>>>
>>>
>>> Professor, Department of Environment and Occupational Health
>>> College of Public Health
>>> University of South Florida
>>> 13201 Bruce B. Downs Blvd., MDC56
>>> Tampa, Fl 33612-3805
>>>
>>> Tel: (813) 974-9571
>>> Fax: (813) 974-4986
>>> Email: mmittal_at_health.usf.edu
>>> _______________________________________________
>>> 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
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Apr 10 2009 - 14:44:34 MDT

This archive was generated by hypermail 2.2.0 : Sun Apr 12 2009 - 14:28:35 MDT