Re: NCL help for extraction of some particluar station datas from WRF (precipitation)

From: A.R Ragi <ar.ragi_at_nyahnyahspammersnyahnyah>
Date: Mon, 12 Oct 2009 12:34:50 +0530

Dear Mary,
My problem for extracting grid values is solved.
The Second one ( ascciwrite( "griddata.txt",precip) i cleared just after i
send you the mail itself.
But the array declaration was the problem. I was facing problem with array
manipulation in NCL.
Now its also solved. I got the desired output.

Thanks a ton Madame.

Am attaching the corrected code.

--
A.R. @ +919960462099
Sent from Maharashtra, India
On Mon, Oct 12, 2009 at 12:18, Mary Haley <haley_at_ucar.edu> wrote:
> I think  the problem is that you've set "precip" to an
> integer, and then you tried to assign floats to it.
>
> You need to do this:
>
>        precip =0.0
>
> However you are then trying to treate "precip" as an array,
> but as far as I can tell, you've made it a scalar.
> I think you will need to do this:
>
>      precip = new(9,float)
>      precip = 0.0
>
> Finally, you are doing this:
>
>                asciiwrite("griddata.txt",precip(i))
>
> What's going to happen is that it's going to keep writing one value to
> the same file, overwriting the original value.
>
> You want to move "asciiwrite" outside the do loop and call it with:
>
>   asciiwrite("griddata.txt",precip)
>
> --Mary
>
>
> On Mon, 12 Oct 2009, A.R Ragi wrote:
>
>  *Dear Mary,**
>> *
>> *Thanks.*
>>
>> *Still some probs are there.*
>> *
>> *
>> *Now i changed my code like this:*
>>
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>> begin
>>
>> wrf_out = addfile("./wrfout_d01_2000-01-24_12:00:00.nc","r")
>>
>>  rain_con = wrf_user_getvar(wrf_out,"RAINC",-1)
>>  rain_exp = wrf_user_getvar(wrf_out,"RAINNC",-1)
>>  rainfall_tot = rain_con + rain_exp
>>  rainfall_tot_at_description = "Total Precipitation"
>>
>> printVarSummary(rainfall_tot)
>>
>>       grid = asciiread("data.txt",(/9,3/),"integer")
>>       print(grid)
>>       printVarSummary(grid)
>>
>>       ntime = grid(:,0)
>>       nlat = grid(:,1)
>>       mlon = grid(:,2)
>>
>>       print(ntime)
>>       print(nlat)
>>       print(mlon)
>>
>>       precip =0
>>
>>       do i = 0, 8
>>
>>               precip(i) = rainfall_tot(ntime(i),nlat(i),mlon(i))
>>               asciiwrite("griddata.txt",precip(i))
>>       end do
>>
>> end
>>
>>
>>
>> *The output am getting with the error showing  is:*
>>
>>
>> Variable: rainfall_tot
>> Type: float
>> Total Size: 87600 bytes
>>           21900 values
>> Number of Dimensions: 3
>> Dimensions and sizes:   [5] x [60] x [73]
>> Coordinates:
>> Number Of Attributes: 1
>>  description : Total Precipitation
>>
>>
>> Variable: grid
>> Type: integer
>> Total Size: 108 bytes
>>           27 values
>> Number of Dimensions: 2
>> Dimensions and sizes:   [9] x [3]
>> Coordinates:
>> Number Of Attributes: 1
>>  _FillValue :  -999
>> (0,0)   1
>> (0,1)   22
>> (0,2)   33
>> (1,0)   1
>> (1,1)   23
>> (1,2)   34
>> (2,0)   2
>> (2,1)   12
>> (2,2)   45
>> (3,0)   2
>> (3,1)   15
>> (3,2)   56
>> (4,0)   2
>> (4,1)   15
>> (4,2)   67
>> (5,0)   2
>> (5,1)   15
>> (5,2)   56
>> (6,0)   3
>> (6,1)   23
>> (6,2)   48
>> (7,0)   3
>> (7,1)   22
>> (7,2)   56
>> (8,0)   4
>> (8,1)   13
>> (8,2)   21
>>
>>
>> Variable: grid
>> Type: integer
>> Total Size: 108 bytes
>>           27 values
>> Number of Dimensions: 2
>> Dimensions and sizes:   [9] x [3]
>> Coordinates:
>> Number Of Attributes: 1
>>  _FillValue :  -999
>>
>>
>> Variable: ntime
>> Type: integer
>> Total Size: 36 bytes
>>           9 values
>> Number of Dimensions: 1
>> Dimensions and sizes:   [9]
>> Coordinates:
>> Number Of Attributes: 1
>>  _FillValue :  -999
>> (0)     1
>> (1)     1
>> (2)     2
>> (3)     2
>> (4)     2
>> (5)     2
>> (6)     3
>> (7)     3
>> (8)     4
>>
>>
>> Variable: nlat
>> Type: integer
>> Total Size: 36 bytes
>>           9 values
>> Number of Dimensions: 1
>> Dimensions and sizes:   [9]
>> Coordinates:
>> Number Of Attributes: 1
>>  _FillValue :  -999
>> (0)     22
>> (1)     23
>> (2)     12
>> (3)     15
>> (4)     15
>> (5)     15
>> (6)     23
>> (7)     22
>> (8)     13
>>
>>
>> Variable: mlon
>> Type: integer
>> Total Size: 36 bytes
>>           9 values
>> Number of Dimensions: 1
>> Dimensions and sizes:   [9]
>> Coordinates:
>> Number Of Attributes: 1
>>  _FillValue :  -999
>> (0)     33
>> (1)     34
>> (2)     45
>> (3)     56
>> (4)     67
>> (5)     56
>> (6)     48
>> (7)     56
>> (8)     21
>> fatal:Assignment type mismatch, right hand side can't be coerced to type
>> of
>> left hand side
>> fatal:Execute: Error occurred at or near line 32 in file newextract.ncl
>>
>>
>>
>> Thanks again
>> --
>> A.R. @ +919960462099
>>
>>
>> Sent from Maharashtra, India
>>
>> On Fri, Oct 9, 2009 at 18:55, Mary Haley <haley_at_ucar.edu> wrote:
>>
>>
>>> On Oct 9, 2009, at 4:15 AM, A.R Ragi wrote:
>>>
>>> *Dear Mary,*
>>> *
>>> *
>>> *I have one more problem to be solved.*
>>> *
>>> *
>>> *That is for extraxting station data from the given output.*
>>> *
>>> *
>>> *I wrote the script for one grid.*
>>> *
>>> *
>>>
>>> precip = rainfall_tot(1,27,33)
>>>
>>>
>>> *At that time I was geeting the output.*
>>> *Now i would like to found data for more than 10 station grids (or for
>>> 100
>>> grids).*
>>> *
>>> *
>>> *I saved these values of time, lat, lon in a file named "data.txt"
>>>  10*3.*
>>> *
>>> *
>>> *Now i tried to read the data using ascii. *
>>> *Using:*
>>>
>>>  grid = asciiread("data.txt",(/10,3/),"integer")
>>>
>>>
>>> *Am getting thw whole data in the form:*
>>>
>>> (0,0) 1
>>> (0,1) 27
>>> (0,2) 33
>>> .
>>> .
>>> .
>>> .
>>> (9,2) 56
>>>
>>> *Depends on the value i saved in the "data.txt" file.*
>>> *
>>> *
>>> *How can i take (0,0),(0,1),(0,2) values for first time and so on??*
>>> *
>>> *
>>> *Will you please help me to do so???*
>>>
>>>
>>> Do something like this:
>>>
>>>
>>>  time = grid(0,:)
>>>
>>> The other two dimensions are similar, if you need that data too:
>>>
>>>  x1 = grid(1,:)
>>>  x2 = grid(2,:)
>>>
>>> Of course, you'll probably want to use something more appropriate than
>>> "x1"
>>> and "x2".
>>>
>>> --Mary
>>>
>>>
>>> *
>>> *
>>> *Thanks in advance.*
>>>  *
>>> *
>>> *
>>> *
>>> *The code i attempted is:*
>>>
>>>
>>>
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>>> begin
>>>
>>> wrf_out = addfile("./wrfout_d01_2000-01-24_12:00:00.nc","r")
>>>
>>>  rain_con = wrf_user_getvar(wrf_out,"RAINC",-1)
>>>  rain_exp = wrf_user_getvar(wrf_out,"RAINNC",-1)
>>>  rainfall_tot = rain_con + rain_exp
>>>  rainfall_tot_at_description = "Total Precipitation"
>>>
>>> printVarSummary(rainfall_tot)
>>>
>>>
>>> ;gridvalues = (/(/1,22,34/),(/1,24,33/),(/3,12,56/)/)
>>> ;print(gridvalues)
>>>
>>>
>>>        grid = asciiread("data.txt",(/9,3/),"integer")
>>>        print(grid)
>>>
>>>        precip = 0
>>>
>>>        ;do i = 1, 3
>>>
>>>                precip = rainfall_tot(grid(0,0))
>>>
>>>
>>>                asciiwrite("griddata.txt",precip)
>>>
>>>        ;end do
>>> end
>>> --
>>> A.R. @ +919960462099
>>>
>>>
>>> Sent from Maharashtra, India
>>>
>>>
>>>
>>>
>>


_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Mon Oct 12 2009 - 01:04:50 MDT

This archive was generated by hypermail 2.2.0 : Mon Oct 12 2009 - 03:45:17 MDT