[ncl-talk] Get hourly values from cumulative 24hr sum

Guido Cioni guidocioni at gmail.com
Tue May 30 08:58:59 MDT 2017


Orestis, 
look carefully at your code. 
You have written 

 ACUM_HOURLY= ACUM(nt+1,:,:)- ACUM (nt,:,:)

Since you haven't defined ACUM_HOURLY before NCL will try to guess the type and dimension based on the right-hand side of the assignment. Thus, ACUM_HOURLY will have dimensions 32x31 (note the lack of attributes given that you are doing a mathematical operation without retaining metadata) and type float. 

At every loop iteration you are basically defining and overwriting ACUM_HOURLY again, thus the lack of a time dimension. You can define the variable in the same way as ACUM, that is 

ACUM_HOURLY=new(dimsizes(ACUM), typeof(ACUM))

and then perform the loop as 

do nt =0,dimsizes(time)-1 ; the 1 is not important
           ACUM_HOURLY(nt, :, :)= ACUM(nt+1, :, :)- ACUM (nt,: , :)        
end do

Good luck 

> On 30 May 2017, at 16:51, Orestis <ospeyer at meteo.noa.gr> wrote:
> 
>  
> Hi everyone,
>  
> I have a variable ACUM that is accumulated every hour for a total of 24 hours (like accumulated rainfall to give an example).
> I would like to get the variable's value for each hour.
>  
> Variable: ACUM
> Type: float
> Total Size: 95232 bytes
>             23808 values
> Number of Dimensions: 3
> Dimensions and sizes:   [time | 24] x [rlat | 32] x [rlon | 31]
>  
> I want to use something like this:
> do nt =0,22,1
>            ACUM_HOURLY= ACUM(nt+1,:,:)- ACUM (nt,:,:)               ;For example hour 5th hourly value  is hour 5th value minus hour 4th value
> end do
>  
> but in this way I do not get an array for ACUM_HOURLY but only one time dimension:
>  
> Variable: ACUM_HOURLY
> Type: float
> Total Size: 3968 bytes
>             992 values
> Number of Dimensions: 2
> Dimensions and sizes:   [32] x [31]
>  
> Do you have any suggestions?
>  
>  
> Thank you,
> Orestis
>  
>  
>  
>  
>  
> Orestis Speyer, MSc
> 
> Research Fellow, National Observatory of Athens
> Institute for Environmental Research and Sustainable Development
>  
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>

Guido Cioni
http://guidocioni.altervista <http://guidocioni.altervista/>.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170530/1bf1cf47/attachment.html 


More information about the ncl-talk mailing list