Hi Ferreters,
Steve (Hankin) gave me a solution to the problem which worked right from
the start (I expected this when I got the answer from the master
itself...). But also thanks to Graham Gladman who gave me a lot of
suggestions.
Before I come to the solution I should mention that the value is
slightly different from what I calculated by hand (compare values 2 and
3 in the list command below). I currently don't have a clue why. Maybe
it has to do with details how FERRET integrates.
Here are Steves lines:
The simplistic answer is to use a vertical mask:
LET zcoord = Z[g=myvar]
LET zmask = IF zcoord LT bathymetry2Dfield THEN 1
Then apply this mask to the quantity in question before integration. The
effect of the approach is to count every data point either 100% or 0%
It sounds like you want to weight the bottom points by where within the
grid cell the bottom lies. For that you could use a "weighted mask"
LET margin_mask = IF zcoord[k=@shf] GT bathymetry2Dfield AND zcoord
GT
bathymetry2Dfield THEN
(bathymetry2Dfield-zcoord)/(zcoord[k=@shf]-zcoord)
LET weighted_mask = MISSING(zmask, margin_mask)
Then
LET summand = myvar * weighted_mask * ZBOX[g=myvar]
LET result = summand[k=@sum]
I ran this on a testfile (attached to this email) and got:
NOAA/PMEL TMAP
Program FERRET
Version 5.22 - 07/27/00
27-Sep-00 10:44
yes? use test
yes? show data
currently SET data sets:
1> ./test.cdf (default)
name title I J
K L
TEMP POTENTIAL TEMPERATURE 1:1 1:1 1:30
1:1
BOTTOM (-1)*DEPTH[D=depth] 1:1 1:1 ...
1:1
yes? LET zcoord = Z[g=temp]
yes? LET zmask = IF zcoord LT bottom THEN 1
yes? LET margin_mask = IF zcoord[k=@shf] GT bottom AND zcoord GT bottom
THEN (bottom-zcoord)/(zcoord[k=@shf]-zcoord)
yes? LET weighted_mask = MISSING(zmask, margin_mask)
yes? LET summand = temp * weighted_mask * ZBOX[g=temp]
yes? LET result = summand[k=@sum]
yes?
yes? list/l=1 temp[z=@din],temp[k=1:26@din]+temp[k=27]*270,result
*** NOTE: Ambiguous coordinates on T axis: TEMP * WEIGHTED_MASK *
ZBOX[G=TEMP]
DATA SET: ./test.cdf
LONGITUDE: 50W(-50)
LATITUDE: 56N
TIME: 30-APR-1992 12:00
Column 1: TEMP[Z=0:6525@DIN] is POTENTIAL TEMPERATURE (deg C)
Column 2: EX#2 is TEMP[K=1:26@DIN]+TEMP[K=27]*270
Column 3: RESULT[Z=0:6525] is SUMMAND[K=@SUM]
TEMP EX#2 RESULT
I / *: 13545. 12872. 12286.
yes?
Ciao,
Arne
Arne Biastoch wrote:
>
> Hi Ferreters,
>
> sorry, I have to bother you again. Steves suggestion did not solved by
> case. But I am sure that this is a general problem that all modelers
> with variable bottom and free surface formulations should also have.
>
> I hope that there might be solutions around (Steve might already have 3
> lines in mind that do this...).
>
> Here's the case:
>
> I have a standard netCDF file with one depth axis. Here I would like to
> integrate not over the full water column but only down to a certain
> depth given by a 2D field (the bottom is not at the edges of the grid
> cells).
>
> standard case shallower deeper
> +---+ +---+ +---+
> | | | | | |
> | T | | T | | T |
> | | | | | |
> +---+ +---+ +---+
> | | | | | |
> | T | | T | | T |
> | | | | | |
> +---+ +---+ +---+
> | | | | | |
> | | | | | |
> | T | | T | | T |
> | | | | | |
> | | |...| <--- | |
> +---+ <--- +---+ +---+
> |...| |...| | |
> |...| |...| |...| <---
> |...| |...| | T |
> |...| |...| |...|
> |...| |...| |...|
> +---+ +---+ +---+
>
> T are the values that are NOT missing values, "<--" marks the bottom,
> given by a 2D field
>
> The most intuitive solution would be:
>
> shade T[z=0:depth] whereby depth[i,j]
>
> but as I understand FERRET it is not possible to use variable
> integration limits.
>
> I appreciate any help.
>
> Ciao,
> Arne
>
> Steve Hankin wrote:
> >
> > Hi Arne,
> >
> > A good starting point might be the FAQ
> >
> > "How do I handle sigma coordinate output in Ferret?"
> >
> > at
> > ../../faq/using-sigma-and-curvilinear-model-coordinates.html
> >
> > Happy Ferreting - steve
> >
> --
>
> Dr. Arne Biastoch
> Scripps Institution of Oceanography phone: +1-858-822-3787
> Physical Oceanography Research Division fax : +1-858-534-9820
> MS: 0230 email: abiastoch@ucsd.edu
> 8605 La Jolla Shores Dr.
> La Jolla, CA 92093-0230, U.S.A. http://www.ecco.ucsd.edu/~biastoch
--
Dr. Arne Biastoch
Scripps Institution of Oceanography phone: +1-858-822-3787
Physical Oceanography Research Division fax : +1-858-534-9820
MS: 0230 email: abiastoch@ucsd.edu
8605 La Jolla Shores Dr.
La Jolla, CA 92093-0230, U.S.A. http://www.ecco.ucsd.edu/~biastoch
Attachment:
test.cdf
Description: Binary data