[ncl-talk] converting grib averages into hourly values

Micah Sklut micahs2005 at gmail.com
Sat Apr 4 08:42:21 MDT 2020


Thanks Dennis.

I was able to patch together the GFS data from hours 0 to 384 (including an
additional 6 hours from previous day run), and put cloud percentages into
hourly values. For anyone that also might need this, here's my approach:

cloud = new ( (/nHours, nLat, nLon /) , "float" )
>
> cloud(0,:,:) = f[1]->TCDC_P8_L10_GLL0_avg(:,{latNGFS:latSGFS},{lonWGFS:lonEGFS})
> cloud(1:5,:,:) = f[1:5]->TCDC_P8_L10_GLL0_avg(:,{latNGFS:latSGFS},{lonWGFS:lonEGFS})
> cloud(6,:,:) = f[7]->TCDC_P8_L10_GLL0_avg(:,{latNGFS:latSGFS},{lonWGFS:lonEGFS})
> cloud(7:12,:,:) = f[7:12]->TCDC_P8_L10_GLL0_avg(:,{latNGFS:latSGFS},{lonWGFS:lonEGFS})
> cloud(13:121:6,:,:) = f[13:121:6]->TCDC_P8_L10_GLL0_avg1h(:,{latNGFS:latSGFS},{lonWGFS:lonEGFS})
> cloud(14:122:6,:,:) = f[14:122:6]->TCDC_P8_L10_GLL0_avg2h(:,{latNGFS:latSGFS},{lonWGFS:lonEGFS})
> cloud(15:123:6,:,:) = f[15:123:6]->TCDC_P8_L10_GLL0_avg3h(:,{latNGFS:latSGFS},{lonWGFS:lonEGFS})
> cloud(16:124:6,:,:) = f[16:124:6]->TCDC_P8_L10_GLL0_avg4h(:,{latNGFS:latSGFS},{lonWGFS:lonEGFS})
> cloud(17:125:6,:,:) = f[17:125:6]->TCDC_P8_L10_GLL0_avg5h(:,{latNGFS:latSGFS},{lonWGFS:lonEGFS})
> cloud(18:126:6,:,:) = f[18:126:6]->TCDC_P8_L10_GLL0_avg6h(:,{latNGFS:latSGFS},{lonWGFS:lonEGFS})
> cloud(127:213:2,:,:) = f[127:213:2]->TCDC_P8_L10_GLL0_avg3h(:,{latNGFS:latSGFS},{lonWGFS:lonEGFS})
> cloud(128:214:2,:,:) = f[128:214:2]->TCDC_P8_L10_GLL0_avg6h(:,{latNGFS:latSGFS},{lonWGFS:lonEGFS})
>
> do i=0,nHours-1
>     if (i .eq. 0 .or. i .eq. 6) then
>         cloud(i,:,:) = cloud(i,:,:)
>     elseif (i .lt. 126) then
>         if ( i % 6 .eq. 1) then
>             cloud(i,:,:) = cloud(i,:,:)
>         elseif (i % 6 .eq. 2) then
>             c2 = 2 * cloud(i,:,:)
>             cloud(i,:,:) = c2 - cloud(i-1,:,:)
>         elseif (i % 6 .eq. 3) then
>             c3 = 3 * cloud(i,:,:)
>             cloud(i,:,:) = c3 - c2
>         elseif (i % 6 .eq. 4) then
>             c4 = 4 * cloud(i,:,:)
>             cloud(i,:,:) = c4 - c3
>         elseif (i % 6 .eq. 5) then
>             c5 = 5 * cloud(i,:,:)
>             cloud(i,:,:) = c5 - c4
>         elseif (i % 6 .eq. 0) then
>             c6 = 6 * cloud(i,:,:)
>             cloud(i,:,:) = c6 - c5
>         end if
>     else
>         if ( i % 6 .eq. 3) then
>             cloud(i,:,:) = cloud(i,:,:)
>         elseif ( i % 6 .eq. 0) then
>             cloud(i,:,:) = 2 * cloud(i,:,:) - cloud(i-1,:,:)
>         end if
>     end if
> end do
>
>

On Fri, Apr 3, 2020 at 2:40 PM Dennis Shea <shea at ucar.edu> wrote:

> I am sure there is no 'handy-dandy' function to do this specific task.
> I ould think it would 'easy' to create a function to do this
>
> undef("gfs_micah")
> function gfs_micha(x)
> begin
>    ...
>    return(xhour)
> end
> ;--------------------
> ;    MAIN
> ;--------------------
>    dir_gfs = "./"
>    pth_gfs  =  *systemfunc*("ls "+dir_gfs+"/gfs*")
>    n_gfs   = *dimsizes(*pth_gfs)
>    print("n_gfs="+n_gfs)
>
>   f_gfs = *addfiles*(pth_gfs, "r")
>   cld = f_gfs[:]->...
>   *printVarSummary*(cld)
>
>   CLD = *gfs_micah*(cld)
>   printVarSummary(CLD)
>
>
> On Fri, Apr 3, 2020 at 11:45 AM Micah Sklut via ncl-talk <
> ncl-talk at ucar.edu> wrote:
>
>> Hi,
>>
>> I am looking at Cloud Cover values for GFS data. I download the GFS files
>> for each individual hour, and for each hour the cloud cover represents a
>> fraction of a 6 hour period, like this:
>>
>> hour 1: 0-1 hour average
>> hour 2: 0-2 hour average
>> hour 3: 0-3 hour average
>> hour 4: 0-4 hour average
>> hour 5: 0-5 hour average
>> hour 6: 0-6 hour average
>>
>> I would like to convert this to:
>>
>> hour 1: 0-1 hour average
>> hour 2: 1-2 hour average
>> hour 3: 2-3 hour average
>> hour 4: 3-4 hour average
>> hour 5: 4-5 hour average
>> hour 6: 5-6 hour average
>>
>> I understand it's just some simple arithmetic to get the averages of the
>> values for each hour, but I was wondering if there are any handy NCL
>> functions that can help me efficiently go through the global dataset for
>> hours 0 - 384.
>>
>> I did notice there was a wgrib2 function to handle this problem but was
>> hoping to handle this through NCL, where all my other files/variable
>> modifications are happening.
>>
>> Thanks,
>>
>> --
>> Micah Sklut
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>

-- 
Micah Sklut
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200404/79a4de79/attachment.html>


More information about the ncl-talk mailing list