[ncl-talk] Removing annual cycle and nth harmonics from one dimensional data

Lyndz olagueralyndonmark429 at gmail.com
Sat Aug 7 01:52:21 MDT 2021


Dear Sir Dennis, NCL-Experts,

Thank you so much for the fast response.

I tried your second suggestion but I am not sure how to remove the cycle (3
harmonics)


I am attaching my sample data here:


The code is as follows:



filename = "test_data.csv"
lines    = asciiread(filename,-1,"string")
data     = lines(1:)
rain    = tofloat(str_get_field(data,5,","))
yyyyddd    = toint(str_get_field(data,4,","))

prc1d_ClmDay    = *clmDayT*(rain, yyyyddd)
printVarSummary(prc1d_ClmDay )

;remove annual mean
prc1d_AnomDay =* calcDayAnomT*(rain, yyyyddd, prc1d_ClmDay)
printVarSummary(prc1d_AnomDay)

;Remove seasonal cycle
prc1d_SmClDay = smthClmDayT(prc1d_AnomDay, yyyyddd,3)
prc1d_AnomDaySm = *calcDayAnomT*(prc1d_AnomDay , yyyyddd,prc1d_SmClDay)


The last part, is that the correct approach for removing the seasonal cycle?

I will do spectral analysis on this time series. The annual cycle, linear
trend (I think can be activated in the specx_anal), and seasonal cycle
should be removed.

-Lyndz




On Sat, Aug 7, 2021 at 9:56 AM Dennis Shea <shea at ucar.edu> wrote:

> Not tested
>
> Explicit approach
>
>    prc1d(time)
>    ntim = dimsizes(prc1d)
>    nlat = 1
>    mlon = 1
>
> ; expand 1D to 3D
>
>    prc3d  = *conform_dims*((/ntim,nlat,mlon/), prc1d, 0)
>    printVarSummary(prc3d)
>
>    yyyyddd =
>
>    prc3d_ClmDay = *clmDayTLL*
> <http://www.ncl.ucar.edu/Document/Functions/Contributed/clmDayTLL.shtml>(prc3d,
> yyyyddd)
>    printVarSummary(prc_3d)
>
>
>    prc3d_ClmDay = *clmDayTLL*
> <http://www.ncl.ucar.edu/Document/Functions/Contributed/clmDayTLL.shtml>(prc3d,
> yyyyddd)
>    prc3d_Anom   = *calcDayAnomTLL* (prc3d, yyyyddd, prc3d_ClmDay)
>     :
>     :
> ======================
> 2nd approach, cleaner and easier
>
> there are *undocumented functions*  *clmDayT*, *calcDayAnomT*
>
> prc1d_ClmDay    = *clmDayT*(prc1d, yyyyddd)
> printVarSummary(prc1d_ClmDay )
> prc1d_AnomDay =* calcDayAnomT*(prc1d, yyyyddd, prc1d_ClmDay)
> printVarSummary(prc1d_AnomDay)
>
> Look at *contributed.ncl*
>  search for the above functions if you want
>
>
>
>
>
>
> On Fri, Aug 6, 2021 at 12:20 PM Lyndz via ncl-talk <
> ncl-talk at mailman.ucar.edu> wrote:
>
>> Dear NCL-Experts,
>>
>> I have daily rainfall data from 1979-2017.
>>
>> I would like to:
>>
>> [a] Remove the annual cycle
>> [b] Then remove the seasonal cycle (3rd harmonics).
>>
>> I saw this function in NCL which computes the daily climatology first
>> before getting the anomalies (including smoothed anomalies).
>>
>> *http://www.ncl.ucar.edu/Document/Functions/Contributed/calcDayAnomTLL.shtml
>> <http://www.ncl.ucar.edu/Document/Functions/Contributed/calcDayAnomTLL.shtml>*
>>
>> But this can only be applied for *time x lat x lon data*.
>>
>> Is there an equivalent function of one-dimationsal (time series) data
>> like this?
>> If none, do you have any suggestions on how I can do this in NCL?
>>
>>
>> I'll appreciate any help.
>>
>> -Lyndz
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at mailman.ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210807/643f372f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_data.csv
Type: text/csv
Size: 335210 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210807/643f372f/attachment-0001.csv>


More information about the ncl-talk mailing list