Commit 28112559 authored by Miguel Tremblay's avatar Miguel Tremblay
Browse files

Modification to have an optional parameter in station XML file for the subsurface sensor.

parent 326ffd9e
......@@ -35,6 +35,7 @@
from metro_data import Metro_data
import metro_logger
import metro_config
from toolbox import metro_util
......@@ -119,3 +120,22 @@ class Metro_data_station(Metro_data):
bFlat = False
return bFlat
def get_sst_depth(self):
"""
Get the sensor SST depth value
Return 0.4 if value in station config file is not between 0.2 and 0.6 and if no flag '--use-sst-sensor-depth' is used. Else returns value provided for sensor SST depth in station config file.
"""
if metro_config.get_value('SST_DEPTH') == False:
return 0.4
else:
dStation_header = self.get_header()
sStation_sst_depth = dStation_header['SST_DEPTH']
if sStation_sst_depth == "None" or sStation_sst_depth > 0.6 or sStation_sst_depth < 0.2:
sMessage = _("Sensor SST depth value in station config file is not between 0.2 and 0.6. Value 0.4 for sensor SST depth will be used.")
metro_logger.print_message(metro_logger.LOGGER_MSG_CRITICAL,\
sMessage)
return 0.4
else:
return sStation_sst_depth
......@@ -287,6 +287,12 @@ class Metro_model(Metro_module):
bFlat = cs_data.get_station_type()
dSstDepth = cs_data.get_sst_depth()
sMessage = _( "SST sensor depth: ") + str(dSstDepth)
metro_logger.print_message(metro_logger.LOGGER_MSG_DEBUG,
sMessage)
sMessage = _("------------station config END---------------------")
metro_logger.print_message(metro_logger.LOGGER_MSG_DEBUG,
sMessage)
......@@ -304,7 +310,8 @@ class Metro_model(Metro_module):
lAT_obs,lST_obs, lSST_obs, \
lAH, lTime_obs, lSWO, bNoObs,\
fDeltaTMetroObservation, nLenObservation, \
nNbrTimeSteps, bSilent)
nNbrTimeSteps, bSilent, \
dSstDepth)
bEchec = (macadam.get_echec())[0]
# Check if the execution of the model was a succes:
if bEchec != 0:
......
......@@ -95,6 +95,7 @@ CFG_LONG_OPTIONS = ["help","version",
"selftest", "silent", "roadcast-start-date=", "lang=",
"use-solarflux-forecast", "use-infrared-forecast",
"use-anthropogenic-flux",
"use-sst-sensor-depth",
"output-subsurface-levels",
]
......@@ -386,11 +387,19 @@ def save_command_line_parameter( lArgv, sShort_opt, lLong_opt ):
if o == "--use-anthropogenic-flux":
dConfig['FA']['VALUE'] = True
dSFDict= {'NAME':"FA",
dFADict= {'NAME':"FA",
'XML_TAG':"fa",
'DATA_TYPE':"REAL"}
dConfig['XML_FORECAST_PREDICTION_EXTENDED_ITEMS'][\
'VALUE'].append(dSFDict)
'VALUE'].append(dFADict)
if o == "--use-sst-sensor-depth":
dConfig['SST_DEPTH']['VALUE'] = True
dSST_DEPTHDict = {'NAME':"SST_DEPTH",
'XML_TAG':"sst-sensor-depth",
'DATA_TYPE':"REAL"}
dConfig['XML_STATION_HEADER_EXTENDED_ITEMS'][\
'VALUE'].append(dSST_DEPTHDict)
if o == "--output-subsurface-levels":
dConfig['TL']['VALUE'] = True
......@@ -949,7 +958,7 @@ def set_default_value( ):
dConfig['XML_ROADCAST_HEADER_EXTENDED_ITEMS'] = \
{'VALUE' :[],
'FROM' :CFG_HARDCODED,
'FROM' :CFG_INTERNAL,
'COMMENTS' :_("extended roadcast header items")}
dConfig['XML_ROADCAST_PREDICTION_STANDARD_ITEMS'] = \
......@@ -1245,6 +1254,10 @@ def set_default_value( ):
'FROM' :CFG_HARDCODED,
'COMMENTS' :_("default time zone for station header date")}
dConfig['SST_DEPTH'] = \
{'VALUE' :False,
'FROM' :CFG_HARDCODED,
'COMMENTS':_("Use subsurface temperature sensor depth value from station")}
# ------------------------------ roadcast ----------------------------------
......
......@@ -48,7 +48,7 @@
***
SUBROUTINE GRILLE (iref, ir40, FLAT, NZONE, ZONES,
* MAT, DIFF, dpTemperatureDepth, ECHEC, dpCapacity,
* dpConductivity)
* dpConductivity, dSstDepth)
IMPLICIT NONE
INTEGER i, j, k
INTEGER Nl, n
......@@ -84,6 +84,7 @@
DOUBLE PRECISION dpTemperatureDepth(n)
DOUBLE PRECISION dpCapacity(n)
DOUBLE PRECISION dpConductivity(n)
DOUBLE PRECISION dSstDepth
***
* Local
* --------
......@@ -122,7 +123,7 @@
* ----------------------------------------------------
NMAX = NZONE
DO k=1,NZONE
IF ( ZONES(NZONE + 1 - k) .ge. 0.40 ) NMAX = NZONE + 1 - k
IF ( ZONES(NZONE + 1 - k) .ge. dSstDepth ) NMAX = NZONE + 1 - k
IF ( MAT(k) .eq. 1 ) THEN
* asphalt(e)
* ----------
......@@ -148,10 +149,10 @@
return
END IF
END DO
DIFF = (MIN(0.4, REAL(ZONES(1)))/0.4)*KS(1)/CS(1)
DIFF = (MIN(dSstDepth, REAL(ZONES(1)))/dSstDepth)*KS(1)/CS(1)
DO i=2,NMAX
DIFF = ((MIN(0.4,REAL(ZONES(i)))-ZONES(i-1))/0.4)*
DIFF = ((MIN(dSstDepth,REAL(ZONES(i)))-ZONES(i-1))/dSstDepth)*
* KS(i)/CS(i) + DIFF
END DO
* Creation of the grid itself and his derivatives
......@@ -172,15 +173,15 @@
YPG(j) = 1.0
* Derivate on the temperature layer
YPT(j) = 1.0
IF ( dpTemperatureDepth(j) .le. 0.4 ) ir40 = j
IF ( dpTemperatureDepth(j) .le. dSstDepth ) ir40 = j
END DO
ELSE
* Case FLAT = .false. => ROAD
* ---------------------------
CC = 3.6
dd = 20.0
ir40=int(0.5+((1-exp(-(CC*0.4)))/(1-exp(-(CC*0.01)))))
DY = dd * (1-exp(-(CC*0.4)))/(real(ir40)-0.5)
ir40=int(0.5+((1-exp(-(CC*dSstDepth)))/(1-exp(-(CC*0.01)))))
DY = dd * (1-exp(-(CC*dSstDepth)))/(real(ir40)-0.5)
j=1
12 IF ( real(j)*DY/dd .ge. 1.0 ) THEN
iref = j - 1
......
......@@ -117,6 +117,7 @@ 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 double dSstDepth : SST sensor depth from station file]
Returns: None
......@@ -143,7 +144,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, BOOL* bpNoObs, double dDeltaT, long nLenObservation, long nNbrTimeSteps, BOOL bSilent)
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, double dSstDepth)
{
/* Argument de la ligne de commande. Donne par python */
......@@ -231,7 +232,7 @@ void Do_Metro( BOOL bFlat, double dMLat, double dMLon, double* dpZones, long nNb
f77name(grille)(&(stTemperatureDepth.nSize), &nIR40, &bFlat, &nNbrOfZone, \
dpZones, npMateriau, &dDiff, stTemperatureDepth.pdArray, \
stEc.plArray, dpCapacity, dpConductivity);
stEc.plArray, dpCapacity, dpConductivity, &dSstDepth);
if(*(stEc.plArray)){
bSucces = FALSE;
goto liberation;
......
......@@ -39,7 +39,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, BOOL* bpNoObs, double dDeltaT, long nLenObservation, long nNbrTimeSteps, BOOL bSilent);
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, double dSstDepth);
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*, long*, double, 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, double);
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