Hi David,
Good question. Yes, there's a pretty straightforward way to do this.
You can always redefine any axis with a DEFINE AXIS command, and it
doesn't cause trouble with the dataset as long as you don't change the
number of coordinate values.
Say you had a z axis that came in defined like this, so that the first
zbox extends above the surface.
yes? DEFINE AXIS/Z/DEPTH/UNITS=meters zax = {1,5,9,15}
yes? LIST ZBOXLO[GZ=zax], Z[GZ=zax], ZBOXHI[GZ=zax]
DEPTH (m): -1 to 18
Column 1: ZBOXLO is ZBOXLO (axis ZAX)
Column 2: Z is Z (axis ZAX)
Column 3: ZBOXHI is ZBOXHI (axis ZAX)
ZBOXLO Z ZBOXHI
1 / 1: -1.00 1.00 3.00
5 / 2: 3.00 5.00 7.00
9 / 3: 7.00 9.00 12.00
15 / 4: 12.00 15.00 18.00
If you want to keep everything the same, but reset the first zboxlo to
0, here's a way to do it. Looking at the DEFINE AXIS/BOUNDS syntax,
we'll use the one where the bounds are a single list of length N+1.
Concatenate a 0 to the start of the list of zboxhi values and we have
the new list.
yes? LET new_edges = ZCAT ({0}, zboxhi[gz=zax])
yes? LIST new_edges
VARIABLE : ZCAT({0}, ZBOXHI[GZ=ZAX])
SUBSET : 5 points (Z)
X : 1
1
1
1 / 1: 0.00
2 / 2: 3.00
3 / 3: 7.00
4 / 4: 12.00
5 / 5: 18.00
Now use the original axis coordinates and redefine the axis.
yes? LET zpts = z[gz=zax]
yes? DEFINE AXIS/Z/UNITS=meters/DEPTH/BOUNDS zax = zpts, new_edges
Replacing definition of axis ZAX
yes? LIST ZBOXLO[GZ=zax], Z[GZ=zax], ZBOXHI[GZ=zax]
DEPTH (m): 0 to 18
Column 1: ZBOXLO is ZBOXLO (axis ZAX)
Column 2: Z is Z (axis ZAX)
Column 3: ZBOXHI is ZBOXHI (axis ZAX)
ZBOXLO Z ZBOXHI
1 / 1: 0.00 1.00 3.00
5 / 2: 3.00 5.00 7.00
9 / 3: 7.00 9.00 12.00
15 / 4: 12.00 15.00 18.00
I'll make this into an FAQ - it's a handy thing to be able to do.
Ansley
On 8/10/2010 10:57 AM, David Wang wrote:
Hi
Ansley et al.,
I have a follow-up question. Is there an easy way to add or change the
cell edges on the fly in Ferret? I'm talking about a scenario where the
depth axis of an oceanic variable has no "bounds" attribute. Ferret
would take the midpoints between consecutive axis values as cell edges;
whereas the axis values should be the midpoints between cell edges
starting from z=0 as the uppermost cell edge. This scenario is common
among OGCM output and important for accurate vertical integration. I
understand it can be done offline. In fact, I'm used to adding a proper
"bounds" attribute and "depth_bnds" variable in Matlab. But I wonder if
Ferret itself can compute and apply the correct cell edges on the fly
given z=0 as the uppermost cell edge.
Thanks,
David
On 08/10/2010 12:25 PM, Ansley Manke wrote:
Hi Sudheer,
An alternate way to define coordinate axes is with the /EDGES
qualifier, so that the points you give describe the cell edges rather
than the coordinate values. This will probably give you the control
you want. You can also define both the edges and coordinates, so that
the coordinates do not have to be centered in the grid cells. This is
done using the /BOUNDS qualifier. These are all described under DEFINE
AXIS in the Ferret Users Guide.
Ansley
On 8/10/2010 6:04 AM, Marco Steinacher wrote:
Dear Sudheer,
I think the values you get for ZBOX make sense. Think of your
measurements as they were taken at the center of grid cells and ZBOX(Z)
is the height of the box with the center at depth Z. If no explicit
edge
definition is given Ferret takes the midpoints between coordinate
values
as edges. This leads to the results you have got. Here's a picture:
Z Edges ZBOX
...
|
296.5
298 -- | --> 3.0
299.5
301 -- | --> 4.0
303.5
306 -- | --> 4.5
308.0
310 -- | --> 7.0
315.0
320 -- | --> 10.0
325.0
330 -- | --> 10.0
335.0
340 -- | --> 10.0
345.0
350 -- | --> 15.0
360.0
370 -- | --> 20.0
...
Z = center of grid cells
Edges = Midpoints between Z (assumed by Ferret)
ZBOX = height of grid cell
In many cases this makes sense. For example if you want to calculate
the
vertical integral you assume that your measurement is the average of
some space above and below the point where it was taken. If you have no
other information it makes sense to take the midpoints between the
measurements.
If you want other values for ZBOX for some reason you have to specify
the edges of your grid boxes explicitly by using the /bounds qualifier
with the define axis command (see Ferret documentation).
Marco
Sudheer Joseph wrote:
Dear Users,
I am trying to get data sampled at every 3 meters in upper 3
hundred meters and then switching to 30 meters in few steps of 5 10 20
for that I used the pasted below depth intervals.
and below commands to define the grid.
file/var=tt tt
def axis/z/from_data/depth/units=meters zax tt[d=1]
define grid/z=zax ngrd
file/var=var_1/grid ngrd
But If I list the zbox and corresponding z values I get some thing
which I did not expect. Can any one comment on this? is it a bug or am
I using ferret in a way I am not supposed to do?
I get un expected values for zbox with 15 against z values of 10
meter gap!! How this can happen?
4.5 may be expected as depth adjustment between 301 and 306 but how
can it be expected to see 15 meter depth between 340 and 350?
yes? list zbox[gz=zax],z[gz=zax]
DEPTH (m): 278.5 to 625
Column 1: ZBOX is ZBOX (axis ZAX)
Column 2: Z is Z (axis ZAX)
ZBOX Z
280 / 1: 3.00 280.0
283 / 2: 3.00 283.0
286 / 3: 3.00 286.0
289 / 4: 3.00 289.0
292 / 5: 3.00 292.0
295 / 6: 3.00 295.0
298 / 7: 3.00 298.0
301 / 8: 4.00 301.0
306 / 9: 4.50 306.0
310 / 10: 7.00 310.0
320 / 11: 10.00 320.0
330 / 12: 10.00 330.0
340 / 13: 10.00 340.0
350 / 14: 15.00 350.0
370 / 15: 20.00 370.0
390 / 16: 15.00 390.0
400 / 17: 20.00 400.0
430 / 18: 30.00 430.0
460 / 19: 30.00 460.0
490 / 20: 30.00 490.0
520 / 21: 30.00 520.0
550 / 22: 30.00 550.0
580 / 23: 30.00 580.0
610 / 24: 30.00 610.0
--
depths in file tt
$ cat tt
280
283
286
289
292
295
298
301
306
310
320
330
340
350
370
390
400
430
460
490
520
550
580
610
with best regards
Sudheer
**********************************************************************************
Sudheer Joseph
Scientist
Indian National Centre for Ocean Information Services (INCOIS)
Ocean Valley, Post Box No# 21,
IDA Jeedimetla P.O.
Hyderabad, Ranga Reddy District - 500 055
Andhra Pradesh, India.
TEl:+91-40-23044600(R),Tel:+91-9440832534(Mobile)
Tel:+91-40-23886047(O),Fax:+91-40-23892910(O)
E-mail:sjo@xxxxxxxxxxxxxx<mailto:E-mail%3Asjo@xxxxxxxxxxxxxx>;
sudheer.joseph@xxxxxxxxx<mailto:sudheer.joseph@xxxxxxxxx>;
sjo@xxxxxxxxxxxxx<mailto:sjo@xxxxxxxxxxxxx>.
Web- http://oppamthadathil.tripod.com
--------------* ---------------
"The ultimate measure of a man is
not where he stands in moments of
comfort and convenience, but where
he stands at times of challenge and
controversy."
Martin Luther King, Jr.
"What we have done for ourselves alone dies with us.
What we have done for others and the world remains and is immortal."
- Albert Pines
|