HTML automatically generated with rman
Table of Contents


hdfgrid - Regrid a polar HDF4 SDS to cartesian image


hdfgrid [parameter=value]


hdfgrid regrids HDF (SDS) files that are assumed to be in polar (rad-phi) coordinates. This program was initially developed for the bar-hydro project (Piner, Stone & Teuben, ApJ - nov 1995) using a version of cmhog, though it can now also handle rank=3 SDS files for which the last dimension (in HDF the first) is 1, as long as the first two dimensions are radius and angle. Another constraint is that the data must fill half the plane (mirror=t) or a full plane (mirror=f), otherwise interpolation errors will dominate the gaps in the region of missing data. There are some keywords (phi1, scale2, phi3) that allow you to rotate and scale your data around the positive X-axis into either -pi/2:pi/2 (mirror=t) or -pi:pi (mirror=f).

The (2D) four-point interpolation that is used in regridding is based on the one in cmhog/movie.src, but includes correct interpolations for points near the Y axis that need contributions from the phantom "mirror" points (recall that the files are assumed to contain X>0 information only, the X<0 plane is assumed from point symmetry around the origin).

It is also possible to simply average the polar grid values into cartesian cells, using the pic=t method, but this will generally result in variable amount of smoothing and depending on the distribution of points in Rad-Phi can cause moire patterns.


The following parameters are recognized in any order if the keyword is also given:
Input file (HDF SD). No default.
Output file, in image(5NEMO) format.
Select which SDS from the file (1=first). See also zvar= below. [Default: 1].
Number of pixels in X. [Default: 256]
Number of pixels in Y [Default: 256].
Range in X [Default: -16:16].
Range in Y [Default: -16:16].
Gridding variable. Normally left alone, unless certain allowed mathematical expressions on the direct griddable variables (as defined by select=) need to be overriden. Allowed are vr (select=1), vt (select=2), den (select=3), vx, vy, vm and vp. Note that vm and vp are special cases of a linear combination of vx, vy vm = (vx-vy)/sqrt(2) and vp = (vx+vy)/sqrt(2) , just to get an idea of the velocity field under a "middle" position angle. Default: not used, select= is used.
Use the Particle In Cell method of gridding? This method is similar, but not as sophisticated as snapgrid(1NEMO) . The alternative, and also the default method, is 4-point interpolation from the corner cell in polar coordinates in which the cartesian cell center lies. [Default: t].
Mirror points? [Default: t].
Override symmetry properties of the variable to be gridded. This option is not used yet. See also mirror=
Shifts the values in theta by it0 pixels. This is equivalent by rotating the image counterclockwise by that many pixels. Useful for double bars and manually rotating the frame of reference (Maciejewski et al). [Default: 0]
The first operation is a rotation. This angle (in radians) will be added to the angles. Do not ues for serious work, as it only applies to density fields. Default: 0
The second operation is a scaling. All angles are multiplies by this number.
The third, and last, operation is a rotation again. This angle (in radians) will be added to the angles after the previous two. It was added for convenience, since in principle phi1 and scale2 can get you anywhere on the plane. The resulting formulae is:
    phi_out = (phi  + phi1) * scale2  + phi3
Default: 0


Often used in scripts, here is a snippet from a script that regrids an HDF file into TIFF for movie recording, but applying a non-linear scaling to the data.
  hdfgrid hdf001 - select=3 nx=256 ny=256 xrange=-8:8 yrange=-8:8 |\
     ccdmath - - "log(%1)" |\
     ccdmath - - "ifeq(%1,0.0,$dmin,%1)" |\
     ccdfits - tmp$$
  fitstiff tmp$$ movie1.$i.tiff datamin=-1 datamax=2 lut=ds
Several interesting peculiarities are to be noted: (1) ccdmath is called twice, because of a bug in combining the two; ifeq(%1,0.0,$dmin,log(%1)) could not be used. (2) fitstiff cannot read from a pipe, hence the extra annoying disk file tmp$$. (3) Lookup RGB color tables are in $NEMODAT/lut.

See Also



src/image/hdf/cmhog    hdfgrid.c


Peter Teuben

Update History

25-May-95    V1.0 Created for IAU157 movie    PJT
12-dec-99    V1.3 added it0= shifting arrays to fake a rotation, for Witold    PJT
27-aug-02    V1.5 added mirror= to allow for full grid simulations    PJT
3-dec-04    V2.0 increased MAXRANK to handle 2+1 dim input files    PJT
15-dec-04    V2.1 added pic=, and documented the new phi1,scale2,phi3 transformations    PJT

Table of Contents