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

Anthropogenic flux is now managed in python code.

It is still set to 10 W/m² by default, but it is now possible to overwritte this value with an input in the forecast file under the tag '<fa>'.

Enjoy!

parent e84003f1
......@@ -226,6 +226,8 @@ class Metro_model(Metro_module):
lAP = wf_interpolated_data.get_matrix_col('AP').tolist()
lSF = wf_interpolated_data.get_matrix_col('SF').tolist()
lIR = wf_interpolated_data.get_matrix_col('IR').tolist()
npFA = wf_interpolated_data.get_matrix_col('FA')
lFA = npFA.tolist()
lFT = wf_interpolated_data.get_matrix_col('Time').tolist()
lPI = wf_interpolated_data.get_matrix_col('PI').tolist()
lSC = wf_interpolated_data.get_matrix_col('SC').tolist()
......@@ -298,7 +300,7 @@ class Metro_model(Metro_module):
macadam.Do_Metro(bFlat,\
fLat, fLon, \
lLayerThick, nNbrOfLayer, lLayerType, \
lAT, lQP, lWS, lAP, lSF, lIR, lFT, lPI, lSC,\
lAT, lQP, lWS, lAP, lSF, lIR, lFT, lFA, lPI, lSC,\
lAT_obs,lST_obs, lSST_obs, \
lAH, lTime_obs, lSWO, bNoObs,\
fDeltaTMetroObservation, nLenObservation, \
......@@ -359,7 +361,6 @@ class Metro_model(Metro_module):
lSF = (macadam.get_sf())[:iNb_timesteps]
lIR = (macadam.get_ir())[:iNb_timesteps]
lFC = (macadam.get_fc())[:iNb_timesteps]
lFA = (macadam.get_fa())[:iNb_timesteps]
lFG = (macadam.get_g())[:iNb_timesteps]
lBB = (macadam.get_bb())[:iNb_timesteps]
lFP = (macadam.get_fp())[:iNb_timesteps]
......@@ -398,6 +399,7 @@ class Metro_model(Metro_module):
npRT = npRT + 30
npHH = wf_data.get_matrix_col('Time')[:iNb_timesteps]
npAT = wf_data.get_matrix_col('AT')[:iNb_timesteps]
npFA = wf_data.get_matrix_col('FA')[:iNb_timesteps]
# 3.6 is to convert from m/s to km/h
npWS = wf_data.get_matrix_col('WS')[:iNb_timesteps]*3.6
npTD = wf_data.get_matrix_col('TD')[:iNb_timesteps]
......@@ -424,8 +426,8 @@ class Metro_model(Metro_module):
roadcast.set_matrix_col('SF', lSF)
roadcast.set_matrix_col('FV', lFV)
roadcast.set_matrix_col('FC', lFC)
roadcast.set_matrix_col('FA', lFA)
roadcast.set_matrix_col('FG', lFG)
roadcast.set_matrix_col('FA', npFA.tolist())
roadcast.set_matrix_col('BB', lBB)
roadcast.set_matrix_col('FP', lFP)
roadcast.set_matrix_col('CC', npCC)
......
......@@ -48,6 +48,7 @@ Note: Solar and infrared flux are interpolated in metro_preprocess_fsint2.py
from metro_preprocess import Metro_preprocess
import metro_config
import time
import numpy
......@@ -88,7 +89,8 @@ class Metro_preprocess_interpol_forecast(Metro_preprocess):
forecast_data.get_interpolated_data() )
self.__interpolate_CC(forecast_data.get_original_data(), \
forecast_data.get_interpolated_data() )
self.__interpolate_FA(forecast_data.get_original_data(), \
forecast_data.get_interpolated_data() )
pForecast.set_data_collection(forecast_data)
......@@ -427,3 +429,36 @@ class Metro_preprocess_interpol_forecast(Metro_preprocess):
wf_interpolated_data.append_matrix_col('CC', npCC)
# Anthropogenic flux
def __interpolate_FA(self, wf_originpl_data, wf_interpolated_data):
"""
Name: __interpolate_FA
Parameters:[I] metro_data wf_originpl_data : originpl data. Read-only
[I] metro_data wf_processed_data : container of the interpolated
data.
Returns: None
Functions Called: metro_util.interpolate,
metro_data.get_matrix_col
metro_data.append_matrix_col
Description: Does the interpolation of the anthropogenic flux
Revision History:
Author Date Reason
Rok Krsmanc October 22th 2010
"""
if metro_config.get_value('FA') == True:
npFA = wf_originpl_data.get_matrix_col('FA')
# If anthropogenic flux is not specified, FA is set to a constant value of 10 W/m^2
else:
lFA = [10]
npFA = numpy.array(lFA)
npFA = metro_util.interpolate(self.npTime, npFA)
wf_interpolated_data.append_matrix_col('FA', npFA)
\ No newline at end of file
......@@ -94,7 +94,9 @@ CFG_LONG_OPTIONS = ["help","version",
"config=","generate-config=","log-file=","verbose-level=",
"selftest", "silent", "roadcast-start-date=", "lang=",
"use-solarflux-forecast", "use-infrared-forecast",
"output-subsurface-levels"]
"use-anthropogenic-flux",
"output-subsurface-levels",
]
......@@ -382,6 +384,13 @@ def save_command_line_parameter( lArgv, sShort_opt, lLong_opt ):
dConfig['XML_FORECAST_PREDICTION_EXTENDED_ITEMS'][\
'VALUE'].append(dSFDict)
if o == "--use-anthropogenic-flux":
dConfig['FA']['VALUE'] = True
dSFDict= {'NAME':"FA",
'XML_TAG':"fa",
'DATA_TYPE':"REAL"}
dConfig['XML_FORECAST_PREDICTION_EXTENDED_ITEMS'][\
'VALUE'].append(dSFDict)
if o == "--output-subsurface-levels":
dConfig['TL']['VALUE'] = True
......@@ -1204,6 +1213,11 @@ def set_default_value( ):
'FROM' :CFG_HARDCODED,
'COMMENTS':_("Use solar flux value from forecast")}
dConfig['FA'] = \
{'VALUE' :False,
'FROM' :CFG_HARDCODED,
'COMMENTS':_("Use anthropogenic flux value from forecast")}
dConfig['TL'] = \
{'VALUE' :False,
'FROM' :CFG_HARDCODED,
......
......@@ -46,7 +46,7 @@
***
SUBROUTINE BALANC ( FS , FI , P0 , TA , QA , VA , TYP, FT, PR,
* iref, ir40, NTP, NTFM, CNT_IN, ITP, FLAT,
* FCOR, WW , WA, ALN, ALR, FP,
* FCOR, WW , ALN, ALR, FP,
* FSCORR , FICORR , ER1, ER2,
* EPSILON, Z0, Z0T, ZU, ZT, ECHEC, dpRT,
* dpRA, dpSN,
......@@ -88,7 +88,7 @@
* TS0: Target temperature for the end of coupling (C)
* FCOR: Coriolis factor
* WW: Minimum winds for the day and the night (m/s)
* WA: Anthropogenic flux
* dpFA: Anthropogenic flux
* ALN: Snow Albedo
* ALR: Road Albedo
* FP: Frozing point (C)
......@@ -105,7 +105,7 @@
DOUBLE PRECISION TA(DTMAX), QA(DTMAX), VA(DTMAX)
DOUBLE PRECISION TYP(DTMAX), FT(DTMAX), PR(DTMAX)
DOUBLE PRECISION CNT(n,2), CNT_IN(2*n), ITP(n)
DOUBLE PRECISION FCOR, WW(2), WA
DOUBLE PRECISION FCOR, WW(2)
DOUBLE PRECISION ALN, ALR, FP
DOUBLE PRECISION FSCORR, FICORR
DOUBLE PRECISION EPSILON, ZU, ZT, Z0, Z0T
......@@ -339,7 +339,6 @@
dpFV(i) = RHO*CTU*(CL*(QA(i)-QG))
dpBB(i) = - RA
dpFC(i) = RHO*CTU*( CPD*(TA(i)-T(1,now)))
dpFA(i) = WA
dpFP(i) = PRG
dpSST(i) = T(ir40, now)
G(0) = dpSF(i) + dpBB(i) + dpIR(i)
......
......@@ -44,7 +44,7 @@
***
SUBROUTINE COUPLA ( FS, FI, P0, TA , QA , VA , TYP, FT, PR,
* PVC , iref, NTP, NTP2, CNT_IN, ITP, TSO, FLAT,
* FCOR, WW , WA, ALN, ALR, FP,
* FCOR, WW , ALN, ALR, FP,
* FSCORR , FICORR , ER1, ER2,
* FAIL, EPSILON, Z0, Z0T, ZU, ZT, ECHEC,
* dpRA, dpSN, npRC, dpRT, dpIR, dpSF, dpFV,
......@@ -86,7 +86,7 @@
* TS0: Target temperature for the end of coupling (C)
* FCOR: Coriolis factor
* WW: Minimum winds for the day and the night (m/s)
* WA: Anthropogenic flux
* dpFA: Anthropogenic flux
* ALN: Snow Albedo
* ALR: Road Albedo
* FP: Frozing point (C)
......@@ -99,7 +99,7 @@
DOUBLE PRECISION VA(DTMAX), P0(DTMAX), FT(DTMAX)
DOUBLE PRECISION TYP(DTMAX), PVC(DTMAX)
DOUBLE PRECISION CNT(n,2), CNT_IN(2*n)
DOUBLE PRECISION FCOR, WW(2), WA
DOUBLE PRECISION FCOR, WW(2)
DOUBLE PRECISION ALN, ALR, TSO, FP
DOUBLE PRECISION EPSILON, ZU, ZT, Z0, Z0T
DOUBLE PRECISION dpSN(DTMAX), dpRA(DTMAX)
......@@ -338,14 +338,13 @@
G(0) = max(0.0,REAL(COFS*AL*FS(i))) - RA
* + COFI*EPSILON*FI(i)
* + RHO*CTU*( CPD*(TA(i)-T(1,now))
* + CL*(QA(i)-QG)) + PRG + WA
* + CL*(QA(i)-QG)) + PRG + dpFA(i)
* Output information
dpIR(i) = COFI*EPSILON*FI(i)
dpSF(i) = COFS*AL*FS(i)
dpFV(i) = RHO*CTU*(CL*(QA(i)-QG))
dpBB(i) = - RA
dpFC(i) = RHO*CTU*( CPD*(TA(i)-T(1,now)))
dpFA(i) = WA
dpFP(i) = PRG
dpG(i) = G(0)
......
This diff is collapsed.
......@@ -36,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* 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);
void init_structure(long nTimeStepMax, long nGrilleLevelMax);
......@@ -48,7 +48,6 @@ struct doubleStruct get_ir(void);
struct doubleStruct get_sf(void);
struct doubleStruct get_fv(void);
struct doubleStruct get_fc(void);
struct doubleStruct get_fa(void);
struct doubleStruct get_g(void);
struct doubleStruct get_bb(void);
struct doubleStruct get_fp(void);
......
......@@ -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*, 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);
extern struct doubleStruct get_ra(void);
extern struct doubleStruct get_sn(void);
......@@ -400,7 +400,6 @@ extern struct doubleStruct get_ir(void);
extern struct doubleStruct get_sf(void);
extern struct doubleStruct get_fv(void);
extern struct doubleStruct get_fc(void);
extern struct doubleStruct get_fa(void);
extern struct doubleStruct get_g(void);
extern struct doubleStruct get_bb(void);
extern struct doubleStruct get_fp(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