diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /pkg/tbtables/tbcscal.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/tbtables/tbcscal.x')
-rw-r--r-- | pkg/tbtables/tbcscal.x | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/pkg/tbtables/tbcscal.x b/pkg/tbtables/tbcscal.x new file mode 100644 index 00000000..35b2bcf3 --- /dev/null +++ b/pkg/tbtables/tbcscal.x @@ -0,0 +1,75 @@ +include <tbset.h> +include "tbtables.h" + +# This routine copies the tscal & tzero values to COL_TSCAL & COL_TZERO. +# +# This routine will return without doing anything if: +# the table type isn't FITS +# the "true" data type is a floating type, or boolean, or text +# the input tscal & tzero are 1 & 0 respectively or are INDEFD. +# +# Unless the data type already is a floating type, it will be changed to +# real or double. If the actual data type in the table file is int, the +# apparent data type will be set to double; otherwise (i.e. short or byte), +# the apparent data type will be set to real. +# +# If the table is open, the TSCALi and TZEROi keywords will be added to +# the header (or updated, if they're already present). +# +# This is the interface routine; tbfscal is lower level. +# +# Phil Hodge, 23-Jun-2000 Subroutine created. + +procedure tbcscal (tp, cp, tscal, tzero) + +pointer tp # i: pointer to table struct +pointer cp # i: pointer to column struct +double tscal # i: scale factor for column +double tzero # i: zero offset for column +#-- +int tdtype # "true" data type (we expect short or int) +int dtype # "apparent" data type +bool modify # true if either tscal or tzero differs from default +errchk tbfscal + +begin + if (TB_TYPE(tp) != TBL_TYPE_FITS) + return # scaling parameters can't be used + + dtype = COL_DTYPE(cp) + tdtype = COL_TDTYPE(cp) + + # Scaling is only appropriate if the true data type in the table + # file is an integer type. + if (tdtype == TBL_TY_REAL || tdtype == TBL_TY_DOUBLE || + tdtype == TBL_TY_BOOL || tdtype < 0) { + return + } + + modify = false # initial value + + if (tscal != 1.d0 && !IS_INDEFD(tscal)) { + COL_TSCAL(cp) = tscal + modify = true + } + + if (tzero != 1.d0 && !IS_INDEFD(tzero)) { + COL_TZERO(cp) = tzero + modify = true + } + + if (!modify) + return # nothing to do + + # Change the data type to a floating type, if it isn't already. + if (dtype != TBL_TY_REAL && dtype != TBL_TY_DOUBLE) { + if (tdtype == TBL_TY_INT) + COL_DTYPE(cp) = TBL_TY_DOUBLE + else + COL_DTYPE(cp) = TBL_TY_REAL + } + + # Write these values to keywords TSCALi and TZEROi. + if (TB_IS_OPEN(tp)) + call tbfscal (tp, cp) +end |