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