[ncl-talk] Time interpolation problem, annual to monthly

Hyacinth Nnamchi hyacinth.1 at hotmail.com
Tue Feb 6 19:54:28 MST 2018


Hi Adam,


Thank you for the suggestion, I am posting the actual code that worked for me in range of some real data here:



;------------------------------------------
begin

yrStrt = 1900
yrLast = 1999

f      = addfile ("TS_ts_100yr.nc", "r")
TIME   = f->TIME
YYYY   = cd_calendar(TIME,-1)/100
iYYYY  = ind(YYYY.ge.yrStrt .and. YYYY.le.yrLast)
x    = dble2flt(f->SST(iYYYY,0))
printVarSummary(x)

x_time = fspan(yrStrt,yrLast,(yrLast-yrStrt+1))
x_time!0 = "time"
printVarSummary(x_time)

tNew0 = yyyymm_time(yrStrt,yrLast,"float")
tNew1 = yyyymm_to_yyyyfrac(tNew0,0)   ; creating time in units of fraction to match x&time
printVarSummary(tNew1)
xNew = linint1(x_time,x,True,tNew1,0)
print(xNew)

end

;------------------------------------------

Best regards,


Hyacinth


________________________________
From: Adam Phillips <asphilli at ucar.edu>
Sent: 05 February 2018 11:44 PM
To: Hyacinth Nnamchi
Cc: ncl-talk at ucar.edu
Subject: Re: [ncl-talk] Time interpolation problem, annual to monthly

Hi Hyacinth,
Are your x&time and y&time arrays in the same range? The following worked for me:
x = (/1,2,3./)
x!0 = "time"
x&time = (/1980.5,1981.5,1982.5/)

time2 = yyyymm_time(1980,1982,"float")
time3 = yyyymm_to_yyyyfrac(time2,0)   ; creating time in units of fraction to match x&time
xNew = linint1(x&time,x,False,time3,0)
print(xNew)

Variable: xNew
Type: float
Total Size: 144 bytes
            36 values
Number of Dimensions: 1
Dimensions and sizes: [36]
Coordinates:
Number Of Attributes: 1
  _FillValue : 9.96921e+36
(0) 9.96921e+36
(1) 9.96921e+36
(2) 9.96921e+36
(3) 9.96921e+36
(4) 9.96921e+36
(5) 9.96921e+36
(6) 1
(7) 1.083374
(8) 1.166626
(9) 1.25
(10) 1.333374
(11) 1.416626
(12) 1.5
(13) 1.583374
(14) 1.666626
(15) 1.75
(16) 1.833374
(17) 1.916626
(18) 2
(19) 2.083374
(20) 2.166626
(21) 2.25
(22) 2.333374
(23) 2.416626
(24) 2.5
(25) 2.583374
(26) 2.666626
(27) 2.75
(28) 2.833374
(29) 2.916626
(30) 3
(31) 9.96921e+36
(32) 9.96921e+36
(33) 9.96921e+36
(34) 9.96921e+36
(35) 9.96921e+36

Hope that helps. If not, or if you have further questions please respond to the ncl-talk email list only.
Adam

On Mon, Feb 5, 2018 at 11:49 AM, Hyacinth Nnamchi <hyacinth.1 at hotmail.com<mailto:hyacinth.1 at hotmail.com>> wrote:

Hi NLCers,


I have an annual time series I want to re-interpolate to monthly values. I do this and get the correct size but everything is missing (and setting the @_FillValue and @missingvalue doesn't change result).


x  is an annual time series, 80 years

y is a monthly time series, 80 years (i.e. 80 x 12 months)


xNew   = linint1_n(x&time,x,False,y&time,0,0)


This new time series (xNew) contains all missing values (monthly, 80 years). Defining x&time and y&time outside the equation doesn't change the result.


Does anyone know why I'm having the wrong values?


Thanks in advance.


Hyacinth




_______________________________________________
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




--
Adam Phillips
Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/<http://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/20180207/efc82547/attachment.html>


More information about the ncl-talk mailing list