[Thread Prev][Thread Next][Index]

Re: set region subtlety (and point correlation script)



Hello Rob,
Yes, it is a subtlety!   -- and thanks for the point correlation
script.

What you are seeing is the difference between y=@AVE as a
regridding transform and y=35N:45N@AVE as a regular
transformation.   When used as a regridding transformation, the
variable still has a range in Y.   You can see this in the version
of your script with the regridding transform: evaluating sst_np
for different values of Y gives different results; they are just
sst on the new x axis.

   set region /y=35N:45N
   let sst_np = sst[GX=xax_np,y=@AVE]
   list/L=1/y=35/x=145W sst_np   ! varies with Y,
   list/L=1/y=37/x=145W sst_np   ! same as sst[gx=xax_np]
   say `sst_np,return=shape`     ! the shape is XYT

On the other hand if you use the transformation, the result
is a single number in Y, the average of the variable between
two endpoints. Now the variable is independent of Y.

      cancel region
   let sst_np = sst[GX=xax_np,y=35N:45N@AVE]
   list/L=1/y=35/x=145W sst_np  ! same result for all Y
   list/L=1/y=40/x=145W sst_np
   say `sst_np,return=shape`    ! the shape is XT

The other variables in your script depend on Y in the same way,
including the result "covar", and when you go to regrid it to the desired
output X axis, an ambiguity somewhere results in the wrong result.
In the case of "set region /y=35N:45N; let sst_np = sst[GX=xax_np,y=@AVE]"
you expect covar to be a scalar but its context still has a y dependence.

In your script with the
"set region /y=35N:45N; let sst_np = sst[GX=xax_np,y=@AVE]"

you can get the correct result if you force covar to be evaluated
as a scalar when it's used.   Grave accents around covar will get
the correct result.   Inside the repeat loop:

LET acvf = reshape(`covar`,dummy[i=`k`]) ; \

Ansley Manke

Rob Scott wrote:

 
Ferret Users:

I've encountered a problem using set region that makes me uneasy.
Should these two lines,

        set region /y=35N:45N
        let sst_np = sst[GX=xax_np,y=@AVE]

not give the same numerical results as these:

        let sst_np = sst[GX=xax_np,y=35N:45N@AVE]

?? I avoided the latter because I thought it was harder on memory, no?

Well they give different results in the following script

Rob Scott

(hopefully someone may find it useful for doing point correlations)

! Description: get the point correlation of 1D SST field
!-------------------------------------------------------

set data coads_climatology
define axis/x=140E:130W:1/units=longitude/edges xax_np

!-------------------------------------------------------
! the following gets the wrong answer
!-------------------------------------------------------

set region /y=35N:45N
let sst_np = sst[GX=xax_np,y=@AVE]

!-------------------------------------------------------
! but this would make it work:
!            **     let sst_np = sst[GX=xax_np,y=35N:45N@AVE]   **
!-------------------------------------------------------
 

!-------------------------------------------------------
! keep q fixed:
! move p in zonal direction, find acvf = <p q>
!-------------------------------------------------------
let q = sst_np[x=145W]
!-------------------------------------------------------
! setup NetCDF file to hold the answer
!-------------------------------------------------------
let dummy = x[GX=xax_np]
let/title="SST Autocovariance" acvf = (1/0) * x[GX=xax_np]
save/clobber/file=sst_acvf.cdf acvf
!-------------------------------------------------------
! for all p points, get acvf
! save to NetCDF (use RESHAPE to get it on the right grid)
! save to ASCII (for comparison)
!-------------------------------------------------------
repeat/k=1:5 (let p = sst_np[i=`k`]; go variance; \
LIST/FORMAT=(1X,E14.7)/FILE="sst_acvf.dat"/CLOBBER/NOHEAD covar ; \
LET acvf = reshape(covar,dummy[i=`k`]) ; \
SAVE/APPEND/FILE=sst_acvf.cdf acvf)

-- 
Postal Address:

Program in Atmospheric and Oceanic Sciences
P.O. Box CN710, Sayre Hall
Princeton, NJ 08544-0710
USA

Tel: 609-452-6519                    o__    ____ 
Fax: 609-987-5063                    _,>/'_  -----
E-mail: rscott@princeton.edu        (_) \(_) ------
 
--
Ansley Manke  Pacific Marine Environmental Laboratory  Seattle WA  (206)526-6246
 
[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement