[ncl-talk] Fw: script for daily average

Dennis Shea shea at ucar.edu
Thu Feb 1 12:16:17 MST 2018


You had the wrong syntax.

@ is for attributes
&  is for coordinates

---
So I try to do the following to correct this error

   tc2 at Time=wrf_times_c(a->Times,0)
and repeat the command but I still receive the same error as above.
---

Please try:
   tc2&Time=wrf_times_c(a->Times,0)

On Thu, Feb 1, 2018 at 9:43 AM, Mary Haley <haley at ucar.edu> wrote:

> The calculate_daily_values documentation states that the variable must
> have a "time" coordinate attached to the leftmost dimension, with units
> recognized by cd_calendar, i.e., units like "hours since 1-1-1 00:00:0.0"
>
> You are working with WRF data, which doesn't have these kind of units
> ​for time by default. You may need to use "wrf_times_c" to first convert
> time to have the correct units, and then attach this new time array to your
> variable before you call calculate_daily_values:
>
>      Time_0
> ​  ​
> = wrf_times_c(
>> a->Times, 0 )
> ​        ​
> ;
> ​ ​
> opt=0 ==>
> ​ ​
> "hours since" initial time on file
>> tc2
> ​&Time = Time_0​
>>
> ​                        ​
> ; a
> ​ttach Time_0 to the "Time" dimension of tc2​
>
>
> ​     ​
> tc2DayAvg
> ​ ​
> = calculate_daily_values(tc2, "avg", nDim, False)
>
> Please read the documentation on wrf_times_c to see what other options are
> available, as the above may not be appropriate for your data.​
>
> http://www.ncl.ucar.edu/Document/Functions/WRF_
> contributed/wrf_times_c.shtml
>
> --Mary
>
>>
> On Wed, Jan 31, 2018 at 6:31 PM, Muhammad Omer Mughal via ncl-talk <
> ncl-talk at ucar.edu> wrote:
>
>> Hi
>>
>>
>> I tried to use the suggestion provided by Dennis below and it shows the
>> error.I am using NCL version 6.4.0. I am repeating the steps here for
>> convenience.
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
>>
>> a=addfile("wrfout_d05_2016-04-01_00:00:00","r")
>>
>>  tc2= wrf_user_getvar(a,"T2",-1)
>>
>> nDim    = 0
>>
>> tc2DayAvg= calculate_daily_values(tc2, "avg", nDim, False)
>>
>>
>> At this stage I get the following error
>>
>> fatal:No coordinate variable exists for dimension (Time) in variable (x)
>> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 18125
>> in file /usr/local/ncl-6.4.0/lib/ncarg/nclscripts/csm/contributed.ncl
>>
>> So I try to do the following to correct this error
>>
>> tc2 at Time=wrf_times_c(a->Times,0)
>>
>> and repeat the command but I still receive the same error as above.
>>
>>
>> I would appreciate the help depending upon your convenience.
>>
>> Muhammad Omer Mughal
>> MSc BSc Mechanical Engineering
>> PhD  Research Scholar
>> Remote Sensing and Satellite Research Group
>> Department of Imaging and Applied Physics
>> Curtin University
>>
>> Curtin University
>> Tel | +61 8 9266 7962
>> Fax | +61 8 9266 2377
>> Mobile | 0470 237 525
>>
>> Email | m.mughal1 at postgrad.curtin.edu.au <m.lynch at curtin.edu.au>
>> Web | http://curtin.edu.au
>>
>> Curtin University is a trademark of Curtin University of Technology.
>> CRICOS Provider Code 00301J (WA), 02637B (NSW)
>>
>>
>> ------------------------------
>> *From:* Dennis Shea <shea at ucar.edu>
>> *Sent:* Thursday, 1 February 2018 5:51:50 AM
>> *To:* Muhammad Omer Mughal
>> *Cc:* ncl-talk at ucar.edu
>> *Subject:* Re: [ncl-talk] Fw: script for daily average
>>
>> I am not sure what you were doing but *read the following documentation":
>>
>> https://www.ncl.ucar.edu/Document/Functions/Contributed/
>> calculate_daily_values.shtml
>> requires 6.4.0
>>
>> ========
>>   nDim    = 0
>>   tc2DayAvg= calculate_daily_values(tc2, "avg", nDim, False)
>>   tc2DayAvg at description = "Daily Mean: " + tc2 at description
>>
>>   printVarSummary(tc2DayAvg)
>>   printMinMax(tc2DayAvg,0)
>>   print("-----")
>>
>> On Wed, Jan 31, 2018 at 2:24 PM, Muhammad Omer Mughal via ncl-talk <
>> ncl-talk at ucar.edu> wrote:
>>
>>
>>
>>
>>>> Muhammad Omer Mughal
>> MSc BSc Mechanical Engineering
>> PhD  Research Scholar
>> Remote Sensing and Satellite Research Group
>> Department of Imaging and Applied Physics
>> Curtin University
>>
>> Curtin University
>> Tel | +61 8 9266 7962 <+61%208%209266%207962>
>> Fax | +61 8 9266 2377 <+61%208%209266%202377>
>> Mobile | 0470 237 525
>>
>> Email | m.mughal1 at postgrad.curtin.edu.au
>> Web | http://curtin.edu.au
>>
>> ​ Curtin University is a trademark of Curtin University of Technology.
>> CRICOS Provider Code 00301J (WA), 02637B (NSW)
>>
>>>> ------------------------------
>> *From:* Muhammad Omer Mughal
>> *Sent:* Wednesday, 31 January 2018 12:17:57 PM
>> *To:* ncl-talk at ucar.edu
>> *Subject:* script for daily average
>>
>>
>> Hi
>>
>>
>> I wrote the following script to calculate the daily averages
>>
>>
>> a=addfile("./wrfout_d05_2016-04-01_00:00:00","r")
>> tc2= wrf_user_getvar(a,"T2",-1)
>> tc2_dims=dimsizes(tc2)
>> ntim=tc2_dims(0)
>> nlat=tc2_dims(1)
>> nlon=tc2_dims(2)
>>
>> ndays=ntim/24
>>
>> tc2D=reshape(tc2,(/ndays,nlat,nlon/))
>> copy_VarAtts(tc2,tc2D)
>> tc2_hr_avg=dim_avg_n_Wrap(tc2D,0)
>>
>> printVarSummary(tc2_hr)
>>
>> but I am seeing the following error
>>
>>
>> input dimension sizes cannot conform to dimensions of input array
>>
>> The Var summaries are as follows
>> Variable: tc2
>> Type: float
>> Total Size: 75526920 bytes
>>             18881730 values
>> Number of Dimensions: 3
>> Dimensions and sizes:    [Time | 697] x [south_north | 129] x [west_east
>> | 210]
>> Coordinates:
>> Number Of Attributes: 6
>>   coordinates :    XLONG XLAT XTIME
>>   stagger :
>>   units :    K
>>   description :    TEMP at 2 M
>>   MemoryOrder :    XY
>>   FieldType :    104
>>
>> Variable: nlat
>> Type: integer
>> Total Size: 4 bytes
>>             1 values
>> Number of Dimensions: 1
>> Dimensions and sizes:    [1]
>> Coordinates:
>> (0)    129
>>
>>
>>
>>
>>
>>
>>
>> Muhammad Omer Mughal
>> MSc BSc Mechanical Engineering
>> PhD  Research Scholar
>> Remote Sensing and Satellite Research Group
>> Department of Imaging and Applied Physics
>> Curtin University
>>
>> Curtin University
>> Tel | +61 8 9266 7962
>> Fax | +61 8 9266 2377
>> Mobile | 0470 237 525
>>
>> Email | m.mughal1 at postgrad.curtin.edu.au <m.lynch at curtin.edu.au>
>> Web | http://curtin.edu.au
>>
>> Curtin University is a trademark of Curtin University of Technology.
>> CRICOS Provider Code 00301J (WA), 02637B (NSW)
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180201/8a156aed/attachment.html>


More information about the ncl-talk mailing list