[ncl-talk] unregulated daily data plotting
Adam Phillips
asphilli at ucar.edu
Tue Apr 7 15:26:15 MDT 2015
Hi Hesham,
For simple non-weighted running averages you have two choices when it comes
to the class of functions to use: the runave* suite of functions and the
dim_avg suite of functions. Missing values are allowed and ignored in the
dim_avg* functions, while missing data results in missing averages in the
runave suite of functions. I would suggest you use dim_avg_n and run the
data through a do loop.
https://www.ncl.ucar.edu/Document/Functions/Built-in/dim_avg.shtml
For example, you can do something like this:
int = 7 ; 7 day average
data_7day = new(dimsizes(data),typeof(data)
do gg = 3,dimsizes(data)-4
data_7day(gg) = (/ dim_avg(data(gg-3:gg+3)) /)
end do
data_7day would hold 7 day running averages at each timestep, and would
compute it if there is 1 day out of 7 that has data. The above can be
generalized without the do loop as well using syntax from the script I sent
you:
stime = 19991001 ; plot start time in YYYYMMDD
etime = 19991031 ; plot end time in YYYYMMDD
si = ind(time.eq.stime)
ei = ind(time.eq.etime)
data_avg = dim_avg_Wrap(data(si:ei))
data_avg would hold the October 1999 average.
Finally, if you would like to interpolate to fill in the missing data, I
would recommend using the linmsg function:
https://www.ncl.ucar.edu/Document/Functions/Built-in/linmsg.shtml
Hope all that helps. If not, please respond to the ncl-talk email list and
not to me personally.
Adam
On Mon, Apr 6, 2015 at 1:00 PM, Hesham Afify <algocomp at gmail.com> wrote:
> Hi Adam
> Thanks for your kind attention and reply, I used the script and it's
> really helpful and hits the point.
> The aspect facing me now is that the missing data not temporally evenly
> distributed, so I'm wondering if NCL has some function that could make
> weekly or monthly average with minimal error, on other words, Is there a
> way to relax missing values in data to some ideal function (or
> climatological values)
>
> thanks in advance
>
> Hesham
>
> On Fri, Mar 27, 2015 at 3:28 PM, Adam Phillips <asphilli at ucar.edu> wrote:
>
>> Hi Hesham,
>> Due to the fact that you are reading in an ascii file, are working on
>> daily data, and wish to plot customized time ranges, this is a case where
>> conceptually what you ask for sounds simple but in reality it is not.
>>
>> I have come up with an example code that (somewhat) does what you want.
>> You will have to modify the attached script to suit your own needs. I
>> cannot spend any more time on this. You will also have to take a close look
>> at the coding to verify that the data is being read in and used correctly.
>>
>> I used a number of functions to parse and prepare the ascii data for
>> plotting: str_squeeze, str_split, str_split_csv, tofloat, toint and
>> sprinti. I also used cd_inv_calendar to prepare a time array that could be
>> used with the time_axis_labels procedure so that you would get nicer tick
>> mark labels. Note that you will likely need to play with time_axis_labels
>> somewhat to get the tick mark labels where you want them:
>>
>>
>> http://www.ncl.ucar.edu/Document/Functions/User_contributed/time_axis_labels.shtml
>>
>> Finally, note that you can set the range of times to be plotted by
>> setting stime/etime. You can plot any range of times from a few days to a
>> few months.
>>
>> I have attached the code and an example graphic here. If you have any
>> further questions please respond to the ncl-talk email list and not to me
>> personally. That way others can see the dialog and can assist.
>> Good luck,
>> Adam
>>
>> On Tue, Mar 24, 2015 at 8:45 AM, Hesham Afify <algocomp at gmail.com> wrote:
>>
>>> Hi All
>>> I have some observational daily data for a couple of years, this data
>>> have many changes in regularity by the mean it toke on daily, one per three
>>> days, and one per six days patterns, have some missed periods.
>>> the point here that I want to plot this data and my inquiry about that
>>> is how to plot this data in daily, weekly, and monthly basis.
>>> a sample of this data is attached
>>>
>>> best regards
>>> Hesham
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>>
>> --
>> Adam Phillips
>> Associate Scientist, Climate and Global Dynamics Laboratory, NCAR
>> www.cgd.ucar.edu/staff/asphilli/ 303-497-1726
>>
>> <http://www.cgd.ucar.edu/staff/asphilli>
>>
>
>
>
> --
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
--
Adam Phillips
Associate Scientist, Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/ 303-497-1726
<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150407/4c1600b0/attachment.html
More information about the ncl-talk
mailing list