This reverts commit 4c1637974b
[formerly d3388798e0f55a35f429347c24b408d0e8ae3b7f].
Change-Id: I76b2eb1e28297eed288555d056c88812fe76faac
Former-commit-id: 954250c0b33bab2538cceea77afa2946b0c19445
This commit is contained in:
parent
4c1637974b
commit
de112777bd
5 changed files with 2715 additions and 1791 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -6,30 +6,48 @@
|
||||||
#include "RadarLoc.h"
|
#include "RadarLoc.h"
|
||||||
|
|
||||||
#define HPE_RFC_BIAS_LAG 2 // default number of bias lag hours
|
#define HPE_RFC_BIAS_LAG 2 // default number of bias lag hours
|
||||||
RadarLoc * pRadarLocHead = NULL;
|
|
||||||
|
RadarLoc * pRadarLocHead = NULL ;
|
||||||
extern int dualpol_on_flag;
|
extern int dualpol_on_flag;
|
||||||
|
|
||||||
void retrieveOfficeIDByRadarID(const char * radarID, char * officeID,
|
void retrieveOfficeIDByRadarID(const char * radarID,
|
||||||
long int * status);
|
char * officeID,
|
||||||
|
long int * status);
|
||||||
|
|
||||||
void read_rwbiasdyn2(const char *radar_id, const char *office_id,
|
void read_rwbiasdyn2(const char *radar_id,
|
||||||
const char * str, const int lag_cut, double *num_pairs, double *sumgag,
|
const char *office_id,
|
||||||
double *sumrad, double *bias, int *lag, char sstr1[19], long int *irc);
|
const char * str,
|
||||||
|
const int lag_cut,
|
||||||
|
double *num_pairs,
|
||||||
|
double *sumgag,
|
||||||
|
double *sumrad,
|
||||||
|
double *bias,
|
||||||
|
int *lag,
|
||||||
|
char sstr1[19],
|
||||||
|
long int *irc);
|
||||||
|
|
||||||
void readRWBiasDyn(const char *radar_id, const char *site_id,
|
void readRWBiasDyn(const char *radar_id,
|
||||||
const char *datehour, const int lag_cut, double *num_pairs,
|
const char *site_id,
|
||||||
double *sumgag, double *sumrad, double *bias, int *lag,
|
const char *datehour,
|
||||||
char datetime1[19], int dualpol_data_avail, long int *irc)
|
const int lag_cut,
|
||||||
|
double *num_pairs,
|
||||||
|
double *sumgag,
|
||||||
|
double *sumrad,
|
||||||
|
double *bias,
|
||||||
|
int *lag,
|
||||||
|
char datetime1[19],
|
||||||
|
int dualpol_data_avail,
|
||||||
|
long int *irc)
|
||||||
|
|
||||||
{
|
{
|
||||||
const char * HPE_RFC_BIAS_LAG_TOKEN = "hpe_rfc_bias_lag";
|
const char * HPE_RFC_BIAS_LAG_TOKEN = "hpe_rfc_bias_lag";
|
||||||
const char * HPE_BIAS_SOURCE_TOKEN = "hpe_bias_source";
|
const char * HPE_BIAS_SOURCE_TOKEN = "hpe_bias_source";
|
||||||
|
|
||||||
static int first = 1;
|
static int first = 1 ;
|
||||||
static int rfc_bias_lag = HPE_RFC_BIAS_LAG;
|
static int rfc_bias_lag = HPE_RFC_BIAS_LAG;
|
||||||
static char bias_source[6] = "rfc"; // RFC or LOCAL, default to RFC
|
static char bias_source[6] = "rfc"; // RFC or LOCAL, default to RFC
|
||||||
char officeID[WFO_LEN + 1] = { '\0' };
|
char officeID[WFO_LEN + 1] = {'\0'};
|
||||||
char strTokenValue[6] = { '\0' };
|
char strTokenValue[6] = {'\0'} ;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* load and store the token values:
|
* load and store the token values:
|
||||||
|
@ -37,103 +55,138 @@ void readRWBiasDyn(const char *radar_id, const char *site_id,
|
||||||
* HPE_BIAS_SOURCE_TOKEN
|
* HPE_BIAS_SOURCE_TOKEN
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (first == 1) {
|
if(first == 1)
|
||||||
if ((hpe_fieldgen_getAppsDefaults(HPE_RFC_BIAS_LAG_TOKEN, strTokenValue)
|
{
|
||||||
!= -1) && (hpe_fieldgen_isDigits(strTokenValue) == 1)) {
|
if((hpe_fieldgen_getAppsDefaults(HPE_RFC_BIAS_LAG_TOKEN, strTokenValue) != -1)
|
||||||
|
&& (hpe_fieldgen_isDigits(strTokenValue) == 1))
|
||||||
|
{
|
||||||
int value = atoi(strTokenValue);
|
int value = atoi(strTokenValue);
|
||||||
|
if(value > 0)
|
||||||
if (value > 0) {
|
{
|
||||||
rfc_bias_lag = value;
|
rfc_bias_lag = value;
|
||||||
sprintf(message,
|
sprintf ( message , "STATUS: token value for \"%s\" is: %d.",
|
||||||
"STATUS:in readRWBiasDyn - token value for \"%s\" is: %d",
|
HPE_RFC_BIAS_LAG_TOKEN, rfc_bias_lag) ;
|
||||||
HPE_RFC_BIAS_LAG_TOKEN, rfc_bias_lag);
|
hpe_fieldgen_printMessage( message );
|
||||||
hpe_fieldgen_printMessage(message);
|
|
||||||
} else {
|
|
||||||
sprintf(message, "ERROR:in readRWBiasDyn - Invalid token value"
|
|
||||||
" for token \"%s\". Default value is set to: %d",
|
|
||||||
HPE_RFC_BIAS_LAG_TOKEN, HPE_RFC_BIAS_LAG);
|
|
||||||
hpe_fieldgen_printMessage(message);
|
|
||||||
}
|
}
|
||||||
} else {
|
else
|
||||||
sprintf(message, "ERROR:in readRWBiasDyn - Invalid token value"
|
{
|
||||||
" for token \"%s\". Default value is set to: %d",
|
sprintf ( message , "ERROR: Invalid token value"
|
||||||
HPE_RFC_BIAS_LAG_TOKEN, HPE_RFC_BIAS_LAG);
|
" for token \"%s\". Default it's value to: %d.",
|
||||||
hpe_fieldgen_printMessage(message);
|
HPE_RFC_BIAS_LAG_TOKEN, HPE_RFC_BIAS_LAG) ;
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf ( message , "ERROR: Invalid token value"
|
||||||
|
" for token \"%s\". Default it's value to: %d.",
|
||||||
|
HPE_RFC_BIAS_LAG_TOKEN, HPE_RFC_BIAS_LAG) ;
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hpe_fieldgen_getAppsDefaults(HPE_BIAS_SOURCE_TOKEN, strTokenValue)
|
if(hpe_fieldgen_getAppsDefaults(HPE_BIAS_SOURCE_TOKEN, strTokenValue) != -1)
|
||||||
!= -1) {
|
{
|
||||||
if (strcmp(hpe_fieldgen_toLowerCase(strTokenValue), "local") == 0) {
|
if(strcmp(hpe_fieldgen_toLowerCase(strTokenValue), "local") == 0)
|
||||||
|
{
|
||||||
strcpy(bias_source, "local");
|
strcpy(bias_source, "local");
|
||||||
|
|
||||||
sprintf(message,
|
sprintf ( message , "STATUS: token value for \"%s\" is: %s.",
|
||||||
"STATUS:in readRWBiasDyn - token value for \"%s\" is: %s",
|
HPE_BIAS_SOURCE_TOKEN, bias_source) ;
|
||||||
HPE_BIAS_SOURCE_TOKEN, bias_source);
|
hpe_fieldgen_printMessage( message );
|
||||||
hpe_fieldgen_printMessage(message);
|
}
|
||||||
} else if (strcmp(hpe_fieldgen_toLowerCase(strTokenValue), "rfc")
|
else if(strcmp(hpe_fieldgen_toLowerCase(strTokenValue), "rfc") == 0)
|
||||||
== 0) {
|
{
|
||||||
strcpy(bias_source, "rfc");
|
strcpy(bias_source, "rfc");
|
||||||
|
|
||||||
sprintf(message,
|
sprintf ( message , "STATUS: token value for \"%s\" is: %s.",
|
||||||
"STATUS:in readRWBiasDyn - token value for \"%s\" is: %s",
|
HPE_BIAS_SOURCE_TOKEN, bias_source) ;
|
||||||
HPE_BIAS_SOURCE_TOKEN, bias_source);
|
hpe_fieldgen_printMessage( message );
|
||||||
hpe_fieldgen_printMessage(message);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
sprintf(message, "ERROR:in readRWBiasDyn - Invalid token value"
|
}
|
||||||
" for token \"%s\". Default value is set to: rfc",
|
else
|
||||||
HPE_BIAS_SOURCE_TOKEN);
|
{
|
||||||
hpe_fieldgen_printMessage(message);
|
sprintf ( message , "ERROR: Invalid token value"
|
||||||
|
" for token \"%s\".",
|
||||||
|
HPE_BIAS_SOURCE_TOKEN) ;
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
}
|
}
|
||||||
|
|
||||||
first = 0;
|
first = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if the bias source is LOCAL,
|
* if the bias source is LOCAL,
|
||||||
* pick up bias value based on the FXA_LOCAL_SITE
|
* pick up bias value based on the FXA_LOCAL_SITE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (strcmp(bias_source, "local") == 0) /*for LOCAL MFB */
|
if(strcmp(bias_source, "local") == 0)
|
||||||
{
|
{
|
||||||
if (dualpol_on_flag == 0) {
|
sprintf ( message , "STATUS: in readRWBiasDyn,loading bias value based on FXA_LOCAL_SITE.") ;
|
||||||
sprintf(message,
|
hpe_fieldgen_printMessage( message );
|
||||||
" STATUS:in readRWBiasDyn - Loading SP LOCAL MFB bias from RWBiasDyn "
|
|
||||||
"table for siteID (token fxa_local_site) = %s, lag time = %d",
|
if (dualpol_on_flag == 0)
|
||||||
site_id, lag_cut);
|
{
|
||||||
hpe_fieldgen_printMessage(message);
|
read_rwbiasdyn2(radar_id, site_id, datehour,
|
||||||
|
lag_cut, num_pairs, sumgag,
|
||||||
read_rwbiasdyn2(radar_id, site_id, datehour, lag_cut, num_pairs,
|
sumrad, bias, lag, datetime1, irc) ;
|
||||||
sumgag, sumrad, bias, lag, datetime1, irc);
|
|
||||||
} else {
|
sprintf (message, " STATUS:in readRWBiasDyn, dualpol_on_flag is NO, loading bias value from RWBiasDyn table.");
|
||||||
sprintf(message,
|
hpe_fieldgen_printMessage( message );
|
||||||
"STATUS:in readRWBiasDyn - Loading DP LOCAL MFB bias from DAABiasDyn "
|
}
|
||||||
"table for siteID (token fxa_local_site) = %s, lag time = %d",
|
else
|
||||||
site_id, lag_cut);
|
{
|
||||||
hpe_fieldgen_printMessage(message);
|
sprintf (message, "STATUS: in readRWBiasDyn, dualpol_on_flag is YES, loading bias value from DAABiasDyn table");
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
read_daabiasdyn(radar_id, site_id, datehour, lag_cut, num_pairs,
|
|
||||||
sumgag, sumrad, bias, lag, datetime1, irc);
|
read_daabiasdyn(radar_id, site_id, datehour,
|
||||||
}
|
lag_cut, num_pairs, sumgag,
|
||||||
} else /* for RFC MFB */
|
sumrad, bias, lag, datetime1, irc) ;
|
||||||
|
if (*irc != 0)
|
||||||
|
{
|
||||||
|
read_rwbiasdyn2(radar_id, site_id, datehour,
|
||||||
|
lag_cut, num_pairs, sumgag,
|
||||||
|
sumrad, bias, lag, datetime1, irc) ;
|
||||||
|
|
||||||
|
sprintf(message, "STATUS: in readRWBiasDyn, dualpol_on_flag is YES. Fail to load bias value from DAABiasDyn table. Try RWBiasDyn table");
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (dualpol_data_avail == 0)
|
||||||
|
{
|
||||||
|
read_rwbiasdyn2(radar_id, site_id, datehour,
|
||||||
|
lag_cut, num_pairs, sumgag,
|
||||||
|
sumrad, bias, lag, datetime1, irc) ;
|
||||||
|
|
||||||
|
sprintf( message, "STATUS: in readRWBiasDyn, bias value is found in DAABiasDyn table.But dualpol raw data is not available. "
|
||||||
|
"Try RWBiasDyn table.");
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf( message, "STATUS: in readRWBiasDyn, bias value is found in DAABiasDyn table. Dualpol raw data is available.");
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* retrieve the office ID from RadarLoc table
|
* retrieve the office ID from RadarLoc table
|
||||||
*/
|
*/
|
||||||
|
|
||||||
retrieveOfficeIDByRadarID(radar_id, officeID, irc);
|
retrieveOfficeIDByRadarID(radar_id, officeID, irc);
|
||||||
|
|
||||||
if (*irc == -1) {
|
if(*irc == -1)
|
||||||
sprintf(message,
|
{
|
||||||
"ERROR:in readRWBiasDyn - could not find office ID for radar: %s",
|
sprintf ( message, "ERROR: could not find office ID for radar: %s",
|
||||||
radar_id);
|
radar_id);
|
||||||
shutdown(message);
|
shutdown( message );
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(message, "STATUS:in readRWBiasDyn - officeID = %s, siteID = %s",
|
|
||||||
officeID, site_id);
|
|
||||||
hpe_fieldgen_printMessage(message);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pick up the bias value based on the radar's office ID.
|
* Pick up the bias value based on the radar's office ID.
|
||||||
* If there is no record found, check if the office ID is
|
* If there is no record found, check if the office ID is
|
||||||
|
@ -141,215 +194,345 @@ void readRWBiasDyn(const char *radar_id, const char *site_id,
|
||||||
* FXA_LOCAL_SITE as office ID to pick up the bias value again.
|
* FXA_LOCAL_SITE as office ID to pick up the bias value again.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (strcmp(officeID, site_id) != 0) {
|
if(strcmp(officeID, site_id) != 0)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* if the office ID != FXA_LOCAL_SITE,
|
* if the office ID != FXA_LOCAL_SITE,
|
||||||
* then use the HPE_RFC_BIAS_LAG_TOKEN value
|
* then use the HPE_RFC_BIAS_LAG_TOKEN value
|
||||||
* to pick up the bias value.
|
* to pick up the bias value.
|
||||||
*/
|
*/
|
||||||
if (dualpol_on_flag == 0) {
|
|
||||||
sprintf(message,
|
|
||||||
"STATUS:in readRWBiasDyn - start to load SP RFC MFB from RWBiasDyn table"
|
|
||||||
" for officeID = %s, lag time = %d", officeID,
|
|
||||||
rfc_bias_lag);
|
|
||||||
hpe_fieldgen_printMessage(message);
|
|
||||||
|
|
||||||
read_rwbiasdyn2(radar_id, officeID, datehour, rfc_bias_lag,
|
sprintf ( message , "STATUS: loading bias value based on"
|
||||||
num_pairs, sumgag, sumrad, bias, lag, datetime1, irc);
|
" %s and lag time: %d",
|
||||||
if (*irc != 0) {
|
officeID, rfc_bias_lag) ;
|
||||||
sprintf(message,
|
hpe_fieldgen_printMessage( message );
|
||||||
"STATUS:in readRWBiasDyn - can not load SP RFC MFB bias from RWBiasDyn"
|
|
||||||
" table for officeID = %s. Loading SP LOCAL MFB for siteID = %s, lag time = %d",
|
if (dualpol_on_flag == 0)
|
||||||
officeID, site_id, lag_cut);
|
{
|
||||||
hpe_fieldgen_printMessage(message);
|
read_rwbiasdyn2(radar_id, officeID, datehour,
|
||||||
|
rfc_bias_lag, num_pairs, sumgag,
|
||||||
read_rwbiasdyn2(radar_id, site_id, datehour, lag_cut,
|
sumrad, bias, lag, datetime1, irc) ;
|
||||||
num_pairs, sumgag, sumrad, bias, lag, datetime1,
|
sprintf (message, "STATUS: in readRWBiasDyn, dualpol_on_flag is NO, loading bias value from RWBiasDyn table.");
|
||||||
irc);
|
hpe_fieldgen_printMessage( message );
|
||||||
} else {
|
|
||||||
sprintf(message,
|
}
|
||||||
"STATUS:in readRWBiasDyn - Loading SP RFC MFB bias from RWBiasDyn "
|
else
|
||||||
"table for officeID = %s, lag time = %d",
|
{
|
||||||
officeID, rfc_bias_lag);
|
sprintf (message, "STATUS: in readRWBiasDyn, dualpol_on_flag is YES, loading bias value from DAABiasDyn table");
|
||||||
hpe_fieldgen_printMessage(message);
|
hpe_fieldgen_printMessage( message );
|
||||||
}
|
|
||||||
} else {
|
read_daabiasdyn(radar_id, officeID, datehour,
|
||||||
sprintf(message,
|
rfc_bias_lag, num_pairs, sumgag,
|
||||||
"STATUS:in readRWBiasDyn - start to load DP RFC MFB from DAABiasDyn table"
|
sumrad, bias, lag, datetime1, irc) ;
|
||||||
" for officeID = %s, lag time = %d", officeID,
|
|
||||||
rfc_bias_lag);
|
if (*irc != 0)
|
||||||
hpe_fieldgen_printMessage(message);
|
{
|
||||||
|
read_rwbiasdyn2(radar_id, officeID, datehour,
|
||||||
read_daabiasdyn(radar_id, officeID, datehour, rfc_bias_lag,
|
rfc_bias_lag, num_pairs, sumgag,
|
||||||
num_pairs, sumgag, sumrad, bias, lag, datetime1, irc);
|
sumrad, bias, lag, datetime1, irc) ;
|
||||||
if (*irc != 0) {
|
sprintf(message, "STATUS: in readRWBiasDyn, Fail to load bias value from DAABiasDyn table. Try RWBiasDyn table");
|
||||||
sprintf(message,
|
hpe_fieldgen_printMessage( message );
|
||||||
"STATUS:in readRWBiasDyn - can not load DP RFC MFB from DAABiasDyn table"
|
|
||||||
" for officeID = %s. Loading DP LOCAL MFB for siteID = %s, lag time = %d",
|
|
||||||
officeID, site_id, lag_cut);
|
|
||||||
hpe_fieldgen_printMessage(message);
|
|
||||||
|
|
||||||
read_daabiasdyn(radar_id, site_id, datehour, lag_cut,
|
|
||||||
num_pairs, sumgag, sumrad, bias, lag, datetime1,
|
|
||||||
irc);
|
|
||||||
} else {
|
|
||||||
sprintf(message,
|
|
||||||
"STATUS:in readRWBiasDyn - Loading DP RFC MFB bias from DAABiasDyn table"
|
|
||||||
" for officeID = %s, lag time = %d",
|
|
||||||
officeID, rfc_bias_lag);
|
|
||||||
hpe_fieldgen_printMessage(message);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (dualpol_data_avail == 0)
|
||||||
|
{
|
||||||
|
read_rwbiasdyn2(radar_id, officeID, datehour,
|
||||||
|
rfc_bias_lag, num_pairs, sumgag,
|
||||||
|
sumrad, bias, lag, datetime1, irc) ;
|
||||||
|
sprintf( message, "STATUS: in readRWBiasDyn, bias value is found in DAABiasDyn table.But dualpol data is not available. "
|
||||||
|
"Try RWBiasDyn table.");
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf( message, "STATUS: in readRWBiasDyn, bias value is found in DAABiasDyn table. Dualpol data is available.");
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if (dualpol_on_flag == 0) {
|
else
|
||||||
read_rwbiasdyn2(radar_id, officeID, datehour, lag_cut,
|
{
|
||||||
num_pairs, sumgag, sumrad, bias, lag, datetime1, irc);
|
sprintf ( message , "STATUS: in readRWBiasDyn, loading bias value based on"
|
||||||
|
" %s and lag time: %d",
|
||||||
|
officeID, lag_cut) ;
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
|
|
||||||
|
if (dualpol_on_flag == 0)
|
||||||
|
{
|
||||||
|
read_rwbiasdyn2(radar_id, officeID, datehour,
|
||||||
|
lag_cut, num_pairs, sumgag,
|
||||||
|
sumrad, bias, lag, datetime1, irc) ;
|
||||||
|
sprintf (message, "STATUS: in readRWBiasDyn, dualpol_on_flag is NO. Loading bias value from RWBiasDyn table.");
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf (message, "STATUS: in readRWBiasDyn, dualpol_on_flag is YES. Loading bias value from DAABiasDyn table");
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
|
|
||||||
|
read_daabiasdyn(radar_id, officeID, datehour,
|
||||||
|
lag_cut, num_pairs, sumgag,
|
||||||
|
sumrad, bias, lag, datetime1, irc) ;
|
||||||
|
if (*irc != 0)
|
||||||
|
{
|
||||||
|
sprintf(message, "STATUS: in readRWBiasDyn, faild to load bias value from DAABiasDyn table. Try RWBiasDyn table.");
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
|
|
||||||
|
read_rwbiasdyn2(radar_id, officeID, datehour,
|
||||||
|
lag_cut, num_pairs, sumgag,
|
||||||
|
sumrad, bias, lag, datetime1, irc) ;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (dualpol_data_avail == 0)
|
||||||
|
{
|
||||||
|
read_rwbiasdyn2(radar_id, officeID, datehour,
|
||||||
|
rfc_bias_lag, num_pairs, sumgag,
|
||||||
|
sumrad, bias, lag, datetime1, irc) ;
|
||||||
|
sprintf( message, "STATUS: in readRWBiasDyn, bias value is found in DAABiasDyn table.But dualpol data is not available. "
|
||||||
|
"Try RWBiasDyn table.");
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf(message, "STATUS: in readRWBiasDyn, bias value is found in DAABiasDyn table. Dualpol data is available.");
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sprintf(message,
|
}
|
||||||
"STATUS:in readRWBiasDyn - Loading SP RFC MFB bias from RWBiasDyn table"
|
|
||||||
" for officeID(siteID) = %s, lag time = %d",
|
|
||||||
officeID, lag_cut);
|
|
||||||
hpe_fieldgen_printMessage(message);
|
|
||||||
} else {
|
|
||||||
read_daabiasdyn(radar_id, officeID, datehour, lag_cut,
|
|
||||||
num_pairs, sumgag, sumrad, bias, lag, datetime1, irc);
|
|
||||||
|
|
||||||
sprintf(message,
|
/*
|
||||||
"STATUS:in readRWBiasDyn - Loading DP RFC MFB bias from DAABiasDyn table "
|
* Record not found in RWBiasDyn table based on office ID.
|
||||||
"for officeID(siteID) = %s, lag time = %d",
|
* try to pick up bias value based on the FXA_LOCAL_SITE
|
||||||
officeID, lag_cut);
|
* if it is different from office ID.
|
||||||
hpe_fieldgen_printMessage(message);
|
*/
|
||||||
|
|
||||||
|
if(*irc == 100)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(strcmp(officeID, site_id) != 0)
|
||||||
|
{
|
||||||
|
sprintf ( message , "STATUS: in readRWBiasDyn,Record not found in"
|
||||||
|
" RWBiasDyn table based on %s."
|
||||||
|
" try to pick up the bias value"
|
||||||
|
" based on the %s",
|
||||||
|
officeID, site_id) ;
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
|
|
||||||
|
if (dualpol_on_flag == 0)
|
||||||
|
{
|
||||||
|
read_rwbiasdyn2(radar_id, site_id, datehour,
|
||||||
|
lag_cut, num_pairs, sumgag,
|
||||||
|
sumrad, bias, lag, datetime1, irc) ;
|
||||||
|
sprintf (message, "STATUS: in readRWBiasDyn, dualpol_on_flag is NO. Loading bias value from RWBiasDyn table.");
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf (message, "STATUS: in readRWBiasDyn, dualpol_on_flag is YES. Loading bias value from DAABiasDyn table.");
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
|
|
||||||
|
read_daabiasdyn(radar_id, site_id, datehour,
|
||||||
|
lag_cut, num_pairs, sumgag,
|
||||||
|
sumrad, bias, lag, datetime1, irc) ;
|
||||||
|
if (*irc != 0)
|
||||||
|
{
|
||||||
|
sprintf(message, "STATUS: in readRWBiasDyn, faild to find bias value in DAABiasDyn table. Try RWBiasDyn table.");
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
|
read_rwbiasdyn2(radar_id, site_id, datehour,
|
||||||
|
lag_cut, num_pairs, sumgag,
|
||||||
|
sumrad, bias, lag, datetime1, irc) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (dualpol_data_avail == 0)
|
||||||
|
{
|
||||||
|
read_rwbiasdyn2(radar_id, site_id, datehour,
|
||||||
|
lag_cut, num_pairs, sumgag,
|
||||||
|
sumrad, bias, lag, datetime1, irc) ;
|
||||||
|
|
||||||
|
sprintf( message, "STATUS: in readRWBiasDyn, bias value is found in DAABiasDyn table.But dualpol data is not available. "
|
||||||
|
"Try RWBiasDyn table.");
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf(message, "STATUS: in readRWBiasDyn, bias value is found in DAABiasDyn table. Dualpol data is available.s");
|
||||||
|
hpe_fieldgen_printMessage( message );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_rwbiasdyn2(const char *radar_id, const char *office_id,
|
void read_rwbiasdyn2(const char *radar_id,
|
||||||
const char * str, const int lag_cut, double *num_pairs, double *sumgag,
|
const char *office_id,
|
||||||
double *sumrad, double *bias, int *lag, char sstr1[19], long int *irc)
|
const char * str,
|
||||||
|
const int lag_cut,
|
||||||
|
double *num_pairs,
|
||||||
|
double *sumgag,
|
||||||
|
double *sumrad,
|
||||||
|
double *bias,
|
||||||
|
int *lag,
|
||||||
|
char sstr1[19],
|
||||||
|
long int *irc)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
this function reads records from the RWBiasDyn table for previous hours
|
this function reads records from the RWBiasDyn table for previous hours
|
||||||
these records contain the state variables used in the bias calculations
|
these records contain the state variables used in the bias calculations
|
||||||
each previous hour up to lag_cut hours is searched to find records in the
|
each previous hour up to lag_cut hours is searched to find records in the
|
||||||
table if no records is found, then state variables are reinitialized
|
table if no records is found, then state variables are reinitialized
|
||||||
|
|
||||||
calling function: mfb_subr
|
calling function: mfb_subr
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
int j, irec, ctr;
|
int j, irec, ctr;
|
||||||
RWBiasDyn *bdHead = NULL;
|
RWBiasDyn *bdHead = NULL;
|
||||||
RWBiasDyn *bdPtr = NULL;
|
RWBiasDyn *bdPtr = NULL;
|
||||||
char rrad[4] = { '\0' };
|
char rrad[4] = {'\0'};
|
||||||
char strp[22] = { '\0' };
|
char strp[22] = {'\0'};
|
||||||
char dude[22] = { '\0' };
|
char dude[22] = {'\0'};
|
||||||
char where[BUFSIZ] = { '\0' };
|
char where[BUFSIZ] = {'\0'};
|
||||||
char obstime_ANSI[ANSI_TIME_LEN + 1] = { '\0' };
|
char obstime_ANSI[ANSI_TIME_LEN+1] = {'\0'};
|
||||||
time_t firstTime = 0;
|
time_t firstTime = 0;
|
||||||
|
|
||||||
strncpy(rrad, radar_id, 3);
|
strncpy(rrad, radar_id, 3);
|
||||||
strncpy(dude, str, 19);
|
strncpy(dude, str, 19);
|
||||||
|
|
||||||
yearsec_ansi_to_timet(dude, &firstTime);
|
yearsec_ansi_to_timet(dude, &firstTime);
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
/* subtract 1 hour and attempt to select record */
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
/*------------------------------------------------*/
|
*irc = -1;
|
||||||
/* subtract 1 hour and attempt to select record */
|
for(j = 0; j < lag_cut; j ++)
|
||||||
/*------------------------------------------------*/
|
{
|
||||||
|
|
||||||
*irc = -1;
|
|
||||||
for (j = 0; j < lag_cut; j++) {
|
|
||||||
firstTime -= SECONDS_PER_HOUR;
|
firstTime -= SECONDS_PER_HOUR;
|
||||||
timet_to_yearsec_ansi(firstTime, strp);
|
timet_to_yearsec_ansi(firstTime, strp);
|
||||||
strncpy(sstr1, strp, 19);
|
strncpy(sstr1, strp, 19);
|
||||||
|
|
||||||
irec = 0;
|
irec = 0;
|
||||||
*lag = j + 1;
|
*lag = j+1;
|
||||||
|
|
||||||
/*------------------------------------------*/
|
/*------------------------------------------*/
|
||||||
/* select records for all mem_span values */
|
/* select records for all mem_span values */
|
||||||
/*------------------------------------------*/
|
/*------------------------------------------*/
|
||||||
|
|
||||||
timet_to_yearsec_ansi(firstTime, obstime_ANSI);
|
timet_to_yearsec_ansi(firstTime, obstime_ANSI);
|
||||||
sprintf(where, " WHERE radid='%s' AND obstime='%s' AND "
|
sprintf(where, " WHERE radid='%s' AND obstime='%s' AND "
|
||||||
" office_id = '%s'", rrad, obstime_ANSI, office_id);
|
" office_id = '%s'",
|
||||||
|
rrad, obstime_ANSI, office_id);
|
||||||
|
|
||||||
bdHead = GetRWBiasDyn(where);
|
bdHead = GetRWBiasDyn(where);
|
||||||
if (bdHead) {
|
if (bdHead)
|
||||||
bdPtr = (RWBiasDyn *) ListFirst(&bdHead->list);
|
{
|
||||||
|
bdPtr = (RWBiasDyn *) ListFirst(&bdHead->list);
|
||||||
ctr = 0;
|
ctr = 0;
|
||||||
while (bdPtr) {
|
while (bdPtr)
|
||||||
num_pairs[ctr] = (double) bdPtr->numpairs;
|
{
|
||||||
sumgag[ctr] = (double) bdPtr->sumgag;
|
num_pairs[ctr] = (double)bdPtr->numpairs;
|
||||||
sumrad[ctr] = (double) bdPtr->sumrad;
|
sumgag[ctr] = (double)bdPtr->sumgag;
|
||||||
bias[ctr] = (double) bdPtr->bias;
|
sumrad[ctr] = (double)bdPtr->sumrad;
|
||||||
|
bias[ctr] = (double)bdPtr->bias;
|
||||||
|
|
||||||
ctr++;
|
ctr++;
|
||||||
bdPtr = (RWBiasDyn *) ListNext(&bdPtr->node);
|
bdPtr = (RWBiasDyn *) ListNext(&bdPtr->node);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bdHead != NULL) {
|
if ( bdHead != NULL )
|
||||||
|
{
|
||||||
FreeRWBiasDyn(bdHead);
|
FreeRWBiasDyn(bdHead);
|
||||||
bdHead = NULL;
|
bdHead = NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctr > 0) {
|
if (ctr > 0)
|
||||||
|
{
|
||||||
*irc = 0;
|
*irc = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
*irc = 100;
|
*irc = 100;
|
||||||
}
|
}
|
||||||
} /* end for (j=0 ... */
|
} /* end for (j=0 ... */
|
||||||
|
|
||||||
return;
|
return ;
|
||||||
|
|
||||||
} /* end read_rwbiasdyn2 function */
|
} /* end read_rwbiasdyn2 function */
|
||||||
|
|
||||||
void retrieveOfficeIDByRadarID(const char * radarID, char * officeID,
|
|
||||||
long int * status) {
|
|
||||||
char where_clause[BUFSIZ] = { '\0' };
|
|
||||||
RadarLoc * pRadarLocNode = NULL;
|
|
||||||
|
|
||||||
*status = 0;
|
void retrieveOfficeIDByRadarID(const char * radarID,
|
||||||
|
char * officeID,
|
||||||
|
long int * status)
|
||||||
|
{
|
||||||
|
char where_clause [ BUFSIZ ] = {'\0'};
|
||||||
|
RadarLoc * pRadarLocNode = NULL ;
|
||||||
|
|
||||||
|
*status = 0 ;
|
||||||
strcpy(officeID, "");
|
strcpy(officeID, "");
|
||||||
|
|
||||||
sprintf(where_clause, " ");
|
sprintf ( where_clause, " ");
|
||||||
|
|
||||||
if (pRadarLocHead == NULL) {
|
if(pRadarLocHead == NULL)
|
||||||
pRadarLocHead = GetRadarLoc(where_clause);
|
{
|
||||||
|
pRadarLocHead = GetRadarLoc ( where_clause ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pRadarLocHead != NULL) {
|
if ( pRadarLocHead != NULL )
|
||||||
pRadarLocNode = (RadarLoc *) ListFirst(&pRadarLocHead->list);
|
{
|
||||||
|
pRadarLocNode = ( RadarLoc * ) ListFirst (&pRadarLocHead->list);
|
||||||
|
|
||||||
while (pRadarLocNode != NULL) {
|
while (pRadarLocNode != NULL)
|
||||||
if (strcmp(pRadarLocNode->radid, radarID) == 0) {
|
{
|
||||||
|
if(strcmp(pRadarLocNode->radid, radarID) == 0)
|
||||||
|
{
|
||||||
strcpy(officeID, pRadarLocNode->office_id);
|
strcpy(officeID, pRadarLocNode->office_id);
|
||||||
|
|
||||||
sprintf(message,
|
sprintf ( message , "From RadarLoc table, Radar ID: %s, Office ID: %s",
|
||||||
"STATUS:in retrieveOfficeIDByRadarID - From RadarLoc table, Radar ID: %s, Office ID: %s",
|
radarID, officeID );
|
||||||
radarID, officeID);
|
hpe_fieldgen_printMessage( message);
|
||||||
hpe_fieldgen_printMessage(message);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
pRadarLocNode = (RadarLoc *) ListNext(&pRadarLocNode->node);
|
pRadarLocNode = (RadarLoc *) ListNext(&pRadarLocNode->node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
*status = -1;
|
else
|
||||||
|
{
|
||||||
|
* status = -1 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void freeRadarLocMemory() {
|
|
||||||
|
void freeRadarLocMemory()
|
||||||
|
{
|
||||||
/* Deallocate the RadarLoc linked list. */
|
/* Deallocate the RadarLoc linked list. */
|
||||||
|
|
||||||
if (pRadarLocHead != NULL) {
|
if ( pRadarLocHead != NULL )
|
||||||
FreeRadarLoc(pRadarLocHead);
|
{
|
||||||
pRadarLocHead = NULL;
|
FreeRadarLoc ( pRadarLocHead ) ;
|
||||||
|
pRadarLocHead = NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ============== Statements containing RCS keywords: */
|
||||||
|
{static char rcs_id1[] = "$Source: /fs/hseb/ob83/ohd/pproc/src/hpe_fieldgen/RCS/read_rwbiasdyn2.c,v $";
|
||||||
|
static char rcs_id2[] = "$Id: read_rwbiasdyn2.c,v 1.2 2007/10/30 13:33:13 gzhou Exp $";}
|
||||||
|
/* =================================================== */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue