Resampling dataset from monthly to annual

Hello,
I am new to Igor and I have been trying to use the resampling option to change a monthly dataset to an annual dataset, with a value every year centered on the mid-year (i.e 1991.5: 1992.5; 1992.5 ...). My new dataset should get 12 times shorter than my original one.
I have been trying to use the resample tool window, with intepolated:12, and decimate:0.5, I left the filter lenght onthe default value (21).
and...I just can't click on the button "do it" ...
do I do something wrong? should I try to type the command in?
I am attaching my file with a column with the decimal year (monthly), 1991.04; 1991.12; 1991.21...and a column with the monthly dataset which I need to resample from years 1850 to 2002)

Thanks a lot!

Guizmo
Resample.pxp
Guizmo,

My guess is that after selecting your waves in the Waves list, you did not press the yellow arrow to the right of that list. This will add the selected waves to the box below the row of headings (Wave, Points, etc.). Then the "Do It" button becomes active.

To get the sampling rate that you want try using Interpolate 1, Decimate 12 and, I think, Filter Length 1 if you want the mid-point of your data rather than an average. The ratio of Inerpolate to Decimate controls the final sampling rate. So Interpolate 1 Decimate 12 sets the output point density at 1/12 of the starting wave point density. Also, I had to delete the first 6 data points from both "cal years" and "concs" to get an output wave containing the point at mid year.

Others might have better suggestions for these settings.

I attached a modified version of your experiment with the outputs of my tests.

Jeff
I tried jtigor's method. It seems to work. However, if you want each output point to be the average of the corresponding 12 input points, it does not do this.

I executed:

WaveStats /Q /R=[0,11] conc; Print V_avg  // Print average of first 12 points
Print conc_samp[0]  // Print resampled output for first 12 points


I got 0.0862091 and 0.0922917.

I'm not sure how to solve this using Resample.

Once you get the right output, you can use wave scaling to set the X values of the output wave, like this:
SetScale/P x, 1850.5, .5, "year", conc_samp
Display conc_samp


Now you no longer need the X wave ('cal years_samp').

To learn about X scaling, execute this:
DisplayHelpTopic "Waves - The Key Igor Concept"


and then:

DisplayHelpTopic "The Waveform Model of Data"

Actually the idea behind my method

... Interpolate 1, Decimate 12 and, ... Filter Length 1 .... Also, I had to delete the first 6 data points from both "cal years" and "concs" ...

was to get the value of the data point occuring at the middle of each year rather than the average for the year. That was my interpretation of Guizmo's message. I could be wrong in that assumption.

Like Howard, I don't know how to get the average for each year using Resample. However, here is a short function that will return the average for every n points in a wave, using the usual wave assignment syntax:

Function AvgPts(w, CurrentPoint, PointsInAvg)
    Wave w
    Variable CurrentPoint
    Variable PointsInAvg
   
    Variable first = PointsInAvg * CurrentPoint
    Variable last = first + PointsInAvg -1
    wavestats/Q/R=[first, last] w
    print CurrentPoint
    return V_avg
End


To return the annual average from a wave with 12 points per year, one would write:

concs_samp = avgpts(concs, p, 12)

It would be necessary to appropriately size the output wave.

For Guizmo's data the first three annual points are: 0.0862091, 0.32879 and 0.358203.

Jeff
How about another averaging approach that doesn't require Wavestats:
function refine(calendar, data)
    wave calendar, data
    make/O/N=(numpnts(data)/12) red_cal, red_concs
    red_cal = calendar[12*p+5]
    red_concs = mean(data , 12*p,  12*p+11 )   
end