# [ferret_users] Saving new dataset

Hi everyone!

I want to make cross correlation (with time lag) between two variables (such as SLP and SST). Referring to many sources, i.e. http://ferret.pmel.noaa.gov/Ferret/FAQ/analysis/correlations.html and http://ferret.wrc.noaa.gov/Ferret/Mail_Archives/fu_97/msg00037.html I managed to calculate the correlation. For further analysis I introduced the timelag by shifting one of the time series. And now I want to save a new dataset with the correlations and the timelag. As I don't use the z axis I thought I could use it for the time lag. But how was I supposed to save the information properly? Refering to http://ferret.wrc.noaa.gov/Ferret/FAQ/data_management/multi_dataset.html I had found the solution. So I wrote the script above, which tries to save the time laged correlations to the z axis. But it doesn't work. The only thing I achieve is a properly dimensioned grid, but always with repeating values on the z axis.

Can anyone explain me how I could save my data properly?

Thanks,
Sebastian

! ----------------------------------------------------------------------
! Setting up for saving correl.cdf
! - Defining Z axis interval (for the lag)
! - Defining grid
! - Sets every value CORREL's grid to zero
! - Reseting file 'correl.cdf'
DEFINE AXIS/z=-12:12:1/UNIT=meters zmeters
DEFINE GRID/z=zmeters gg
!SPAWN rm correl.cdf
LET/QUIET/TITLE="CROSS CORRELATION OF P AND Q" CORREL = (z[g=gg] + rPQ)*0
SAVE/FILE=correl.cdf/CLOBBER CORREL

LET/QUIET/TITLE="CROSS CORRELATION OF P AND Q" CORREL = z[g=gg]*0 + rPQ
LET/QUIET Qi = Q[l=@shf:12]
SAVE/FILE=correl.cdf/APPEND CORREL[k=25]
LET/QUIET Qi = Q[l=@shf:11]
SAVE/FILE=correl.cdf/APPEND CORREL[k=24]
LET/QUIET Qi = Q[l=@shf:10]
SAVE/FILE=correl.cdf/APPEND CORREL[k=23]
:
:
:
! ----------------------------------------------------------------------