[Thread Prev][Thread Next][Index]

Re: [ferret_users] question of filled region



Hello Xhb,

i am doing masking with a fortran code (if you have the coordinates for the border of China), but you can do that also in ferret. Though its more complicated.
The methodology: you need to have a rectangle over China, then use IF conditions to decide whether the grid cell is out of China or not, finally apply that mask on your global data.

I am showing how i did this earlier (after some mailing-list help) for Hungary.

1) this is the rectangle with the grid cell size and define the points in there
let xlo=16.75
let xhi=22.75
let dx=0.5
let ylo=46.25
let yhi=48.25
let dy=0.5
let xpts=x[x=`xlo`:`xhi`:`dx`] + 0*y[y=`ylo`:`yhi`:`dy`]
let ypts=0*x[x=`xlo`:`xhi`:`dx`] + y[y=`ylo`:`yhi`:`dy`]

2) x21 is my variable and nothere is used for points outside of China (missing)
let nothere=`x21,r=bad`

3) use IF conditions to decide wether a point is in the interested region.
let x1=if x[gx=xpts] le 16.75 and y[gy=xpts] le 46.25 then nothere else xpts
let x2=if x[gx=xpts] ge 20.25 and y[gy=xpts] le 46.25 then nothere else x1
let x3=if x[gx=xpts] le 19.25 and y[gy=xpts] ge 48.25 then nothere else x2
let x4=if x[gx=xpts] ge 21.75 and y[gy=xpts] le 46.75 then nothere else x3
let x5=if x[gx=xpts] ge 22.25 and y[gy=xpts] le 47.25 then nothere else x4
let x6=if x[gx=xpts] ge 22.75 and y[gy=xpts] le 47.75 then nothere else x5
let y6=x6*0+ypts

4) make this 1 dimensional, select the good points and have the variable only with the points of interest. now you can contour etc.

let xpts_1d=xsequence(x6)
let xpts_comp=compressi(xpts_1d)
let xpts_good=xpts_comp[i=1:`xpts_comp[i=@ngd]`]

let ypts_1d=xsequence(y6)
let ypts_comp=compressi(ypts_1d)
let ypts_good=ypts_comp[i=1:`ypts_comp[i=@ngd]`]

let hupoints21=samplexy(x21,xpts_good,ypts_good)

Basicaly the 1) and 3) should be different for you.
If the question is simpler, the answer is also (i mean if you want to fill a rectangle and not using a mask).
Hope, this is what you wanted :)

Have a nice day,

Peter


2009/5/21 xhbhyq11 <xhbhyq11@xxxxxxx>
Hi :
   I want to fill only in China, but my data is global. How can I do to fill value only in China?
Thanks in advance!




                                                                              Xhb
                                                                          2009.05.21


穿越地震带 纪念汶川地震一周年


[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement