Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
METRo projects
metro
Commits
fccad198
Commit
fccad198
authored
Oct 02, 2014
by
Miguel Tremblay
Browse files
Addition of the --fix-deep-soil-temperature option to fix the deep soil temperature.
parent
eca8458e
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/frontend/executable_module/metro_model.py
View file @
fccad198
...
...
@@ -242,6 +242,9 @@ class Metro_model(Metro_module):
lST_obs
=
ro_interpolated_data
.
get_matrix_col
(
'ST'
).
tolist
()
lSST_obs
=
ro_interpolated_data
.
get_matrix_col
(
'SST'
).
tolist
()
lTime_obs
=
ro_interpolated_data
.
get_matrix_col
(
'Time'
).
tolist
()
# Deep soil value given in command line
bDeepTemp
=
metro_config
.
get_value
(
'DEEP_SOIL_TEMP'
)
dDeepTemp
=
float
(
metro_config
.
get_value
(
'DEEP_SOIL_TEMP_VALUE'
))
nLenObservation
=
self
.
__get_observation_lenght
(
observation
)
fDeltaTMetroObservation
=
self
.
__get_observation_delta_t
(
observation
)
...
...
@@ -302,6 +305,7 @@ class Metro_model(Metro_module):
_
(
"Start sending data to METRo core"
))
bEchec
=
[]
macadam
.
Do_Metro
(
bFlat
,
\
fLat
,
fLon
,
\
lLayerThick
,
nNbrOfLayer
,
lLayerType
,
\
...
...
@@ -310,7 +314,7 @@ class Metro_model(Metro_module):
lAH
,
lTime_obs
,
lSWO
,
bNoObs
,
\
fDeltaTMetroObservation
,
nLenObservation
,
\
nNbrTimeSteps
,
bSilent
,
\
dSstDepth
)
dSstDepth
,
bDeepTemp
,
dDeepTemp
)
bEchec
=
(
macadam
.
get_echec
())[
0
]
# Check if the execution of the model was a succes:
if
bEchec
!=
0
:
...
...
src/frontend/executable_module/metro_preprocess_qa_qc_observation.py
View file @
fccad198
...
...
@@ -87,6 +87,8 @@ class Metro_preprocess_qa_qc_observation(Metro_preprocess):
observation_data
.
\
get_interpolated_data
(),
\
observation_data
)
self
.
__check_deep_soil_value
()
pForecast
.
set_data_collection
(
forecast_data
)
pObservation
.
set_data_collection
(
observation_data
)
...
...
@@ -486,3 +488,47 @@ class Metro_preprocess_qa_qc_observation(Metro_preprocess):
ro_controlled_data
.
set_matrix_col
(
'TD'
,
npTD
)
def
__check_deep_soil_value
(
self
):
"""
Description: Check if the value given to --fix-deep-soil-temperature
is valid.
"""
# If the option is not used, do not perform the check
if
not
metro_config
.
get_value
(
'DEEP_SOIL_TEMP'
):
return
# Check if the option is given while on a bridge
pStation
=
self
.
get_infdata_reference
(
'STATION'
)
station_data
=
pStation
.
get_data
()
if
station_data
.
get_station_type
():
sMessage
=
_
(
"Option '--fix-deep-soil-temperature' is used while "
)
+
\
_
(
"the station is of type BRIDGE. Deep soil "
)
+
\
_
(
"Temperature will not be used."
)
metro_logger
.
print_message
(
metro_logger
.
LOGGER_MSG_WARNING
,
\
sMessage
)
else
:
# In case of a road verify if the value is a double
sTemperature
=
metro_config
.
get_value
(
'DEEP_SOIL_TEMP_VALUE'
)
try
:
dTemperature
=
float
(
sTemperature
)
if
dTemperature
>
metro_constant
.
nRoadTemperatureHigh
or
\
dTemperature
<
metro_constant
.
nRoadTemperatureMin
:
sMessage
=
_
(
"Deep soil temperature following the option "
)
+
\
_
(
"'-fix-deep-soil-temperature' must be between "
)
+
\
_
(
"boundaries ["
)
+
\
str
(
metro_constant
.
nRoadTemperatureMin
)
+
","
+
\
str
(
metro_constant
.
nRoadTemperatureHigh
)
+
"]. '"
+
\
sTemperature
+
"' is not in those boundaries."
metro_logger
.
print_message
(
metro_logger
.
LOGGER_MSG_STOP
,
\
sMessage
)
# If there is no error, the value is a number, we can continue
except
ValueError
:
sMessage
=
_
(
"Option '-fix-deep-soil-temperature' must be "
)
+
\
_
(
"followed by a numeric value. The given value '"
)
+
\
sTemperature
+
_
(
"' is not a number."
)
metro_logger
.
print_message
(
metro_logger
.
LOGGER_MSG_STOP
,
\
sMessage
)
src/frontend/metro_config.py
View file @
fccad198
...
...
@@ -98,7 +98,8 @@ CFG_LONG_OPTIONS = ["help","version",
"use-sst-sensor-depth"
,
"enable-sunshadow"
,
"sunshadow-method="
,
"output-subsurface-levels"
"output-subsurface-levels"
,
"fix-deep-soil-temperature="
]
...
...
@@ -276,6 +277,7 @@ def save_command_line_parameter( lArgv, sShort_opt, lLong_opt ):
try
:
opts
,
args
=
getopt
.
gnu_getopt
(
lArgv
,
sShort_opt
,
lLong_opt
)
print
args
except
getopt
.
GetoptError
,
sError
:
# print help information and exit:
...
...
@@ -285,7 +287,7 @@ def save_command_line_parameter( lArgv, sShort_opt, lLong_opt ):
if
args
!=
[]:
sMessage
=
_
(
"problem with arg: "
)
+
str
(
args
)
+
\
_
(
"
\n
String(s) was not recognize as an argument."
)
_
(
"
\n
String(s) was not recognize
d
as an argument."
)
print
sMessage
sys
.
exit
(
3
)
...
...
@@ -433,7 +435,12 @@ def save_command_line_parameter( lArgv, sShort_opt, lLong_opt ):
pass
if
o
==
"--fix-deep-soil-temperature"
:
try
:
dConfig
[
'DEEP_SOIL_TEMP'
][
'VALUE'
]
=
True
dConfig
[
'DEEP_SOIL_TEMP_VALUE'
][
'VALUE'
]
=
a
except
:
pass
if
o
==
"--output-subsurface-levels"
:
dConfig
[
'TL'
][
'VALUE'
]
=
True
...
...
@@ -1280,6 +1287,16 @@ def set_default_value( ):
'FROM'
:
CFG_HARDCODED
,
'COMMENTS'
:
_
(
"default time zone for observation measure date"
)}
dConfig
[
'DEEP_SOIL_TEMP_VALUE'
]
=
\
{
'VALUE'
:
0.0
,
'FROM'
:
CFG_HARDCODED
,
'COMMENTS'
:
_
(
"Value of deep soil temperature"
)}
dConfig
[
'DEEP_SOIL_TEMP'
]
=
\
{
'VALUE'
:
False
,
'FROM'
:
CFG_HARDCODED
,
'COMMENTS'
:
_
(
"Is the deep soil temperature fixed?"
)}
# ------------------------------ station -----------------------------------
...
...
src/model/lib_gen.f
View file @
fccad198
...
...
@@ -45,7 +45,8 @@
*
Date
:
Decembre
1999
/
December
1999
***
SUBROUTINE
MAKITP
(
ITP
,
iref
,
ir40
,
FLAT
,
FT
,
TS
,
*
TU
,
TA
,
DIFF
,
LON
,
SWO_IN
,
dpTemperatureDepth
)
*
TU
,
TA
,
DIFF
,
LON
,
SWO_IN
,
dpTemperatureDepth
,
*
bDeepTemp
,
dDeepTemp
)
IMPLICIT
NONE
INTEGER
j
INTEGER
Nl
,
n
...
...
@@ -71,10 +72,12 @@
* LON: Longitude de la station
* DIFF: Vecteur utilise pour creer les profiles initiaux de temperature
* dpTemperatureDepth: Depth of temperature grid levels
* bDeepTemp: is the bottom temperature layer given as input?
* fDeepTemp: temperature of the bottom layer if bDeepTemp == TRUE
***
LOGICAL FLAT
LOGICAL FLAT
, bDeepTemp
DOUBLE PRECISION FT, TS, TU, TA, DIFF, LON
DOUBLE PRECISION dpTemperatureDepth(n)
DOUBLE PRECISION dpTemperatureDepth(n)
, dDeepTemp
INTEGER iref, ir40, SWO_IN(Nl*4), SWO(Nl,4)
***
...
...
@@ -152,6 +155,9 @@
* EXP((-K)*dpTemperatureDepth(j))*ASURF
* *SIN(OMEGA*FT-K*dpTemperatureDepth(j)+C)
end do
if ( bDeepTemp ) then
ITP(iref) = dDeepTemp
end if
end if
if( .not. bSilent) then
...
...
src/model/macadam.c
View file @
fccad198
...
...
@@ -118,6 +118,8 @@ static struct doubleStruct stLT; /* Level temperature */
[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]
[I BOOL* bDeepTemp : is the bottom temperature layer given as input?]
[I double* dDeepTemp : temperature of the bottom layer if bDeepTemp == TRUE]
Returns: None
...
...
@@ -144,7 +146,14 @@ 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
*
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
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
*
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
,
BOOL
bDeepTemp
,
double
dDeepTemp
)
{
/* Argument de la ligne de commande. Donne par python */
...
...
@@ -194,6 +203,8 @@ void Do_Metro( BOOL bFlat, double dMLat, double dMLon, double* dpZones, long nNb
long
i
;
long
nDeltaTIndice
=
0
;
long
nOne
=
1
;
/* Deep temperature */
/* Allocate memory for all structures */
init_structure
(
nNbrTimeSteps
,
nNGRILLEMAX
);
...
...
@@ -253,7 +264,7 @@ void Do_Metro( BOOL bFlat, double dMLat, double dMLon, double* dpZones, long nNb
}
f77name
(
makitp
)(
dpItp
,
&
stTemperatureDepth
.
nSize
,
&
nIR40
,
&
bFlat
,
&
(
dpTimeO
[
0
]),
\
&
(
dpRTO
[
0
]),
&
(
dpDTO
[
0
]),
&
(
dpTAO
[
0
]),
&
dDiff
,
\
&
dMLon
,
npSwo
,
stTemperatureDepth
.
pdArray
);
&
dMLon
,
npSwo
,
stTemperatureDepth
.
pdArray
,
&
bDeepTemp
,
&
dDeepTemp
);
f77name
(
initial
)(
dpItp
,
(
dpRTO
+
1
),
(
dpDTO
+
1
),
(
dpTAO
+
1
),
&
nOne
,
\
&
nLenObservation
,
&
stTemperatureDepth
.
nSize
,
&
nIR40
,
\
&
bFlat
,
npSwo
,
dpCapacity
,
dpConductivity
);
...
...
@@ -269,7 +280,8 @@ void Do_Metro( BOOL bFlat, double dMLat, double dMLon, double* dpZones, long nNb
nNtdcl
=
1
;
f77name
(
makitp
)(
dpItp
,
&
stTemperatureDepth
.
nSize
,
&
nIR40
,
&
bFlat
,
&
(
dpTimeO
[
nNtdcl
]),
\
&
(
dpRTO
[
nNtdcl
]),
&
(
dpDTO
[
nNtdcl
]),
&
(
dpTAO
[
nNtdcl
]),
\
&
dDiff
,
&
dMLon
,
npSwo
,
stTemperatureDepth
.
pdArray
);
&
dDiff
,
&
dMLon
,
npSwo
,
stTemperatureDepth
.
pdArray
,
\
&
bDeepTemp
,
&
dDeepTemp
);
nNtp
=
-
nDeltaTIndice
+
nNtdcl
;
nNtp2
=
nLenObservation
-
nDeltaTIndice
;
f77name
(
coupla
)(
dpFS
,
dpFI
,
dpPS
,
dpTA
,
dpAH
,
dpFF
,
dpTYP
,
dpQP
,
dpRC
,
\
...
...
@@ -302,7 +314,7 @@ void Do_Metro( BOOL bFlat, double dMLat, double dMLon, double* dpZones, long nNb
&
(
dpTimeO
[
nDeltaTIndice
]),
\
&
(
dpRTO
[
nDeltaTIndice
]),
&
(
dpDTO
[
nDeltaTIndice
]),
\
&
(
dpTAO
[
nDeltaTIndice
]),
&
dDiff
,
&
dMLon
,
npSwo
,
\
stTemperatureDepth
.
pdArray
);
stTemperatureDepth
.
pdArray
,
&
bDeepTemp
,
&
dDeepTemp
);
nNtdcl
=
nLenObservation
-
nDeltaTIndice
-
\
((
nLenObservation
-
nDeltaTIndice
<
28800
.
0
/
dDT
)
\
?
nLenObservation
-
nDeltaTIndice
:
28800
.
0
/
dDT
);
...
...
src/model/macadam.h
View file @
fccad198
...
...
@@ -36,7 +36,14 @@
#define dOMEGA 0.7292e-4
/* Main call from python */
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
*
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
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
*
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
,
BOOL
bDeepTemp
,
double
dDeepTemp
);
void
init_structure
(
long
nTimeStepMax
,
long
nGrilleLevelMax
);
...
...
@@ -49,7 +56,7 @@ extern void grille_(long* nSize, long* nIR40, BOOL* bFlat, long* nNbrOfZone,\
long
*
plArray
,
double
*
dpCapacity
,
double
*
dpConductivity
,
double
*
dSstDepth
);
extern
void
makitp_
(
double
*
dpItp
,
long
*
nSize
,
long
*
nIR40
,
BOOL
*
bFlat
,
double
*
dpTimeO
,
\
double
*
dpRTO
,
double
*
dpDTO
,
double
*
dpTAO
,
double
*
dDiff
,
\
double
*
dMLon
,
long
*
npSwo
,
double
*
pdArray
);
double
*
dMLon
,
long
*
npSwo
,
double
*
pdArray
,
BOOL
*
bDeepTemp
,
double
*
dDeepTemp
);
extern
void
initial_
(
double
*
dpItp
,
double
*
dpRTO
,
double
*
dpDTO
,
double
*
dpTAO
,
long
*
nOne
,
\
long
*
nLenObservation
,
long
*
nSize
,
long
*
nIR40
,
\
BOOL
*
bFlat
,
long
*
npSwo
,
double
*
dpCapacity
,
double
*
dpConductivity
);
...
...
src/model/macadam.i
View file @
fccad198
...
...
@@ -390,7 +390,14 @@ 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
*
,
long
*
,
long
*
,
double
,
long
,
long
,
long
,
double
)
;
extern
void
Do_Metro
(
long
,
double
,
double
,
double
*
,
\
long
,
long
*
,
double
*
,
double
*
,
\
double
*
,
double
*
,
double
*
,
double
*
,
\
double
*
,
double
*
,
double
*
,
double
*
,
\
double
*
,
double
*
,
double
*
,
double
*
,
\
long
*
,
long
*
,
double
,
\
long
,
long
,
long
,
\
double
,
long
,
double
)
;
extern
struct
doubleStruct
get_ra
(
void
)
;
extern
struct
doubleStruct
get_sn
(
void
)
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment