NOAA-PMEL / Ferret

The Ferret program from NOAA/PMEL
https://ferret.pmel.noaa.gov/Ferret/
The Unlicense
55 stars 20 forks source link

SAMPLE in other than XY #1101

Closed karlmsmith closed 6 years ago

karlmsmith commented 6 years ago

Reported by @AnsleyManke on 6 Apr 2011 23:12 UTC Billy Kessler wanted to sample in XZ. We hunted around and found the old USER command, for which there's a USER/COMMAND=SAMPLE

Is it worth capturing these capabilities and putting them into external functions?

v4.4 Ferret documentation:

33.2 Scattered sampling

The command selection "sample" uses multi-linear interpolation to sample a gridded field of data at a list of scattered coordinates. This procedure is useful in statistics, in experimental design studies, and in advective tracer animations. The variable "four_dee_field" is a 1 to 4 dimensional gridded field of values. The variables xpts, ypts, zpts, and tpts are the ordered-tuples of points at which the field should be sampled. To indicate that a particular axis is not to be involved in the sampling process, pass a missing value flag ("1/0") for that axis. For example,

yes? USER/COMMAND="sample"  temp[d=levitus_climatology,K=1], \
         xpts, ypts, 1/0, 1/0

will sample (X,Y) points from the K=1 field of Levitus climatological temperatures. Multi-linear interpolation is used to interpolate between grid points.

yes? USER/COMM="sample"/OPT1=/OPT2=/FILE=/FORMAT= \
              four_dee_field, xpts, ypts, zpts, tpts

/OPT1=coaching The parameter "coaching" may contain these substrings: "hole" or "fill" To perform the linear interpolation of all of the grid points surrounding the requested sample, tuple must contain valid data. If "fill" is specified then Ferret attempts to fill any missing surrounding points with an average of their neighbors. If "hole" (the default) then the result is "missing" whenever a neighboring point is missing.

"standard_bad" indicating that the standard Ferret bad value flag of -1E34 is used for missing data points (default is the missing data flag from "four_dee_field".

/OPT2=coordinates_or_indices The parameter "coordinates_or_indices" determines if the input sampling points are to be interpreted as world coordinates or as subscripts. If it is "c" (default) the input points are world coordinates. If "i", they are indices. Indices may be fractional locations (e.g., 2.5 is midway between 2 and 3). By specifying a 4-character "coordinates_or_indices" each axis may be separately specified. (e.g., /OPT2="ccci" will interpret T axis positions, only, as indices).

/FILE=filename Specifies the name of an output file to which sampled data will be written.

/FORMAT=format The format may contain a FORTRAN format in parentheses or "unf" (default) to indicate unformatted, binary, floating point output. A special, condensed (high performance) format option is possible by specifying "unf:nnn". In this case only the sampled values are written (no coordinates or codes) and nnn specifies the number of values to be written per record (e.g., "unf:100").

By default each output record consists of:

value  xcoord  ycoord  zcoord  tcoord  code

where "code" is 0 fully successful 1 successful via hole filling -1...-4 failed due to beyond input data limits on axis -code -9 failed due to hole in input data field -99 failed due to hole in input coordinate

See polar_demo.jnl which uses convert_to_polar_2d.jnl which uses USER/COMMAND=SAMPLE.

Migrated-From: http://dunkel.pmel.noaa.gov/trac/ferret/ticket/1829

karlmsmith commented 6 years ago

Comment by @AnsleyManke on 7 Apr 2011 16:51 UTC We do have a bunch of SAMPLE functions. Billy and I needed to ask Ferret to

show function sample*

before doing this. Some of them are not documented, so this is in fact a doc bug, #1380