Commit 957d11fd authored by Miguel Tremblay's avatar Miguel Tremblay
Browse files

Revert change for to the verification of the number of hours of observations.

parent 8c4546e5
......@@ -265,7 +265,7 @@ class Metro_model(Metro_module):
npSWO[4*i+3] = npSWO4[i]
lSWO = npSWO.astype(numpy.int32).tolist()
bThreeHoursObs = observation.get_attribute('THREE_HOURS_OBS')
bNoObs = observation.get_attribute('NO_OBS')
sMessage = _( "------------station config START---------------------")
metro_logger.print_message(metro_logger.LOGGER_MSG_DEBUG,
......@@ -287,9 +287,6 @@ class Metro_model(Metro_module):
bFlat = cs_data.get_station_type()
metro_logger.print_message(metro_logger.LOGGER_MSG_DEBUG,
sMessage)
sMessage = _("------------station config END---------------------")
metro_logger.print_message(metro_logger.LOGGER_MSG_DEBUG,
sMessage)
......@@ -305,10 +302,9 @@ class Metro_model(Metro_module):
lLayerThick, nNbrOfLayer, lLayerType, \
lAT, lQP, lWS, lAP, lSF, lIR, lFT, lFA, lPI, lSC,\
lAT_obs,lST_obs, lSST_obs, \
lAH, lTime_obs, lSWO, \
lAH, lTime_obs, lSWO, bNoObs,\
fDeltaTMetroObservation, nLenObservation, \
nNbrTimeSteps, bSilent, \
bThreeHoursObs)
nNbrTimeSteps, bSilent)
bEchec = (macadam.get_echec())[0]
# Check if the execution of the model was a succes:
if bEchec != 0:
......
......@@ -215,7 +215,8 @@ class Metro_preprocess_qa_qc_observation(Metro_preprocess):
npTime = ro_controlled_data.get_matrix_col('Time')
npCheck = metro_util.get_difference_array(npTime)
# If a gap of more than nGapMinuteObservation
# minutes is identified, cut the value before.
# minutes is identify, cut the value before.
npCheck = metro_util.get_difference_array(npTime)
npBad = numpy.where( npCheck > metro_constant.\
nGapMinuteObservation*60, 1, 0)
npBadIndice = (numpy.nonzero(npBad))[0]
......@@ -287,8 +288,7 @@ class Metro_preprocess_qa_qc_observation(Metro_preprocess):
if sStart_time == "":
return
# Check if the observation are not before the start of the roadcast
# if specified.
# Check if the observation are not before the start of the roadcast if specified.
fStart_time = metro_date.parse_date_string(sStart_time)
npOT = ro_controlled_data.get_matrix_col('Time')\
+nHourStart*3600
......@@ -409,19 +409,31 @@ class Metro_preprocess_qa_qc_observation(Metro_preprocess):
"""
# Take any of the column of the observation to check the dimensions.
npAT = ro_controlled_data.get_matrix_col('AT')
npTime = ro_controlled_data.get_matrix_col('Time')
nNbr30Seconds = (npTime[len(npTime)-1]-npTime[0]) \
/metro_constant.fTimeStep
# Initialize the boolean field
bThreeHoursObs = True
bNoObs = [0, 0, 0, 0]
# Check if there is any data for initialisation
# Less than 3 hours of observation (3*3600/30 = 360)
if nNbr30Seconds < 360:
bThreeHoursObs = False
fDeltaT = observation_data.get_attribute('DELTA_T')
if fDeltaT <= 0:
bNoObs[0] = 1
# Less than 3 hours of observation
if nNbr30Seconds-fDeltaT*3600/30. < metro_constant.nThreeHours*3600/30:
bNoObs[1] = 1
# No valid observation
if len(npAT) == 0:
bNoObs[2] = 1
# One valid observation
if len(npAT) == 1:
bNoObs[3] = 1
# Set the variable
observation_data.set_attribute('THREE_HOURS_OBS',bThreeHoursObs)
observation_data.set_attribute('NO_OBS',bNoObs)
def __set_time_difference(self, ro_controlled_data, wf_controlled_data, \
......
......@@ -386,12 +386,11 @@ def save_command_line_parameter( lArgv, sShort_opt, lLong_opt ):
if o == "--use-anthropogenic-flux":
dConfig['FA']['VALUE'] = True
dFSDict= {'NAME':"FA",
dSFDict= {'NAME':"FA",
'XML_TAG':"fa",
'DATA_TYPE':"REAL"}
dConfig['XML_FORECAST_PREDICTION_EXTENDED_ITEMS'][\
'VALUE'].append(dFSDict)
'VALUE'].append(dSFDict)
if o == "--output-subsurface-levels":
dConfig['TL']['VALUE'] = True
......@@ -409,6 +408,7 @@ def save_command_line_parameter( lArgv, sShort_opt, lLong_opt ):
'VALUE'].append(dTL)
# Selftest value
if o == "--selftest":
......@@ -856,6 +856,7 @@ def set_default_value( ):
'FROM' :CFG_INTERNAL,
'COMMENTS' :_("standard station header items")}
dConfig['XML_STATION_HEADER_EXTENDED_ITEMS'] = \
{'VALUE' :[],
'FROM' :CFG_HARDCODED,
......@@ -948,7 +949,7 @@ def set_default_value( ):
dConfig['XML_ROADCAST_HEADER_EXTENDED_ITEMS'] = \
{'VALUE' :[],
'FROM' :CFG_INTERNAL,
'FROM' :CFG_HARDCODED,
'COMMENTS' :_("extended roadcast header items")}
dConfig['XML_ROADCAST_PREDICTION_STANDARD_ITEMS'] = \
......@@ -1084,7 +1085,7 @@ def set_default_value( ):
"TD_VALID_INTERPOLATED",
"WS_VALID_INTERPOLATED",
"DELTA_T",
"THREE_HOURS_OBS"
"NO_OBS"
],
'FROM' :CFG_INTERNAL,
'COMMENTS' :_("default observation attribute.")}
......
......@@ -65,6 +65,7 @@ nAirTempMin = -60
nMaxWindSpeed = 90
nHourForExpirationOfObservation = 48
nGapMinuteObservation = 240
nThreeHours = 3
nLowerPressure = 900
fNormalPressure = 1013.25 # 1 atmosphere
nUpperPressure = 1100
......@@ -86,4 +87,3 @@ nNL = 11520
# METRo output
# Indicates at what will be the time interval between 2 field in the roadcast
nMinutesForOutput = 20
#include "global.h"
/***********************************************
** Set method
**********************************************/
void SetVocal(BOOL bVocal)
{
g_bVocal = bVocal;
}
void SetNoEol(BOOL bNoEol)
{
g_bNoEol = bNoEol;
}
void SetForMan(BOOL bForMan)
{
g_bForMan = bForMan;
}
void SetManuel(BOOL bManuel)
{
g_bManuel = bManuel;
}
void SetDual(BOOL bDual)
{
g_bDual = bDual;
}
void SetProtect(BOOL bProtect)
{
g_bProtect = bProtect;
}
void SetVerbose(BOOL bVerbose)
{
g_bVerbose = bVerbose;
}
void SetVerPlus(BOOL bVerPlus)
{
g_bVerPlus = bVerPlus;
}
void SetHLocal(BOOL bHLocal)
{
g_bHLocal = bHLocal;
}
void SetLang(char* cpLang)
{
strcpy(g_cpLang,cpLang);
}
void SetMess(char** cppMess, long nDim)
{
long i;
for(i=0; i<nDim; i++)
strcpy(g_cppMess[i], cppMess[i]);
}
/***********************************************
** Get method
**********************************************/
BOOL GetVocal()
{
return g_bVocal;
}
BOOL GetNoEol()
{
return g_bNoEol;
}
BOOL GetForMan()
{
return g_bForMan;
}
BOOL GetManuel()
{
return g_bManuel;
}
BOOL GetDual()
{
return g_bDual;
}
BOOL GetProtect()
{
return g_bProtect;
}
BOOL GetVerbose()
{
return g_bVerbose;
}
BOOL GetVerPlus()
{
return g_bVerPlus;
}
BOOL GetHLocal()
{
return g_bHLocal;
}
char* GetLang()
{
return g_cpLang;
}
char** GetMess()
{
return g_cppMess;
}
#define BOOL long
#define TRUE 1
#define FALSE 0
static BOOL g_bVocal=FALSE;
static BOOL g_bNoEol=FALSE;
static BOOL g_bForMan;
static BOOL g_bManuel;
static BOOL g_bDual;
static BOOL g_bProtect;
static BOOL g_bVerbose;
static BOOL g_bVerPlus;
static BOOL g_bHLocal;
static char* g_cpLang;
static char** g_cppMess;
/* Set */
void SetVocal(BOOL bVocal);
void SetNoEol(BOOL bNoEol);
void SetForMan(BOOL bForMan);
void SetManuel(BOOL bManuel);
void SetDual(BOOL bDual);
void SetProtect(BOOL bProtect);
void SetVerbose(BOOL bVerbose);
void SetVerPlus(BOOL bVerPlus);
void SetHLocal(BOOL bHLocal);
void SetLang(char* cpLang);
void SetMess(char** cppMess, long nDim);
/* Get */
BOOL GetVocal();
BOOL GetNoEol();
BOOL GetForMan();
BOOL GetManuel();
BOOL GetDual();
BOOL GetProtect();
BOOL GetVerbose();
BOOL GetVerPlus();
BOOL GetHLocal();
char* GetLang();
char** GetMess();
......@@ -117,8 +117,6 @@ static struct doubleStruct stLT; /* Level temperature */
and the start of METRo.]
[I long nLenObservation : Number of valid observations. 30 seconds steps.]
[I long nNbrTimeSteps : number of 30 seconds steps in the forecast]
[I long bThreeHoursObs: True if the number of observations is over 3 hours ]
Returns: None
......@@ -145,7 +143,7 @@ Miguel Tremblay May 2004
***************************************************************************/
void Do_Metro( BOOL bFlat, double dMLat, double dMLon, double* dpZones, long nNbrOfZone, long* npMateriau, double* dpTA, double* dpQP, double* dpFF, double* dpPS, double* dpFS, double* dpFI, double* dpFT, double* dpFA, double* dpTYP, double* dpRC, double* dpTAO, double* dpRTO, double* dpDTO, double* dpAH, double* dpTimeO, long* npSwo, double dDeltaT, long nLenObservation, long nNbrTimeSteps, BOOL bSilent, BOOL bThreeHoursObs)
void Do_Metro( BOOL bFlat, double dMLat, double dMLon, double* dpZones, long nNbrOfZone, long* npMateriau, double* dpTA, double* dpQP, double* dpFF, double* dpPS, double* dpFS, double* dpFI, double* dpFT, double* dpFA, double* dpTYP, double* dpRC, double* dpTAO, double* dpRTO, double* dpDTO, double* dpAH, double* dpTimeO, long* npSwo, BOOL* bpNoObs, double dDeltaT, long nLenObservation, long nNbrTimeSteps, BOOL bSilent)
{
/* Argument de la ligne de commande. Donne par python */
......@@ -172,6 +170,8 @@ void Do_Metro( BOOL bFlat, double dMLat, double dMLon, double* dpZones, long nNb
BOOL bSucces = TRUE;
long nNtp;
long nNtp2;
long nNRec;
long nNtdcl;
double* dpItp;
double dDiff;
double* dpWw;
......@@ -189,6 +189,7 @@ void Do_Metro( BOOL bFlat, double dMLat, double dMLon, double* dpZones, long nNb
double dEr2=0;
double dFp=0.0;
/* Grid values */
/* long nIRef=0; */
long nIR40;
double* dpCnt;
double* dpCapacity;
......@@ -244,16 +245,30 @@ void Do_Metro( BOOL bFlat, double dMLat, double dMLon, double* dpZones, long nNb
/***********************************************************************/
/* Coupling is different if there is more or less than 3 hours. */
/* Couplage de la prevision et des observations.
/* Differentes possibilites selon la quantite d'observations
/* presentes.
/**********************************************************************/
bFail = FALSE;
if( !bThreeHoursObs){
if(bpNoObs[2]){
goto liberation;
}
else if(bpNoObs[3]){
BOOL bFalse = FALSE;
if(!bSilent)
printf(" Only one valid observation: No initialization nor coupling.\n");
f77name(makitp)(dpItp, &stTemperatureDepth.nSize, &nIR40, &bFlat,\
&(dpTimeO[0]), &(dpRTO[0]), &(dpDTO[0]), &(dpTAO[0]),\
&dDiff, &dMLon, npSwo, stTemperatureDepth.pdArray);
nNtp2 = nLenObservation - nDeltaTIndice;
}
else if(bpNoObs[1]){
/* less than 3 hours of observation in the coupling */
BOOL bFalse = FALSE;
long nOne =1;
if(!bSilent)
printf(" Not enough data for coupling.\n");
f77name(makitp)(dpItp, &stTemperatureDepth.nSize, &nIR40, &bFlat, \
&(dpTimeO[0]), \
f77name(makitp)(dpItp, &stTemperatureDepth.nSize, &nIR40, &bFlat, &(dpTimeO[0]),\
&(dpRTO[0]), &(dpDTO[0]), &(dpTAO[0]), &dDiff, \
&dMLon, npSwo, stTemperatureDepth.pdArray);
f77name(initial)(dpItp , (dpRTO+1), (dpDTO+1), (dpTAO+1), &nOne, \
......@@ -261,6 +276,44 @@ void Do_Metro( BOOL bFlat, double dMLat, double dMLon, double* dpZones, long nNb
&bFlat, npSwo, dpCapacity, dpConductivity);
nNtp2 = nLenObservation - nDeltaTIndice;
}
else if(bpNoObs[0]){
BOOL bTmp = FALSE;
if(!bSilent)
printf(" Not enough data for initialization.\n");
nNtdcl = nLenObservation - ((nLenObservation < 28800.0/dDT)\
? nLenObservation : 28800.0/dDT);
/* Patch because nNtdcl does not take the value 0 in fortran!*/
if(nNtdcl == 0)
nNtdcl =1;
f77name(makitp)(dpItp, &stTemperatureDepth.nSize, &nIR40, &bFlat, &(dpTimeO[nNtdcl]),\
&(dpRTO[nNtdcl]), &(dpDTO[nNtdcl]), &(dpTAO[nNtdcl]),\
&dDiff, &dMLon, npSwo, stTemperatureDepth.pdArray);
nNtp = - nDeltaTIndice + nNtdcl;
nNtp2 = nLenObservation - nDeltaTIndice;
f77name(coupla)(dpFS, dpFI, dpPS, dpTA, dpAH, dpFF, dpTYP, dpFT, dpQP, dpRC, \
&stTemperatureDepth.nSize, &nNtp, &nNtp2, dpItp, \
&(dpRTO[nLenObservation]), &bFlat, &dFCorr, dpWw, \
&dAln, &dAlr, &dFp, &dFsCorr, &dFiCorr, &dEr1, &dEr2, \
&bFail, &dEpsilon, &dZ0, &dZ0t, &dZu, &dZt, stEc.plArray, \
stRA.pdArray, stSN.pdArray, stRC.plArray, stRT.pdArray,\
stIR.pdArray, stSF.pdArray, stFV.pdArray, stFC.pdArray, \
dpFA, stG.pdArray, stBB.pdArray, stFP.pdArray,\
dpCapacity, dpConductivity);
if(!bSilent)
printf("coupla 1 \n");
if(*(stEc.plArray)){
bSucces = FALSE;
goto liberation;
}
if(bFail){
long nOne = 1;
if(!bSilent)
printf("fail\n");
f77name(initial)(dpItp, (dpRTO+1), (dpDTO+1), (dpTAO+1), &nOne,\
&nLenObservation, &stTemperatureDepth.nSize,\
&nIR40, &bFlat, npSwo, dpCapacity, dpConductivity);
}
}
else{/* observation complete */
long nOne =1;
if(!bSilent)
......@@ -271,11 +324,13 @@ void Do_Metro( BOOL bFlat, double dMLat, double dMLon, double* dpZones, long nNb
&(dpRTO[nDeltaTIndice]), &(dpDTO[nDeltaTIndice]), \
&(dpTAO[nDeltaTIndice]), &dDiff, &dMLon, npSwo, \
stTemperatureDepth.pdArray);
nNtdcl = nLenObservation - nDeltaTIndice -\
((nLenObservation-nDeltaTIndice < 28800.0/dDT) \
? nLenObservation-nDeltaTIndice : 28800.0/dDT);
f77name(initial)(dpItp , (dpRTO+1), (dpDTO+1), (dpTAO+1), &nOne, \
&nLenObservation, &stTemperatureDepth.nSize,\
&nIR40, &bFlat, npSwo, dpCapacity, dpConductivity);
nNtp = 0; // + nNtdcl;
nNtp = 0 + nNtdcl;
nNtp2 = nLenObservation - nDeltaTIndice;
f77name(coupla)(dpFS, dpFI, dpPS, dpTA, dpAH, dpFF, dpTYP, dpFT, dpQP, \
dpRC, &stTemperatureDepth.nSize, &nNtp, &nNtp2, dpItp,\
......
......@@ -17,12 +17,9 @@
**
****************************************************************************/
#include "global.h"
#include "number.h"
#define BOOL long
#define TRUE 1
#define FALSE 0
/* Pas de temps du modèle de bilan énergétique */
#define dDT 30.0
......@@ -39,7 +36,7 @@
#define dPI 3.141592653590e0
#define dOMEGA 0.7292e-4
void Do_Metro(BOOL bFlat, double dMLat, double dMLon, double* dpZones, long nNbrOfZone, long* npMateriau, double* dpTA, double* dpQP, double* dpFF, double* dpPS, double* dpFsPy, double* dpFI, double* dpFT, double* dpFA, double* dpTYP, double* dpRc, double* dpTAO, double* dpRTO, double* dpDTO, double* dpAH, double* dpTimeO, long* npSWO, double dDeltaT, long nLenObservation, long nNbrTimeSteps, BOOL bSilent, BOOL bThreeHoursObs);
void Do_Metro(BOOL bFlat, double dMLat, double dMLon, double* dpZones, long nNbrOfZone, long* npMateriau, double* dpTA, double* dpQP, double* dpFF, double* dpPS, double* dpFsPy, double* dpFI, double* dpFT, double* dpFA, double* dpTYP, double* dpRc, double* dpTAO, double* dpRTO, double* dpDTO, double* dpAH, double* dpTimeO, long* npSWO, BOOL* bpNoObs, double dDeltaT, long nLenObservation, long nNbrTimeSteps, BOOL bSilent);
void init_structure(long nTimeStepMax, long nGrilleLevelMax);
......
......@@ -390,7 +390,7 @@ int print_args(char **argv) {
extern void Do_Metro(long, double, double, double*, long, long*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, long*, double, long, long, long, long);
extern void Do_Metro(long, double, double, double*, long, long*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, long*, long*, double, long, long, long);
extern struct doubleStruct get_ra(void);
extern struct doubleStruct get_sn(void);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment