/* *********************************
 * *                               *
 * *  IRIS BUFR Table Header File  *
 * *                               *
 * *********************************
 * File: utils/bufr/sigbufr.h
 *
 *                   COPYRIGHT (c) 2002, 2003  BY
 *          SIGMET INCORPORATED, WESTFORD MASSACHUSETTS, U.S.A.
 * 
 * THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND  COPIED
 * ONLY  IN  ACCORDANCE WITH  THE  TERMS  OF  SUCH  LICENSE  AND WITH THE
 * INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE  OR  ANY OTHER
 * COPIES  THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
 * OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE  IS  HEREBY
 * TRANSFERED.
 */

/* -----------------------------------------------
 * Things related to BUFR format and to the OPERA code.
 * Clarification on number of data levels:  If (for example)
 * data is recorded in 14 levels, then there are a total
 * of 14 level seems sent: 1, followed by a replication count
 * of 13, followed by 13.  These are the bottom levels for
 * the 14 levels.  All data above the 14th level goes into
 * the 14th color.  Based on email from Rosa Dias on 7 Oct 2002.
 */

#define BUFR_LBUFLEN (1000)   /* Max line length supported in rlenc.c */

/* Class type names */
#define BUFR_CLASS_IDENTIFICATION  (1)
#define BUFR_CLASS_INSTRUMENTATION (2)
#define BUFR_CLASS_TIME            (4)
#define BUFR_CLASS_LOCATION1       (5)
#define BUFR_CLASS_LOCATION2       (6)
#define BUFR_CLASS_LOCATION_VERT   (7)
#define BUFR_CLASS_RADAR_DATA     (21)
#define BUFR_CLASS_PROCESSING     (25)
#define BUFR_CLASS_MAP            (29)
#define BUFR_CLASS_IMAGE          (30)
#define BUFR_CLASS_QUALIFIERS     (31)
#define BUFR_CLASS_QUALITY        (33)

/* Z/R conversion, Table 0.25.006 */
#define BUFR_ZH_TO_R          (0)
#define BUFR_ZH_AND_ZDR_TO_R  (1)
#define BUFR_Z_F1_AND_F2_TO_R (2)
#define BUFR_OTHER_TO_R       (6)

/* Projection type, Table 0.29.001 */
#define BUFR_PROJ_GNOMONIC      (0)
#define BUFR_PROJ_POLSTEREO     (1)
#define BUFR_PROJ_LAMBERTS      (2)
#define BUFR_PROJ_MERCATOR      (3)
#define BUFR_PROJ_AZIMUTHAL     (4)

/* Coordinate grid type, Table 0.29.002 */
#define BUFR_GRID_CARTESIAN  (0)
#define BUFR_GRID_POLAR      (1)

/* Picture type, Table 0.30.031 */
#define BUFR_PTYPE_PPI       (0)
#define BUFR_PTYPE_COMPOSITE (1)
#define BUFR_PTYPE_CAPPI     (2)
#define BUFR_PTYPE_XSECT     (3)
#define BUFR_PTYPE_OTHER     (14)

/* Quality information, Table 0.33.003 */
#define BUFR_QUALITY_NOT_SUSPECT      (0)
#define BUFR_QUALITY_SLIGHTLY_SUSPECT (1)
#define BUFR_QUALITY_HIGHLY_SUSPECT   (2)
#define BUFR_QUALITY_UNFIT            (3)
#define BUFR_QUALITY_UNKNOWN          (7)

/* -----------------------------------------------
 * Things related to the IRIS convertor code.
 */

/* Useful structures
 */
struct convert_site_table8
{
  struct latlon8 Center;
  int   iBlockNumber;
  int   iStationNumber;
  SINT4 iMinutesWest;
  char  sSitename16[20];   /* IRIS Sitename, null terminated */
  SINT4 iSiteNumber;     /* IRIS Sitenumber, range 0-30 */
};
#define MAX_CONVERT_SITES (20)

/* Information from the config file to customize the convertor */
struct convert_config8
{
  struct convert_site_table8 Sites[ MAX_CONVERT_SITES ];
  UINT1 lLogToFile;
  UINT1 lLogToTerm;
  UINT1 lVerbose;              /* Log more details */
  UINT1 lAppendToLog;          /* Append to previous log file */
  UINT1 lEnableGts;            /* Add GTS header/footer to BUFR output */
  UINT1 lSitesFromStation;     /* Determine IRIS sitename from station ID */
  UINT1 lPinFromCorners;       /* Determine location from corners */
  UINT1 ipad_7x1;
  FILE *iLogFile;              /* Open file descriptor to log file */
  FLT4  fMinReflectivity;      /* Minimum refl. All lower values are thresholded */
  char  sGtsSource[8];         /* 4-char GTS source string */
  char  sGtsBulletinId[4];     /* 2-char GTS product ID ii string */
  SINT4 iSiteCount;
};

/* Function prototypes 
 */
void LoadBufrDescriptor                /* File: BufrSubs.C */
( const struct convert_config8 *pCSetup_a );

void LoadSetup                         /* File: BufrSubs.C */
( struct convert_config8 *pCSetup_a,
  const char* sFile_a,                  /* Filename of config file */
  int iDevice_a );                      /* Device number */

void Lprintf                           /* File: BufrSubs.C */
( const struct convert_config8 *pCSetup_a,
  const char *sString_a );
