From f131c4e6624adc11052615e0491aa9f0740a2580 Mon Sep 17 00:00:00 2001 From: Jingtao Deng Date: Wed, 18 Feb 2015 13:53:36 -0500 Subject: [PATCH] VLab Issue #6488 - DR17123 Hydro HPE bias_source field in HPERadarResult table needs NO BIAS for some products; fixes #6488 Change-Id: I8c33b5e39222c13d2d3c1143d17ba77a06f6f877 Former-commit-id: 683b558d258907d487274e2c79c42a14c5a9d3d5 [formerly 812fc2dc49b813d2dc2d8220ce0bc73e4b2743cb] [formerly bc8875c276a457b31ee88f9b1c316c5c92d2d13f] [formerly 5756c660b4c89bb9e24bfe6d2f592315309eb294 [formerly bc8875c276a457b31ee88f9b1c316c5c92d2d13f [formerly d8f55d811a11bdb76f69dc7a5ee7cd656c8e63fe]]] Former-commit-id: 5756c660b4c89bb9e24bfe6d2f592315309eb294 Former-commit-id: 5839f437bc175a5dc6f34b7f4a12d2513703747c [formerly a5954a12a0c4dec2d0e1aeac3df17b61cba57025] Former-commit-id: 452cf666c9c1922a3cf5822fb7c2285d15732168 --- .../src/hpe_fieldgen/TEXT/apply_local_bias.c | 12 ++++++----- .../src/hpe_fieldgen/TEXT/empe_fieldgen.h | 5 ++++- .../src/hpe_fieldgen/TEXT/project.c | 17 ++++++++++++---- .../src/hpe_fieldgen/TEXT/run_bdhrmosaic.c | 8 +++++++- .../src/hpe_fieldgen/TEXT/run_dhrmosaic.c | 13 ++++++++---- .../src/hpe_fieldgen/TEXT/run_ebmosaic.c | 8 ++++++-- .../src/hpe_fieldgen/TEXT/run_ermosaic.c | 7 ++++++- .../hpe_fieldgen/TEXT/wrtodb_HPERadarResult.c | 20 +++++++++++++------ 8 files changed, 66 insertions(+), 24 deletions(-) diff --git a/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/apply_local_bias.c b/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/apply_local_bias.c index 9ff0cc531c..e86b29acb6 100644 --- a/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/apply_local_bias.c +++ b/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/apply_local_bias.c @@ -71,6 +71,7 @@ * Date Developer Action * 08/16/2007 Guoxian Zhou first version * 07/2013 JingtaoD dual pol +* 02/2015 JingtaoD A2 OB14.4.1 DR#17123 - HPE Bias Source field ***********************************************************************/ static double ** origLocBias = NULL; @@ -102,7 +103,8 @@ int applyLocalBias(const time_t tRunTime , struct tm * pRunTime = NULL ; static int first = 0; - char prefix[10] = {'\0'}; + + char prefix[20] = {'\0'}; int i, j ; @@ -128,7 +130,7 @@ int applyLocalBias(const time_t tRunTime , { strcpy(prefix, "LOCBIASDP"); sprintf ( message , "STATUS: using dual pol local bias.") ; - printMessage( message ); + hpe_fieldgen_printMessage( message ); } } @@ -138,7 +140,7 @@ int applyLocalBias(const time_t tRunTime , { sprintf ( message , "WARNING: token \"%s\" not available" " - using mean field bias.", LOCBIAS_DIR_TOKEN) ; - printMessage( message ); + hpe_fieldgen_printMessage( message ); return 0; @@ -147,7 +149,7 @@ int applyLocalBias(const time_t tRunTime , { strcpy(prefix, "LOCBIAS"); sprintf ( message , "STATUS: using single pol local bias.") ; - printMessage( message ); + hpe_fieldgen_printMessage( message ); } } @@ -161,7 +163,7 @@ int applyLocalBias(const time_t tRunTime , "%Y%m%d%H", pRunTime); sprintf(fileName, "%s/%s%sz", localBiasDir, prefix, strDateTime ); - sprintf(message, "STATUS: local bias file name is %s.", fileName); + sprintf(message, "STATUS: in apply_local_bias-local bias file name is %s.", fileName); hpe_fieldgen_printMessage( message ); diff --git a/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/empe_fieldgen.h b/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/empe_fieldgen.h index 9d79e38797..16959f674b 100644 --- a/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/empe_fieldgen.h +++ b/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/empe_fieldgen.h @@ -11,6 +11,8 @@ * MODIFICATION HISTORY: * DATE PROGRAMMER DESCRIPTION/REASON * 07/2013 JingtaoD add prototypes for dual pol proudcts DSA/DPR +* 02/2015 JingtaoD A2 OB14.4.1 DR#17123 - HPE Bias Source field +* update wrtodb_HPERadarResult() ******************************************************************************** */ @@ -742,6 +744,7 @@ void read_daabiasdyn(const char *radar_id, void wrtodb_HPERadarResult(const char * hpe_productname, const char * producttime, const empe_params_struct * pEMPEParams, - const int radar_data_source); + const int radar_data_source, + const int nobias_flag); #endif /* #ifndef MPE_FIELDGEN_H */ diff --git a/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/project.c b/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/project.c index a6ad9b7a8a..77d74429b1 100644 --- a/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/project.c +++ b/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/project.c @@ -92,7 +92,7 @@ * Jul. 2001 R. Fulton added mxpra limiting of projected rates * Aug. 11, 2006 Shucai Guan finish conversion to C Language * Mar., 2008 Guoxian Zhou finish first operational version - * + * 02/2015 JingtaoD A2 OB14.4.1 DR#17123 - HPE Bias Source field ***********************************************************************/ static void writeGrib(char * fileName, char * procFlag) @@ -175,6 +175,7 @@ void project(const geo_data_struct * pGeoData, const char * mosaicID, int i, j, iprj, isFilled; long irc; + int nobias_flag; int origRowSize = pGeoData->num_rows; int origColSize = pGeoData->num_cols; @@ -508,11 +509,13 @@ void project(const geo_data_struct * pGeoData, const char * mosaicID, if (strstr(mosaicID, "BDHR") != NULL) { + nobias_flag = 0; sprintf(procFlag, "%s%02d ", biasedRateFilePrefix, k * 15); sprintf(fileName, "%sM%d%sz", biasedRateFilePrefix, k * 15, strDateTime); } else { + nobias_flag = 1; sprintf(procFlag, "%s%02d ", rateFilePrefix, k * 15); sprintf(fileName, "%sM%d%sz", rateFilePrefix, k * 15, strDateTime); @@ -587,8 +590,10 @@ void project(const geo_data_struct * pGeoData, const char * mosaicID, sprintf ( message , "\nSTATUS: In Project, insert/update 1km mosaic nowcast into HPERadarResult table"); printLogMessage( message ); + sprintf ( message, "nobias flag is %d", nobias_flag); + printLogMessage( message ); - wrtodb_HPERadarResult(fileName, prdDateTime, pEMPEParams, radar_data_source); + wrtodb_HPERadarResult(fileName, prdDateTime, pEMPEParams, radar_data_source, nobias_flag); } @@ -636,10 +641,12 @@ void project(const geo_data_struct * pGeoData, const char * mosaicID, { if (strstr(mosaicID, "BDHR") != NULL) { + nobias_flag = 0; sprintf(procFlag, "rfcwide "); sprintf(fileName, "%s4kmH%sz", biasedAccFilePrefix, strDateTime); } else { + nobias_flag = 1; sprintf(procFlag, "rfcwide "); sprintf(fileName, "%s4kmH%sz", accFilePrefix, strDateTime); } @@ -662,7 +669,7 @@ void project(const geo_data_struct * pGeoData, const char * mosaicID, sprintf ( message , "\nSTATUS: In Project, insert/update 4km mosaic nowcast into HPERadarResult table"); printLogMessage( message ); - wrtodb_HPERadarResult(fileName, prdDateTime, pEMPEParams, radar_data_source); + wrtodb_HPERadarResult(fileName, prdDateTime, pEMPEParams, radar_data_source, nobias_flag); } } @@ -683,10 +690,12 @@ void project(const geo_data_struct * pGeoData, const char * mosaicID, if (strstr(mosaicID, "BDHR") != NULL) { + nobias_flag = 0; sprintf(procFlag, "BTP1H "); sprintf(fileName, "%sH%sz", biasedAccFilePrefix, strDateTime); } else { + nobias_flag = 1; sprintf(procFlag, "TP1H "); sprintf(fileName, "%sH%sz", accFilePrefix, strDateTime); } @@ -760,7 +769,7 @@ void project(const geo_data_struct * pGeoData, const char * mosaicID, sprintf ( message , "\nSTATUS: In Project, insert/update 1km mosaic nowcast into HPERadarResult table"); printLogMessage( message ); - wrtodb_HPERadarResult(fileName, prdDateTime, pEMPEParams, radar_data_source); + wrtodb_HPERadarResult(fileName, prdDateTime, pEMPEParams, radar_data_source, nobias_flag); } /* diff --git a/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/run_bdhrmosaic.c b/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/run_bdhrmosaic.c index 27968f05dd..8bf818eee1 100644 --- a/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/run_bdhrmosaic.c +++ b/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/run_bdhrmosaic.c @@ -71,6 +71,7 @@ * Date Developer Action * 10/24/2006 Guoxian Zhou Modified from run_bmosaic.c * 07/2013 JingtaoD dual pol +* 02/2015 JingtaoD A2 OB14.4.1 DR#17123 - HPE Bias Source field ***********************************************************************/ static double ** Mosaic = NULL; @@ -114,9 +115,14 @@ void runBDHRMosaic(const run_date_struct * pRunDate , static int first = 1 ; struct tm * pRunTime = NULL ; long int irc ; + int nobias_flag; + + /*for BDHR product, there is bias applied */ + nobias_flag = 0; int status = 0 ; + /* * strDateTime string should be in format: yyyymmddHHMM */ @@ -235,7 +241,7 @@ void runBDHRMosaic(const run_date_struct * pRunDate , sprintf ( message , "\nSTATUS: In BDHRMOSAIC, insert/update HPERadarResult table"); printLogMessage( message ); - wrtodb_HPERadarResult(fileName, prdDateTime, pEMPEParams, dualpol_used); + wrtodb_HPERadarResult(fileName, prdDateTime, pEMPEParams, dualpol_used, nobias_flag); sprintf ( message , "\nSTATUS: In BDHRMOSAIC, complete insert/update HPERadarResult table"); diff --git a/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/run_dhrmosaic.c b/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/run_dhrmosaic.c index 83efa96c22..e72cf4728d 100644 --- a/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/run_dhrmosaic.c +++ b/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/run_dhrmosaic.c @@ -74,9 +74,10 @@ * Date Developer Action * 8/13/2006 Guoxian Zhou Build operational version * 07/2013 Jingtao Deng Modify for adding dual pol producat DPR - * first try to find the DPR product from dprradar - * table and calculate the rain rate. if - * not able to get DPR product, then use DHR product +* first try to find the DPR product from dprradar +* table and calculate the rain rate. if +* not able to get DPR product, then use DHR product +* 02/2015 JingtaoD A2 OB14.4.1 DR#17123 - HPE Bias Source field ***********************************************************************/ extern short ** radarMiscBins ; @@ -164,6 +165,10 @@ void runDHRMosaic(const run_date_struct * pRunDate, int dualpol_meanbias_flag[MAX_RADAR_NUM]; int sp_meanbias_flag[MAX_RADAR_NUM]; int dualpol_data_avail[MAX_RADAR_NUM]; + int nobias_flag; + + /* for DHR product, there is no bias applied */ + nobias_flag = 1; /* initialize no dualpol MFB and no dual pol product avialble for each radar */ for (i = 0; i < MAX_RADAR_NUM; i++) @@ -652,7 +657,7 @@ void runDHRMosaic(const run_date_struct * pRunDate, sprintf ( message , "\nSTATUS: In DHRMOSAIC, insert/update HPERadarResult table"); printLogMessage( message ); - wrtodb_HPERadarResult(dhrmosaic_fileName, prdDateTime, pEMPEParams, dualpol_used); + wrtodb_HPERadarResult(dhrmosaic_fileName, prdDateTime, pEMPEParams, dualpol_used, nobias_flag); sprintf ( message , "\nSTATUS: In DHRMOSAIC, complete insert/update HPERadarResult table"); printLogMessage( message ); diff --git a/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/run_ebmosaic.c b/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/run_ebmosaic.c index 749d94b6d9..0dc525e133 100644 --- a/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/run_ebmosaic.c +++ b/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/run_ebmosaic.c @@ -73,7 +73,7 @@ * April 2005 Guoxian Zhou converted to C Language * 10/05/2006 Guoxian Zhou Modified for empe version * 08/08/2007 Guoxian Zhou add option to use local bias data -* +* 02/2015 JingtaoD A2 OB14.4.1 DR#17123 - HPE Bias Source field ***********************************************************************/ extern int dualpol_used; @@ -113,9 +113,13 @@ void runEBMosaic(const run_date_struct * pRunDate , static int first = 1 ; struct tm * pRunTime = NULL ; long int irc ; + int nobias_flag; int status = 0 ; + /* for EBMOSAIC, there is bias applied */ + nobias_flag = 0; + /* * strDateTime string should be in format: yyyymmddHHMM */ @@ -225,7 +229,7 @@ void runEBMosaic(const run_date_struct * pRunDate , sprintf ( message , "\nSTATUS: In EBMOSAIC, insert/update HPERadarResult table"); printLogMessage( message ); - wrtodb_HPERadarResult(fileName, prdDateTime, pEMPEParams, dualpol_used); + wrtodb_HPERadarResult(fileName, prdDateTime, pEMPEParams, dualpol_used, nobias_flag); sprintf ( message , "\nSTATUS: In EBMOSAIC, complete insert/update HPERadarResult table"); printLogMessage( message ); diff --git a/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/run_ermosaic.c b/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/run_ermosaic.c index 0c15edc77a..e7f5cccfff 100644 --- a/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/run_ermosaic.c +++ b/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/run_ermosaic.c @@ -81,6 +81,7 @@ * first try to find the DSA product from dsaradar * table and calculate the 1 hour precipitation. if * not able to get DSA product, then use DSP product +* 02/2015 JingtaoD A2 OB14.4.1 DR#17123 - HPE Bias Source field ***********************************************************************/ extern short ** radarMiscBins ; @@ -195,6 +196,10 @@ void runERMosaic(const run_date_struct * pRunDate, int dualpol_meanbias_flag[MAX_RADAR_NUM]; int sp_meanbias_flag[MAX_RADAR_NUM]; int dualpol_data_avail[MAX_RADAR_NUM]; + int nobias_flag; + + /*ERMOSAIC product has no bias applied */ + nobias_flag = 1; /* initialize no dualpol MFB and no dual pol product avialble for each radar */ for (i = 0; i < MAX_RADAR_NUM; i++) @@ -970,7 +975,7 @@ void runERMosaic(const run_date_struct * pRunDate, printLogMessage( message ); if(blnMosaic[ermosaic] == 1) - wrtodb_HPERadarResult(ermosaic_fileName, prdDateTime, pEMPEParams, dualpol_used); + wrtodb_HPERadarResult(ermosaic_fileName, prdDateTime, pEMPEParams, dualpol_used, nobias_flag); sprintf ( message , "\nSTATUS: In ERMOSAIC, complete insert/update HPERadarResult table"); printLogMessage( message ); diff --git a/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/wrtodb_HPERadarResult.c b/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/wrtodb_HPERadarResult.c index c001cb2397..f8fab61109 100644 --- a/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/wrtodb_HPERadarResult.c +++ b/nativeLib/rary.ohd.pproc/src/hpe_fieldgen/TEXT/wrtodb_HPERadarResult.c @@ -12,7 +12,7 @@ * MACHINE: * MODIFICATION HISTORY: * MODULE # DATE PROGRAMMER DESCRIPTION/REASON -* +* 02/2015 JingtaoD A2 OB14.4.1 DR#17123 - HPE Bias Source field ******************************************************************************** */ @@ -55,19 +55,20 @@ void wrtodb_HPERadarResult(const char * hpe_productname, const char * producttime, const empe_params_struct * pEMPEParams, - const int radar_data_source) + const int radar_data_source, + const int nobias_flag) { HPERadarResult hperadarresult_struct; const char * HPE_BIAS_SOURCE_TOKEN = "hpe_bias_source"; - static int first = 1 ; + static int first = 0 ; static char bias_source[6] = "RFC"; // RFC or LOCAL, default to RFC char strTokenValue[6] = {'\0'} ; /* retrieve token HPE_BIAS_SOURCE_TOKEN, it can be LOCAL or RFC */ - if(first == 1) + if(first == 0) { if(hpe_fieldgen_getAppsDefaults(HPE_BIAS_SOURCE_TOKEN, strTokenValue) != -1) { @@ -97,12 +98,19 @@ void wrtodb_HPERadarResult(const char * hpe_productname, hpe_fieldgen_printMessage( message ); } - first = 0; + first = 1; } + + /* Initialize the product name. and assign value */ /*hperadarresult_struct.hpe_productname [ PRESET_DESCR_LEN + 1 ] = '\0';*/ strncpy(hperadarresult_struct.hpe_productname, hpe_productname, PRESET_DESCR_LEN); + sprintf ( message, "STATUS: the hpe productname is %s", hpe_productname); + hpe_fieldgen_printMessage( message ); + + sprintf ( message, "STATUS: the nobias_flag is %d", nobias_flag); + hpe_fieldgen_printMessage( message ); /* assign producttime */ yearsec_ansi_to_dt(producttime, &hperadarresult_struct.producttime); @@ -114,7 +122,7 @@ void wrtodb_HPERadarResult(const char * hpe_productname, /* Initialize the bias source . and assign value */ hperadarresult_struct.bias_source[BIAS_LEN + 1] = '\0'; - if (pEMPEParams->blnMeanFieldBias == 0 && pEMPEParams->blnDHRMeanFieldBias == 0) + if (nobias_flag == 1) strcpy(hperadarresult_struct.bias_source, "NO BIAS"); else //EBMOSAIC or BDHRMOSAIC {