Re: error in coordinate variable

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Jul 09 2012 - 09:19:16 MDT

Dear Marzie,

WRF data doesn't have concept of latitude/longitude coordinate arrays, so you can't use the "{" and "}" syntax to do coordinate subscripting.

What you can use is wrf_user_ll_to_ij, to give it a lat/lon value, and it will return the i,j location that is closest to this point.

Note that what's returned is the i,j, index into a Fortran array, hence the index values start at 1, not 0. To use
them in NCL, you need to subtract 1.

Assuming that data(i+1) is your longitude value, and data(i) is latitude, your code might look something like this:

do i = 0,19,2
  loc = wrf_user_ll_to_ij(a, data(i+1),data(i), 0)
  output(i/2) = dusttotal(loc(1)-1,loc(0)-1)
end do

Note that you don't have to have the whole thing in a loop. You could also do this:

; output = new((/10/),float) ; Don't need this, remove or comment out.

locs = wrf_user_ll_to_ij(a, data(1::2),data(0::2), 0)
output = dusttotal(locs(1,:)-1,locs(0,:)-1)
output!0 = "Dust"

--Mary

On Jul 7, 2012, at 2:02 PM, marziyeh dadizadeh wrote:

> Hi all,
>
> I have a WRF output, and I want to craet an ascii output of it, acording to a list of lat&lon.
> when run my script, get this error:
>
> fatal:Dimension (west_east) of (dusttotal) does not have an associated coordinate variable
> fatal:Execute: Error occurred at or near line 35 in file pm10.ncl
>
> I could not resolve this error, can anyone help me please?!
>
> thanks in advance
> Marzie
>
>
>
>
> here 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/wrf/WRFUserARW.ncl"
>
>
>
> begin
>
> a = addfile("wrfout_d01_2010-05-18_00_00_00.nc","r")
>
> times = wrf_user_list_times(a) ; get times in the file
> ntimes = dimsizes(times)
> do it = 0,ntimes-1,1 ; TIME LOOP
>
> DUST_1 = wrf_user_getvar(a,"DUST_1",it)
> DUST_2 = wrf_user_getvar(a,"DUST_2",it)
> DUST_3 = wrf_user_getvar(a,"DUST_3",it)
> DUST_4 = wrf_user_getvar(a,"DUST_4",it)
> DUST_5 = wrf_user_getvar(a,"DUST_5",it)
> dusttot=DUST_1
> dusttot=((DUST_1)+(DUST_2)+(DUST_3)+(DUST_4)+(DUST_5))
> dusttotal=dusttot(0,:,:)
> printVarSummary(DUST_1)
> printVarSummary(dusttotal)
> data= asciiread("lat&lon-M.csv",(/20/),"float")
>
> output = new((/10/),float)
> output!0 = "Dust"
>
>
> do i = 0,19,2
>
> output(i/2) = dusttotal({data(i)},{data(i+1)})
>
> end do
>
>
> printVarSummary(output)
> asciiwrite("dust.txt",output)
>
> end do
>
> end
>
> //******************************************
> and here is summary of variables:
>
> ----------------------------------------------
> 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) 2010-05-18_00:00:00
>
> ------------------------------------------------------
> Variable: DUST_1
> Type: float
> Total Size: 1152000 bytes
> 288000 values
> Number of Dimensions: 3
> Dimensions and sizes: [bottom_top | 40] x [south_north | 60] x [west_east | 120]
> Coordinates:
> Number Of Attributes: 6
> coordinates : XLONG XLAT
> stagger :
> units : ug/kg-dryair
> description : dust size bin 1: 0.5um effective radius
> MemoryOrder : XYZ
> FieldType : 104
>
> -----------------------------------------------------
> Variable: dusttotal
> Type: float
> Total Size: 28800 bytes
> 7200 values
> Number of Dimensions: 2
> Dimensions and sizes: [south_north | 60] x [west_east | 120]
> Coordinates:
> Number Of Attributes: 6
> coordinates : XLONG XLAT
> stagger :
> units : ug/kg-dryair
> description : dust size bin 1: 0.5um effective radius
> MemoryOrder : XYZ
> FieldType : 104
>
>
>
>
> _______________________________________________
> 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 Mon Jul 9 09:19:30 2012

This archive was generated by hypermail 2.1.8 : Mon Jul 09 2012 - 10:45:32 MDT