OGIP Calibration Memo CAL/SW/93-005
Summary of CALLIB routines
Rehana Yusaf
Ian M George,
and
Ron S Zellar
Codes 664 & 668,
Last Update: 1994 Feb 22
NASA/GSFC,
Greenbelt,
MD 20771
(by IMG)
|
| Release | Sections Changed | Brief Notes |
| Date | ||
| 1994 Feb 10 | All | FTOOLS Version 2.8 Public Release |
| 1994 Mar 30 | All | FTOOLS Version 2.9 Public Release |
| 1994 Jun 01 | All | FTOOLS Version 3.0 Public Release |
| 1994 Oct 21 | All | FTOOLS Version 3.1 Internal Release |
| 1995 Jan 10 | All | Made compatible with LaTeX2HTML software |
| 1995 Jan 13 | All | FTOOLS Version 3.2 Public Release |
| 2004 Apr 01 | All | Made compatible with tth |
This document was constructed from a single LATEXavailable
via anonymous ftp from the HEASARC (legacy.gsfc.nasa.gov) as:
However, due to its size, two postscript versions are
available:
Typically this document is up-dated once a month, but at least
once per FTOOLS release. The last update and corresponding FTOOLS
release are given on the front page.
CALLIB
is a subroutine library which contains useful utilities that
have been used by several calibration related FTOOLS. The /callib
library is a subdirectory of the FTOOLS package (see Users.v3.0.ps).
The CALLIB
library has three sub-directories, src/gen which contains
system independant routines, src/unx which contains UNIX/ULTRIX
specific code and src/vms which contains the VMS specific
routines.
One of the primary features of the CALLIB
library is that it contains
OGIP standard format FITS readers and writers, for example wtpha1.f (see
section 2.1.8) writes a FITS PHA extension that conforms to the OGIP
standard format, that software expects.
For a complete guide to installing FTOOLS see the Ftools installation guide
(Install.v3.0.ps). In addition the Developer's Guide to FTOOLS is a useful
referance (Develop.v3.0.ps). FTOOLS developers should note that the
CALLIB
library is not available with the CORE FTOOLS distribution, therefore it
should not be used for a core package task. Currently the core packages are
FUTILS,FIMAGE, and TIME. Assuming FTOOLS is installed, any user can access
the
CALLIB
or any other FTOOLS library using the following path,
for UNIX/ULTRIX :
LIBF = -L/path/host -lcaltools -lftools -lhost -lxanlib
-lfitsio
where path should contain your path to the FTOOLS host directory. For
HEASARC users this is ftools/SUN/release for Suns, SUN should
be replaced by DEC for DECstations.
for VMS :
ftools:[host]caltools/lib,ftools:[host]ftools/lib
The caltools link enables users to access the CALLIB
library.
ABOUT THIS DOCUMENT
caldb/docs/memos/cal_sw_93_005.tex
(It should be noted that the Table of Contents of
cal_sw_93_005_small.ps includes the full Table of Contents
of cal_sw_93_005.ps).
It is strongly recommended that casual users start
with this document.
consisting of the full memo.
This document is Large since it contains the
headers from all the
CALLIB
subroutines. It is anticipated
that only a small minority of users will require this
document.
1 INTRODUCTION
1.1 Using CALLIB routines
2 SUMMARY TABLES
| Subroutine | Primary | Versions | Description | |
| Name | Author | Pub | Dev | Writes ... |
| wt_ear1992a | IMG | 0.9.0 | 0.9.0 | a EARVERSN=1992a extension |
| wt_eef1992a | IMG | 1.0.2 | 1.0.2 | a EEFVERSN = 1992a extension |
| wt_flt1992a | IMG | 1.0.0 | 1.0.0 | a FLTVERSN = 1992a extension |
| wt_spec | RY | 1.0.8 | 1.0.8 | a PHAVERSN = 1992a extension |
| wtarf1 | IMG | 1.0.1 | 1.0.1 | an ARFVERSN = 1992a dataset |
| wtebd1 | IMG | 2.0.1 | 2.0.1 | an EBOUNDS ext of an RMFVERSN = 1992a dataset |
| wtexm1 | RY | 1.0.1 | 1.0.1 | a Exposure map in the Primary array |
| wtpha1 | IMG | 3.0.3 | 3.0.3 | a PHAVERSN = 1992a extension |
| wtrmf1 | IMG | 3.2.0 | 3.2.0 | a RMFVERSN = 1992a extension |
| wtrpf1 | RY | 1.0.1 | 1.0.1 | a RPSFVERS = 1992a dataset |
| Subroutine | Author | Priority | Status | Description |
| Name | Writes ... | |||
| wtcol1.f | IMG | 1 | 99% | a COLVERSN = 1992a dataset |
| wtear1 | IMG | 1 | 99% | a EARVERSN = 1992a dataset |
| wteef1 | IMG | 1 | 95% | a EEFVERSN = 1992a dataset |
| wteff1.f | IMG | 1 | 99% | a EFFVERSN = 1992a dataset |
| wtegd1.f | IMG | 1 | 99% | a EGRDVERS = 1992a dataset |
| wtobf1 | IMG | 1 | 99% | a OBSVERSN = 1992a dataset |
| wtspr1.f | IMG | 1 | 99% | a SPRVERSN = 1992a dataset |
| wttrs1.f | IMG | 1 | 99% | a TRANSVER = 1992a dataset |
| wtvig1.f | IMG | 1 | 99% | a VIGVERSN = 1992a dataset |
| Subroutine | Primary | Versions | Description | |
| Name | Author | Pub | Dev | Reads ... |
| rdarf1 | IMG | 1.0.0 | 1.0.0 | an ARFVERSN = 1992a dataset |
| rdatrd | RY | 1.0.0 | 1.0.0 | a RDF Attitude dataset |
| rdebd1 | RY | 1.1.2 | 1.1.2 | an EBOUNDS ext of an RMFVERSN = 1992a dataset |
| rdetm1 | RY | 1.0.0 | 1.0.0 | a detector map from a FITS Primary Array |
| rdgti1 | RY | 2.0.0 | 2.0.0 | a GTI dataset |
| rdmvrd | RY | 1.0.0 | 1.0.0 | a RDF Event Rate dataset |
| rdoht1 | RY | 1.1.0 | 1.1.0 | a SPECTRUM DETECTOR dataset |
| rdpha1 | RY | 1.0.3 | 1.0.3 | a PHAVERSN = 1992a dataset |
| rdrmf1 | RY | 1.1.1 | 1.1.1 | a RMFVERSN = 1992a dataset |
| rdrpf1 | RY | 1.1.1 | 1.1.1 | a RPSFVERS = 1992a dataset |
| Subroutine | Author | Priority | Status | Description |
| Name | Reads ... | |||
| rdeprd | RY | 1 | 75% | a RDF EPHEM dataset |
| rdhkrd | RY | 1 | 75% | a RDF HKP dataset |
| rdstrd | RY | 1 | 75% | a RDF HKSTA dataset |
| Subroutine | Primary | Versions | Description | |
| Name | Author | Pub | Dev | Writes ... |
| wt_addcom | IMG | 1.0.0 | 1.0.0 | COMMENTS to CDU from ASCII i/p file |
| wt_cifkys | IMG | 1.1.0 | 1.1.0 | keywords mandatory for CIF purposes |
| wt_objradec | IMG | 1.0.1 | 1.0.1 | RA & dec keywords for an object/target |
| wt_obsinfo | IMG | 1.1.1 | 1.1.1 | keywords containing observational details |
| wt_pntradec | IMG | 1.0.1 | 1.0.1 | RA, dec & roll keywords for pointing direction |
| wt_regdesc | IMG | 1.3.0 | 1.3.0 | keywords describing region descriptors |
| wt_scradec | IMG | 1.0.1 | 1.0.1 | RA, dec & roll keywords for spacecraft orientation |
| wtftim | IMG | 1.0.2 | 1.0.2 | keywords describing (observing) time (in detail) |
| wttobs | IMG | 1.0.1 | 1.0.1 | keywords describing (observing) time (crudely) |
| Subroutine | Author | Priority | Status | Description |
| Name | ||||
| Subroutine | Author | Latest | Description |
| Name | Version | ||
| rd_cifkys | IMG | 1993 Feb 17 | Reads Mandatory keywords from current header unit |
| rd_obsinfo | IMG | 1.0.0 | Reads Observation details of CHDU |
| rdtobs | IMG | 1.0.0 | Reads details of time of observation from CHDU |
| Subroutine | Author | Priority | Status | Description |
| Name | ||||
| Subroutine | Primary | Versions | Description | |
| Name | Author | Pub | Dev | |
| cfappend | RY | spawns FTOOL fappend | ||
| cgetlun | IMG | sys-dep | sys-dep | Gets a free logical unit |
| ck_file | RY | 1.0.3 | 1.0.3 | Checks for illegal (output) filenames etc |
| ck_man | RY | 1.0.1 | 1.0.1 | Checks whether record is mandatory keyword |
| copyphd | RY | 1.0.2 | 1.0.2 | Copys the primary header from one file to another |
| do_addcom | IMG | 1.0.1 | 1.0.1 | Opens FITS file & adds COMMENTS from ASCII file |
| fndext | IMG | 1.1.0 | 1.1.0 | Finds extension(s) with given EXTNAME |
| fndhdu | IMG | 1.1.0 | 1.1.0 | Finds extension(s) with given HDUCLASn values |
| getkeys | RY | 1.0.0 | 1.0.0 | Returns list of keywords |
| gt_csysnms | IMG | 1.1.0 | 1.1.0 | Returns standard colnames for given spatial coord sys |
| mver | RY | 1.0.0 | 1.0.0 | moves to desired extension |
| mvext | RY | 1.1.0 | 1.1.0 | opens file and moves to desired extension |
| mvfile | RZ | 1.0 | 1.0 | renames a given file |
| op_npa | IMG | 1.0.3 | 1.0.3 | Gets free unit & opens a null P.array FITS file |
| par_dim | RY | 1.0.0 | 1.0.0 | Parse TDIMnnn keyword |
| pg_fcecho | RY | 1.0.0 | 1.0.0 | pages screen output |
| wt_com | RY | 1.0.3 | 1.0.3 | Copy i/p file to o/p file excl PHA extension |
| wt_copy | RY | 1.0.1 | 1.0.1 | Copy i/p extn to o/p file excl PHA extension |
| wt_ferrmsg | RY | 1.0 | 1.0 | writes FITSIO error message in standard format |
| Subroutine | Primary | Versions | Description | |
| Name | Author | Pub | Dev | |
| apndfl | RZ | 1.0 | 1.0 | Concatinates path & filename |
| cconc | RZ | (no #) | (no #) | Converts string to system default |
| clenact | RY | ?? | ?? | Returns length of string (excluding trailing blanks) |
| clnstr | IMG | 1.0.0 | 1.0.0 | Replaces ïllegal" ASCII characters within a string |
| clocase | RY | 1.0 | 1.0 | Converts to lower case |
| cptend | RZ | 1.0 | 1.0 | Concats logical,director & filename |
| crmvblk | IMG | 1.0.0 | 1.0.0 | Removes all blanks from a string |
| crmvlbk | RZ ?? | ?? | ?? | Removes LEADING blanks from a string |
| crmvxbk | ?? | ?? | ?? | Removes extra blanks from strings |
| rmvexsp | RY | 1.0.0 | 1.0.0 | Replaces multiple blanks with single blank |
| Subroutine | Primary | Versions | Description | |
| Name | Author | Pub | Dev | |
| cbftoch | IMG | (no #) | (no #) | Converts a (SF) byte buffer to char string |
| ccaldj | RZ | (no #) | (no #) | Converts Gregorian Calendar to MJD |
| ccldj | RZ | (no #) | (no #) | Converts Gregorian Calendar to MJD |
| cmp_fact | RY | 1.0.2 | 1.0.2 | Determines compression factor for rebinning |
| cnxpksf | IMG | 1.0.1 | 1.0.1 | Gets and decodes SF package header |
| copnrsf | IMG | 1.0.4 | 1.0.4 | Opens an SF format file for reading |
| crstrsf | IMG | 1.0.0 | 1.0.0 | Write strings as aux records to SF file |
| crsubsf | IMG | 1.0.2 | 1.0.2 | Reads subsidiary SF record |
| cspawn | IMG | 1.1.0 | 1.1.0 | Spawns to operating system |
| ctrlog | RZ | 1.0 | 1.0 | Translates logical name |
| delfil | RZ | 1.0 | 1.0 | Deletes a file |
| grp_rmf | IMG | 1.1.2 | 1.1.2 | Calculates channel subsets for an RSP_MATRIX dataset |
| gtdate | RZ | 1.0 | 1.0 | Returns system date as integer day, month, year |
| gtdir | RZ | 1.0 | 1.0 | Gets current working directory |
| gttime | RZ | 1.0 | 1.0 | Returns system time as integer hr,min,sec |
| ppthnm | RZ | 1.0 | 1.0 | Parse string into disk,directory,filename strings |
| rd_rsp | IMG | 1.1.4 | 1.1.4 | Reads an SF-style RSP file |
| remap | IMG | - | 1.0.0 | Remaps 1-d array onto another grid |
| Subroutine | Author | Priority | Status | Description |
| Name | ||||
| gt_instalias | RY | 1 | 0% | Returns any aliases for INSTRUME keyword value |
| gt_telealias | RY | 1 | 0% | Returns any aliases for TELESCOPE keyword value |
| parse_cdb | RY | 1 | 0% | Parses a CBD expression |
| Subroutine | Primary | Versions | Description | |
| Name | Author | Pub | Dev | |
| wtehr1 | IMG | - | 1.1.0 | writes DETECTOR extension for the HRI |
| wtipc1 | IMG | - | 1.2.0 | writes DETECTOR extension for the IPC |
| Subroutine | Primary | Versions | Description | |
| Name | Author | Pub | Dev | |
| cma_detnam | IMG | - | 1.0.0 | returns DETNAM & FILTER strings for the CMA |
| cshfdmy | IMG | - | ? | converts SHF key to calendar dd/mm/yy |
| cshftime | IMG | - | ? | converts SHF key to integer yr,day,hr,min,sec |
| me_detnam | IMG | - | 1.0.0 | returns DETNAM string for the ME |
| wtxgs1 | IMG | - | 1.0.0 | writes DETECTOR extension for the GSPC |
| wtxme1 | IMG | - | 2.0.0 | writes DETECTOR extension for the ME |
| Subroutine | Primary | Versions | Description | |
| Name | Author | Pub | Dev | |
| livtim | ??? | ??? | ??? | calc PSPC livetime ???? |
| rdatu0 | RY | - | 1.0.1 | reads US REV0 format Attitude extension |
| rdmvu0 | RY | - | 1.0.0 | reads US REV0 format (Qualified) EVRAT extension |
| wtrhr1 | IMG | - | 1.1.0 | writes DETECTOR extension for the HRI |
| wtrps1 | IMG | - | 2.1.0 | writes DETECTOR extension for the PSPC |
Develop.v3.0.ps, Blackburn, J.K,
available via anonymous FTP, /FTP/software/ftools/release/Develop.v3.0.ps
Install.v3.0.ps, Blackburn, J.K, Greene, E.A,
available via anonymous FTP, /FTP/software/ftools/release/Install.v3.0.ps
Users.v3.0.ps, Blackburn, J.K, Greene, E.A,
available via anonymous FTP, /FTP/software/ftools/release/Users.v3.0.ps
Lists and descriptions of mission-independent CALLIB routines are given in:
List of currently available and planned CALLIB routines concerning the writing of calibration datasets in standard formats are given in Tables 1 & 2 respectively.
... OUT OF DATE - to be superceded by wtear1
... Needs to be updated so as not to confuse EAR & EEF
*+WT_EAR1992a
subroutine wt_ear1992a(ounit, chatter,
& nk_hist, hist,
& nk_comm, comment,
& telescop, instrume, detnam, filter,
& coordsys,
& icoord1, coord1, c1units,
& icoord2, coord2, c2units,
& ienerg, energ_lo, energ_hi, enunits,
& ear, earunits, ierr)
IMPLICIT NONE
integer chatter, ierr
integer ounit, nk_hist, nk_comm
integer icoord1, icoord2, ienerg
integer fcstln
real energ_lo(ienerg), energ_hi(ienerg)
real ear(ienerg,icoord1,icoord2)
real coord1(icoord1), coord2(icoord2)
character*8 coordsys, c1units, c2units, enunits, earunits
character*16 telescop, instrume, detnam, filter
character*80 hist(nk_hist), comment(nk_comm)
c
c Description:
c Creates and Writes the EFF AREA extension for an EARVERSN=1992a
c Effective Area file. Assumes the FITS file is open and has had the
c Primary Header written
c !!! Note !!!! File is left open at the end
c and MUST BE CLOSED by FTCLOS
c or ANOTHER EXTENSION ADDED by FTCRHD
c in order to (automatically) write the mandatory END header keyword.
c Matrix etc written as FIXED length arrays only at present
c
c Passed parameters
c OUNIT i : FORTRAN unit number of open output file
c CHATTER i : chattiness flag for o/p (5 quite,10 normal,>20
c NK_HIST i : No. records to be written as HISTORY records
c HIST i : Array of history strings to be written
c NK_COMM i : No. records to be written as COMMENT records
c COMMENT i : Array of comment strings to be written
c TELESCOP i : String listing telescope/mission
c INSTRUME i : String listing instrument/detector
c DETNAM i : String listing specific detector name
c FILTER i : String listing instrument filter in use
c COORDSYS i : String giving (OGIP caldb) coordinate system in
c ICOORD1 i : No. coordinate 1 bins
c COORD1 i : Array containing coord 1 bins
c C1UNITS i : String giving physical units of COORD1 array
c ICOORD2 i : No. coordinate 2 bins
c COORD2 i : Array containing coord 2 bins
c C2UNITS i : String giving physical units of COORD2 array
c IENERG i : No. energy bins
c ENERG_LO i : Array containing lower bound to each energy bin
c ENERG_HI i : Array containing upper bound to each energy bin
c ENUNITS i : String giving physical units of ENERG_LO & HI a
c EAR i : Array containing the full Eff area matrix (cm**
c EARUNITS i : String giving physical units of EAR array
c IERR o : Error Flag (ierr = 0 on successful completion)
c
c User i/ps required (prompted for):
c None
c
c Include files
c None
c
c Called Routines:
c subroutine CRMVBLK : (CALTOOLS) Removes blank from a string
c subroutine CRMVLBK : (CALTOOLS) Removes leading blanks from a st
c subroutine FTBDEF : (FITSIO) Defines the BINTABLE data structur
c subroutine FTCRHD : (FITSIO) Creates a new FITS extension file
c subroutine FTPHBN : (FITSIO) Writes the required header keyword
c subroutine FTPCOM : (FITSIO) Writes a FITS comment keyword
c subroutine FTPCLx : (FITSIO) Writes the data
c subroutine FTPHIS : (FITSIO) Writes a FITS history keyword
c subroutine FTPKYS : (FITSIO) Writes a keyword
c subroutine GT_CSYSNAM : (CALLIB) Returns col names for coord system
c subroutine WT_FERRMSG : (CALLIB) Writes fitsio error message
c
c Compilation & Linking
c link with FITSIO & CALLIB
c
c Origin:
c Original
c
c Authors/Modification History:
c Ian M George (1993 Jan 04), original
c Ian M George (1993 Mar 29), converted to use fcecho etc
character*7 version
parameter (version = '0.9.0')
*-
... OUT OF DATE - to be superceded by wteef1
*+WT_EEF1992a
subroutine wt_eef1992a(ounit, chatter,
& nk_hist, hist,
& nk_comm, comment,
& telescop, instrume, detnam, filter,
& ienerg, energ_lo, energ_hi, enunits,
& coordsys,
& icoord1, coord1, c1units,
& icoord2, coord2, c2units,
& irad, rad_lo, rad_hi, runits,
& ef, efunits, ierr)
IMPLICIT NONE
integer chatter, ierr
integer ounit, nk_hist, nk_comm
integer icoord1, icoord2, ienerg, irad
integer fcstln
real energ_lo(ienerg), energ_hi(ienerg)
real ef(irad,icoord1,icoord2, ienerg)
real coord1(icoord1), coord2(icoord2)
real rad_lo(irad), rad_hi(irad)
character*8 coordsys, c1units, c2units, enunits, runits
character*16 telescop, instrume, detnam, filter
character*80 efunits
character*80 hist(nk_hist), comment(nk_comm)
c
c Description:
c Creates and Writes the EEF PSF extension for
c an EEFVERSN=1992a Encicirled fraction point spread function file.
c Assumes the FITS file is open and has had the Primary Header writte
c !!! Note !!!! File is left open at the end
c and MUST BE CLOSED by FTCLOS
c or ANOTHER EXTENSION ADDED by FTCRHD
c in order to (automatically) write the mandatory END header keyword.
c
c Passed parameters
c OUNIT i : FORTRAN unit number of open output file
c CHATTER i : chattiness flag for o/p (5 quite,10 normal,>20
c NK_HIST i : No. records to be written as HISTORY records
c HIST i : Array of history strings to be written
c NK_COMM i : No. records to be written as COMMENT records
c COMMENT i : Array of comment strings to be written
c TELESCOP i : String listing telescope/mission
c INSTRUME i : String listing instrument/detector
c DETNAM i : String listing specific detector name
c FILTER i : String listing instrument filter in use
c IENERG i : No. energy bins
c ENERG_LO i : Array containing lower bound to each energy bin
c ENERG_HI i : Array containing upper bound to each energy bin
c ENUNITS i : String giving physical units of ENERG_LO & HI a
c COORDSYS i : String giving (OGIP caldb) coordinate system in
c ICOORD1 i : No. coordinate 1 bins
c COORD1 i : Array containing coord 1 bins
c C1UNITS i : String giving physical units of COORD1 array
c ICOORD2 i : No. coordinate 2 bins
c COORD2 i : Array containing coord 2 bins
c C2UNITS i : String giving physical units of COORD2 array
c IRAD i : No. of radial (offset from maximum) coords
c RAD_LO i : Array containing lower radius for each rad bin
c RAD_HI i : Array containing upper radius for each rad bin
c RUNITS i : String giving physical units for RAD_LO & HI ar
c EF i : Array containing the Encirc Fract dataset
c EFUNITS i : String giving physical units of EF array
c IERR o : Error Flag (ierr = 0 on successful completion)
c
c User i/ps required (prompted for):
c None
c
c Include files
c None
c
c Called Routines:
c subroutine CRMVBLK : (CALTOOLS) Removes blank from a string
c subroutine CRMVLBK : (CALTOOLS) Removes leading blanks from a st
c subroutine FTBDEF : (FITSIO) Defines the BINTABLE data structur
c subroutine FTCRHD : (FITSIO) Creates a new FITS extension file
c subroutine FTPHBN : (FITSIO) Writes the required header keyword
c subroutine FTPCOM : (FITSIO) Writes a FITS comment keyword
c subroutine FTPCLx : (FITSIO) Writes the data
c subroutine FTPHIS : (FITSIO) Writes a FITS history keyword
c subroutine FTPKYS : (FITSIO) Writes a keyword
c subroutine GT_CSYSNAM : (CALLIB) Returns col names for coord system
c subroutine WT_FERRMSG : (CALLIB) Writes fitsio error message
c
c Compilation & Linking
c link with FITSIO & CALLIB
c
c Origin:
c Original
c
c Authors/Modification History:
c Ian M George (1993 Jan 04), original
c Ian M George (1993 Mar 29), converted to use fcecho etc
c Ian M George (1993 Jun 18), fixed TDIM bug
character*7 version
parameter (version = '1.0.2')
*-
... OUT OF DATE - to be superceded by wtflt1
*+WT_FLT1992a
subroutine wt_flt1992a(ounit, chatter,
& nk_hist, hist,
& nk_comm, comment,
& telescop, instrume, detnam, filter,
& ienerg, E_lo, E_hi, eunits,
& csys, ipos, x, y, punits,
& trans, ierr)
IMPLICIT NONE
integer chatter, ierr
integer ounit, nk_hist, nk_comm
integer ienerg, ipos
real E_lo(ienerg), E_hi(ienerg)
real x(ipos), y(ipos)
real trans(ienerg, ipos)
character*8 csys
character*20 eunits, punits
character*16 telescop, instrume, detnam, filter
character*80 hist(nk_hist), comment(nk_comm)
c
c Description:
c Creates and Writes the TRANSMISSION extension for an FLTVERSN=1992a
c Assumes the FITS file is open and has had the Primary Header writte
c !!! Note !!!! File is left open at the end
c and MUST BE CLOSED by FTCLOS
c or ANOTHER EXTENSION ADDED by FTCRHD
c in order to (automatically) write the mandatory END header keyword.
c
c Passed parameters
c OUNIT i : FORTRAN unit number of open file
c CHATTER i : chattiness flag for o/p (5 quite,10 normal,>20
c NK_HIST i : No. records to be written as HISTORY records
c HIST i : Array of history strings to be written
c NK_COMM i : No. records to be written as COMMENT records
c COMMENT i : Array of comment strings to be written
c TELESCOP i : String listing telescope/mission
c INSTRUME i : String listing instrument/detector
c DETNAM i : Name of specific detector (if INSTRUME insuffic
c FILTER i : String listing instrument filter in use
c IENERG i : No. energy bins
c E_LO i : Array containing lower bound to each energy bin
c E_HI i : Array containing upper bound to each energy bin
c EUNITS i : Physical units of E_LO & E_HI arrays
c CSYS i : Coordinate system in use
c I_POS i : No. of positional bins
c X i : Array of positions along one axis
c Y i : Array of positions along other axis
c PUNITS i : Physical units of X & Y arrays
c TRANS i : 2-d array of transmission vs energy & position
c IERR o : Error status flag (0 = OK)
c
c User i/ps required (prompted for):
c None
c
c Include files
c None
c
c Called Routines:
c subroutine FCECHO : (FTOOLS) Writes to standard o/p device
c subroutine FTBDEF : (FITSIO) Defines the BINTABLE data structur
c subroutine FTPBNH : (FITSIO) Writes to BINTABLE header keywords
c subroutine FTCRHD : (FITSIO) Creates a new FITS extension file
c subroutine FTPCOM : (FITSIO) Writes a FITS comment keyword
c subroutine FTPCLx : (FITSIO) Writes the data
c subroutine FTPHIS : (FITSIO) Writes a FITS history keyword
c subroutine FTPKYx : (FITSIO) Writes a keyword
c subroutine GT_CSYSNMS : (CALLIB) Gets col/key names for coord syste
c subroutine RMVLBK : (XANLIB) Removes leading blanks from string
c subroutine WT_FERRMSG : (CALLIB) Writes FITSIO error message etc
c
c Compilation & Linking
c link with XANLIB & FITSIO & CALLIB & FTOOLS
c
c Origin:
c Original
c
c Authors/Modification History:
c Ian M George (1993 Feb 22), original
character*7 version
parameter (version = '1.0.0')
*-
... wtpha1 is a more general routine,this has been written with specific task needs.
*+WT_SPEC
c --------------------------------------------------------------
subroutine wt_spec(infile,outfile,hduclas2,phaversn,fchan,
& channel,counts,rcts,dtype,qerror,serr,
& qsys,syserr,qqual,qualty,qgroup,grping,
& nchan,detchans,conv,phsize,specext,mnver,task
& n_comm,comms,ckeys,ckrec,nckeys,errflg,chatte
c --------------------------------------------------------------
c
c --- DESCRIPTION -------------------------------------------------
c
c This subroutine writes the SPECTRUM extension with the current
c changes. It is appended onto the Primary Header. In OGIP standard
c
c --- VARIABLES ---------------------------------------------------
c
IMPLICIT NONE
character*(*) infile,outfile,ckeys(*),ckrec(*)
character*(*) task, comms(*), hduclas2, phaversn
integer phsize,nchan,chatter,specext,nckeys,n_comm,fchan
integer channel(phsize),counts(phsize),qualty(phsize)
integer grping(phsize),dtype,errflg,detchans
integer*2 conv(phsize)
real serr(phsize),syserr(phsize),rcts(phsize)
logical qerror,qsys,qqual,qgroup
character*5 mnver
c
c --- INTERNALS ---------------------------------------------------
c
character*70 subinfo
character*8 key,keys(40),keyval
character*5 hduvers1
character*80 rec,hist,temprec
character*28 errstr,wrnstr,taskname
integer nfields,status,keyspres,lchan
parameter (nfields = 6)
character*16 ttype(nfields),tform(nfields),tunit(nfields)
integer i,rw,block,nkeys,nmore,key_val,vd,step,j
integer htype,frow,felem,colnum,iunit,ounit,iend,tfields
logical man_key,at_end,chkey
c
c --- VARIABLE DIRECTORY ------------------------------------------
c
c Arguments ...
c
c infile char : PHA filename, user defined
c outfile char : Output filename, user defined
c chatter int : Chattines flag
c phsize int : Array dimensions
c channel int : Array of detector channels
c dtype int : Datatype, 1 if counts, 2 is rcts
c counts int : Array of observed counts
c rcts real : Array of count rate
c qualty int : Array of qualty flag
c grping int : Array of grouping flag
c serr real : Array of Observed statistical errors
c syserr real : Array of Fractional systematic error
c qgroup logical: True if data is grouped
c qqual logical: True if data has qualty flags
c qerror logical: True if statistical errors included
c qsys logical: True if systematic errors included
c ckeys char : Keywords that can have their values changed
c ckrec char : Records of ckeys
c nckeys int : counter for above
c
c --- CALLED ROUTINES ---------------------------------------------
c
c FTOPEN : (FITSIO) Opens FITS file
c FTCRHD : (FITSIO) Creates header
c FTMAHD : (FITSIO) Move to specified header number
c FTMRHD : (FITSIO) Move a specified number of headers
c forward or backward
c FTGHSP : (FITSIO) Obtain the number of keywords
c FTPHIS : (FITSIO) Write history keywords
c FTBDEF : (FITSIO) Define Binary header
c FTPCL(IE) : (FITSIO) Write (integer real) column
c FTCLOS : (FITSIO) Close FITS FILE
c
c --- AUTHORS/MODIFICATION HISTORY --------------------------------
c
c Rehana Yusaf (1993 April 7)
c Rehana Yusaf (1993 June 23) : Add history about this routine
c Rehana Yusaf (1993 July 6) : CKEYS, and CKREC are used
c Rehana Yusaf (1993 July 19) : Comment array is passed to routine
c Rehana Yusaf (1993 August 6) (1.0.4): Use FTPREC instead of CFTPREC,
c illegal characters in comments or
c history, no longer supported
c Rehana Yusaf (1993 Nov 18) 1.0.5; hduclas2,phaversn, detchans and
c fchan are passed to this subroutine
c In addition new keyword CREATOR is
c used to write taskname and version
character*5 version
parameter (version = '1.0.5')
*-
*+WTARF1
subroutine wtarf1(ounit, chatter,
& nk_hist, hist,
& nk_comm, comment,arfversn,phafil,
& telescop, instrume, detnam, filter,
& maxen, ienerg, energ_lo, energ_hi,
& sprsp, ierr)
IMPLICIT NONE
integer chatter, ierr,maxen
integer ounit, nk_hist, nk_comm
integer ienerg
real energ_lo(maxen), energ_hi(maxen)
real sprsp(maxen)
character*5 arfversn
character*20 telescop, instrume, detnam, filter
character*70 hist(*), comment(*), phafil
c
c Description:
c Creates and Writes the SPECRESP extension for an ARF file one of th
c conforming to the HDUVERS2='1.*.*' family.
c Currently the following formats are supported (see OGIP/92-002a)
c HDUVERS2 = '1.0.0'
c HDUCERS2 = '1.1.0'
c The requested format is checked, and if belonging to the '1.*.*' fam
c but not included above, the extension is written in the last format
c Assumes the FITS file is open and has had the Primary Header writte
c !!! Note !!!! File is left open at the end
c and MUST BE CLOSED by FTCLOS
c or ANOTHER EXTENSION ADDED by FTCRHD
c in order to (automatically) write the mandatory END header keyword.
c
c Passed parameters
c OUNIT i : FORTRAN unit number of open RMF file
c CHATTER i : chattiness flag for o/p (5 quite,10 normal,>20
c NK_HIST i : No. records to be written as HISTORY records
c HIST i : Array of history strings to be written
c NK_COMM i : No. records to be written as COMMENT records
c COMMENT i : Array of comment strings to be written
c ARFVERSN i : String denoting OGIP HDUVERS2 family
c TELESCOP i : String listing telescope/mission
c INSTRUME i : String listing instrument/detector
c DETNAM i : String listing specific detector name
c FILTER i : String listing instrument filter in use
c MAXEN i : Maximum Energy index array dimension
c IENERG i : No. energy bins
c ENERG_LO i : Array containing lower bound to each energy bin
c ENERG_HI i : Array containing upper bound to each energy bin
c SPRSP i : Array containing the specresp dataset
c IERR o : Error flag (0 = OK)
c
c Called Routines:
c subroutine CRMVBLK : (CALLIB) Removes blanks from a string
c subroutine FCECHO : (FTOOLS) Writes to standard o/p device
c subroutine FTBDEF : (FITSIO) Defines the BINTABLE data structur
c subroutine FTCRHD : (FITSIO) Creates a new FITS extension file
c subroutine FTPHBN : (FITSIO) Writes the required header keyword
c subroutine FTPCOM : (FITSIO) Writes a FITS comment keyword
c subroutine FTPCLx : (FITSIO) Writes the data
c subroutine FTPHIS : (FITSIO) Writes a FITS history keyword
c subroutine FTPKYS : (FITSIO) Writes a keyword
c subroutine WT_FERRMSG : (CALLIB) Writes FITSIO error message etc
c
c Compilation & Linking
c link with FITSIO & CALLIB & FTOOLS
c
c Origin:
c Code mostly hacked from within the BBRSP program
c
c Authors/Modification History:
c Ian M George (1.0.0: 1993 Oct 17), original "proper" version
character*7 version
parameter (version = '1.0.0')
*-
*+WTEBD1
subroutine wtebd1(ounit, chatter,
& nk_hist, hist,
& nk_comm, comment,rmfversn,
& telescop, instrume, detnam, filter, areascal,
& iebound, e_min, e_max, ierr)
IMPLICIT NONE
integer chatter, ierr
integer ounit, nk_hist, nk_comm
integer iebound
real areascal
real e_min(*), e_max(*)
character*5 rmfversn
character*16 telescop, instrume, detnam, filter
character*70 hist(*), comment(*)
c
c Description:
c Creates and Writes the EBOUNDS extension for an RMF file one of the
c conforming to the HDUVERS2='1.*.*' family.
c Currently the following formats are supported (see OGIP/92-002a)
c HDUVERS2 = '1.0.0'
c HDUCERS2 = '1.1.0'
c The requested format is checked, and if belonging to the '1.*.*' fam
c but not included above, the extension is written in the last format
c Assumes the FITS is open and has had the Primary Header written
c !!! Note !!!! File is left open at the end
c and MUST BE CLOSED by FTCLOS
c or ANOTHER EXTENSION ADDED by FTCRHD
c in order to (automatically) write the mandatory END header keyword.
c
c Passed parameters
c OUNIT i : FORTRAN unit number of open RMF file
c CHATTER i : chattiness flag for o/p (5 quite,10 normal,>20
c NK_HIST i : No. records to be written as HISTORY records
c HIST i : Array of history strings to be written
c NK_COMM i : No. records to be written as COMMENT records
c COMMENT i : Array of comment strings to be written
c RMFVERSN i : String denoting OGIP HDUVERS2 family
c TELESCOP i : String listing telescope/mission
c INSTRUME i : String listing instrument/detector
c DETNAM i : String listing specific detector name
c FILTER i : String listing instrument filter in use
c AREA i : Area scaling factor
c IEBOUND i : No. channels in the full array
c E_MIN i : Array containing min nominal energy bound to ea
c E_MAX i : Array containing max nominal energy bound to ea
c IERR o : Error Flag (0=OK)
c
c User i/ps required (prompted for):
c None
c
c Include files
c None
c
c Called Routines:
c subroutine FCECHO : (FTOOLS) writes to standard o/p unit
c subroutine FTBDEF : (FITSIO) Defines the BINTABLE data structur
c subroutine FTCRHD : (FITSIO) Creates a new FITS extension file
c subroutine FTPHBN : (FITSIO) Writes the required header keyword
c subroutine FTPCOM : (FITSIO) Writes a FITS comment keyword
c subroutine FTPCLx : (FITSIO) Writes the data
c subroutine FTPHIS : (FITSIO) Writes a FITS history keyword
c subroutine FTPKYS : (FITSIO) Writes a keyword
c subroutine WT_FERRMSG : (CALLIB) Dumps FITSIO Error message etc
c
c Compilation & Linking
c link with FITSIO & CALLIB & FTOOLS
c
c Origin:
c Code mostly hacked from within the BBRSP program
c
c Authors/Modification History:
c Alan Smale (1992 Sept/Oct), original BBRSP version
c Ian M George (1.0.0; 1992 Dec 31), tidied-up version
c Ian M George (1.0.1; 1993 Feb 16), replaced write(5,*) with FCE
c Ian M George (1.0.2: 1993 Feb 28), minor debug of History Recor
c Ian M George (1.0.3; 1993 May 19), hist & comment made chara*70
c Rehana Yusaf (1.0.4; 1993 July 26), e_min,e_max array dimension
c changed to *
c Ian M George (2.0.0: 1993 Oct 14), renamed from wt_ebd1992a & m
c overhaul of HDUCLAS/VERS stuff
c Rehana Yusaf (2.0.1; 1993 Nov 10), only wqarn about rmfversn no
c being 1.0.0 or 1.1.0 at high
character*7 version
parameter (version = '2.0.1')
*-
*+WTEXM1
c ------------------------------------------------------------
subroutine wtexm1(ounit,telescop,instrum,detnam,filter,
& deadapp,vignapp,radecsys,equinox,ctype1,
& ctype2,crpix1,crpix2,cunit1,cunit2,bunit,
& crval1,crval2,cdelt1,cdelt2,
& map_max,exparr,chatter,errflg)
c ------------------------------------------------------------
c --- DESCRIPTION ----------------------------------------------------
c
c This routine writes Exposure Map data in the form of a Primary Array
c It assumes the file is already open ...
c use FTCLOS to close the file OR write another extension
c Format ...
c
c HDUCLASS OGIP
c HDUCLAS1 IMAGE
c HDUCLAS2 EXPOSURE
c HDUVERS1 1.0.0
c HDUVERS2 1.0.0
c
c Additional (non-mandantory) Keywords written ...
c
c TELESCOP : Mission/Telescope name
c INSTRUME : Instrument name
c DETNAM : Specific detector name in use
c FILTER : Filter in use
c DEADAPP : Deadtime correction applied
c VIGNAPP : Vignetting correction applied
c RADECSYS : WCS for this file
c EQUINOX : Equinox (Epoch) for this file
c CTYPE1 : Axis type for dim 1
c CTYPE2 : Axis type for dim 2
c CRPIX1 : x pixel of tangent plane direction
c CRPIX2 : y pixel of tangent plane direction
c CRVAL1 : sky coordinate of 1st axis (deg)
c CRVAL2 : sky coordinate of 2nd axis (deg)
c CUNIT1 : units of dim 1
c CUNIT2 : units of dim 2
c CDELT1 : x degrees per pixel
c CDELT2 : y degrees per pixel
c BUNIT : Units of exposure map data
c DATAMIN : Minimum value in image
c DATAMAX : Maximum value in image
c
c
c --- VARIABLES ------------------------------------------------------
c
IMPLICIT NONE
character*(*) telescop,instrum,detnam,filter,radecsys
character*(*) cunit1,cunit2,ctype1,ctype2,bunit
real equinox,crval1,crval2,cdelt1,cdelt2
real crpix1,crpix2
integer ounit
integer map_max,chatter,errflg
real*4 exparr(map_max,map_max)
logical deadapp,vignapp
c
c --- CALLED ROUTINES ------------------------------------------------
c
c FTPPRH : (FITSIO) Writes Primary array keywords
c FTPDEF : (FITSIO) Defines primary array
c FTP2DE : (FITSIO) Writes primary array
c FTPKYx : (FITSIO) Writes keyword
c
c --- AUTHORS/MODIFICATION HISTORY -----------------------------------
c
c Rehana Yusaf (Oct 5 1993) 1.0.0;
c Rehana Yusaf (Nov 11 1993) 1.0.1; Additional keywords section added
c
character*5 version
parameter (version = '1.0.1')
*-
*+WTPHA1
subroutine wtpha1(ounit,chatter,nk_hist,hist,nk_comm,
& comment,telescop,instrume,detnam,filter,
& phaversn,hduclas2,fchan,
& texpos,areascal,backfil,backscal,corrfil,
& corrscal,respfil,ancrfil,detchans,chantyp,
& channel,counts,dtype,qerror,serr,qsys,
& syserr,qqual,qualty,qgroup,grping,nchan,
& ierr)
IMPLICIT NONE
integer ounit,chatter,nk_hist, nk_comm
integer detchans, dtype, nchan, ierr
integer channel(detchans),qualty(detchans),grping(detchans)
integer fchan
real texpos,areascal,backscal,corrscal
real counts(detchans), serr(detchans), syserr(detchans)
character*5 phaversn
character*16 telescop,instrume,detnam,filter
character*16 chantyp
character*20 hduclas2
character*70 hist(nk_hist), comment(nk_comm)
character*70 backfil,corrfil,respfil,ancrfil
logical qerror,qsys,qqual,qgroup
c
c Description
c This subroutine writes the SPECTRUM extension for a PHA file in
c one of the formats conforming to the HDUVERS1='1.*.*' family.
c Currently the following formats are supported (see OGIP/92-007a)
c HDUVERS1 = '1.0.0'
c HDUVERS1 = '1.1.0'
c The requested format is checked, and if belonging to the '1.*.*' fam
c but not included above, the extension is written in the last format
c !!! Note !!! the o/p file is assumed to have been opened, and wound
c desired location. The file is left open at the end of t
c newly written SPECTRUM extension on return and MUST be
c using FTCLOS or another extension written starting with
c in order that the mandatory END keyword is written
c In all cases, the 1.*.* family of formats consists of a BINTABLE ext
c with the number of rows equal to the number of channels passed (this
c not have to be the total number of detector channels the instrument
c capable of).
c
c Passed Parameters
c OUNIT i : FORTRAN unit number of open PHA file
c CHATTER i : chattiness flag for o/p (5 quite,10 norm,>19 sil
c NK_HIST i : No. records to be written as HISTORY records
c HIST i : Array of history record strings to be written
c NK_COMM i : No. records to be written as COMMENT records
c COMMENT i : Array of comment record strings to be written
c TELESCOP i : String giving telescope/mission
c INSTRUME i : String giving instrument/detector name
c DETNAM i : String giving specific detector name/code (if an
c FILTER i : String giving instrument filetr in use (if any)
c PHAVERSN i : String denoting OGIP HDUVERS1 family
c HDUCLAS2 i : String containing HDUCLAS2 value
c FCHAN i : First legal channel number (ie 0, 1 etc)
c TEXPOS i : exposure (Live) time
c AREASCAL i : area scaling factor
c BACKFIL i : associated background filename
c BACKSCAL i : background scaling factor
c CORRFIL i : associated correction filename
c CORRSCAL i : correction scaling factor
c RESPFIL i : detector redistribution matrix file (RMF)
c ANCRFIL i : ancillary response file (ARF)
c DETCHANS i : total number of possible detector channels
c CHANTYP i : type of detector channels (PHA, PI etc)
c CHANNEL i : array of detector channel numbers
c COUNTS i : array of obs'd counts (or count rate) per chan
c DTYPE i : flag to denote counts (1) or count rates (2)
c QERROR i : flag as to whether stat errors passed down
c SERR i : array of statistical errors on COUNTS (for QERRO
c QSYS i : flag as to whether systematic errors passed down
c SYSERR i : array of systematic errors on COUNTS (for QSYS=T
c QQUAL i : flag as to whether quality array passed down
c QUALTY i : array of quality flags (for QQUAL=T)
c QGROUP i : flag as to whether grouping array passed down
c GRPING i : array of quality flags (for QGROUP=T)
c NCHAN i : No. channels actually passed down
c IERR o : Error Flag (0=OK)
c
c Format Written
c Each row consists of the following columns/contents:
c CHANNEL - (int) the channel number
c either: COUNTS - (int) the number of counts/channel
c or RATE - (real) the number of counts/channel/second
c STAT_ERR- (real) the statistical error on COUNTS or RATE
c SYS_ERR - (real) the fractional systematic error on COUNTS or RATE
c QUALITY - (int) quality flag for the data in channel
c GROUPING- (int) gropuing flag for this channel
c If all the rows would contain the same value in the STAT_ERR,SYS_ERR
c QUALITY or GROUPING columns, then that column is not written and t
c value supplied by a header keyword instead.
c
c The following keywords are written:
c HDUCLASS='OGIP'-indicating the format conforms to OGIP standards
c HDUCLAS1='SPECTRUM' - indicating major class in the heirarchy
c HDUVERS1- (passed) The phaversn to be written (must in '1.*.*' fami
c HDUCLAS2- (passed) - Whether the spectrum is srce, bkgd, or both
c HDUCLAS3- Indicating whether the data are stored as counts of count
c TELESCOP- The mission/satellite name'
c INSTRUME- The instrument/detector name'
c DETNAM - The sub-detector in use
c FILTER - The name of the filter in use
c EXPOSURE- The exposure time (or "live-time") in seconds
c AREASCAL- The area scaling factor
c BACKFIL - The name of the associated background file
c BACKSCAL- The background file scaling factor
c CORRFIL - The name of the associated correction file
c CORRSCAL- The correction file scaling factor
c RESPFILE- The name of the associated redistrib matrix file
c ANCRFILE- The name of the associated ancillary response file
c PHAVERSN='1992a' - The OGIP classification of FITS format
c DETCHANS- The total number possible detector channels
c CHANTYPE- The channel type (PHA, PI etc)
c POISSERR- Logical as the whether poissonian errors are to be assume
c
c Called routines etc
c subroutine FCECHO : (FTOOLS) Writes to standard o/p
c subroutine FTOPEN : (FITSIO) Opens FITS file
c subroutine FTCRHD : (FITSIO) Creates header
c subroutine FTMAHD : (FITSIO) Move to specified header number
c subroutine FTMCOM : (FITSIO) Modify comment of existing keywo
c subroutine FTMRHD : (FITSIO) Move a specified number of heade
c subroutine FTGHSP : (FITSIO) Obtain the number of keywords
c subroutine FTPHIS : (FITSIO) Write history keywords
c subroutine FTBDEF : (FITSIO) Define Binary header
c subroutine FTPCLn : (FITSIO) Write FITS column of type n
c subroutine FTCLOS : (FITSIO) Close FITS FILE
c subroutine WT_FERRMSG : (CALLIB) writes FITSIO error message
c
c Authors/modification history
c Rehana Yusaf (1.0.0: 1993 April 7), original based on KAAs routine
c Ian M George (1.1.0: 1993 Jun 02), made more general for incl in C
c Ian M George (1.2.0: 1993 Oct 08), added the HDUCLASn & HDUVERSn s
c Ian M George (2.0.0: 1993 Oct 12), renamed from wt_pha1992a & majo
c overhaul of HDUCLAS/VERS stuff
c Ian M George (2.0.1: 1993 Oct 21), minor changes required by OFSP
c Ian M George (3.0.0: 1993 Oct 22), added the fchan passed paramete
character*5 version
parameter (version = '3.0.0')
*-
*+WTRMF1
subroutine wtrmf1(ounit, chatter,
& nk_hist, hist,
& nk_comm, comment,rmfversn, hduclas3,
& telescop, instrume, detnam, filter, areascal,
& maxchan, ichan, maxen, ienerg, energ_lo, energ_hi,
& imaxgrp, ngrp, F_chan, N_chan,
& fmatrix, lo_thresh, ierr)
IMPLICIT NONE
integer chatter, ierr,maxchan,maxen
integer ounit, nk_hist, nk_comm
integer ichan, ienerg, imaxgrp
integer ngrp(maxen), F_chan(maxen,*)
integer N_chan(maxen,*)
real areascal, lo_thresh
real energ_lo(maxen), energ_hi(maxen)
real fmatrix(maxchan,maxen)
character*5 rmfversn
character*16 telescop, instrume, detnam, filter
character*20 hduclas3
character*70 hist(*), comment(*)
c
c Description:
c Creates and Writes the RMF extension for an RMF file one of the for
c conforming to the HDUVERS2='1.*.*' family.
c Currently the following formats are supported (see OGIP/92-002a)
c HDUVERS2 = '1.0.0'
c HDUCERS2 = '1.1.0'
c The requested format is checked, and if belonging to the '1.*.*' fam
c but not included above, the extension is written in the last format
c Assumes the FITS file is open and has had the Primary Header writte
c !!! Note !!!! File is left open at the end
c and MUST BE CLOSED by FTCLOS
c or ANOTHER EXTENSION ADDED by FTCRHD
c in order to (automatically) write the mandatory END header keyword.
c For The matrix will be written as a VARIABLE LENGTH ARRAY if the re
c in storage requirements (ie total number of stroed values) exceeds
c factor 3.0 over that obtained using a FIXED length array.
c
c Passed parameters
c OUNIT i : FORTRAN unit number of open RMF file
c CHATTER i : chattiness flag for o/p (5 quite,10 normal,>20
c NK_HIST i : No. records to be written as HISTORY records
c HIST i : Array of history strings to be written
c NK_COMM i : No. records to be written as COMMENT records
c COMMENT i : Array of comment strings to be written
c RMFVERSN i : String denoting OGIP HDUVERS2 family
c HDUCLAS3 i : String containing HDUCLAS3 value
c TELESCOP i : String listing telescope/mission
c INSTRUME i : String listing instrument/detector
c DETNAM i : String listing specific detector name
c FILTER i : String listing instrument filter in use
c AREASCAL i : Area scaling factor
c MAXCHAN i : Maximum Channel index array dimension
c ICHAN i : No. channels in the full array
c MAXEN i : Maximum Energy index array dimension
c IENERG i : No. energy bins
c ENERG_LO i : Array containing lower bound to each energy bin
c ENERG_HI i : Array containing upper bound to each energy bin
c NGRP i : Array containing no. channel subsets at each en
c IMAXGRP i : Max no. grps in any given row
c F_CHAN i : Array containing 1st chan of each subset at eac
c N_CHAN i : Array containing no. chans within each subset
c at each energy
c FMATRIX i : Array containing the full matrix
c LO_THRESH i : The lower threshold used to construct the matri
c IERR o : Error flag (0 = OK)
c
c Called Routines:
c subroutine CRMVBLK : (CALLIB) Removes blanks from a string
c subroutine FCECHO : (FTOOLS) Writes to standard o/p device
c subroutine FTBDEF : (FITSIO) Defines the BINTABLE data structur
c subroutine FTCRHD : (FITSIO) Creates a new FITS extension file
c subroutine FTPHBN : (FITSIO) Writes the required header keyword
c subroutine FTPCOM : (FITSIO) Writes a FITS comment keyword
c subroutine FTPCLx : (FITSIO) Writes the data
c subroutine FTPHIS : (FITSIO) Writes a FITS history keyword
c subroutine FTPKYS : (FITSIO) Writes a keyword
c subroutine WT_FERRMSG : (CALLIB) Writes FITSIO error message etc
c
c Compilation & Linking
c link with FITSIO & CALLIB & FTOOLS
c
c Origin:
c Code mostly hacked from within the BBRSP program
c
c Authors/Modification History:
c Alan Smale (1992 Sept/Oct), original BBRSP version
c Ian M George (1.0.1; 1992 Dec 29), tidied-up version
c Ian M George (1.0.2; 1993 Feb 28), minor debugging of History r
c Ian M George (1.0.3; 1993 May 19), hist & comment made chara*70
c Rehana Yusaf (1.0.4; 1993 July 27), array dimensions changed fr
c hard coded to using new argu
c MAXCHAN and MAXEN
c Ian M George (1.1.0; 1993 Jul 30), cosmetics
c Ian M George (2.0.0; 1993 Sep 03), added variable length arrays
c Ian M George (2.1.0; 1993 Oct 12), added HDUCLASn stuff
c Ian M George (3.0.0: 1993 Oct 13), renamed from wt_rmf1992a & m
c overhaul of HDUCLAS/VERS stuff
c Rehana Yusaf (3.0.1; 1993 Nov 10), minor change - only warn abo
c rmfversn not being 1.0.0 or
c at high chatter
character*7 version
parameter (version = '3.0.1')
*-
*+WTRPF1
c ------------------------------------------------------------
subroutine wtrpf1(ounit,extname,hduclas3,nrad,rad_lo,rad_hi,
& radunit,ntheta,theta_lo,theta_hi,thetaunit,
& nenerg,energ_lo,energ_hi,energunit,
& rpsf,qerror,rpsf_err,rpsfunit,qarea,
& area_wgt,hist,nk_hist,comms,
& nk_comm,telescop,instrume,maxrad,maxtheta,
& ierr,chatter)
c ------------------------------------------------------------
c
c ___ DESCRIPTION ____________________________________________________
c
c This routine writes a FITS extension in OGIP RPSF HDUVERS1 1.0.0 for
c
c HDUCLASS = OGIP
c HDUCLAS1 = RESPONSE
c HDUCLAS2 = RPRF
c HDUCLAS3 = PREDICTED
c TOTAL
c NET (background = 0)
c HDUVERS1 = 1.0.0
c HDUVERS2 = 1.0.1
c
c This routine can write one or more radial profile, at one or more
c theta, and energy values. The data is written as vectors for concise
c
c NOTE : Assumes FITS file is open and has had the primary header writ
c File is left open at end ... use FTCLOS to close file
c ... or FTCRHD to add another extensi
c Columns written are ...
c
c RAD_LO : Lower edge of radial bins
c RAD_HI : Upper edge of radial bins
c THETA_LO : Lower bound for off_axis angle, if single value, it is
c written as keyword
c If value is not defined pass -99
c THETA_HI : Upper bound for off_axis angle, if single value, it is
c written as keyword
c If value is not defined pass -99
c ENERG_LO : Low energy bound, if single value, it is
c written as keyword
c If value is not defined pass -99
c ENERG_HI : High energy bound, if single value, it is
c written as keyword
c If value is not defined pass -99
c RPSF : Radial Point Spread function,
c 3D array-RPSF(irad,itheta,ien)
c RPSF_ERR : Error on RPSF, 3D array - RPSF_ERR(irad,itheta,ien)
c if there is a consistent error it is written as keywor
c if this is not supplied pass qerror as false
c default value is 0.
c AREA_WGT : Area weighting factor, 3D - AREA_WGT(irad,itheta,ien)
c if this is not supplied pass qarea as false.
c Default value is 1.0
c
c Keywords are ...
c
c RPSFVER : Routine version
c TELESCOP : Mission/Telescope name (if not known, pass 'UNKNOWN')
c INSTRUME : Instrument/Detector name (if not known, pass 'UNKNOWN'
c HDUCLASS : HDU 'family' keywords
c DATE
c
c History comments are written if passed to routine
c Comments are written if passed to routine
c
c ___ VARIABLES ______________________________________________________
c
IMPLICIT NONE
integer nrad,nenerg,ntheta,ounit,ierr,maxrad,maxtheta
character*(*) radunit,thetaunit,energunit,rpsfunit
character*(*) telescop,instrume,extname,hduclas3
real rad_lo(maxrad),rad_hi(maxrad),area_wgt(maxrad,maxtheta,*)
real theta_lo(maxtheta), theta_hi(maxtheta)
real energ_lo(*),energ_hi(*)
real rpsf(maxrad,maxtheta,*),rpsf_err(maxrad,maxtheta,*)
integer nk_hist,chatter,nk_comm
character*80 hist(*),comms(*)
logical qarea,qerror
c
c --- VARIABLE DIRECTORY ---------------------------------------------
c
c Arguments ...
c
c maxrad int : Array dimensions for radial profile data
c maxtheta int : Array dimensions for theta data
c rad_lo real : Array of lower edge of radial bins
c rad_hi real : Array of upper edge of radial bins
c theta_lo real : Array of lower theta bounds for radial profiles
c theta_hi real : Array of upper theta bounds for radial profiles
c energ_lo real : Array of lower energy bound
c energ_hi real : Array of upper energy bound
c radunit char : radial bins unit
c thetaunit char : Unit for theta angles
c energunit char : Unit for energy
c qarea logical: False if area_wgt not passed
c qerror logical: False if rpsf_err not passed
c ounit int : Fortran output unit
c nk_hist int : No of lines of history comments (max is maxhist)
c nk_comm int : No of lines of comments
c hist char : History array, containing comments
c comms char : Comment array
c telescop char : Mission/Telescope name
c instrume char : Instrument/Detector name
c hduclas3 char : Approved values are PREDICTED, TOTAL or NET
c chatter int : chattiness flag for o/p (5 quite,10 normal,>20 s
c
c --- CALLED ROUTINES ------------------------------------------------
c
c subroutine FTCRHD : (FITSIO) Creates new FITS extension
c subroutine FTPBNH : (FITSIO) Writes required header keywords
c subroutine FTBDEF : (FITSIO) Defines the BINTABLE data structu
c subroutine FTPCLx : (FITSIO) Writes the data, here ftpcle and
c ftpclj, x is the datatype
c subroutine WT_FERRMSG : (CALLIB) Writes error text if required
c
c --- COMPILATION AND LINKING ----------------------------------------
c
c Link with FITSIO and CALLIB
c
c --- AUTHORS/MODIFICATION HISTORY -----------------------------------
c
c Rehana Yusaf (1993 September) 1.0.0;
c Rehana Yusaf (1994 Jan 14) 1.0.1; Add HDUCLASS/HDUVERS keywords
character*5 version
parameter ( version = '1.0.1' )
*-
List of currently available and planned CALLIB routines concerning the reading of datasets etc. in standard formats are given in Tables 3 & 4 respectively.
*+RDARF1
c --------------------------------------------------------
subroutine rdarf1(iunit,chatter,
& telescop,instrume,detnam,filter,
& iebound,e_lo,e_hi,sprsp, arfversn,ierr)
c --------------------------------------------------------
IMPLICIT NONE
integer chatter, ierr
integer iunit
integer iebound
real e_lo(*), e_hi(*)
real sprsp(*)
character*5 arfversn
character*20 telescop, instrume, detnam, filter
c --- DESCRIPTION ----------------------------------------------------
c Reads the SPECRESP extension for an ARFVERSN=1992a ARF file
c Assumes the extension conforms to HDUVERS2='1.*.*' family
c Currently the following formats are supported -
c HDUVERS2='1.0.0'
c HDUVERS2='1.1.0'
c see OGIP/92-002a
c The HDU CLASS keywords have only been currently introduced thus DO N
c have to be present to use this reader.
c
c Assumes the FITS is open.
c !!! Note !!!! File is left open at the end
c ... close file using FTCLOS, or
c ... read another extension
c
c Columns read are ...
c ENERG_LO : lower energy bound
c ENERG_HI : upper energy bound
c SPECRESP : Spectral Response
c
c Keywords read ...
c TELESCOP : Mission/Telescope name, NOTE: If not present set to UNKN
c INSTRUME : Instrument/Detector name NOTE: If not present set to UNK
c DETNAM : Specific detector name NOTE: If not present set to NONE
c FILTER : Filter in use, if not present set to NONE
c ARFVERSN : RMF version
c
c Passed Paramters
c IUNIT i : FORTRAN unit number of open RMF file
c CHATTER i : chattiness flag for o/p (0 quite,10 normal,>20
c TELESCOP o : String listing telescope/mission
c INSTRUME o : String listing instrument/detector
c DETNAM o : String listing specific detector name
c FILTER o : String listing instrument filter in use
c AREA o : Area scaling factor
c IEBOUND o : No. channels in the full array
c CHANNEL o : Channel array
c E_MIN o : Array containing min nominal energy bound to ea
c E_MAX o : Array containing max nominal energy bound to ea
c RMFVERSN o : RMF version
c IERR o : Error Flag, ierr = 0 okay
c
c CALLED ROUTINES
c subroutine FTMRHD : (FITSIO) Move to extension
c subroutine FTGKYS : (FITSIO) Read FITS extension header keyword
c subroutine FTGCNO : (FITSIO) Get column number
c subroutine FTGCVx : (FITSIO) Read data in x format
c subroutine WT_FERRMSG : (CALLIB) Dumps FITSIO Error message etc
c
c Compilation & Linking
c link with FITSIO & CALLIB & FTOOLS
c
c Authors/Modification History:
c Ian M George (93 Nov 16) Original
character*7 version
parameter (version = '1.0.0')
*-
*+RDATRD
c -------------------------------------------------------------
subroutine rdatrd(iunit,n_att,max_att,time,roan_cas,
& ra_cas,dec_cas,chatter,ierr)
c -------------------------------------------------------------
c
c ___ DESCRIPTION ____________________________________________________
c
c This subroutine reads a FITS RDF format Attitude (ASPECT) extension
c NOTE : Assumes file is already open at the desired extension.
c ... close file at end, using FTCLOS, or
c ... read another extension
c
c Columns read are ...
c
c TIME : Time of corected aspect in full seconds
c ROAN_CAS : Corrected Roll angle
c RA_CAS : X-translation in NS-system
c DEC_CAS : Y-translation in NS-system
c
c ___ VARIABLES ______________________________________________________
c
IMPLICIT NONE
integer iunit,max_att,n_att,ierr,chatter
real*8 time(max_att),roan_cas(max_att)
real*8 ra_cas(max_att),dec_cas(max_att)
c
c --- VARIABLE DIRECTORY ---------------------------------------------
c
c Arguments ...
c
c max_att int : Array dimensions
c iunit int : Fortran unit number for file
c chatter int : Chatter flag ( <5 quiet,>5 normal,>20 noisy)
c n_att int i/r: Counter attitude data (IF NE 0 on entry then tha
c many attitude entries already assumed to have been
c read in [from previous extensions])
c time int : Array of corrected aspect
c roan_cas int : Array of roll angle
c ra_cas int : Array of X-translation in NS-system
c dec_cas int : Array of Y-translation in NS-system
c ierr int : Error flag, ierr = 0 okay
c ierr = 107/207 error finding extensi
c ierr = 2 Column/keyword number not f
c ierr = 3 Error in reading data
c ierr = 4 Mandatory keyword not found
c
c --- CALLED ROUTINES ------------------------------------------------
c
c subroutine FTMAHD : FITSIO routine to move to extension header
c subroutine FTGKYj : FITSIO routine to read extension header key
c where the j, is for an integer
c subroutine FTGKNS : FITSIO routine to read extension header key
c where a rootstring is given, thus an array
c keywords can be read
c subroutine FCECHO : FTOOLS routine to write to screen
c subroutine WT_FERRMSG : Writes FITSIO error text if required
c
c --- COMPILATION AND LINKING ----------------------------------------
c
c Link with FTOOLS - FITSIO, CALLIB
c
c --- AUTHORS/MODIFICATION HISTORY -----------------------------------
c
c Rehana Yusaf (Oct 1 1993) 1.0.0; rdatrd.f used as a basis
c
character*5 version
parameter (version = '1.0.0' )
*-
*+RDEBD1
c --------------------------------------------------------
subroutine rdebd1(iunit,chatter,
& telescop,instrume,detnam,filter,areascal,
& iebound,channel,e_min,e_max,rmfversn,ierr)
c --------------------------------------------------------
c --- DESCRIPTION ----------------------------------------------------
c
c Reads the EBOUNDS extension for an RMFVERSN=1992a RMF file
c Assumes the extension conforms to HDUVERS2='1.*.*' family
c Currently the following formats are supported -
c HDUVERS2='1.0.0'
c HDUVERS2='1.1.0'
c see OGIP/92-002a
c The HDU CLASS keywords have only been currently introduced thus DO N
c have to be present to use this reader.
c
c Assumes the FITS is open.
c !!! Note !!!! File is left open at the end
c ... close file using FTCLOS, or
c ... read another extension
c
c Columns read are ...
c
c CHANNEL : Channel numbers
c E_MIN : Nominal lower energy bound
c E_MAX : Nominal upper energy bound
c
c Keywords read ...
c
c TELESCOP : Mission/Telescope name, NOTE: If not present set to UNKN
c INSTRUME : Instrument/Detector name NOTE: If not present set to UNK
c DETNAM : Specific detector name NOTE: If not present set to NONE
c FILTER : Filter in use, if not present set to NONE
c EFFAREA : Areascaling factor, if not present set to 1
c RMFVERSN : RMF version
c
c --- VARIABLES ------------------------------------------------------
c
IMPLICIT NONE
integer chatter, ierr
integer iunit
integer iebound, channel(*)
real areascal
real e_min(*), e_max(*)
character*5 rmfversn
character*16 telescop, instrume, detnam, filter
c
c --- INTERNALS ---
c
character*25 errstr, wrnstr
character*30 comm
character*70 desc, errinfo
integer status, htype, inull, felem, frow, colnum
integer nhdu
real enull
character*8 extname,hduclas1,hduclas2
logical anyflg, foundcol, extfind,endfile
c
c --- VARIABLE DIRECTORY ---------------------------------------------
c
c Passed parameters
c
c IUNIT i : FORTRAN unit number of open RMF file
c CHATTER i : chattiness flag for o/p (0 quite,10 normal,>20
c TELESCOP o : String listing telescope/mission
c INSTRUME o : String listing instrument/detector
c DETNAM o : String listing specific detector name
c FILTER o : String listing instrument filter in use
c AREA o : Area scaling factor
c IEBOUND o : No. channels in the full array
c CHANNEL o : Channel array
c E_MIN o : Array containing min nominal energy bound to ea
c E_MAX o : Array containing max nominal energy bound to ea
c RMFVERSN o : RMF version
c IERR o : Error Flag, ierr = 0 okay
c ierr = 1 error finding extension
c ierr = 2 error finding Column numbe
c ierr = 3 error reading data
c ierr = 4 NAXIS2 not found
c
c --- CALLED ROUTINES ------------------------------------------------
c
c subroutine FTMRHD : (FITSIO) Move to extension
c subroutine FTGKYS : (FITSIO) Read FITS extension header keyword
c subroutine FTGCNO : (FITSIO) Get column number
c subroutine FTGCVx : (FITSIO) Read data in x format
c subroutine WT_FERRMSG : (CALLIB) Dumps FITSIO Error message etc
c
c --- Compilation & Linking ------------------------------------------
c
c link with FITSIO & CALLIB & FTOOLS
c
c --- Authors/Modification History: ----------------------------------
c
c Rehana Yusaf (1993 July 15)
c Rehana Yusaf (1993 Oct 27) 1.0.1; Rename from RD_EBD1992a, and
c additional argument passed, rmfversn
c Also HDUCLASS is now used to find
c extension if not present then extname
c searched for.
c Rehana Yusaf (1993 Nov 10) 1.0.2; Read HDUVERS2 keyword to get rmfve
c if HDUVERSN not present the read RMFVERSN
c previously RMFVERSN was read
c Ian M George (93 Nov 17) 1.1.0; Took out extension searching stuff
character*7 version
parameter (version = '1.1.0')
*-
*+RDETM1
c -----------------------------------------------------------
subroutine rdetm1(dmapfil,map_max,instrum,telescop,
& chanmin,chanmax,tmap,chatter,ierr)
c -----------------------------------------------------------
c
c ___ DESCRIPTION ____________________________________________________
c
c This subroutine reads a detector map from a FITS Primary Array
c
c ___ VARIABLES ______________________________________________________
c
IMPLICIT NONE
integer map_max,ierr,chatter,chanmin,chanmax
real*4 tmap(map_max,map_max)
character*(*) instrum,telescop,dmapfil
c
c --- VARIABLE DIRECTORY ---------------------------------------------
c
c Arguments ...
c
c dmapfil char : detector map filename
c map_max int : Array dimensions
c chatter int : Chatter flag ( <5 quiet,>5 normal,>20 noisy)
c tmap real : detector map
c chanmin int : Minimum PI channel for image
c chanmax int : Maximum PI channel for image
c instrum char : Instrument/Detector name
c telescop char : Telescope name
c ierr int : Error flag, ierr = 0 okay
c ierr = 1 error finding extension
c ierr = 2 Column/keyword number not f
c ierr = 3 Error in reading data
c ierr = 4 Mandatory keyword not found
c
c --- CALLED ROUTINES ------------------------------------------------
c
c subroutine FTOPEN : (FITSIO) opens FITS file
c subroutine FTGKY(sj) : (FITSIO) reads keyword
c subroutine FTCLOS : (FITSIO) closes FITS file
c subroutine FTG2DE : (FITSIO) read image data
c subroutine FCECHO : FTOOLS routine to write to screen
c subroutine WT_FERRMSG : Writes FITSIO error text if required
c
c --- COMPILATION AND LINKING ----------------------------------------
c
c Link with FTOOLS - FITSIO, CALLIB
c
c --- AUTHORS/MODIFICATION HISTORY -----------------------------------
c
c Rehana Yusaf (Oct 1 1993) 1.0.0;
c
character*5 version
parameter (version = '1.0.0' )
*-
*+RDGTI1
c --------------------------------------------------------------
subroutine rdgti1(iunit,n_gti,max_gti,start,stop,chatter,ierr)
c --------------------------------------------------------------
c
c ___ DESCRIPTION ____________________________________________________
c
c This subroutine reads a FITS GTI file
c NOTE : Assumes file is already open.
c ... close file at end, using FTCLOS, or
c ... read another extension
c
c Columns read are ...
c
c START : Accepted time period
c STOP : Ed of accepted time period
c
c ___ VARIABLES ______________________________________________________
c
IMPLICIT NONE
integer iunit,max_gti,n_gti,ierr,chatter
real*8 start(max_gti),stop(max_gti)
c
c --- VARIABLE DIRECTORY ---------------------------------------------
c
c Arguments ...
c
c iunit int : Fortran unit number for file
c chatter int : Chatter flag ( <5 quiet,>5 normal,>20 noisy)
c ierr int : Error flag, ierr = 0 okay
c ierr = 1 error finding extension
c ierr = 2 Column/keyword number not f
c ierr = 3 Error in reading data
c ierr = 4 Mandatory keyword not found
c start int : array of start times
c stop int : array of stop times
c n_gti int : Number of times
c max_gti int : Maximum array dimension
c
c --- CALLED ROUTINES ------------------------------------------------
c
c subroutine FTMAHD : FITSIO routine to move to extension header
c subroutine FTGKYj : FITSIO routine to read extension header key
c where the j, is for an integer
c subroutine FTGKNS : FITSIO routine to read extension header key
c where a rootstring is given, thus an array
c keywords can be read
c subroutine FCECHO : FTOOLS routine to write to screen
c subroutine WT_FERRMSG : Writes FITSIO error text if required
c
c --- COMPILATION AND LINKING ----------------------------------------
c
c Link with FTOOLS - FITSIO, CALLIB
c
c --- AUTHORS/MODIFICATION HISTORY -----------------------------------
c
c Rehana Yusaf (Oct 1 1993) 1.0.0;
c
character*5 version
parameter (version = '1.0.0' )
*-
*+RDMVRD
c -------------------------------------------------------------
subroutine rdmvrd(iunit,n_evr,max_evr,time,mv_aco,
& xtransm,a1_al,xacc,chatter,ierr)
c -------------------------------------------------------------
c
c ___ DESCRIPTION ____________________________________________________
c
c This subroutine reads a FITS RDF format EVRATE Qualified
c Event rate extension
c NOTE : Assumes file is already open.
c ... close file at end, using FTCLOS, or
c ... read another extension
c
c Columns read are ...
c
c TIME : Time of event rate
c MV_ACO : MV anticoincident rate
c XTRANSM : Transmitted X-ray rate
c A1_AL : Events in A1 above low level threshold
c XACC : Accepted X-ray rate
c
c ___ VARIABLES ______________________________________________________
c
IMPLICIT NONE
integer iunit,max_evr,n_evr,ierr,chatter
real*8 time(max_evr)
integer*4 mv_aco(max_evr),xtransm(max_evr)
integer*4 a1_al(max_evr),xacc(max_evr)
c
c --- VARIABLE DIRECTORY ---------------------------------------------
c
c Arguments ...
c
c max_evr int : Array dimensions
c iunit int : Fortran unit number for file
c chatter int : Chatter flag ( <5 quiet,>5 normal,>20 noisy)
c n_evr int : Counter event rate data
c (IF NE 0 on entry then that many evr entries alr
c aaumed to have been read in (fron prevoius ext'
c
c ierr int : Error flag, ierr = 0 okay
c ierr = 107/207 error finding extensi
c ierr = 2 Column/keyword number not f
c ierr = 3 Error in reading data
c ierr = 4 Mandatory keyword not found
c
c --- CALLED ROUTINES ------------------------------------------------
c
c subroutine FTMAHD : FITSIO routine to move to extension header
c subroutine FTGKYj : FITSIO routine to read extension header key
c where the j, is for an integer
c subroutine FTGKNS : FITSIO routine to read extension header key
c where a rootstring is given, thus an array
c keywords can be read
c subroutine FCECHO : FTOOLS routine to write to screen
c subroutine WT_FERRMSG : Writes FITSIO error text if required
c
c --- COMPILATION AND LINKING ----------------------------------------
c
c Link with FTOOLS - FITSIO, CALLIB
c
c --- AUTHORS/MODIFICATION HISTORY -----------------------------------
c
c Rehana Yusaf (21 MArch 1994) 1.0.0; RDMVU0 used as basis
c
character*5 version
parameter (version = '1.0.0' )
*-
*+RDOHT1
c ---------------------------------------------------------------
subroutine rdoht1(iunit,telescop,instrume,filter,
& texpos,areascal,detchans,chantyp,nrad,theta_mi
& theta_max,sohist,bohist,ierr,chatter)
c ---------------------------------------------------------------
c --- DESCRIPTION ----------------------------------------------------
c
c This subroutine reads an
c HDUCLAS = OGIP
c HDUCLAS1=SPECTRUM
c HDUCLAS2=DETECTOR
c FITS extension, the file is assumed to be at desired location.
c !!! Note !!! the i/p file is assumed to have been opened, and is lef
c open at the end. Close the file using FTCLOS or read another extensi
c
c The HDUVERS1 format consists of a BINTABLE extension,with
c the number of rows equal to the number of off-axis angles passed, an
c the following columns/contents:
c
c THET_MIN - (real) theta min for this histogram bin
c THET_MAX - (real) theta min for this histogram bin
c SOU_FRAC - (real) weighting factor for SOURCE region
c BKG_FRAC - (real) weighting factor for BKGD region
c
c The following keywords are also read :
c
c INSTRUME= Name of the instrument
c FILTER - Name of filter in use (if any)
c EXPOSURE- Total exposure (s) for entire integration (incl deadtime
c AREASCAL- Area scaling factor for PHA dataset
c DETCHANS- Max no. of detector channels in integration
c CHANTYPE- Type of PHA channels in use ('PHA' or 'PI'[usual])
c
c --- VARIABLES ------------------------------------------------------
c
IMPLICIT NONE
integer iunit,chatter
integer detchans, dtype, ierr, nrad
real texpos,areascal
real theta_min(*), theta_max(*)
real sohist(*), bohist(*)
character*16 instrume,filter,telescop
character*16 chantyp
c
c --- VARIABLE DIRECTORY ---------------------------------------------
c
c Passed Parameters ...
c
c IUNIT int i: FORTRAN unit number of open PHA file
c CHATTER int i: chattiness flag for o/p (5 quite,10 norm,>19 si
c TELESCOP char o: Telescope name
c INSTRUME char o: Instrument name
c FILTER char o: Name of filter
c TEXPOS real o: Exposure time
c AREASCAL real o: Area scaling factor
c DETCHANS int o: Max number of detector channels
c CHANTYPE char o: Type of channels
c NRAD int o: Number of rows of data
c THETA_MIN real o: Theta min for this histogram bin
c THETA_MAX real o: Theta max for this histogram bin
c SO_HIST real o: Weighting factors for source region
c SO_BIST real o: Weighting fcator for BKGD region
c IERR int o: Error flag, 0 is okay
c
c --- CALLED ROUTINES ---------------------------------------------
c
c FTMRHD : (FITSIO) Move to extension
c FTGKY(sije) : (FITSIO) Read extension header keyword,
c s for string, j for integer etc
c FTGCNO : (FITSIO) Get column number
c FTGCVx : (FITSIO) Read data in x format
c WT_FERRMSG : (CALLIB) Dumps FITSIO and routine error message
c
c --- LINK/COMPILATION --------------------------------------------
c
c FITSIO and CALLIB
c
c --- AUTHORS/MODIFICATION HISTORY --------------------------------
c
c Rehana Yusaf 1.0.0 ; WT_PSCC1992A.F (IMG) used as a basis
c Rehana Yusaf 1.1.0 (1994 Feb 7) ; Change name to RDOHT1, no longer
c ROSAT specific
*-
*+RDPHA1
c ----------------------------------------------------------------
subroutine rdpha1(iunit,maxpha,nchan,tlscop,instrum,detnam,
& filter,detchan,texpos,areascal,backscal,
& corscal,backfil,corfil,rmffil,arffil,xflt,
& n_xflt,dmode,chantyp,phaversn,hduclas2,
& fchan,chan,dtype,
& ipha,pha,qerror,error,qsys,sysfrc,qqual,
& qualty,qgroup,group,pois,ierr,chatter)
c ----------------------------------------------------------------
c --- DESCRIPTION ----------------------------------------------------
c
c This subroutine reads the SPECTRUM extension of a PHA file in
c PHAVERSN = 1992a format. HDUVERS 1
c
c NOTE : The file is assumed to be open. It is assumed that the file
c is at the desired SPECTRUM extension.
c Close file using FTCLOS or read another ext'
c
c KEYWORDS READ ...
c
C TELESCOP : Telescope name
c INSTRUME : Instrument name
c FILTER : Filter in use
c POISERR : True if Poission errors apply
c EXPOSURE : Exposure time
c AREASCAL : Area scaling factor
c BACKSCAL : Background scaling factor
c CORRSCAL : Correction scaling factor
c BACKFILE : Associated background filename
c CORRFILE : Associated correction filename
c RESPFILE : Associated response filename
c ANCRFILE : Associated ancillary response filename
c XFLTxxxx : XSPEC filter description
c CHANTYPE : Channel type - PHA or PI
c DETCHANS : Number of possible detector channels
c DATAMODE : Datamode - for ASCA SIS - BRIGHT,FAINT etc
c PHAVERSN : PHA file format version
c HDUCLAS2 : Describes SPECTRUM - BKG,TOTAL,NET
c TLMIN1 : First possible value of first column (Channel)
c if TLMIN not found the default value 1 is assumed
c
c COLUMNS READ (if present) ...
c
c COUNTS/RATE : data in counts OR counts per sec
c STAT_ERR : Statistical error on data
c SYS_ERR : Systematic Error
c QUALITY : Channel Quality flags
c GROUPING : Channel grouping flags
c
c --- VARIABLES ------------------------------------------------------
c
IMPLICIT NONE
integer iunit,chatter,maxpha,nchan,dtype,ierr,n_xflt
character*(*) tlscop,instrum,filter,chantyp,xflt(*)
character*(*) backfil,corfil,rmffil,dmode,hduclas2
character*(*) arffil,detnam,phaversn
integer group(maxpha),qualty(maxpha),fchan
integer chan(maxpha),ipha(maxpha),detchan
real error(maxpha),sysfrc(maxpha),pha(maxpha)
real texpos,areascal,backscal,corscal
logical qgroup,qqual,qerror,qsys,pois
c
c --- VARIABLE DIRECTORY ---------------------------------------------
c
c Arguments (only those that are not described in keywords read)...
c
c iunit int : Fortran file unit number
c qgroup logical : true if grouping flags have been set
c qerror logical : true if statistical errors present
c qsys logical : true if systematic errors present
c pois logical : true if poisonian errors
c chatter int : chattiness flag (>20 verbose)
c maxpha int : Maximum array size
c nchan int : Number of channels available
c detchan int : Number of possible channels
c dtype int : Datatype, 1 - counts, 2 - rate
c ipha int : Array used for counts (if dtype = 1)
c pha real : Array used for rate ( if dtype = 2)
c ierr int : error flag, 0 is okay ...
c 1 = failed to find extension
c 2 = failed to read primary header
c 3 = array sizes are not large enough
c 4 = column not found
c 5 = error reading data
c 6 = error reading keyword
c
c --- CALLED ROUTINES ------------------------------------------------
c
c FTMRHD : (FITSIO) Move to extension
c FTGHBN : (FITSIO) Get binary header info
c FTGKYx : (FITSIO) Get keyword value of format x
c FTGCNO : (FITSIO) Get column number
c FTGCVx : (FITSIO) Reads data
c WT_FERRMSG : (CALLIB) Writes fitsio and routine error message
c FCECHO : Screen write
c
c --- AUTHORS/MODIFICATION HISTORY -----------------------------------
c
c Rehana Yusaf (1.0.0) : Keith Arnaud's RFTSPF used as a basis
c Rehana Yusaf (1.0.1) Nov 19 1993; Additional arguments - hduclas2
c and fchan. Also the extension search is
c removed and assumed the file is assumed to
c be in the desired position
c
c
character*5 version
parameter (version = '1.0.1')
*-
*+RDRMF1
c ---------------------------------------------------------
subroutine rdrmf1(iunit, chatter,matext,
& telescop, instrume, detnam, filter, areascal,
& ichan, ienerg, energ_lo, energ_hi,
& imaxgrp, ngrp, F_chan, N_chan,
& fmatrix, lo_thresh, maxchan,maxen,
& rmfversn,hduclas3,ierr)
c ---------------------------------------------------------
c --- DESCRIPTION ----------------------------------------------------
c
c Reads the RMF extension for an RMFVERSN = 1992a RMF file
c The file is assumed to conform to the HDUVERS2='1.*.*' family.
c Currently the OGIP formats supported are
c HDUVERS2 = '1.0.0'
c HDUVERS2 = '1.1.0'
c see OGIP/92-002a
c The HDU CLASS keywords have only been currently introduced thus DO N
c have to be present to use this reader.
c
c Assumes the FITS file is open.
c !!! NOTE !!! File is left open at end
c ... close file using FTCLOS, or
c ... read another extension
c
c Columns read are ...
c
c ENERG_LO : Low energy bound for row
c ENERG_HI : High energy bound for row
c N_GRP : Number of channel subsets for row
c F_CHAN : Firstchannel in each subset for row
c N_CHAN : Number of channels for each subset for row
c MATRIX : (non-zero) Matrix element for row
c
c Keywords read ...
c
c TELESCOP : Mission/Telescop name , if not present set to UNKNOW
c INSTRUME : Instrument/Detector name, if not present set to UNKN
c DETNAME : Specific detector name, if not present set to NONE
c FILTER : Filter in use, if not present set to NONE
c EFFAREA : Effective area, if not present,set to 1
c LO_THRESH : Threshold used to construct the MATRIX, if not prese
c set to 0
c HDUCLAS3 : Values describing data, OGIP approved - REDIST,FULL,
c DETECTOR
c RMFVERSN : OGIP RMF version
c
c --- VARIABLES ------------------------------------------------------
c
IMPLICIT NONE
integer chatter, ierr, maxchan,maxen
integer iunit
integer ichan, ienerg, imaxgrp
integer ngrp(maxen), F_chan(maxen,*)
integer N_chan(maxen,*)
real areascal, lo_thresh
real energ_lo(maxen), energ_hi(maxen)
real fmatrix(maxchan,maxen)
character*5 rmfversn
character*20 hduclas3
character*16 telescop, instrume, detnam, filter
character*8 extname,matext
c
c --- VARIABLE DIRECTORY ---------------------------------------------
c
c Passed parameters
c IUNIT i : FORTRAN unit number of open RMF file
c CHATTER i : chattiness flag for o/p (5 quite,10 normal,>20
c MATEXT o : extension name SPECRESP/MATRIX
c TELESCOP o : String listing telescope/mission
c INSTRUME o : String listing instrument/detector
c DETNAM o : String listing specific detector name
c FILTER o : String listing instrument filter in use
c AREASCAL o : Area scaling factor
c RMFVERSN o : RMF version
c HDUCLAS3 o : Hduclas3 keyword value
c ICHAN o : No. channels in the full array
c IENERG o : No. energy bins
c ENERG_LO o : Array containing lower bound to each energy bin
c ENERG_HI o : Array containing upper bound to each energy bin
c NGRP o : Array containing no. channel subsets at each en
c IMAXGRP o : Max no. grps in any given row
c F_CHAN o : Array containing 1st chan of each subset at eac
c N_CHAN o : Array containing no. chans within each subset
c at each energy
c FMATRIX o : Array containing the full matrix
c LO_THRESH o : The lower threshold used to construct the matri
c IERR o : Error flag (0 = OK)
c
c User i/ps required (prompted for):
c None
c
c Include files
c None
c
c Called Routines:
c subroutine FCECHO : (FTOOLS) Writes to standard o/p device
c subroutine WT_FERRMSG : (CALLIB) Writes FITSIO error message etc
c
c Compilation & Linking
c link with FITSIO & CALLIB & FTOOLS
c
c --- AUTHORS/MODIFICATION HISTORY -----------------------------------
c
c Rehana Yusaf (1993 July 26 : 1.0.0; WT_RMF1992A.F (CALLIB) used as b
c Rehana Yusaf (1993 Oct 27 ) 1.0.1; added arguments for rmfversn and
c hduclas3, also the name has been
c changed from rd_rmf1992a.
c In addition if extname is not found
c HDUCLAS1='RESPONSE' is searched for.
c and HDUCLAS2='RSP_MATRIX'
c Rehana Yusaf (1993 Nov 10) 1.0.2; HDUVERS2 is read to obtain rmfver
c if HDUVERSN not present then RMFVERSN
c is read. Prev' only RMFVERSN read
c Ian M George (93 Nov 17) 1.1.0 Took out searching for correct xt
c (this is now responsibilty of main)
character*7 version
parameter (version = '1.1.0')
*-
*+RDRPF1
c ---------------------------------------------------------------
subroutine rdrpf1(iunit,hduclas3,nrad,rad_lo,rad_hi,
& radunit,ntheta,theta_lo,theta_hi,
& thetaunit,nenerg,energ_lo,energ_hi,
& energunit,rpsf,qerror,rpsf_err,
& rpsfunit,qarea,area_wgt,telescop,
& instrume,maxrad,maxtheta,ierr,chatter)
c ---------------------------------------------------------------
c
c ___ DESCRIPTION ____________________________________________________
c
c This subroutine reads an OGIP standard
c HDUCLAS1 RESPONSE
c HDUCLAS2 RPRF
c HDUCLAS3 PREDICTED,TOTAL or NET (bkgd = 0)
c extension from a FITS file.
c NOTE : Assumes file is already open and in correct position.
c ... close file at end, using FTCLOS, or
c ... read another extension
c
c Columns read are ...
c
c RAD_LO : Lower edge of radial bins
c RAD_HI : Upper edge of radial bins
c THETA_LO : Lower bound for off_axis angle, if it is a single value
c is read from a keyword. If the value is not defined it i
c THETA_HI : Upper bound for off_axis angle, if it is a single value
c is read from a keyword. If the value is not defined it i
c ENERG_LO : Low energy bound, if read from a keyword it is a single
c if it is not defined, it is -99
c ENERG_HI : Upper energy bound, if read from a keyword it is a singl
c if it is not defined, it is -99
c RPSF : Radial Point Spread function,
c 3D array - RPSF(irad,itheta,ien)
c RPSF_ERR : Error on RPSF, 3D array - RPSF_ERR(irad,itheta,ien)
c this is an optional column, if it is not present then
c qerror is set to false
c AREA_WGT : Area weighting factor, 3D - AREA_WGT(irad,itheta,ien)
c this is an optional column, and if it is not present
c then qarea is set to false
c
c Keywords read ...
c
c RPSFVER : Routine version
c TELESCOP : Mission/Telescope name, NOTE: if not present set to UNKN
c INSTRUME : Instrument/Detector name, NOTE: if not present set to UN
c HDUCLAS3 : OGIP approved values are ... PREDICTED
c TOTAL
c NET (bkgd = 0)
c
c ___ VARIABLES ______________________________________________________
c
IMPLICIT NONE
integer iunit,nrad,ntheta,nenerg,chatter
integer ierr,maxrad,maxtheta
real rad_lo(maxrad),rad_hi(maxrad)
real energ_lo(*),energ_hi(*)
real theta_lo(maxtheta),theta_hi(maxtheta)
real rpsf(maxrad,maxtheta,*),rpsf_err(maxrad,maxtheta,*)
character*(*) radunit,thetaunit,energunit,rpsfunit,hduclas3
real area_wgt(maxrad,maxtheta,*)
character*(*) instrume,telescop
logical qarea,qerror
c
c --- VARIABLE DIRECTORY ---------------------------------------------
c
c Arguments ...
c
c maxrad int : Array dimensions
c maxtheta int : Array dimensions
c iunit int : Fortran unit number for file
c chatter int : Chatter flag ( <5 quiet,>5 normal,>20 noisy)
c nrad int : Counter for observed psf data
c rad_lo real : Array of lower edge of observed radial bin
c rad_hi real : Array of upper edge of observed radial bin
c theta_lo real : Array of lower theta values for off_axis angle
c theta_hi real : Array of upper theta values for off_axis angle
c energ_lo real : Array of lower energy bound
c energ_hi real : Array of upper energy bound
c rpsf real : Array of Radial Point Spread Function
c rpsf_err real : Array of errors on rpsf
c area_wgt real : Array of Area Weighting Factors
c qarea logical: True if area_wgt present
c qerror logical: True if rpsf_err present
c ierr int : Error flag, ierr = 0 okay
c ierr = 1 error finding extension
c ierr = 2 Column/keyword number not f
c ierr = 3 Error in reading data
c ierr = 4 Mandatory keyword not found
c ierr = 5 tunits or ttype not found
c
c --- CALLED ROUTINES ------------------------------------------------
c
c subroutine FTMAHD : FITSIO routine to move to extension header
c subroutine FTGKYs : FITSIO routine to read extension header key
c where the s is for string
c subroutine FTGKYj : FITSIO routine to read extension header key
c where the j, is for an integer
c subroutine FTGKNS : FITSIO routine to read extension header key
c where a rootstring is given, thus an array
c keywords can be read
c subroutine FTGCVe : FITSIO routine to read columns of data in a
c extension. The e indicates that it is real
c
c subroutine FCECHO : FTOOLS routine to write to screen
c subroutine WT_FERRMSG : Writes FITSIO error text if required
c
c --- COMPILATION AND LINKING ----------------------------------------
c
c Link with FTOOLS - FITSIO, CALLIB
c
c --- AUTHORS/MODIFICATION HISTORY -----------------------------------
c
c Rehana Yusaf (sept 1993) 1.0.0;
c Rehana Yusaf (1994 Jan 20) 1.1.0; Renamed from RD_RPSF1993a to RDRPF
c hduclas3 keyword is read
c extname extension search removed,i
c assumed that the file is already a
c RPSF extension. FNDHDU and/or FNDE
c be used to find the RPSF extension
c
c Rehana Yusaf (1994 Feb 9) 1.1.1; Bugfix, status flag set to 0 after
c hduclas3 keyword is read
character*5 version
parameter (version = '1.1.1' )
*-
List of currently available and planned CALLIB routines concerning the writing of standard sets of keywords to FITS exyensions are given in Tables 5 & 6 respectively.
*+WT_ADDCOM
subroutine wt_addcom(chatter, ounit, ascfil, ierr)
IMPLICIT NONE
integer ounit, ierr
integer chatter
character*20 ascfil
c
c Description
c Program to add the contents of a simple ASCII i/p file as COMMENT
c keywords in Current FITS Header Unit. A max of 999 comments are
c currently allowed in a single sitting.
c !!! NOTE !!!
c - the FITS file must be closed after return using FTCLOS etc
c
c Passed parameters
c CHATTER i : Chatter flag (5 low, 20 silly)
c OUNIT i : FORTRAN unit of open FITS file
c ASCFIL i : Name of ASCII file containing comments
c IERR o : Error Flag (0=OK)
c
c User i/ps required (prompted for):
c None
c
c Include files
c None
c
c Called routines
c subroutine FCECHO : (FTOOLS) Writes to standard o/p device
c subroutine FTGHSP : (FITSIO) Gets space available in CDU
c subroutine FTPCOM : (FITSIO) Inserts a COMMENT card into CD
c subroutine CGETLUN : (CALLIB) Gets a free FORTRAN unit
c subroutine WT_FERRMSG : (CALLIB) Writes FITSIO error string n s
c
c Compilation
c requires CALLIB, FITSIO, & FTOOLS
c
c Origin
c Original
c
c Authors/Modification History:
c Ian M George (1993 Feb 18), original
character*7 version
parameter (version = '1.0.0')
*-
*+WT_CIFKYS
subroutine wt_cifkys(ounit, chatter, datano, telescop,
& instrume, filter, detnam, ccls,
& ccnm, cdtp, cvsd, cvst, cdes, nbd, cbd, ierr)
IMPLICIT NONE
integer chatter, nbd, ierr, ounit
character*4 datano
character*20 telescop, instrume, filter, detnam
character*20 ccls,ccnm,cdtp,cvsd,cvst
character*69 cdes, cbd(*)
c
c Description:
c Writes the keywords & values mandatory for CIF purposes
c Blank string passed in the filter field results in a corresponding
c value of 'NONE' being written to the file. Blank string passed in t
c detnam field results in keyword not being written.
c
c !!! Note !!! (currently) NO checking of the FITS file is performed.
c ... the file is assumed to be open within the correct
c extension header
c
c Passed parameters
c OUNIT i : FORTAN unit number for o/p
c CHATTER i : chattiness flag for o/p (5 quiet,10 normal,>20
c DATANO i : dataset number string (ie '0001', '0002' etc)
c TELESCOP i : name of telescope/mission
c INSTRUME i : name of instrument/detector
c DETNAM i : name of detector (if INSTRUME insufficient)
c FILTER i : name of filter in use (if applicable)
c CCLS i : OGIP class of calibration file to be written
c CCNM i : OGIP codename for calibration file to be writte
c CDTP i : Type of data file to be written (Real, task etc
c CVSD i : Validity start date (UTC) for dataset
c CVST i : Validity start time (UTC on CVSD) for dataset
c CDES i : Descriptive string for dataset
c NDB i : Number of CBD strings to be written
c CBD i : Array of parmeter boundary strings
c IERR o : Error flag (0 for OK)
c
c User i/ps required (prompted for):
c None
c
c Include files
c None
c
c Called Routines:
c subroutine CRMVBLK : (CALLIB) Removes blanks from string
c subroutine FCECHO : (FTOOLS) WRites to standard o/p device
c subroutine FTGERR : (FITSIO) Gets Error Text
c subroutine FTPKYS : (FITSIO) writes a character string keyword
c subroutine WT_FERRMSG : (CALLIB) writes standard error text string
c
c Compilation:
c link with FITSIO
c
c Origin:
c Original
c
c Authors/Modification History:
c Ian M George (1992 Dec 29), original
c Ian M George (1993 Feb 14) telescop, instrume, filter & detnam
character*7 version
parameter (version = '1.1.0')
*-
*+ WT_OBJRADEC
subroutine wt_objradec(chatter, ounit,
& qsys, radecsys, equinox,
& ra_obj, dec_obj, ra_obje, dec_obje,
& ierr)
IMPLICIT NONE
integer chatter, ounit, ierr
real equinox
real ra_obj, dec_obj, ra_obje, dec_obje
character*70 radecsys
logical qsys
c
c Description
c Writes the RA & dec of the object/target
c and any associated errors into current FITS header unit.
c
c The following keywords can be written (depending upon flags/passed v
c RADECSYS- 'Stellar Reference frame used for EQUINOX'
c EQUINOX - 'Equinox of all RA,dec specifications (AD year)'
c RA_OBJ - 'RA of object (degrees)'
c DEC_OBJ - 'dec of object (degrees)'
c RA_OBJE - 'Error on RA_OBJ (degrees)'
c DEC_OBJE- 'Error on DEC_OBJ (degrees)'
c
c NOTE: A logical flag is used to indicate whether the RADECSYS & EQUI
c keywords are written. These keywords are mandatory if any of t
c RA,dec keywords are written. Thus the only time when this flag
c be set false is when RADECSYS & EQUINOX have already been writ
c to the current header.
c
c Passed Parameters
c CHATTER i : Chatter flag (<5=quite,10=normal,>20=silly)
c OUNIT i : FORTRAN logical unit no. of o/p file
c QSYS i/r : Logical flag whether pointing info to be written
c RADECSYS i : Reference frame for ALL RA & decs
c EQUINOX i : Equinox for ALL RA & decs
c RA_OBJ i : RA of object/target
c DEC_OBJ i : dec of object/target
c RA_OBJE i : Error on RA_OBJ
c DEC_OBJE i : Error on DEC_OBJ
c IERR o : Return error flag (0 = OK)
c
c Called Routines
c subroutine FCECHO : (FTOOLS) writes to standard o/p
c subroutine FTPHIS : (FITSIO) writes a history keyword
c subroutine FTPKYn : (FITSIO) writes a keyword of type n
c subroutine WT_FERRMSG : (CALLIB) writes FITSIO error message
c
c Origin
c Hacked from the old "WT_RADEC" subroutine
c
c Authors/Modification History
c Ian M George (1.0.0: 1993 Oct 04), original
c Ian M George (1.0.1: 1993 Oct 22), moved RA,DEC = 0.0 warning me
character*7 version
parameter (version = ' 1.0.1 ')
*-
*+ WT_OBSINFO
subroutine wt_obsinfo(chatter, ounit,
& object, obs_id, obs_pi, seqno, observer,
& proc_sys, proc_ver,proc_loc, proc_date, proc_time,
& ierr)
IMPLICIT NONE
integer chatter, ounit, ierr
character*70 object, obs_id, obs_pi, seqno, observer
character*70 proc_sys, proc_ver, proc_loc, proc_date
character*70 proc_time
c
c Description
c Writes the Observation details to the current FITS header unit
c The following keywords can be written (assuming valid value)
c OBJECT - 'Object name'
c OBS_ID - 'Observation ID code'
c OBS_PI - 'Principal Investigator of observation'
c SEQNO - 'Sequence Number of Observation'
c OBSERVER- 'Name or ref code for Observer/Duty Scientist'
c PROC_SYS- 'Science Data Processing System used'
c PROC_VER- 'Revision level of Processing System',
c PROC_LOC- 'Location at which Processing System run'
c PROC_DAT- 'Date on which Processing System run'
c PROC_TIM- 'Time at which Processing System run (on PROC_DAT)'
c
c Passed Parameters
c CHATTER i : Chattiness flag (<5=quite,10=normal,>20=silly)
c OUNIT i : FORTRAN logical unit number of o/p file
c OBJECT i : (Astronomical) Target/object name
c OBS_ID i : Observation ID
c OBS_PI i : Name of Principal Investigator of Observation
c SEQNO i : (Scheduling) sequence number of observation
c OBSERVER i : Name or ref code for Observer/Duty Scientist
c PROC_SYS i : Name of data processing system
c PROC_VER i : Revision level of Processing System
c PROC_LOC i : Location at which Processing System run
c PROC_DAT i : Date on which Processing System run
c PROC_TIM i : Time at which Processing System run (on PROC_DAT
c IERR o : Return Error flag (0 = OK)
c
c Called Routines
c subroutine FCECHO : (FTOOLS) writes to standard o/p
c subroutine FTPHIS : (FITSIO) writes a history keyword
c subroutine FTPKYn : (FITSIO) writes a keyword of type n
c subroutine WT_FERRMSG : (CALLIB) writes FITSIO error message etc
c
c Origin
c An IMG original
c
c Authors/Modification History
c Ian M George (1.0.01:1993 Jun 10), first 'proper' version
c Ian M George (1.0.2:1993 Jun 20), times & celestial coords taken
c Ian M George (1.1.0:1993 Aug 16), add proc_sys,_ver,_loc etc etc
c Ian M George (1.1.1:1993 Aug 27), added OBJECT key clnstr
c
character*7 version
parameter (version = '1.1.1')
*-
*+ WT_PNTRADEC
subroutine wt_pntradec(chatter, ounit,
& qsys, radecsys, equinox,
& ra_pnt, dec_pnt, pa_pnt,
& ra_pnte, dec_pnte, pa_pnte,
& ierr)
IMPLICIT NONE
integer chatter, ounit, ierr
real equinox
real ra_pnt, dec_pnt, pa_pnt
real ra_pnte, dec_pnte, pa_pnte
character*70 radecsys
logical qsys
c
c Description
c Writes the (mean) RA, dec & roll angle of the pointing direction
c and any associated errors into current FITS header unit.
c
c The following keywords can be written (depending upon flags/passed v
c RADECSYS- 'Stellar Reference frame used for EQUINOX'
c EQUINOX - 'Equinox of all RA,dec specifications (AD year)'
c RA_PNT - 'RA of pointing (degrees)'
c DEC_PNT - 'dec of pointing (degrees)'
c PA_PNT - 'Roll angle (degrees) from North towards East (degrees)'
c RA_PNTE - 'Error on RA_PNT (degrees)'
c DEC_PNTE- 'Error on DEC_PNT (degrees)'
c PA_PNTE - 'Error on PA_PNT (degrees)'
c
c NOTE: A logical flag is used to indicate whether the RADECSYS & EQUI
c keywords are written. These keywords are mandatory if any of t
c RA,dec keywords are written. Thus the only time when this flag
c be set false is when RADECSYS & EQUINOX have already been writ
c to the current header.
c
c Passed Parameters
c CHATTER i : Chatter flag (<5=quite,10=normal,>20=silly)
c OUNIT i : FORTRAN logical unit no. of o/p file
c QSYS i/r : Logical flag whether RADECSYS & EQUINOX to be wr
c RADECSYS i : Reference frame for ALL RA & decs
c EQUINOX i : Equinox for ALL RA & decs
c RA_PNT i : RA of pointing direction ("Optical axis")
c DEC_PNT i : dec of pointing direction ("Optical axis")
c PA_PNT i : Roll angle (degrees) from North
c RA_PNTE i : Error on RA_PNT
c DEC_PNTE i : Error on DEC_PNT
c PA_PNTE i : Error on PA_PNT
c IERR o : Return error flag (0 = OK)
c
c Called Routines
c subroutine FCECHO : (FTOOLS) writes to standard o/p
c subroutine FTPHIS : (FITSIO) writes a history keyword
c subroutine FTPKYn : (FITSIO) writes a keyword of type n
c subroutine WT_FERRMSG : (CALLIB) writes FITSIO error message
c
c Origin
c Hacked from the old "WT_RADEC" subroutine
c
c Authors/Modification History
c Ian M George (1.0.0: 1993 Oct 04), original
c Ian M George (1.0.1: 1993 Oct 22), moved RA,DEC = 0.0 warning me
character*7 version
parameter (version = ' 1.0.1 ')
*-
*+ WT_REGDESC
subroutine wt_regdesc(chatter, ounit,
& nsreg, sdesc,sfil,sname,sframe,
& sxname, sxunit, syname, syunit,
& sxblk,syblk,sxmin,sxmax,symin,symax,
& sxref, syref, npixsou, sxpsc, sypsc,
& nbreg, bdesc,bfil,bname,bframe,
& bxname, bxunit, byname, byunit,
& bxblk,byblk,bxmin,bxmax,bymin,bymax,
& bxref, byref, npixbkg, bxpsc, bypsc,
& ierr)
IMPLICIT NONE
integer chatter, ounit, ierr
integer sxblk,syblk,bxblk,byblk
integer npixsou, npixbkg
integer nsreg, nbreg
real sxmin, sxmax, symin, symax
real sxref, syref
real bxmin, bxmax, bymin, bymax
real bxref, byref
real sxpsc, sypsc, bxpsc, bypsc
character*70 sdesc(*),bdesc(*), sfil, bfil
character*70 sname, sframe, bname, bframe
character*70 sxname, syname, bxname, byname
character*70 sxunit, syunit, bxunit, byunit
c
c Description
c Writes the region descriptors to the current FITS header unit
c The following keywords may be written (assuming valid values)
c SR_NDSC - (int) 'No. of SR_DSC strings/keywords'
c SR_DSCnn - (char) 'source region descriptor'
c SR_FILE - (char) 'filename from which SR_DSCnn defined'
c SR_IMAG - (char) 'name of Source image'
c SR_FRAM - (char) 'coordinate frame of SR_IMAG'
c SR_XNAM - (char) 'name of X-axis of SR_IMAG'
c SR_XUNT - (char) 'physical units of SR_XNAM'
c SR_YNAM - (char) 'name of Y-axis of SR_IMAG'
c SR_YUNT - (char) 'physical units of SR_YNAM'
c SR_XBLK - (int) 'X-coord blocking factor for SR_DSC values'
c SR_XMIN - (real) 'Min X-coordinate in image SR_IMAG'
c SR_XMAX - (real) 'Max X-coordinate in image SR_IMAG'
c SR_YBLK - (int) 'Y-coord blocking factor for SR_DSC values'
c SR_YMIN - (real) 'Min Y-coordinate in image SR_IMAG'
c SR_YMAX - (real) 'Max Y-coordinate in image SR_IMAG'
c NPIXSOU - (real) 'No. pixels in source region'
c SR_XREF - (real) 'Reference point in X-coord of SR_DSCnn'
c SR_YREF - (real) 'Reference point in Y-coord of SR_DSCnn'
c SR_XPSC - (real) 'Pixel size (in degrees) of X-axis of SR_IMAG'
c SR_YPSC - (real) 'Pixel size (in degrees) of Y-axis of SR_IMAG'
c BR_NDSC - (int) 'No. of BR_DSC strings/keywords'
c BR_DSCnn - (char) 'background region descriptor'
c BR_FILE - (char) 'filename from which BR_DSCnn defined'
c BR_IMAG - (char) 'name of Background image'
c BR_FRAM - (char) 'coordinate frame of BR_IMAG'
c BR_XNAM - (char) 'name of X-axis of BR_IMAG'
c BR_XUNT - (char) 'physical units of BR_XNAM'
c BR_YNAM - (char) 'name of Y-axis of BR_IMAG'
c BR_YUNT - (char) 'physical units of BR_YNAM'
c BR_XBLK - (int) 'X-coord blocking factor for BR_DSC values'
c BR_XMIN - (real) 'Min X-coordinate in image BR_IMAG'
c BR_XMAX - (real) 'Max X-coordinate in image BR_IMAG'
c BR_YBLK - (int) 'X-coord blocking factor for BR_DSC values'
c BR_YMIN - (real) 'Min Y-coordinate in image BR_IMAG'
c BR_YMAX - (real) 'Max Y-coordinate in image BR_IMAG'
c NPIXBACK - (real) 'No. pixels in Background region'
c BR_XREF - (real) 'Reference point in X-coord of BR_DSCnn'
c BR_YREF - (real) 'Reference point in Y-coord of BR_DSCnn'
c BR_XPSC - (real) 'Pixel size (in degrees) of X-axis of BR_IMAG'
c BR_YPSC - (real) 'Pixel size (in degrees) of Y-axis of BR_IMAG'
c
c Passed Parameters
c CHATTER i : Chattiness flag
c OUNIT i : FORTRAN logical unit of o/p file
c NSREG i : Number of source region keywords to be written
c SDESC i : Array of source region descriptor strings
c SFIL i : filename from which source region defined
c SNAME i : name of Source image
c SFRAME i : coordinate frame of source image
c SXBLK i : X-coordinate blocking factor for source image
c SYBLK i : Y-coordinate blocking factor for source image
c SXMIN i : Min X-coordinate in source image
c SXMAX i : Max X-coordinate in source image
c SYMIN i : Min Y-coordinate in source image
c SYMAX i : Max Y-coordinate in source image
c NBREG i : No. of background region descriptors to be writt
c BDESC i : array of background region descriptor strings
c BFIL i : filename from which BRd region defined
c BNAME i : name of Background image
c BFRAME i : coordinate frame of BRd image
c BXBLK i : X-coordinate blocking factor for BRd image
c BYBLK i : Y-coordinate blocking factor for BRd image
c BXMIN i : Min X-coordinate in BRd image
c BXMAX i : Max X-coordinate in BRd image
c BYMIN i : Min Y-coordinate in BRd image
c BYMAX i : Max Y-coordinate in BRd image
c NPIXSOU i : No pixels in Source region
c NPIXBKG i : No pixels in Background region
c SXREF i : Reference point in X-coord of source descriptor
c SYREF i : Reference point in Y-coord of source descriptor
c BXREF i : Reference point in X-coord of BRd descriptor
c BYREF i : Reference point in Y-coord of BRd descriptor
c IERR o : Return error flag (0 = OK)
c
c Called Routines
c subroutine FCECHO : (FTOOLS) writes to standard o/p
c subroutine FTPHIS : (FITSIO) writes a history keyword
c subroutine FTPKYn : (FITSIO) writes a keyword of type n
c subroutine WT_FERRMSG : (CALLIB) writes FITSIO error message
c
c Origin
c An IMG original (and cant you just tell)
c
c Authors/Modification History
c Ian M George (1.1.0:1993 Jun 13), first 'proper' version
c Ian M George (1.1.1:1993 Jun 20), added npixsou, npixbkg, qBR
c Ian M George (1.1.2:1993 Jul 25), added sxref,syref,bxref,byref
c Ian M George (1.2.0:1993 Aug 22), added sr_dsc & bk_dsc keys
c Ian M George (1.2.1:1993 Aug 24), deleted qBR keyword (!)
c
character*7 version
parameter (version = '1.2.1')
*-
*+ WT_SCRADEC
subroutine wt_scradec(chatter, ounit,
& qsys, qscraftx,qscrafty,qscraftz,
& radecsys, equinox,
& ra_scx, dec_scx, pa_scx,
& ra_scy, dec_scy, pa_scy,
& ra_scz, dec_scz, pa_scz,
& ra_scxe, dec_scxe, pa_scxe,
& ra_scye, dec_scye, pa_scye,
& ra_scze, dec_scze, pa_scze,
& ierr)
IMPLICIT NONE
integer chatter, ounit, ierr
real equinox
real ra_scx, dec_scx, ra_scy, dec_scy, ra_scz, dec_scz
real pa_scx, pa_scy, pa_scz
real ra_scxe, dec_scxe, ra_scye, dec_scye, ra_scze, dec_scze
real pa_scxe, pa_scye, pa_scze
character*70 radecsys
logical qsys, qscraftx,qscrafty,qscraftz
c
c Description
c Writes the RA & dec of the s/c X-, Y-, &/or Z-axes to the
c current FITS header unit
c
c Description
c Writes the Observation details to the current FITS header unit
c The following keywords can be written (depending upon flags/passed v
c RADECSYS- 'Stellar Reference frame used for EQUINOX'
c EQUINOX - 'Equinox of all RA,dec specifications (AD year)'
c RA_SCX - 'RA of s/c X-axis (degrees)'
c DEC_SCX - 'Dec of s/c X-axis (degrees)'
c PA_SCX - 'Roll angle of s/c X-axis (degrees)
c RA_SCY - 'RA of s/c y-axis (degrees)'
c DEC_SCY - 'Dec of s/c Y-axis (degrees)'
c PA_SCY - 'Roll angle of s/c Y-axis (degrees)
c RA_SCZ - 'RA of s/c Z-axis (degrees)'
c DEC_SCZ - 'Dec of s/c Z-axis (degrees)'
c PA_SCZ - 'Roll angle of s/c Z-axis (degrees)
c RA_SCXE - Error on RA_SCX (degrees)
c DEC_SCXE- Error on DEC_SCX (degrees)
c PA_SCXE - Error on PA_SCX (degrees)
c RA_SCYE - Error on RA_SCY (degrees)
c DEC_SCYE- Error on DEC_SCY (degrees)
c PA_SCYE - Error on PA_SCY (degrees)
c RA_SCZE - Error on RA_SCZ (degrees)
c DEC_SCZE- Error on DEC_SCZ (degrees)
c PA_SCZE - Error on PA_SCZ (degrees)
c
c Passed Parameters
c CHATTER i : Chatter flag (<5=quite,10=normal,>20=silly)
c OUNIT i : FORTRAN logical unit no. of o/p file
c QSYS i/r : Logical flag whether coord sys info to be written
c QSCRAFTX i : Logical flag whether s/c X-axis info to be writt
c QSCRAFTY i : Logical flag whether s/c Y-axis info to be writt
c QSCRAFTZ i : Logical flag whether s/c Z-axis info to be writt
c RADECSYS i : Reference frame for ALL RA & decs
c EQUINOX i : Equinox for ALL RA & decs
c RA_SCX i : RA along direction of s/c X-axis
c DEC_SCX i : dec along direction of s/c X-axis
c PA_SCX i : position angle (roll) of s/c X-axis
c RA_SCY i : RA along direction of s/c Y-axis
c DEC_SCY i : dec along direction of s/c Y-axis
c PA_SCY i : position angle (roll) of s/c Y-axis
c RA_SCZ i : RA along direction of s/c Z-axis
c DEC_SCZ i : dec along direction of s/c Z-axis
c PA_SCZ i : position angle (roll) of s/c Z-axis
c RA_SCXE i : Error on RA_SCX (degrees)
c DEC_SCXE i : Error on DEC_SCX (degrees)
c PA_SCXE i : Error on PA_SCX (degrees)
c RA_SCYE i : Error on RA_SCY (degrees)
c DEC_SCYE i : Error on DEC_SCY (degrees)
c PA_SCYE i : Error on PA_SCY (degrees)
c RA_SCZE i : Error on RA_SCZ (degrees)
c DEC_SCZE i : Error on DEC_SCZ (degrees)
c PA_SCZE i : Error on PA_SCZ (degrees)
c IERR o : Return error flag (0 = OK)
c
c Called Routines
c subroutine FCECHO : (FTOOLS) writes to standard o/p
c subroutine FTPHIS : (FITSIO) writes a history keyword
c subroutine FTPKYn : (FITSIO) writes a keyword of type n
c subroutine WT_FERRMSG : (CALLIB) writes FITSIO error message
c
c Origin
c Hacked from old general routine "WT_RADEC" which grew too big
c
c Authors/Modification History
c Ian M George (1.0.0: 1993 Oct 04), original hacked version
c Ian M George (1.0.1: 1993 Oct 22), moved RA,DEC = 0.0 warning me
character*7 version
parameter (version = ' 1.0.1 ')
*-
*+ WTFTIM
subroutine wtftim(chatter, ounit,
& mjdref, tstart, tstop, tzero,
& timesys,timeunit,clockapp, timeref,tassign,
& tierrela, tierabso, telapse, ontime, deadapp, deadcorr,
& livetime, vignapp, vignet, ierr)
IMPLICIT NONE
integer chatter, ounit, ierr
real tierrela, tierabso, ontime, deadcorr, vignet
real telapse, livetime
double precision mjdref, tstart, tstop, tzero
character*20 timesys, timeunit, timeref
character*20 tassign
logical deadapp, vignapp, clockapp
c
c Description
c Writes the details of the time of the observation to the current
c FITS header unit
c The following keywords can be written (assuming valid values)
c MJDREF - 'Mission reference time (in MJD)'
c TIMESYS - 'Time frame system in use'
c TIMEUNIT- 'Units for TSTART, TSTOP & TIMEZERO keywords'
c TSTART - 'Start time in TIMESYS frame in TIMEUNIT units'
c TSTOP - 'Stop time in TIMESYS frame in TIMEUNIT units'
c TIMEZERO- 'Time zero off-set in TIMESYS frame & TIMEUNIT units'
c CLOCKAPP- 'Corrections applied for s/c clock ?'
c TIMEREF - 'Reference frame used for times'
c TASSIGN - 'Location where time assignment performed'
c TIERRELA- 'relative errors expressed as a rate'
c TIERABSO- 'timing precision (seconds)'
c TELAPSE - 'total time between TSTART & TSTOP (seconds)
c ONTIME - 'total time on source (excl deadtime corrections)'
c DEADAPP - 'Deadtime correction applied ?'
c DEADCORR- 'Deadtime correction factor'
c LIVETIME- 'ONTIME corrected for Deadtime effects'
c VIGNAPP - 'Vignetting correction applied ?'
c VIGNCORR- 'Vignetting correction factor'
c
c Passed Parameters
c CHATTER i : Chattiness flag (<5 quite, 10=normal,>20 silly)
c OUNIT i : FORTRAN logical unit of o/p file
c MJDREF i : Mission reference time (in MJD)
c TSTART i : Start time in TIMESYS frame in TIMEUNIT units
c TSTOP i : Stop time in TIMESYS frame in TIMEUNIT units
c TZERO i : Time zero off-set in TIMESYS frame & TIMEUNIT units
c TIMESYS i : Time frame system in use
c TIMEUNIT i : Units for TSTART, TSTOP & TIMEZERO keywords
c CLOCKAPP i : Logical as whether corrections applied for s/c c
c TIMEREF i : Reference frame used for times
c TASSIGN i : Location where time assignment performed
c TIERRELA i : relative errors (expressed as a rate)
c TIERABSO i : timing precision (seconds)
c TELAPSE i : TSTOP - TSTART (in seconds)
c ONTIME i : total seconds on source (excl deadtime corrections)
c DEADAPP i : Logical as whether deadtime correction applied
c DEADCORR i : Deadtime correction factor
c LIVETIME i : 'ONTIME corrected for Deadtime effects'
c VIGNAPP i : Logical as whether vignetting correction applied
c VIGNET i : Vignetting correction factor
c
c Called Routines
c subroutine FCECHO : (FTOOLS) writes to standard o/p
c subroutine FTPCOM : (FITSIO) writes a comment keyword
c subroutine FTPHIS : (FITSIO) writes a history keyword
c subroutine FTPKYn : (FITSIO) writes a keyword of type n
c subroutine WT_FERRMSG : (CALLIB) writes FITSIO error message
c
c Origin
c An IMG original
c
c Authors/Modification History
c Ian M George (1993 Jun 20), original
c Ian M George (1.0.1:1993 Oct 07) TIMVERSN keyword NOT written
c
character*7 version
parameter (version = '1.0.1')
*-
*+ WTTOBS
subroutine wttobs(chatter, ounit,
& date_obs, time_obs, date_end, time_end,
& mjdobs,ierr)
IMPLICIT NONE
integer chatter, ounit, ierr
double precision mjdobs
character*8 date_obs, time_obs, date_end, time_end
c
c Description
c Writes the details of the time of the observation to the current
c FITS header unit
c The following keywords can be written (assuming valid values)
c DATE-OBS -'Nominal UT date of obs start (dd/mm/yy)'
c TIME-OBS -'Nominal UT time of obs start (hh:mm:ss)'
c DATE-END -'Nominal UT date of obs end (dd/mm/yy)'
c TIME-END -'Nominal UT time of obs end (hh:mm:ss)'
c
c Passed Parameters
c CHATTER i : chattiness flag for o/p (5 quite, 10 norm, >19 si
c OUNIT i : FORTRAN unit number of open File
c DATE_OBS i : Date of observation start (dd/mm/yy)
c TIME_OBS i : Time of observation start (hh:mm:ss) on day DATA_
c DATE_END i : Date of observation end(dd/mm/yy)
c TIME_END i : Time of observation end (hh:mm:ss) on day DATA_EN
c MJDOBS i : Mean MJD of observation
c IERR o : Error flag on return (zero = OK)
c
c Called Routines
c subroutine FTPHIS : (FITSIO) writes a history keyword
c subroutine FTPKYm : (FITSIO) writes key, values,comment
c subroutine FCECHO : (FTOOLS) writes to standard o/p
c subroutine WT_FERRMSG : (CALLIB) writes standard fitsio error mess
c
c Origin
c An IMG original
c
c Authors/Modification History
c Ian M George (1.0.1: 1993 Jun 20), first 'proper' version
c
character*7 version
parameter (version = '1.0.1')
*-
List of currently available and planned CALLIB routines concerning the reading of standard sets of keywords from extension headers are given in Tables 7 & 8 respectively.
*+RD_CIFKYS
subroutine rd_cifkys(ounit, chatter, datano,
& telescop, instrume, filter, detnam,
& ccls, ccnm, cdtp,
& cvsd, cvst, cdes, nbd, cbd, ierr)
IMPLICIT NONE
integer ounit, nbd, chatter, ierr
character*4 datano
character*20 telescop, instrume, filter, detnam
character*20 ccls,ccnm,cdtp,cvsd,cvst
character*69 cdes, cbd(9)
c
c Description:
c Gets the mandatory CIF keywords from the current FITS header unit
c A max of 9 cbd (parameter boundary strings) allowed
c Returns 'noexist' as value for non-existent strings, or if any other
c FITSIO errors are encounted during reading
c !!! NOTE !!!
c - there is NO checking that the strings have legal values
c
c Passed parameters
c CHATTER i : chattiness flag for o/p (5 quiet,10 normal,>20 silly)
c DATANO i : calibration dataset number (ie 0001, 0002, etc)
c TELESCOP o : name of telescope/mission
c INSTRUME o : name of instrument/detector
c FILTER o : name of filter in use (if applicable)
c DETNAM o : name of specific detector (if INSTRUME insufficient)
c CCLS o : OGIP class of calibration file to be written
c CCNM o : OGIP codename for calibration file to be written
c CDTP o : Type of data file to be written (Real, task etc)
c CVSD o : Validity start date (UTC) for dataset
c CVST o : Validity start time (UTC on CVSD) for dataset
c CDES o : Descriptive string for dataset
c NBD o : Number of CBD strings read in & passed back
c CBD o : Array of Parameter boundary strings
c IERR o : Number of keywords not found (= Error flag; 0 for OK)
c
c User i/ps required (prompted for):
c None
c
c Include files
c None
c
c Called Routines:
c subroutine FCECHO : (FTOOLS) writes to standard o/p device
c subroutine FTGKYS : (FITSIO) Reads (string) keyword
c subroutine RMVBLK : (XANLIB) Removes blanks from a string
c
c Compilation & Linking
c require XANLIB, FITSIO & FTOOLS
c
c Origin:
c Original
c
c Authors/Modification History:
c Ian M George (1993 Feb 13), original
character*7 version
parameter (version = '1.0.0')
*-
*+ RD_OBSINFO
subroutine rd_obsinfo(chatter, iunit,
& object, obs_id, obs_pi, seqno, observer,
& proc_sys, proc_ver,proc_loc, proc_date, proc_time,
& ierr)
IMPLICIT NONE
integer chatter, iunit, ierr
character*(*) object, obs_id, obs_pi, seqno, observer
character*(*) proc_sys, proc_ver, proc_loc, proc_date
character*(*) proc_time
c
c Description
c Reads the Observation details to the current FITS header unit
c The following keywords are read
c (assuming found; blank strings returned otherwise)
c OBJECT - 'Object name'
c OBS_ID - 'Observation ID code'
c OBS_PI - 'Principal Investigator of observation'
c SEQNO - 'Sequence Number of Observation'
c OBSERVER- 'Name or ref code for Observer/Duty Scientist'
c PROC_SYS- 'Science Data Processing System used'
c PROC_VER- 'Revision level of Processing System',
c PROC_LOC- 'Location at which Processing System run'
c PROC_DAT- 'Date on which Processing System run'
c PROC_TIM- 'Time at which Processing System run (on PROC_DAT)'
c
c Passed Parameters
c CHATTER i : Chattiness flag (<5=quite,10=normal,>20=silly)
c IUNIT i : FORTRAN logical unit number of i/p file
c OBJECT i : (Astronomical) Target/object name
c OBS_ID i : Observation ID
c OBS_PI i : Name of Principal Investigator of Observation
c SEQNO i : (Scheduling) sequence number of observation
c OBSERVER i : Name or ref code for Observer/Duty Scientist
c PROC_SYS i : Name of data processing system
c PROC_VER i : Revision level of Processing System
c PROC_LOC i : Location at which Processing System run
c PROC_DAT i : Date on which Processing System run
c PROC_TIM i : Time at which Processing System run (on PROC_DAT
c IERR o : Return Error flag (0 = OK)
c
c Called Routines
c subroutine FCECHO : (FTOOLS) writes to standard o/p
c subroutine FTPHIS : (FITSIO) writes a history keyword
c subroutine FTPKYn : (FITSIO) writes a keyword of type n
c subroutine WT_FERRMSG : (CALLIB) writes FITSIO error message etc
c
c Origin
c An IMG original, based on wt_obsinfo.f (v1.1.1)
c
c Authors/Modification History
c Ian M George (1.0.0:1994 Feb 02), original
c
character*7 version
parameter (version = '1.0.0')
*-
*+ RDTOBS
subroutine rdtobs(chatter, iunit,
& date_obs, time_obs, date_end, time_end,
& mjdobs,ierr)
IMPLICIT NONE
integer chatter, iunit, ierr
double precision mjdobs
character*(*) date_obs, time_obs, date_end, time_end
c
c Description
c Reads the details of the time of the observation from the current
c FITS header unit
c The following keywords can be read
c DATE-OBS -'Nominal UT date of obs start (dd/mm/yy)'
c TIME-OBS -'Nominal UT time of obs start (hh:mm:ss)'
c DATE-END -'Nominal UT date of obs end (dd/mm/yy)'
c TIME-END -'Nominal UT time of obs end (hh:mm:ss)'
c
c Passed Parameters
c CHATTER i : chattiness flag for o/p (5 quite, 10 norm, >19 si
c iunit i : FORTRAN unit number of open File
c DATE_OBS i : Date of observation start (dd/mm/yy)
c TIME_OBS i : Time of observation start (hh:mm:ss) on day DATA_
c DATE_END i : Date of observation end(dd/mm/yy)
c TIME_END i : Time of observation end (hh:mm:ss) on day DATA_EN
c MJDOBS i : Mean MJD of observation
c IERR o : Error flag on return (zero = OK)
c
c Called Routines
c subroutine FTPHIS : (FITSIO) writes a history keyword
c subroutine FTPKYm : (FITSIO) writes key, values,comment
c subroutine FCECHO : (FTOOLS) writes to standard o/p
c subroutine WT_FERRMSG : (CALLIB) writes standard fitsio error mess
c
c Origin
c An IMG original, based upon wttobs (v1.0.1)
c
c Authors/Modification History
c Ian M George (1.0.1: 1994 Feb 02), original
c
character*7 version
parameter (version = '1.0.0')
*-
The tables in this section list other CALLIB routines currently available concerned with general FITS/caldb related tasks (Table 9), string manipulation (Table 10), and other tasks of general use (Table 11).
SYSTEM-SPECIFIC !
*+APNDFL
SUBROUTINE APNDFL(DIR, FILE)
CHARACTER*(*) DIR, FILE
C***********************************************************
C Description: Concatenates DIR and FILE interposing a '/'
C in the unix version. Ex. DIR='$DISK4:[ZELLAR],
C and FILE='TEST.TXT' --> $DISK4:[ZELLAR]TEST.TXT.
C Warning: the concatenated output string is
C written to FILE!
C
C Arguments: DIR (i) : The directory which will precede
C FILE
C FILE (i/o): The file which will follow DIR
C
C Origin: Written for the Calibration Database
C
C Author/Modification History:
C Ron Zellar (1993 Mar 23), original version
C
C************************************************************
*-Version 1.0
*+
subroutine CBFTOCH (buffer, lenb, string)
byte buffer(*)
integer lenb
character*(*) string
C---
C SF subroutine to convert a byte buffer array to a character
C string
C---
C buffer I Input byte array
C lenb I Length of array to be transfered
C string O Character string destination
C---
c Authors & Modifications
C rashafer (1985-Mar-08), original
c Ian M George (1993 Apr 23), made compatible with FTOOLS/CALTOOLS
C---
*-
*+ * - - - - - - * C A L D J * - - - - - - * * Gregorian Calendar to Modified Julian Date * * (Includes century default feature: use sla_CLDJ for years * before 100AD.) * * Given: * IY,IM,ID int year, month, day in Gregorian calendar * * Returned: * DJM dp modified Julian Date (JD-2400000.5) for 0 hr * J int status: * 0 = OK * 1 = bad year (MJD not computed) * 2 = bad month (MJD not computed) * 3 = bad day (MJD computed) * * Acceptable years are 00-49, interpreted as 2000-2049, * 50-99, " " 1950-1999, * 100 upwards, interpreted literally. * * Called: CCLDJ * * P.T.Wallace Starlink November 1985 * Modified by Ron Zellar for use in the OGIP CALDB *-
*+ * - - - - - * C L D J * - - - - - * * Gregorian Calendar to Modified Julian Date * * Given: * IY,IM,ID int year, month, day in Gregorian calendar * * Returned: * DJM dp modified Julian Date (JD-2400000.5) for 0 hr * J int status: * 0 = OK * 1 = bad year (MJD not computed) * 2 = bad month (MJD not computed) * 3 = bad day (MJD computed) * * The year must be -4699 (i.e. 4700BC) or later. * * The algorithm is derived from that of Hatcher 1984 * (QJRAS 25, 53-55). * * P.T.Wallace Starlink December 1985 * Modified by Ron Zellar for use in the OGIP CALDB *-
SYSTEM SPECIFIC
*+CCONC
SUBROUTINE CCONC(CBUF)
CHARACTER CBUF*(*)
C---------------------------------------------------------------------
C Description: Convert case of CBUF to default case of system.
C This ought to be obsolete.
C Modified for the Calibration Database... Used by
C the CPTEND software
C
C Arguments: CBUF I/O The file name to be converted.
C
C Origin: Swiped from Xanadu Library for Calibration Database
C
C Authors/Modification History:
C Xanadu Library
C Ron Zelar (1993, Feb 3) Modified for inclusion in
C Calibration Library
C---------------------------------------------------------------------
*-Version 1.0
SYSTEM SPECIFIC
*+ CGETLUN (UNX version)
subroutine CGETLUN(LUN)
IMPLICIT NONE
INTEGER LUN
c
c Description
C SYSTEM DEPENDENT routine to return a free Logical Unit Number.
c Note, units 1-9 should be avoided, since many programs use these uni
c without warning.
c
c Passed Parameters
c LUN o : An unopened logical unit number.
c
c Called Routines
c subroutine FCERR : (FTOOLS) Writes to standard Error
c
c Origin
c Swiped from XANLIB for inclusion in CALLIB
c
C Authors/Modification History:
c anon (unknown), Original XANADU version
c Ron Zellar (1993, Feb 3) Modified for Calibration Library
c Ian M George (1993 Jul 19), added version number & error checks
c
character*9 version
parameter(version = '1.0.2.UNX')
*-
No lines dumped
No lines dumped
*+CK_FILE
c -------------------------------------------------------
subroutine ck_file(ofile,ill_files,n_ill,valfil,chatter)
c -------------------------------------------------------
c --- DESCRIPTION ----------------------------------------------------
c This subroutine checks the validity of a user defined output filenam
c If the filename is valid, the logical valfil is returned as true.
c There are two forms of filename :
c filename : If it already exists error message is displayed and valfi
c is returned as false.
c !filename : Allows overwrite, with the exception of illegal filename
c in this case permission is denied. The file of this name
c deleted and then a new file of this name can be written.
c *** UNIX/ULTRIX ***
c Comparison between ill_files (illegal files), and ofile is case sens
c *** ----------- ***
c --- VARIABLES ------------------------------------------------------
c
IMPLICIT NONE
character*(*) ofile,ill_files(*)
integer chatter,n_ill
logical valfil
c
c --- INTERNALS ------------------------------------------------------
c
character*80 curfile,desc,checkfile
character*26 errstr
integer i,flen,clenact,fcstln
logical ext
c
c --- VARIABLE DIRECTORY ---------------------------------------------
c
c Arguments ...
c
c ofile char : output filename
c infile char : input filename
c chatter int : chattiness flag, if >20 verbose
c valfil logical : true if valid output filename
c
c Internals ...
c
c curfile char : temp' output filename
c desc char : user info
c errstr char : error string for this routine
c ext logical : true if file exists
c i int : Used a counter
c
c --- CALLED ROUTINES ------------------------------------------------
c
c subroutine DELFIL : (CALLIB) deletes file
c
c --- AUTHORS/MODIFICATION HISTORY -----------------------------------
c
c Rehana Yusaf (1993 June 21)
c Rehana Yusaf (1993 August 2) 1.0.1: Routine is made general, an arra
c illegal filenames is passed.
c Ian M George (93 Aug 09) 1.0.2: minor cosmetics, comm'd out 1 msg to
c Rehana Yusaf (93 Oct 12) 1.0.0; Use clenact to get actual filename l
c
character*5 version
parameter (version = '1.0.3')
*-
No lines dumped
No lines dumped
*+CLOCASE
SUBROUTINE CLOCASE(CBUF)
CHARACTER CBUF*(*)
C---------------------------------------------------------------------
C Description: Converts CBUF to lower case.
C
C Arguments: CBUF (i/r): The character array to convert to lower ca
C
C Origin: Swiped from the Xanadu Library for Calibration Library
C
C Authors/Modification History:
C Xanadu Library
C Ron Zellar (1993 Feb 3) Modified for inclusion in the
C Calibration Library
C---------------------------------------------------------------------
*-Version 1.0
*+CMP_FACT
c ----------------------------------------------------------------
subroutine cmp_fact(finchan,tlscop,instrum,nchan,dmode,cmpmode,
& channel,poschans,
& nfacts,stbins,endbins,cfacts,task,
& errflg,chatter)
c ----------------------------------------------------------------
c --- DESCRIPTION ----------------------------------------------------
c This routine determines the compression factor(s), in order to rebin
c data.
c --- VARIABLES ------------------------------------------------------
c
IMPLICIT NONE
character*(*) task,cmpmode,dmode,tlscop
integer finchan, chatter, nfacts, errflg, nchan,poschans
character*(*) instrum
integer stbins(*), endbins(*), cfacts(*), channel(*)
c
c --- LOCAL VARIABLES ------------------------------------------------
c
integer fact2, rem, comp, ierr, i
character*4 chanchar, chanchar2, ccomp
character*28 errstr
character*30 wrnstr
character*80 errinfo, desc
c
c --- VARIABLE DIRECTORY ---------------------------------------------
c
c --- AUTHORS/MODIFICATION HISTORY -----------------------------------
c
c Rehana Yusaf (1993 July 13)
c Rehana Yusaf (1993 August 23) 1.0.1;Do not read infile, if 'NONE'
c task added as passed parameter
c Rehana Yusaf (1993 Oct 19) 1.0.2; Infile no longer passed as an
c argument, in fact datamode is pass
c as an argument, as well as cmpmode
character*5 version
parameter (version = '1.0.2')
*-
*+ CNXPKSF
subroutine CNXPKSF(iunit,pkgtyp,index,nsubs,infoar,buffer
& ,lenbuf,qskip,ierrsf)
IMPLICIT NONE
integer iunit, index, nsubs, lenbuf, ierrsf
integer infoar(4)
byte buffer(*)
logical qskip
character*(*) pkgtyp
c Description
c SF subroutine to go to a given package, and decode the package head
c The bulk of this code is a direct copy of the XANADU routine NXPKSF
c minor modifications required for FTOOLS/CALTOOLS purposes
c
c Passed Parameters
c IUNIT I Io unit
c PKGTYP I/O Pkg type to be searched for. If blank, then
c -the routine will return at the next package header,
c -with pkgtyp = to the its type
c INDEX I/O Pkg index searched for. This is ignored if
c -pkgtyp is blank. If it is zero on input, then any
c -package is allowed, and its value on return is the
c -value particular to the given package.
c NSUBS O No. of subsequent records
c INFOAR O An array of information taken from the package
c -ID. (some of these values may not be modified)
c BUFFER O Work array to hold the header buffer.
c LEN I/O On input the maximum size of the buffer, on
c -output the actual size returned in the buffer.
c QSKIP I If true, then entire packages are skipped over until
c -one with the given properties is found, or an eof
c -occurs.
c IERRSF I/O SF error flag (see COPNRSF)
c 6 - read error
c 7 - EOF before next package (n.b. this is a 'silent'
c error... it will create no message no matter what the
c initial value of ierrsf
c 8 - wrong type package (qskip = false)
c 9 - wrong index package (qskip = false)
c 10 - wrong type package, backspace error
c 11 - wrong index package, backspace error
c
c N.B. Errors 8 and 9 will generate an automatic backspace in
c the file (if possible) so that the next read will re-read the
c package header that caused the question. It must be explicitly
c skipped over if not desired to read it again in the next call
c to CNXPKSF.
c
c Author & Modification History
c rashafer (85-Mar-08), original XANLIB version
c Ian M George (1.0.0: 1993 Apr 22), made compatible with FTOOLS/CALT
c Ian M George (1.0.1: 1993 Jul 19), better error handling
c
character*7 version
parameter (version = '1.0.1')
*-
*+ COPNRSF
subroutine COPNRSF(filenm,iunit,type,header,tmplte,nhist,ierrsf)
IMPLICIT NONE
character*(*) filenm, type, header, tmplte
integer iunit, nhist, ierrsf
c
c Description
c Subroutine to open for reading an SF format file, stripping
c out information from the ID record.
c On return, the file is positioned at the first history record
c or at the first package (if there is no history package).
c
c Passed Parameters
c FILENM I File name to be opened
c IUNIT I Fortran unit to use
c TYPE I/O If non-blank, it is checked against the current file
C -type. If blank, it is set to the current file type.
c HEADER O The actual contents of the ID record.
c TMPLTE O Template file (Could be empty).
c NHIST O No. of history records in initial history package.
c -If zero, there is no history package (or records).
c IERRSF O sf error (zero = OK)
c
c Author & Modifications
c rashafer (unknown date), XANADU original
c Ian M George (1.0.1:1993 Apr 22), made FTOOLS/CALTOOLS compatible
c Ian M George (1.0.2:1993 Jul 19), improved error handling
c Ian M George (1.0.3:1993 Aug 09), removed "readonly" from OPEN
c Ian M George (1.0.4:1993 Oct 12), rationalize the error handling
character*7 version
parameter (version = '1.0.4')
c
*-
*+COPYPHD
subroutine copyphd(infile,outfile,errflg,chatter)
c -------------------------------------------------
c --- DESCRIPTION ---------------------------------------------------
c
c This subroutine copys the primary header from infile to output file
c
c --- VARIABLES -----------------------------------------------------
c
IMPLICIT NONE
character*(*) infile,outfile
integer chatter, errflg
c
c --- INTERNALS -----------------------------------------------------
c
character*70 subinfo
character*32 errstr
integer i,block,iunit,ounit,status,nmore
c
c --- VARIABLE DIRECTORY ---------------------------------------------
c
c Arguments ...
c
c infile char : Input filename
c outfile char : Output filename
c chatter int : Chattiness flag
c
c --- CALLED ROUTINES ------------------------------------------------
c
c FTOPEN : (FITSIO) Open FITS file
c FTINIT : (FITSIO) Open/Create new FITS file
c FTCOPY : (FITSIO) Copy header and data
c FTCLOS : (FITSIO) Close FITS file
c
c --- AUTHORS/MODIFICATION HISTORY -----------------------------------
c
c Rehana Yusaf (1993 April 2)
c Rehana Yusaf (1993 July 20) : use cgetlun to get unit numbers
c Rehana Yusaf (1993 Aug 5) 1.0.2: USE FTCOPY, instead of calling
c copying header and data using seperate rou
character*5 version
parameter (version = '1.0.2')
*-
SYSTEM SPECIFIC
*+CPTEND
SUBROUTINE CPTEND(CDISK, CDIR, CFILE)
CHARACTER CDISK*(*), CDIR*(*), CFILE*(*)
C---------------------------------------------------------------------
C Description: Prefix exTENsion. Add 'prefix' to file name. Does
C automatic translation of environment variable as "disk"
C
C Arguments: CDISK (i) The disk name
C CDIR (i) The directory name
C CFILE (i/r) The file name
C
C Origin: Swiped form Xanadu Library for Claibration Library
C
C Authors/Modification History:
C AFT (1988 Aug 2) Original Version
C KAA (1990 Sep 23) added TRLOG check.
C Ron Zellar (1993 Apr 7) modified for Calibration Databa
C---------------------------------------------------------------------
*- Version 1.0
*+ CRMVBLK
subroutine crmvblk(name)
IMPLICIT NONE
character*(*) Name
c
c Description:
c Removes all blanks from a string
c
c Passed Parameters:
c NAME i/o: String to be de-blanked
c
c Called Routines:
c None
c
c Origin:
c Direct copy of the XANADU routine RMVBLK (copied 1993 March 31),
c
c Authors/Modification History:
c Linda Osborne (1989 Apr 12), original
c Nick White (1992 Jun 08), removed c*400 dummy array
c Ian M George (1993 Mar 31), direct copy to caldb library
character*7 version
parameter (version = '1.0.0')
*-
No lines dumped
No lines dumped
*+ CRSTRSF
subroutine crstrsf(iunit,strar,nstr,nstrot,ierrsf)
IMPLICIT NONE
integer iunit, nstr, nstrot, ierrsf
character*(*) strar(*)
c
c Description
c SF subroutine to write an array of character strings as
c auxilary records to the current SF package.
c N.B. If the package header shows an indeterminate no. of records
c then good practice is for the user to add a terminating record.
c (one with length 0).
c Hacked version of XANADU routine RSTRSF
c
c Passed Parameters
c iunit i4 i: read unit
c strar c*(nstr) i/r: Array of character strings to be read.
c nstr i4 i: dimension of array.
c nstrot i4 i/r: No. of string. to be read in array.
c A negative value
c indicates that the 'indeterminate' size
c auxilary region condition holds.
c Returns the actual no of strings read.
c If an error condition arises such that too few
c records can be found, then nstr is returned
c with the actual no. of records read.
c ierrsf i4 i/r: SF error flag
c 17 - io read error
c 18 - EOF condition before required records read.
c 19 - Too few input records.
c 20 - Unable to reposition after a badly terminated
c indefinite no. of auxilary records.
c 21 - At least one has insufficient info
c Called Routines
c
c Origin
c IMG Hacked version of XANADU routine RSTRSF, written by Rick Shafer
c which itself was hacked from the XANADU routine WSTRSF
c
c Author/Modification History
c rashafer (1995 Mar 16), original RSTRSF
c Ian M George (1993 Jun 21), FTOOL-ized it
character*7 version
parameter (version = '1.0.0')
*-
*+ CRSUBSF
subroutine crsubsf( unit, buffer, length, ierrsf)
IMPLICIT NONE
integer unit,length,ierrsf
byte buffer(*)
c
c Description
c SF routine to read a single subsidiary record to the current packag
c Nicked from XANLIB (but FTOOL-ized)
c
c Passed Parameters
c UNIT i4 i: unit no.
c BUFFER b(length) i: the buffer
c LENGTH i4 i: the length of the buffer, on return the
c actual number of bytes read. N.B, that when
c a package has been explicitly terminated, the
c terminating record returns a length of zero. (And
c the silent error #27 is raised).
c IERRSF i4 i/r: the error flag
c 7 - eof (silent)
c 17 - I/O read error
c 20 - Unable to reposition after a badly terminated
c package.
c 21 - Buffer too small
c 27 - At end of the package (silent)
c
c Author & Modification History
c rashafer (1986 april 16) , XANADU original
c Ian M George (1.0.1:1993 Apr 22), made FTOOLS/CALTOOLS compatible
c Ian M George (1.0.2:1993 Jul 19), better error diagnostics
character*7 version
parameter (version = '1.0.2')
*-
SYSTEM SPECIFIC
*+CSPAWN
SUBROUTINE CSPAWN(CBUF, LBUF, IER)
CHARACTER CBUF*(*)
INTEGER LBUF, IER
C---------------------------------------------------------------------
C Description: Spawn to operating system. If LBUF=0 then this routine
C should spawn a shell and leave the user in the shell
C until the user logs out or exits the shell. If LBUF<>0
C then the system should only execute that one command an
C immediately return to the calling routine.
C
C Arguments: CBUF (i): The system command to execute
C LBUF (i): The number of valid characters in CBUF
C (can be zero)
C IER (r): =0 spawn was successful, <>0 otherwise
C
C Origin: Swiped from the Xanadu Library for Calibration Library
C
C Authors/Modification History:
C Xanadu Library
C Ron Zellar (1993 Feb 3) Modified for inclusion in
C Calibration Library
c Ian M George (1.1.0: 1993 Aug 10), replaced write(*,*)
C---------------------------------------------------------------------
*-Version 1.1.0
SYSTEM SPECIFIC
*+CTRLOG
SUBROUTINE CTRLOG(CBUF, LBUF, CRET, LRET)
CHARACTER CBUF*(*), CRET*(*)
INTEGER LBUF, LRET, FCSTLN
C---------------------------------------------------------------------
C Description: Translate the logical name CBUF(:LBUF) to return
C CRET(:LRET)
C
C Arguments: CBUF (i): The string to translate
C LBUF (i): The number of valid characters in CBUF
C (can be zero)
C CRET (r): The translated string
C LRET (r): The number of valid characters in CRET
C (can be zero)
C
C Origin: Swiped from the Xanadu Library for Calibration Library
C
C Authors/Modifcation History:
C Ron Zellar (1993 Feb 3) Modifed for inclusion in the
C Calibration Library
C---------------------------------------------------------------------
*-Version 1.0
SYSTEM SPECIFIC
*+DELFIL
SUBROUTINE DELFIL(FILNAM)
character*(*) FILNAM
C********************************************************************
C Description: Deletes the file named FILNAM. FILNAM can contain
C the directory path to the file.
C
C Arguments: FILNAM (i) : The name of the file to be removed
C
C Origin: Written for the Calibrtion Database
C
C Authors/Modification History:
C Ron Zellar (1993 Mar 16), original version
C
C********************************************************************
*-Version 1.0
*+DO_ADDCOM
subroutine do_addcom(chatter, ascfil, fitfil, extname)
IMPLICIT NONE
integer chatter, ierr
character*20 ascfil, fitfil, extname
c
c Description
c Finds & opens fitfil, locates desired extension, then opens & reads
c ascfil, a simple ASCII file, the contents of which it adds to fitfi
c as COMMENT keywords.
c
c Passed parameters
c CHATTER i : chattiness flag for o/p (5 quiet,10 normal,>20
c ASCFIL o : Input ASCII filename
c FITFIL o : Input FITS filename
c EXTNAME o : name of xtension to which keywords are to be ad
c IERR o : Error flag (0 for OK)
c
c User i/ps required:
c None
c
c Include files
c None
c
c Called routines
c subroutine CGETLUN : (CALLIB) Gets a free FORTRAN unit numb
c subroutine CRMVBLK : (CALLIB) Removes blanks from a string
c
c Compilation
c link with XANLIB, FTOOLS & FITSIO
c
c Origin
c Original
c
c Authors/Modification History:
c Ian M George (1992 Nov 04), original
c Ian M George (1993 Feb 18), minor i/o modifications
character*7 version
parameter (version = '1.0.1')
*-
*+ FNDEXT
subroutine fndext(chatter, iunit, instr,
& nsearch, nfound, next, outhdu, outver, extnam, ierr)
IMPLICIT NONE
integer iunit, chatter, ierr, nsearch, nfound
integer next(nsearch)
character*(*) instr
character*(*) outhdu(9,nsearch), extnam(nsearch), outver(9,nsearch)
c Description
c Searches through the current, plus a specified number of additional
c extensions, of a FITS file looking for extensions with a given EXTN
c values which match passed i/p string. Returned are the number of ex
c safifying the criteria, the extension number (relative to the curre
c extension on input), the EXTNAME, the full HDUCLASn hierarchy, and
c HDUVERSn hierarchy for each of those extensions.
c The FITS file is assumed to be open, and is rewound back to the
c Header unit (extension) it was at on entry.
c !!! NOTE !!! Backwards searches are not yet supported.
c The special wild-card character "*" is allowed in any/
c of the i/p strings to indicate that all EXTNAME values
c are required.
c
c Passed Parameters
c CHATTER i : The chattiness flag (>9 increasing verbose)
c IUNIT i : The FORTRAN unit of the open FITS file
c INSTR i : Strings to be searched for
c NSEARCH i : The number extensions to be searched
c (in addition to current extension)
c NFOUND o : The number of extensions found with EXTNAME
c matching INSTR
c NEXT o : Array of the numbers of each extension found
c (relative to the extension on input)
c OUTHDU o : 2-d array of HDUCLASn values for each xtens found
c OUTVER o : 2-d array of HDUVERSn values for each xtens found
c EXTNAM o : Array of EXTNAME value for each xtens found
c IERR o : Error flag (zero = OK)
c
c Origin
c Original
c
c Called Routines
c {incomplete}
c
c Author/Modification History
c Ian M George (1.0.0: 93 Nov 18) Original
character*7 version
parameter (version='1.0.0')
*-
*+ FNDHDU
subroutine fndhdu(chatter, iunit, ninstr, instr,
& nsearch, nfound, next, outhdu, outver, extnam, ierr)
IMPLICIT NONE
integer iunit, chatter, ninstr, ierr, nsearch, nfound
integer next(nsearch)
character*20 instr(ninstr)
character*20 outhdu(9,nsearch), extnam(nsearch), outver(9,nsearch)
c Description
c Searches through the current, plus a specified number of additional
c extensions, of a FITS file looking for extensions which contain HDU
c values which match passed i/p strings. Returned are the number of e
c safifying the criteria, the extension number (relative to the curre
c extension on input), the full HDUCLASn hierarchy, the EXTNAME, and
c HDUVERSn hierarchy for each of those extensions.
c The FITS file is assumed to be open, and is rewound back to the
c Header unit (extension) it was at on entry.
c !!! NOTE !!! Backwards searches are not yet supported.
c The i/p strings must be in ordered is the same way as the
c expected HDUCLASn hierarchy, with instr(1) corresponding
c to the highest level (HDUCLAS1)
c The special wild-card character "*" is allowed in any/
c of the i/p strings to indicate that all HDUCLASn values
c corresponding to this string to deemed acceptable.
c
c Passed Parameters
c CHATTER i : The chattiness flag (>9 increasing verbose)
c IUNIT i : The FORTRAN unit of the open FITS file
c NINSTR i : The number of strings to be searched for
c INSTR i : Array of strings to be searched for
c NSEARCH i : The number extensions to be searched
c (in addition to current extension)
c NFOUND o : The number of extensions found with HDUCLASn
c matching INSTR(n)
c NEXT o : Array of the numbers of each extension found
c (relative to the extension on input)
c OUTHDU o : 2-d array of HDUCLASn values for each xtens found
c OUTVER o : 2-d array of HDUVERSn values for each xtens found
c EXTNAM o : Array of EXTNAME value for each xtens found
c IERR o : Error flag (zero = OK)
c
c Origin
c Original
c
c Called Routines
c {incomplete}
c
c Author/Modification History
c Ian M George (1.0.0: 93 Nov 17) Original
character*7 version
parameter (version='1.0.0')
*-
*+GETKEYS
c -------------------------------------------------
subroutine getkeys(iunit,nkeys,keys,chatter,ierr)
c -------------------------------------------------
c --- DESCRIPTION ----------------------------------------------------
c This subroutine reads all the keywords in an extension and returns
c an array of keywords, this is usefull for other routines as the arra
c can be used to ensure no duplication of keywords.
c NOTE !!! HISTORY AND COMMENT keyword names are NOT included
c --- VARIABLES ------------------------------------------------------
c
IMPLICIT NONE
integer iunit,nkeys,chatter,ierr
character*8 keys(*)
c
c --- VARIABLE DIRECTORY ---------------------------------------------
c
c iunit int i : file unit number
c chatter int i : Verboseness flag
c ierr int i : error flag, 0 is okay
c keys char o : array of keyword names
c
c --- CALLED ROUTINES ------------------------------------------------
c
c FTGHSP : (FTOOLS/FITSIO) Gets numbers of keywords
c FTGREC : (FTOOLS/FITSIO) Reads record
c WT_FERRMSG : (FTOOLS/CALLIB) Writes approriate error message
c
c --- COMPILATION/LINKING --------------------------------------------
c
c FTOOLS/FITSIO, FTOOLS/CALLIB
c
c --- AUTHORS/MODIFICATION HISTORY -----------------------------------
c
c Rehana Yusaf (1993 Oct 27) 1.0.0;
c
character*6 version
parameter (version='1.0.0')
*-
*+GRP_RMF
subroutine grp_rmf(chatter, maxchan, ichan, maxen, ienerg,
& matrix, thresh, maxgrp, ngrp, F_chan, N_chan,
& ierr)
IMPLICIT NONE
integer chatter, ierr
integer ichan, ienerg, maxgrp, maxchan,maxen
real thresh
real matrix(maxchan, *)
integer ngrp(*), F_chan(maxen,*)
integer N_chan(maxen,*)
c
c Description
c Program to find and return the channel subsets from a full matrix
c ie groups of adjacent channels with values above THRESH for each
c energy.
c
c Passed parameters
c CHATTER i : Chatter flag (5 low, 10 normal,>20 debuggi
c MAXCHAN i : Maximum Channel index array dimension
c ICHAN i : Number of channels in full matrix
c MAXEN i : Maximum energy index array dimension
c IENERG i : Number of energy bins in full matrix
c MATRIX i : FULL matrix
c THRESH i : Threshold at or below which elements are i
c MAXGRP i : Max no of chan subsets allowed per energy
c NGRP o : Number of chan subsets per energy bin
c F_CHAN o : First chan is each chan subset
c N_CHAN o : Number chans is each chan subset
c IERR o : Error Flag (0=OK)
c
c Called routines
c subroutine FCECHO : (FTOOLS) Writes to standard o/p device
c
c Origin
c Original
c
c Authors/Modification History:
c Ian M George (1992 Nov 11), original
c Ian M George (1993 Feb 18), major overhaul
c Rehana Yusaf (1.1.1: 1993 July 29), MAXCHAN & MAXEN args added f
c array dimensions
c Ian M George (1.1.2: 1993 Jul 30), cosmetics
character*7 version
parameter (version = '1.1.2')
*-
SYSTEM SPECIFIC
*+GTDATE
subroutine gtdate(day, month, year)
implicit none
integer day, month, year
C---------------------------------------------------------------------
C Description: Gets the current system date and time and returns the
C day of the month, month number and year as integers to
C day, month, and year respectively.
C
C Arguments: day (r): the day of the month (1-31)
C month (r): the month number (1-12)
C year (r): the year (1993-2092)
C
C Origin: Written for the Calibration Database
C
C Authors/Modification History:
C Ron Zellar (1993 June 9) Original Version
C
C---------------------------------------------------------------------
*-Version 1.0
SYSTEM SPECIFIC
*+GTDIR
subroutine gtdir(dir)
character*(*)dir
C---------------------------------------------------------------------
C Description: Gets the current working directory and returns it to th
C argument dir. The VMS version will return the disk and
C directory. If the current working directory is not val
C a blank directory string is returned.
C
C Arguments: dir (r): the current working directory
C
C Origin: Written for the Calibration Database
C
C Authors/Modification History:
C Ron Zellar June 17, 1993 Original Version
C---------------------------------------------------------------------
*-Version 1.0
SYSTEM SPECIFIC
*+GTTIME
subroutine gttime(hour, min, sec)
implicit none
integer hour, min, sec
C---------------------------------------------------------------------
C Description: Gets the current system time and returns the hour,
C minute, and second to the arguments hour, min, sec
C respectively.
C
C Arguments: hour (r): the hour of the day (0-24)
C min (r): the number of minutes after hour (0-60)
C sec (r): the number of seconds after min (0-60)
C
C Origin: Written for the Calibration Database
C
C Authors/Modification History:
C Ron Zellar (1993 Jun 9) Original version
C
C---------------------------------------------------------------------
*-Version 1.0
*+GT_CSYSNMS
subroutine gt_csysnms(chatter, csys,
& nam1, nam2, ierr)
IMPLICIT NONE
integer chatter, ierr
character*8 csys, nam1, nam2
c
c Description:
c Returns the standard OGIP CALDB column names for a given spatial
c coordinate system (csys)
c
c Passed parameters
c CHATTER i : chattiness flag for o/p (5 quite,10 normal,>20
c CSYS i : Coordinate system in use
c nam1 o : Column name for one coordinate
c nam2 o : Column name for other coordinate
c IERR o : Error status flag (0 = OK)
c
c User i/ps required (prompted for):
c None
c
c Include files
c None
c
c Called Routines:
c subroutine FCECHO : (FTOOLS) Writes to standard o/p device
c
c Compilation & Linking
c link with CALLIB & FTOOLS
c
c Origin:
c Original
c
c Authors/Modification History:
c Ian M George (1993 Feb 22), original
c Ian M George (1993 Mar 30), added XMA_CART coords
character*7 version
parameter (version = '1.0.1')
*-
*+MVER
c -----------------------------------------------------
subroutine mver(iunit,extnum,ninstr,instr,nsearch,
& next,outhdu,extnames,outver,
& extname,errflg,chatter)
c -----------------------------------------------------
c --- DESCRIPTION ---------------------------------------------------
c
c This routine moves to the desired extension, either specifed as
c extnum, or by searching for HDUCLAS/EXTNAME values. If more than one
c of the desired extension is found an error is returned.
c NOTE: If extnum .LE.0 then HDUCLAS/EXTNAME are used to move to
c extension.
c
c --- VARIABLES -----------------------------------------------------
c
IMPLICIT NONE
character*(*) instr(*),extname
integer iunit,ninstr,nsearch,errflg,chatter
integer next(*),extnum
character*(*) outhdu(9,*),extnames(*),outver(*)
c
c --- VARIABLE DIRECTORY --------------------------------------------
c
c extnum int i : extnum, if less than 0, than HDUCLAS/EXTNAME
c used to move to desired extension
c iunit int o : i/o unit number
c ninstr int i : Number of hduclas values to be searched for
c instr char i : array of hduclass strings to serach for
c nsearch int i : Number of extensions searched
c extname char i : extension name to search for,if HDUCLAS keys
c not present
c extnames char o : array of extnames found
c chatter int i : chattines flag
c errflg int i : Error flag = 0 okay
c = 2 >1 extensions found
c = 3 0 extensions found
c = 4 problem moving to ext
c
c --- AUTHORS/MODIFICATION HISTORY ----------------------------------
c
c Rehana Yusaf (1994 May 24) 1.0.0; Stripped out from MVEXT
character*5 version
parameter (version = '1.0.0')
*-
*+MVEXT
c -----------------------------------------------------
subroutine mvext(rwmode,infile,iunit,ninstr,instr,
& nsearch,next,outhdu,extnames,outver,
& extname,errflg,chatter)
c -----------------------------------------------------
c --- DESCRIPTION ---------------------------------------------------
c
c This routine opens infile (passed filename) and moves to the
c desired extension, either specifed as INFILE[extnum] or by
c searching for HDUCLAS/EXTNAME values. If more than one of the
c desired extension is found an error is returned.
c
c --- VARIABLES -----------------------------------------------------
c
IMPLICIT NONE
character*(*) infile,instr(*),extname
integer iunit,ninstr,nsearch,errflg,chatter
integer rwmode,next(*)
character*(*) outhdu(9,*),extnames(*),outver(*)
c
c --- VARIABLE DIRECTORY --------------------------------------------
c
c rwmode int i : read/write mode, the file is opened using
c this mode - 0 is readonly,1 is read and write
c infile char i : filename
c iunit int o : i/o unit number
c ninstr int i : Number of hduclas values to be searched for
c instr char i : array of hduclass strings to serach for
c nsearch int i : Number of extensions searched
c extname char i : extension name to search for,if HDUCLAS keys
c not present
c extnames char o : array of extnames found
c chatter int i : chattines flag
c errflg int i : Error flag = 0 okay
c = 1 error opening file
c = 2 >1 extensions found
c = 3 0 extensions found
c = 4 problem moving to ext
c
c --- CALLED ROUTINES -----------------------------------------------
c
c MVER : CALLIB routine which moves to desired extension
c
c --- AUTHORS/MODIFICATION HISTORY ----------------------------------
c
c Rehana Yusaf (1994 March 21) 1.0.0;
c
c Rehana Yusaf (1994 May 24) 1.1.0; subroutine MVER has been
c introduced. It moves to the
c desired extension, assuming
c the file is already open.
character*5 version
parameter (version = '1.1.0')
*-
SYSTEM-SPECIFIC !
*+RENAME
subroutine mvfile(file1,file2)
character*(*) file1,file2
C---------------------------------------------------------------------
C Description: Spawns a 'mv file1 file2' on UNIX systems or a
C 'rename file1 file2' on VMS systems.
C
C Arguments: file1 (i) : the file to be renamed
C file2 (i) : the file name file1 will have
C
C Origin: Written for the Caldb
C
C Authors/Modification History:
C Ron Zellar Oct 1, 1993
C---------------------------------------------------------------------
*+ version 1.0
character*200 str
integer length,errstat,fcstln
str = 'rename '//file1(:fcstln(file1))//' '//file2(:fcstln(file2))
length = fcstln(str)
call cspawn(str,length,errstat)
return
end
*+OP_NPA
subroutine op_npa(filnam, chatter, ounit, ierrstat)
IMPLICIT NONE
integer chatter
integer ounit, ierrstat
character*80 filnam
c
c Description:
c Opens a new (bitpix=-32,blocksize=2880) FITS file & writes a
c primary header & null primary array.
c (system) DATE keyword is also written into the P.header.
c
c !!! Note !!! File is left open on return
c and MUST BE CLOSED by FTCLOS
c or ANOTHER EXTENSION ADDED by FTCRHD
c in order to (automatically) write the mandatory END header keyword
c
c Passed parameters
c FILNAM i : full name (incl extension) of the FITS file to
C opened
c CHATTER i : chattiness flag for o/p (5 quiet,10 normal,>20
C silly)
c OUNIT o : FORTRAN unit number of opened file
c IERRSTAT o : Error flag (.NE.0 on error)
c
c User i/ps required (prompted for):
c None
c
c Include files
c None
c
c Called Routines:
c subroutine CGETLUN : (CALLIB) Gets free i/o unit number
c subroutine FCECHO : (FTOOLS) Write to standard i/o
c subroutine FCERR : (FTOOLS) Write to standard error
c subroutine FCSTLN : (FTOOLS) Get length of string
c subroutine FTINIT : (FITSIO) Creates a new FITS file
c subroutine FTGERR : (FITSIO) Returns Error text
c subroutine FTPDAT : (FITSIO) Writes (current system) DATE keywo
c subroutine FTPDEF : (FITSIO) Defines structure of FITS P.Array
c subroutine FTPPRH : (FITSIO) Writes mandatory P.Array keywords
c subroutine WT_FERRMSG : (CALLIB) write standard fitsio message
c
c Compilation & Linking
c link with XANLIB & FITSIO
c
c Origin:
c Code mostly hacked from within the BBRSP program
c
c Authors/Modification History:
c Alan Smale (1992 Sept/Oct), original BBRSP version
c Ian M George (1.0.1:1992 Dec 28), tidied-up version
C Ron Zellar and Rehana Yusaf (1.0.2:1993 Jul 16), Changed write(5,*)
c Ian M George (1.0.3: 93 Jul 20), better error handling
character*7 version
parameter (version = '1.0.3')
*-
*+PAR_DIM
c --------------------------------------------
subroutine par_dim(dimstr,ndims,indexs,ierr)
c --------------------------------------------
c --- DESCRIPTION ----------------------------------------------------
c This subroutine is a general parser for the FITSIO TDIM keyword.
c An example TDIM keyword -
c TDIM1 = (nrad,ntheta,nenerg) for a 3D column, i.e TDIM1 = (20,1,1)
c This is stored as a character string, and this routine extracts all
c the dimension values.
c --------------------------------------------------------------------
c --- VARIABLES ------------------------------------------------------
c
IMPLICIT NONE
integer ndims,indexs(*),ierr
character*(*) dimstr
c
c --- VARIABLE DIRECTORY ---------------------------------------------
c
c ndims int o : Number of dimensions
c dimstr char i : TDIM string
c indexs int o : Array of dimension values
c ierr int o : Error flag, 0 is okay
c
c --- CALLED ROUTINES ------------------------------------------------
c
c FCSTLN : Fortran library routine, gives string length
c INDEX : Fortran library routine, gives character position
c in a string
c CRMVLBK : Removes leading blanks
c
c --- AUTHORS/MODIFIACTION HISTORY ----------------------------------
c
c Rehana Yusaf 1.0.0 ; Sept 20 1993
c
character*5 version
parameter (version = '1.0.0')
*-
*+PPTHNM
subroutine ppthnm(path, disk, dir, file)
implicit none
character*(*) path, disk, dir, file
C---------------------------------------------------------------------
C Description: Parses a path string into its disk, directory and
C filename parts. The directory name is returned with '/
C characters separating the directory names. For example
C if the VMS version of this routine is used, and the pat
C passed to PPTHNM was DISK:[DIR1.DIR2]FILE.TXT, then
C disk = 'DISK', dir = 'dir1/dir2', and file = 'file.txt'
C would be returned. The UNIX version of this program
C requires that the first character of the pathname be '/
C In addition, the UNIX version will return the first
C directory after the leading '/' as the disk. For
C example, if the path passed to PPTHNM was
C /dir1/dir2/dir3/file.txt, then disk = 'dir1',
C dir = 'dir2/dir3', and file = 'file.txt' would be
C returned.
C
C Arguments: path (i): the pathname to be parsed
C disk (r): the diskname of the path
C dir (r): the directory part of the path
C file (r): the filename part of the path
C
C Origin: Written for the Calibration Database
C
C Authors/Modification History:
C Ron Zellar (1993 June 10) Original Version
C
C---------------------------------------------------------------------
*-Version 1.0
*+RD_RSP
subroutine rd_rsp(rspfil,chatter,
& maxhist, nk_hist, hist,
& maxcomm, nk_comm, Comment,
& telescop, instrume, filter, area,
& maxchan, ichan, maxne, ienerg, energ_lo, energ_hi,
& imaxgrp, ngrp, F_chan, N_chan, matrix,
& iebound, e_min, e_max,
& errstat)
IMPLICIT NONE
integer maxhist, maxcomm
integer maxchan, maxne, imaxgrp
integer chatter, errstat
integer nk_hist, nk_comm
integer ipha, ichan, ienerg, iebound
integer ngrp(imaxgrp)
integer F_chan(maxne,imaxgrp), N_chan(maxne,imaxgrp)
real area
real energ_lo(maxne), energ_hi(maxne), matrix(maxchan,maxne)
real e_min(maxchan), e_max(maxchan)
character*16 telescop, instrume, filter
character*80 rspfil
character*70 hist(maxhist), Comment(maxcomm)
c
c Description:
c Reads old-style (SF) RSP matrices based on the (old) RDRSP program,
c the hacked BBRSP program to convert BBXRT detector response matrice
c from SF to FITS format (credits given below).
c The structure of the RDRSP program has been left fairly intact, but
c a number of "old" SF routines have been copied, inserted & (slightl
c rewritten.
c Messy, and extremely unsophisticated, but moderately straightforwar
c !!! NOTE !!! This routine uses XPI, and assumes an XPI par file
c has been defined & opened (via TBLDSTAND)
c
c Passed parameters
c RSPFIL i : name of the SF RSP file to be read in
c CHATTER i : chattiness flag for o/p (5 quite,10 normal,>20
c MAX_HIST i : max no. of history strings allowed
c NK_HIST o : No. of history keyword strings found
c HIST o : Array of history keyword strings
c (mainly History Records from RSP file)
c MAX_COMM i : max no. of comment strings allowed
c NK_COMM o : No. comments keyword strings
c COMMENT o : Array of comment keyword strings
c (All other terminal o/p originally produced by
c TELESCOP o : Attempt at finding Telescope/Mission Name
c (written to par file & user prompted as check)
c INSTRUME o : Attempt at finding Instrument/Detector Name
c (written to par file & user prompted as check)
c FILTER o : Filter in use - currently assumed to be 'NONE'
c (written to par file & user prompted as check)
c AREA o : Response Effective Area
c MAXCHAN i : max no. of PHA channels allowed
c ICHAN o : Actual Number of PHA channels in full matrix
c MAXNE i : max no. of energy bins allowed
c IENERG o : Actual Number of energy bins in full matrix
c ENERG_LO o : Array containing min energy for each Energy bin
c ENERG_HI o : Array containing max energy for each Energy bin
c IMAXGRP i/o : Max no. grps in any given row
c (must be set to max allowed on i/p)
c NGRP o : Array containing no. Channel subsets for each E
c F_CHAN o : Array containing number of the 1st chan in each
c Channel subset for each energy
c N_CHAN o : Array containing number of channels in each
c Channel subset for each energy
c MATRIX o : Array containing the ** full ** response matrix
c IEBOUND o : Number of channels in E_MIN & E_MAX arrays
c E_MIN o : Array containing Lower energy bound for each ch
c E_MAX o : Array containing Upper energy bound for each ch
c ERRSTAT o : Error Flag (0 if everything OK)
c
c User i/ps required (prompted for from par file):
c None
c
c Include files
c None - responsesf.inc (version 16-OCT-1992) has been hardwired in
c (for SF response file package definitions)
c
c Called Routines:
c subroutine FCECHO : (FTOOLS) Writes to standard o/p device
c subroutine CGETLUN : (CALLIB) Gets free i/o unit number
c subroutine CNXPKSF : (CALLIB) Decodes SF package header
c subroutine COPNRSF : (CALLIB) Opens SF RSP file
c subroutine PCLGST : (XPI) Gets string from parameter file
c subroutine PCLPST : (XPI) Puts string to parameter file
c subroutine CRMVLBK : (CALLIB) Removes leading blanks from a stri
c subroutine CRSUBSF : (CALLIB) Reads a single subsidiary SF file
c
c Compilation & Linking
c link with CALLIB, FTOOLS & XPI
c
c Origin:
c RDRSP & BBRSP as described above & below
c
c Authors/Modification History:
c M A Sweeny (1986 May 02), RDRSP original
c R A Shafer (1986 May 28), unknown RDRSP modifications
c Alan Smale (Sept/Oct 92), original BBRSP version
c Ian M George (1.0.0:1992 Oct 13), tidied-up version
c Ian M George (1.1.0:1993 Feb 18), fixed i/o
c Ian M George (1.1.1:1993 May 19), fixed stupid string probs
c Ian M George (1.1.2:1993 Jun 21), fixed inst/det decoupling
c Ian M George (1.1.3:1993 Jul 19), fixed I*2 nightmare
c Ian M George (1.1.4:1993 Aug 10), changes to COPNRSF
character*7 version
parameter (version = '1.1.4')
*-
*+ REMAP
subroutine remap(chatter, nin, xin_lo, xin_hi, y_in,
& nout, xout_lo, xout_hi, y_out, acc, ierr)
IMPLICIT NONE
integer nin, nout, chatter, ierr
real acc
real xin_lo(nin), xin_hi(nin), y_in(nin)
real xout_lo(nin), xout_hi(nin), y_out(nin)
c
c Description
c Remaps (interpolates/extrapolates) user-supplied 1-d array (y_in) b
c on a grid specified by the lower & upper bin boundaries (xin_lo & xi
c onto a new user-specified grid with bin boundaries xout_lo & xout_hi
c with the output written to y_out.
c
c Passed Parameters
c CHATTER i : Chattiness flag (>20 increasing verbose)
c NIN i : No. bins in i/p grid
c XIN_LO i : Array of Lower boundary of bins in i/p grid
c XIN_HI i : Array of Upper boundary of bins in i/p grid
c Y_IN i : Array to be remapped
c NOUT i : No. bins in o/p grid
c XOUT_LO i : Array of Lower boundary of bins in o/p grid
c XOUT_HI i : Array of Upper boundary of bins in o/p grid
c Y_OUT o: Remapped array
c ACC i : Fractional accuracy in region of overlap betwee
c grid, which if not obtained warning messages will
c be written (and IERR set to bad)
c IERR o: Error flag on return (zero = OK)
c
c Author/Modification History
c Ian M George (93 Nov 17)
character*7 version
parameter (version = '1.0.0')
*-
*+RMVEXSP
subroutine rmvexsp(instr,newstr)
c --------------------------------
c --- DESCRIPTION ----------------------------------------------------
c
c This routine compresses more than one blank to a single blank in
c a string
c
c --- VARIABLES ------------------------------------------------------
c
IMPLICIT NONE
character*(*) instr,newstr
integer i,j,length
c
c --- VARIABLE DIRECTORY ---------------------------------------------
c
c Arguments ...
c
c instr char : Character string
c newstr char : New character string without extra blanks
c
c --- AUTHORS/MODIFICATION HISTORY -----------------------------------
c
c Rehana Yusaf (1993 March 30)
c
character*5 version
parameter (version = '1.0.0')
*-
*+PG_FCECHO
c ------------------------------------------------
subroutine pg_fcecho(context,page,ln_cnt,status)
c ------------------------------------------------
c --- DESCRIPTION -----------------------------------------------
c
c This routine send a message to the terminal, and pages the
c message if page==yes. Using a pagelength of 23
c
c --- VARIABLES -------------------------------------------------
c
IMPLICIT NONE
character*(*) context
logical page
integer status,ln_cnt
c
c --- VARIABLE DIRECTORY ----------------------------------------
c
c context char : message to be sent to screen
c page logical: If "yes" then output is paged by using more
c ln_cnt int : Counter for number of lines displayed to screen
c status int : Error status flag, 0 is okay
c
c --- CALLED ROUTINES -------------------------------------------
c
c UCLGSB : (HOST) Gets boolean input
c FCECHO : (FTOOLS) Screen write
c
c --- AUTHORS/MODIFICATION HISTORY ------------------------------
c
c Rehana Yusaf (1994 April 14) 1.0.0; Original
c
character*5 version
parameter (version ='1.0.0')
*-
*+WT_COM
c ------------------------------------------------------------
subroutine wt_com(infile,outfile,hduclas2,phaversn,fchan,extnum,
& channel,counts,rcts,dtype,qerror,serr,
& qsys,syserr,qqual,qualty,qgroup,grping,
& nchan,detchans,conv,phsize,mnver,task,n_comm,
& comms,ckeys,ckrec,nckeys,errflg,chatter)
c ------------------------------------------------------------
c --- DESCRIPTION ----------------------------------------------------
c
c This subroutine is implemented if the user chooses to write to a
c file, that is the commands WRITE and EXIT (in grppha)
c implement this routine.
c It makes a copy of the input file, apart from the SPECTRUM extension
c this extension is written with the current changes in standard OGIP
c format.
c
c --- VARIABLES ------------------------------------------------------
c
IMPLICIT NONE
character*(*) infile,outfile,ckeys(*),ckrec(*),task, comms(*)
character*(*) hduclas2,phaversn
integer phsize,chatter,nchan,nckeys,n_comm,extnum
integer qualty(phsize),grping(phsize),channel(phsize)
integer counts(phsize),dtype, errflg,detchans,fchan
integer*2 conv(phsize)
real syserr(phsize),serr(phsize),rcts(phsize)
logical qqual,qgroup,qsys,qerror
character*5 mnver
c
c --- INTERNALS ------------------------------------------------------
c
character*28 errstr,wrnstr
character*70 subinfo
integer iunit,status
integer nhdu,htype,block,specext,tothd
logical endfile
c
c
c --- VARIABLE DIRECTORY ---------------------------------------------
c
c Arguments ...
c
c
c infile char : PHA filename, user defined
c outfile char : Output filename, user defined
c chatter int : Chattines flag
c phsize int : Array dimensions
c channel int : Array of detector channels
c dtype int : Datatype, 1 if counts, 2 is rcts
c counts int : Array of observed counts
c rcts real : Array of count rate
c subinfo char : Subroutine info for user
c qualty int : Array of qualty flag
c grping int : Array of grouping flag
c serr real : Array of Observed statistical errors
c syserr real : Array of Fractional systematic error
c qgroup logical: True if data is grouped
c qqual logical: True if data has qualty flags
c qerror logical: True if statistical errors included
c qsys logical: True if systematic errors included
c conv int*2 : Conversion array, within the program
c some of the data arrays, such as
c qualty are stored as int*4, OGIP standard
c requires that they are wriiten in int*2,
c this array is used for such conversions
c ckeys char : Array containing keywords that can have
c their values changed (CHKEY command)
c ckrec char : Array containing ckeys keyword records
c nckeys int : counter for the above
c
c --- CALLED ROUTINES ------------------------------------------------
c
c
c WT_COPYPHD : This subroutine copys the primary header of infile
c WT_SPEC : This routine writes the SPECTRUM extension with the
c modifications. The extension is written after the
c primary header.
c WT_COPY : This copys the remaining extensions from the input
c file
c
c --- AUTHORS/MODIFICATION HISTORY -----------------------------------
c
c Rehana Yusaf (1993 March 31)
c Rehana Yusaf (1993 July 6) : Pass ckeys,ckrec, and nckeys for
c CHKEY command
c Rehana Yusaf (1993 Oct 21) 1.0.2; Pass detchans to wt_spec as this
c is not always the same as nchan
c Rehana Yusaf (1993 Nov 18) 1.0.3; Pass hduclas2,phaversn and fchan
c as arguments to this and to wt_spec
character*5 version
parameter (version = '1.0.3')
*-
*+WT_COPY
c --------------------------------------------------------
subroutine wt_copy(infile,outfile,specext,tothd,chatter)
c --------------------------------------------------------
c --- DESCRIPTION ----------------------------------------------------
c
c This subroutine copys extensions from infile to a new file,
c excluding the SPECTRUM extension. This is done by calling the
c FTOOL FAPPEND.
c
c --- VARIABLES ------------------------------------------------------
c
IMPLICIT NONE
character*(*) infile,outfile
integer chatter,specext,tothd
c
c --- INTERNALS ------------------------------------------------------
c
character*28 errstr,wrnstr
character*70 subinfo,ap_in
character*2 cnum
integer i,status,befspec,iend
integer inum
logical pkey,hist
c
c
c --- VARIABLE DIRECTORY ---------------------------------------------
c
c Arguments ...
c
c infile char : Input file
c outfile char : Output filename
c spectext int : Number of SPECTRUM extension
c tothd int : Total number of extensions
c chatter int : Chattiness flag, >20 verbose
c
c --- CALLED ROUTINES ------------------------------------------------
c
c CFAPPEND : (FTOOL) Appends extension, standard FTOOL with
c minor modifications.
c
c --- AUTHORS/MODIFICATION HISTORY -----------------------------------
c
c Rehana Yusaf (1993 March 31)
c Rehana Yusaf (1993 August 6) : (1.0.1) Add chatter to cfappend
character*5 version
parameter (version = '1.0.1')
*-
*+WT_FERRMSG
subroutine wt_ferrmsg(status,errstr)
c ------------------------------------
c --- DESCRIPTION -------------------------------------------------
c
c This routine checks the error flag obtained from FITSIO routines
c and if appropriate uses FTGERR to get the relevant error text.
c Fcecho is used to write to the screen to ensure that the program
c can be used in differant environments.
c
c --- VARIABLES ---------------------------------------------------
c
character*80 errstr
character*80 errmess
integer status
c
c --- LINKING AND COMPILATION ---
c
c FTOOLS and FITSIO
c
c --- CALLED ROUTINES ---
c
c subroutine FTGERR : (FITSIO) Obtains appropriate error text
c subroutine FCECHO : (FTOOLS) Writes to screen
c
*-Version 1.0
... see Table 13
*+WTEHR1
subroutine wtehr1(ounit,chatter,nk_hist,hist,nk_comm,
& comment,phaversn, instrume,texpos,areascal,
& detchans,chantyp,theta, sorad,
& nrad, rad_lo, rad_hi,
& sohist, bohist, ierr)
IMPLICIT NONE
integer ounit,chatter,nk_hist, nk_comm
integer detchans, dtype, ierr, nrad
real texpos,areascal, theta, sorad
real rad_lo(*), rad_hi(*)
real sohist(*), bohist(*)
character*5 phaversn
character*16 chantyp, instrume
character*70 hist(nk_hist), comment(nk_comm)
c
c --- DESCRIPTION -------------------------------------------------
c
c This subroutine writes a EINSTEIN HRI DETECTOR extension for a PHA f
c PHAVERSN=1992a format.
c !!! Note !!! the o/p file is assumed to have been opened, and wound
c desired location. The file is left open at the end of t
c newly written DETECTOR extension on return and MUST be
c using FTCLOS or another extension written starting with
c in order that the mandatory END keyword is written
c The 1992a format for the EINSTEIN HRI consists of a BINTABLE extensi
c the number of rows equal to the number of off-axis angles passed, an
c the following columns/contents:
c THET_MIN - (real) theta min for this histogram bin
c THET_MAX - (real) theta min for this histogram bin
c SOU_FRAC - (real) weighting factor for SOURCE region
c BKG_FRAC - (real) weighting factor for BKGD region
c The following keywords are also written:
c TELESCOP= 'EINSTEIN'
c INSTRUME= 'instrument/detector name' (ie 'HRI-1','HRI-2','HRI-3')
c PHAVERSN='1992a'
c EXPOSURE- Total exposure (s) for entire integration (incl deadtime
c AREASCAL- Area scaling factor for PHA dataset
c DETCHANS- Max no. of detector channels in integration
c CHANTYPE- Type of PHA channels in use ('PHA' or 'PI'[usual])
c THETA - 'Off-axis angle (decimal degrees)'
c RADIUS - 'Unsure what this really represents'
c
c Passed Parameters
c OUNIT i : FORTRAN unit number of open PHA file
c CHATTER i : chattiness flag for o/p (5 quite,10 norm,>19 sil
c NK_HIST i : No. records to be written as HISTORY records
c HIST i : Array of history record strings to be written
c NK_COMM i : No. records to be written as COMMENT records
c COMMENT i : Array of comment cards to be written
c INSTRUME i : Name of detector/instrument
c TEXPOS i : Exposure time (in secs), corrected for deadtime
c AREASCAL i : Area scaling factor
c DETCHANS i : No of max poss detector channels
c CHANTYP i : Type of channels (PI, PHA etc)
c THETA i : Mean off-axis angle (in decimal degrees)
c SORAD i : ?????
c {list incomplete}
c
c --- CALLED ROUTINES ---------------------------------------------
c {list incomplete}
c
c
c Authors/modification history
c Ian M George (1.0.0:1993 Aug 18), original
c Ian M George (1.1.0:1993 Oct 18), added HDUCLAS stuff
character*5 version
parameter (version = '1.1.0')
*-
*+WTIPC1
subroutine wtipc1(ounit,chatter,nk_hist,hist,nk_comm,
& comment,phaversn,instrume,
& texpos,areascal,detchans,chantyp,
& theta, sorad, arcfrac, bal, balhist,
& bal_lo, bal_hi, bal_inc, bal_step, bal_eps,
& bal_mean, bal_spat, ierr)
IMPLICIT NONE
integer ounit,chatter,nk_hist, nk_comm
integer detchans, dtype, ierr, bal_step
real texpos,areascal
real theta, sorad, arcfrac
real bal_lo, bal_hi, bal_inc, bal_mean, bal_eps
real bal(85), balhist(85)
character*5 phaversn
character*16 instrume
character*16 chantyp
character*20 bal_spat
character*70 hist(nk_hist), comment(nk_comm)
c Description
c This subroutine writes an EINSTEIN IPC DETECTOR extension for a PH
c PHAVERSN=1992a format.
c !!! Note !!!
c The o/p file is assumed to have been opened, and wound to the desi
c location. The file is left open at the end of the written DETECTOR
c extension on return and MUST be closed using FTCLOS or another ext
c written starting with FTCRHD in order that the mandatory END keywo
c is written
c The 1992a format for the EINSTEIN IPC consists of a BINTABLE extensi
c the number of rows equal to the number of non-zero BAL (Bin-Of-Alumi
c steps passed, and the following columns/contents:
c BAL - (real) the BAL step
c BAL_FRAC- (real) the weighting factor for this BAL step
c The following keywords are also written:
c TELESCOP= 'EINSTEIN'
c INSTRUME= 'instrument/detector name' (ie 'IPC-1','IPC-2','IPC-3')
c PHAVERSN='1992a'
c EXPOSURE- Total exposure (s) for entire integration (incl deadtime
c AREASCAL- Area scaling factor for PHA dataset
c DETCHANS- Max no. of detector channels in integration
c CHANTYPE- Type of PHA channels in use ('PHA'[usual] or 'PI')
c THETA - 'Off-axis angle (decimal degrees)'
c RADIUS - 'Unsure what this really represents'
c ARC_FRAC- 'Arcing fraction'
c BAL_LO - 'Lowest BAL possible'
c BAL_HI - 'Highest BAL possible'
c BAL_INC - 'BAL step size'
c BAL_STEP- 'Number of possible BAL steps'
c BAL_EPS - 'BAL EPS ???????'
c BAL_MEAN- 'Mean BAL for this dataset'
c BAL_SPAT- 'BAL SPAT ??????'
c
c Passed Parameters
c OUNIT i : FORTRAN unit number of open PHA file
c CHATTER i : chattiness flag for o/p (5 quite,10 norm,>19 sil
c NK_HIST i : No. records to be written as HISTORY records
c HIST i : Array of history record strings to be written
c NK_COMM i : No. records to be written as COMMENT records
c COMMENT i : Array of comment cards to be written
c INSTRUME i : Name of detector/instrument
c TEXPOS i : Exposure time (in secs), corrected for deadtime
c AREASCAL i : Area scaling factor
c DETCHANS i : No of max poss detector channels
c CHANTYP i : Type of channels (PI, PHA etc)
c THETA i : Mean off-axis angle (in decimal degrees)
c SORAD i : ?????
c ARCFRAC i : Arcing Fraction
c BAL i : Array containing the BAL steps
c BALHIST i : Array containing the BAL weighting factors
c BAL_LO i : Lowest BAL possible
c BAL_HI i : Highest BAL possible
c BAL_INC i : BAL step size (in BAL 'units')
c BAL_STEP i : Total no. of BAL steps possible
c BAL_EPS i : ????
c BAL_MEAN i : Mean BAL for observation
c BAL_SPAT i : ?????
c IERR o : Error flag of return (zero is OK)
c
c Called Routines
c
c subroutine FTPCLn : (FITSIO)
c subroutine FTPHBN : (FITSIO)
c subroutine FTPCOM : (FITSIO)
c subroutine FTPHIS : (FITSIO)
c subroutine FTPKYn : (FITSIO)
c subroutine FCECHO : (FTOOLS)
c subroutine FTBDEF : (FITSIO)
c subroutine FTCRHD : (FITSIO)
c subroutine WT_FERRMSG : (CALLIB)
c
c Authors/Modification History
c Ian M George (1.0.0; 1993 Jun 20), original
c Ian M George (1.1.0; 1993 Aug 17), deleted unness passed parameters
c Ian M George (1.2.0; 1993 Oct 18), added HDUCLAS stuff
character*5 version
parameter (version = '1.2.0')
*-
... see Table 14
*+ CMA_DETNAM
SUBROUTINE cma_detnam(chatter,instring, instrume, filter, ierr)
IMPLICIT NONE
integer chatter, ierr
character*20 instring, instrume, filter
c
c Description
c Works out the official OGIP Detnam string for the EXOSAT ME
c
c Passed Parameters
c CHATTER i : Chatter flag (<5=quite,10=normal,>20=silly)
c INSTRING i : I/p character string
c INSTRUME o : O/p (decoupled) instrume string
c FILTER o : O/p (decoupled) filter string
c IERR o : Return error flag (0 = OK)
c
c Called Routines
c subroutine FCECHO : (FTOOLS) writes to standard o/p
c
c Origin
c IMG special
c
c Authors/Modification History
c Ian M George (1.0.0: 1993 Oct 11), original
character*7 version
parameter (version = ' 1.0.0 ')
*-
*+CSHFDMY
subroutine cshfdmy(shf, datstr, timstr, status)
IMPLICIT NONE
integer shf, status
character*8 datstr, timstr
c
c Description
c Converts SHF key to calendar dd/mm/yy & hh:mm:ss representation
c
c Passed Parmeters
c Oh, sod it, bloody suss it out yerself
c
c Authors/Modification History
c Andy Pollock (3 october 1988), original
c Nick (6 march 1990), modified to make it do 1999 & print yr-
c Anon (15 April 1992), get the leap year right
c Ian M George (1993 Jun 21), nicked for callib & o/p format changed
*-
*+ CSHFTIME
subroutine cshftime(KEY,TARR)
IMPLICIT NONE
INTEGER*4 key
INTEGER*2 tarr(5)
c
c SHF KEY TO I*2 ARRAY = yr, dat, hr, mn ,sc
c
c
c Author/Modification History
c modified by Nick 26/7/89 to start at 1976.
c modified by paul, 21/6/90 to start from 1971.
c Nick, 14/10/92 to make valid from 1971-2000
c modified by pat, 4/1/93 to start from 1968
c Ian M George (1993 Jun 21), nicked for CALLIB
*-
*+ ME_DETNAM
SUBROUTINE me_detnam(chatter,ndets,dets,gas,detnam,status)
IMPLICIT NONE
integer chatter, ndets, status
character*2 gas
character*20 dets(8)
character*20 detnam
c
c Description
c Works out the official OGIP Detnam string for the EXOSAT ME
c
c Passed Parameters
c CHATTER i : Chatter flag (<5=quite,10=normal,>20=silly)
c NDETS i : Number of detectors in array
c DETS i : Array of detector names
c GAS i : Code of gas in use ('AR','XE','AX'= AR+XE)
c DETNAM o : Output string containing the detector name
c STATUS o : Return error flag (0 = OK)
c
c Called Routines
c subroutine FCECHO : (FTOOLS) writes to standard o/p
c subroutine WT_FERRMSG : (CALLIB) writes FITSIO error message
c
c Origin
c Hacked from Lorella's WRITE_DETNAM code
c
c Authors/Modification History
c Ian M George (1.0.0: 1993 Oct 08), original
character*7 version
parameter (version = ' 1.0.0 ')
*-
*+WTXGS1
subroutine wtxgs1(ounit,chatter, blw_start, blw_stop,
& nomgain, gaincor, gsdcol,gsdarea,
& qlinchan, linchan, qgaincor, ierr)
IMPLICIT NONE
integer ounit, chatter, ierr, blw_start, blw_stop
integer linchan(4)
real nomgain, gaincor, gsdcol,gsdarea
logical qlinchan(4), qgaincor
c
c DESCRIPTION
c This subroutine writes an EXOSAT GSPC-specific keywords to the
c **CURRENT** header unit of a PHA file (No Detector extension defined
c or necessary for the GSPC).
c !!! Note !!! the o/p file is assumed to have been opened, and wound
c desired location. The file is left open at the end of t
c newly written keywords on return and MUST be closed
c using FTCLOS or another extension written starting with
c in order that the mandatory END keyword is written
c The following keywords are also written:
c ... incomplete ...
c
c PASSED VARAIABLES
c OUNIT i : FORTRAN unit number of open PHA file
c CHATTER i : chattiness flag for o/p (5 quite,10 norm,>19 sil
c ... incomplete ...
c IERR o : Return Errror flag (0 = OK)
c
c CALLED ROUTINES etc
c ... incomplete ...
c
c AUTHORS/MODIFICATION HISTORY
c
c Ian M George (1.0.0: 1993 Oct 13), original
character*5 version
parameter (version = '1.0.0')
*-
*+WTXME1
subroutine wtxme1(ounit,chatter,nk_hist,hist,nk_comm,
& comment, phaversn, texpos,areascal,detchans,
& chantyp,h1_off, h2_off,shfstart,shfstop,
& ndet,detn, dcol, dare, dexp,dagn,dgco, drco,
& ierr)
IMPLICIT NONE
integer ounit,chatter,nk_hist, nk_comm
integer detchans, dtype, ierr, ndet
real texpos,areascal, h1_off, h2_off
real dcol(8), dare(8), dexp(8), dagn(8)
real dgco(8,4), drco(8,8)
real shfstart, shfstop
character*5 phaversn
character*20 detn(8)
character*16 chantyp
character*70 hist(nk_hist), comment(nk_comm)
c
c DESCRIPTION
c This subroutine writes an EXOSAT ME DETECTOR extension for a PHA f
c one of the formats conforming to the HDUCLAS1='1.*.*' family.
c Currently the following formats are supported (see OGIP/93-024)
c HDUCLAS1 = '1.0.0'
c HDUCLAS1 = '1.1.0'
c The requested format is checked, and if belonging to the '1.*.*' fam
c but not included above, the extension is written in the last format
c listed.
c !!! Note !!! the o/p file is assumed to have been opened, and wound
c desired location. The file is left open at the end of t
c newly written DETECTOR extension on return and MUST be
c using FTCLOS or another extension written starting with
c in order that the mandatory END keyword is written
c In all cases the 1.*.* family of formats for the EXOSAT ME consists
c a BINTABLE extension, with the number of rows equal to the number of
c sub-detectors included in the accumulation, and the following
c columns/contents:
c DETNAM - (16 char) name of the sub-detector ('DET-A AR'etc)
c OBSFACT - (real) Obscuration factor (coll resp) for sub-detector
c GEOAREA - (real) On-axis geometric area for sub-detector
c ONTIME - (real) Exposure time for sub-detector (EXCL deadtime etc)
c DETGAIN - (real) Analogue gain setting for sub-detector
c GNCOEFF - (real) vector containing 4 gain coeffs for sub-detector
c RSCOEFF - (real) vector containing 8 resolution coeffs for sub-dete
c The following keywords are also written:
c HDUCLASS='OGIP'-indicating the format conforms to OGIP standards
c HDUCLAS1='SPECTRUM' - indicating major class in the heirarchy
c HDUVERS1- (passed) The phaversn to be written (must in '1.*.*' fami
c HDUCLAS2='DETECTOR' - indicating this is an instr-specific detector
c TELESCOP= 'EXOSAT'
c INSTRUME= 'ME'
c PHAVERSN='1992a'
c EXPOSURE - Total exposure (s) for entire integration (incl deadtim
c AREASCAL - Area scaling factor for PHA dataset
c DETCHANS - Max no. of detector channels in integration
c CHANTYPE - Type of PHA channels in use ('PHA'[usual] or 'PI')
c HALF1OFF - Mean Off-set angle for ME Half-1 during integration
c HALF2OFF - Mean Off-set angle for ME Half-2 during integration
c SHFSTART - SHF key for start of observation
c SHFSTOP - SHF key for end of observation
c
c PASSED VARAIABLES
c OUNIT i : FORTRAN unit number of open PHA file
c CHATTER i : chattiness flag for o/p (5 quite,10 norm,>19 sil
c NK_HIST i : No. records to be written as HISTORY records
c HIST i : Array of history record strings to be written
c NK_COMM i : No. records to be written as COMMENT records
c COMMENT i : Array of comment record strings to be written
c PHAVERSN i : String denoting OGIP HDUCLAS2 family
c TEXPOS i : Exposure time, in seconds (corrected for deadtim
c AREASCAL i : Area scaling factor
c DETCHANS i : Max number of detector channels
c CHATYPE i : Type of PHA channels ('PHA', 'PI' etc)
c NDET i : Number ME detectors included in this PHA integra
c H1_OFF i : Mean H1 off-set angle (degrees) during integration
c H2_OFF i : Mean H2 off-set angle (degrees) during integration
c SHFSTART i : SHF key for start of observation
c SHFSTOP i : SHF key for end of observation
c DETN i : Array of names of detectors included
c DCOL i : Array of collimator response for each incld dete
c DARE i : Array of assumed onaxis area of each incld detec
c DEXP i : Array of ontime (active integrat time) for each
c DAGN i : Array of analogue gain setting for each incld de
c DGCO i : Array of gain coeffs for each incld detector
c DRCO i : Array of resolution coeffs for each incld detect
c IERR o : Return Errror flag (0 = OK)
c
c CALLED ROUTINES etc
c subroutine FCECHO : (FTOOLS) writes to standard o/p
c subroutine FTBDEF : (FITSIO) defines FITS header
c subroutine FTCRHD : (FITSIO) creates new extension
c subroutine FTPCLE : (FITSIO) writes FITS column
c subroutine FTPCOM : (FITSIO) writes COMMENT keyword
c subroutine FTPHBN : (FITSIO) writes mandatory header keywords
c subroutine FTPHIS : (FITSIO) writes HISTORY keyword
c subroutine FTPKYn : (FITSIO) writes keyword of type n
c subroutine WT_FERRMSG : (CALLIB) writes standard error messages
c
c AUTHORS/MODIFICATION HISTORY
c
c Ian M George (1993 Aug 16), original
c Ian M George (1.0.1; 1993 Sept 02), added SHFSTART & SHFSTOP
c Ian M George (1.1.0; 1993 Oct 08) add HDUCLASn stuff
c Ian M George (2.0.0; 1993 Oct 12) renamed from wt_exome1992a & major
c overhaul of HDUCLAS/VERS stuff
character*5 version
parameter (version = '2.0.0')
*-
... see Table 15
no lines dumped
*+RDATU0
c -------------------------------------------------------------
subroutine rdatu0(iunit,n_att,max_att,it1_cas,it2_cas,
& iro_cas,ixn_cas,iyn_cas,chatter,ierr)
c -------------------------------------------------------------
c
c ___ DESCRIPTION ____________________________________________________
c
c This subroutine reads a FITS US REV0 format Attitude extension
c NOTE : Assumes file is already open.
c ... close file at end, using FTCLOS, or
c ... read another extension
c
c Columns read are ...
c
c IT1_CAS : Time of corected aspect in full seconds
c IT2_CAS : Time of corrected aspect in sub-seconds
c IRO_CAS : Corrected Roll angle
c IXN_CAS : X-translation in NS-system
c IYN_CAS : Y-translation in NS-system
c
c ___ VARIABLES ______________________________________________________
c
IMPLICIT NONE
integer iunit,max_att,n_att,ierr,chatter
integer*4 it1_cas(max_att),iro_cas(max_att)
integer*4 ixn_cas(max_att),iyn_cas(max_att)
integer*4 it2_cas(max_att)
c
c --- VARIABLE DIRECTORY ---------------------------------------------
c
c Arguments ...
c
c max_att int : Array dimensions
c iunit int : Fortran unit number for file
c chatter int : Chatter flag ( <5 quiet,>5 normal,>20 noisy)
c n_att int i/r: Counter attitude data (IF NE 0 on entry then tha
c many attitude entries already assumed to have been
c read in [from previous extensions])
c it1_cas int : Array of corrected aspect
c it2_cas int : Array of sub-seconds of corrected aspect
c iro_cas int : Array of roll angle
c ixn_cas int : Array of X-translation in NS-system
c iyn_cas int : Array of Y-translation in NS-system
c ierr int : Error flag, ierr = 0 okay
c ierr = 107/207 error finding extensi
c ierr = 2 Column/keyword number not f
c ierr = 3 Error in reading data
c ierr = 4 Mandatory keyword not found
c
c --- CALLED ROUTINES ------------------------------------------------
c
c subroutine FTMAHD : FITSIO routine to move to extension header
c subroutine FTGKYj : FITSIO routine to read extension header key
c where the j, is for an integer
c subroutine FTGKNS : FITSIO routine to read extension header key
c where a rootstring is given, thus an array
c keywords can be read
c subroutine FCECHO : FTOOLS routine to write to screen
c subroutine WT_FERRMSG : Writes FITSIO error text if required
c
c --- COMPILATION AND LINKING ----------------------------------------
c
c Link with FTOOLS - FITSIO, CALLIB
c
c --- AUTHORS/MODIFICATION HISTORY -----------------------------------
c
c Rehana Yusaf (Oct 1 1993) 1.0.0;
c Georgie Boy (1.0.0:93 Oct 07), minor cosmetics n stuff
c
character*5 version
parameter (version = '1.0.1' )
*-
*+RDMVU0
c -------------------------------------------------------------
subroutine rdmvu0(iunit,n_evr,max_evr,iti_evr,iac_evr,
& iqe_evr,ia1_evr,iax_evr,chatter,ierr)
c -------------------------------------------------------------
c
c ___ DESCRIPTION ____________________________________________________
c
c This subroutine reads a FITS US REV0 format EVRAT Qualified
c Event rate extension
c NOTE : Assumes file is already open.
c ... close file at end, using FTCLOS, or
c ... read another extension
c
c Columns read are ...
c
c ITI_EVR : Time of event rate
c IAC_EVR : MV anticoincident rate
c IQE_EVR : Transmitted X-ray rate
c IA1_EVR : Events in A1 above low level threshold
c IAX_EVR : Accepted X-ray rate
c
c ___ VARIABLES ______________________________________________________
c
IMPLICIT NONE
integer iunit,max_evr,n_evr,ierr,chatter
integer*4 iti_evr(max_evr)
integer*4 iac_evr(max_evr),iqe_evr(max_evr)
integer*4 ia1_evr(max_evr),iax_evr(max_evr)
c
c --- VARIABLE DIRECTORY ---------------------------------------------
c
c Arguments ...
c
c max_evr int : Array dimensions
c iunit int : Fortran unit number for file
c chatter int : Chatter flag ( <5 quiet,>5 normal,>20 noisy)
c n_evr int : Counter event rate data
c (IF NE 0 on entry then that many evr entries alr
c aaumed to have been read in (fron prevoius ext'
c
c ierr int : Error flag, ierr = 0 okay
c ierr = 107/207 error finding extensi
c ierr = 2 Column/keyword number not f
c ierr = 3 Error in reading data
c ierr = 4 Mandatory keyword not found
c
c --- CALLED ROUTINES ------------------------------------------------
c
c subroutine FTMAHD : FITSIO routine to move to extension header
c subroutine FTGKYj : FITSIO routine to read extension header key
c where the j, is for an integer
c subroutine FTGKNS : FITSIO routine to read extension header key
c where a rootstring is given, thus an array
c keywords can be read
c subroutine FCECHO : FTOOLS routine to write to screen
c subroutine WT_FERRMSG : Writes FITSIO error text if required
c
c --- COMPILATION AND LINKING ----------------------------------------
c
c Link with FTOOLS - FITSIO, CALLIB
c
c --- AUTHORS/MODIFICATION HISTORY -----------------------------------
c
c Rehana Yusaf (Oct 1 1993) 1.0.0;
c
character*5 version
parameter (version = '1.0.0' )
*-
*+WTRHRI1
subroutine wtrhr1(ounit,chatter,nk_hist,hist,nk_comm,
& comment,phaversn, texpos,areascal,
& detchans,chantyp,nrad, rad_lo, rad_hi,
& sohist, bohist, ierr)
IMPLICIT NONE
integer ounit,chatter,nk_hist, nk_comm
integer detchans, dtype, ierr, nrad
real texpos,areascal
real rad_lo(*), rad_hi(*)
real sohist(*), bohist(*)
character*5 phaversn
character*16 chantyp
character*70 hist(nk_hist), comment(nk_comm)
c
c --- DESCRIPTION -------------------------------------------------
c
c This subroutine writes a ROSAT HRI DETECTOR extension for a PHA file
c PHAVERSN=1992a format.
c !!! Note !!! the o/p file is assumed to have been opened, and wound
c desired location. The file is left open at the end of t
c newly written DETECTOR extension on return and MUST be
c using FTCLOS or another extension written starting with
c in order that the mandatory END keyword is written
c The 1992a format for the ROSAT HRI consists of a BINTABLE extension,
c the number of rows equal to the number of off-axis angles passed, an
c the following columns/contents:
c THET_MIN - (real) theta min for this histogram bin
c THET_MAX - (real) theta min for this histogram bin
c SOU_FRAC - (real) weighting factor for SOURCE region
c BKG_FRAC - (real) weighting factor for BKGD region
c The following keywords are also written:
c TELESCOP= 'ROSAT'
c INSTRUME= 'HRI'
c PHAVERSN='1992a'
c EXPOSURE- Total exposure (s) for entire integration (incl deadtime
c AREASCAL- Area scaling factor for PHA dataset
c DETCHANS- Max no. of detector channels in integration
c CHANTYPE- Type of PHA channels in use ('PHA' or 'PI'[usual])
c
c Passed Parameters
c OUNIT i : FORTRAN unit number of open PHA file
c CHATTER i : chattiness flag for o/p (5 quite,10 norm,>19 sil
c NK_HIST i : No. records to be written as HISTORY records
c HIST i : Array of history record strings to be written
c NK_COMM i : No. records to be written as COMMENT records
c {list incomplete}
c
c --- CALLED ROUTINES ---------------------------------------------
c {list incomplete}
c
c
c Authors/modification history
c Ian M George (1.0.0:1993 Aug 17), original
c Ian M George (1.1.0:1993 Oct 18), added HDUCLAS shit
character*5 version
parameter (version = '1.1.0')
*-
*+WTRPS1
subroutine wtrps1(ounit,chatter,nk_hist,hist,nk_comm,
& comment,phaversn,instrume,filter,texpos,areascal,
& detchans,chantyp,nrad, rad_lo, rad_hi,
& sohist, bohist, ierr)
IMPLICIT NONE
integer ounit,chatter,nk_hist, nk_comm
integer detchans, dtype, ierr, nrad
real texpos,areascal
real rad_lo(*), rad_hi(*)
real sohist(*), bohist(*)
character*5 phaversn
character*16 instrume,filter
character*16 chantyp
character*70 hist(nk_hist), comment(nk_comm)
c
c --- DESCRIPTION -------------------------------------------------
c
c This subroutine writes a ROSAT PSPC DETECTOR extension for a PHA fil
c PHAVERSN=1992a format.
c !!! Note !!! the o/p file is assumed to have been opened, and wound
c desired location. The file is left open at the end of t
c newly written DETECTOR extension on return and MUST be
c using FTCLOS or another extension written starting with
c in order that the mandatory END keyword is written
c The 1992a format for the ROSAT PSPC consists of a BINTABLE extension
c the number of rows equal to the number of off-axis angles passed, an
c the following columns/contents:
c THET_MIN - (real) theta min for this histogram bin
c THET_MAX - (real) theta min for this histogram bin
c SOU_FRAC - (real) weighting factor for SOURCE region
c BKG_FRAC - (real) weighting factor for BKGD region
c The following keywords are also written:
c TELESCOP= 'ROSAT'
c INSTRUME= Name of the instrument ('PSPC-B' or 'PSPC-C')
c FILTER - Name of filter in use (if any)
c PHAVERSN='1992a'
c EXPOSURE- Total exposure (s) for entire integration (incl deadtime
c AREASCAL- Area scaling factor for PHA dataset
c DETCHANS- Max no. of detector channels in integration
c CHANTYPE- Type of PHA channels in use ('PHA' or 'PI'[usual])
c
c Passed Parameters
c OUNIT i : FORTRAN unit number of open PHA file
c CHATTER i : chattiness flag for o/p (5 quite,10 norm,>19 sil
c NK_HIST i : No. records to be written as HISTORY records
c HIST i : Array of history record strings to be written
c NK_COMM i : No. records to be written as COMMENT records
c {list incomplete}
c
c --- CALLED ROUTINES ---------------------------------------------
c {list incomplete}
c
c
c --- AUTHORS/MODIFICATION HISTORY --------------------------------
c
c Ian M George (1.0.0:1993 Jun 02), original
c Ian M George (2.0.0:1993 Jun 20), major re-write
c Ian M George (2.1.0:1993 Aug 17), deleted unness passed params
character*5 version
parameter (version = '2.1.0')
*-
The following useful links are available (in the HTML version of this document only):