# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_module import Metro_module import metro_logger import metro_error from toolbox import metro_xml from toolbox import metro_util _ = metro_util.init_translation('metro_string2dom') class Metro_string2dom(Metro_module): def __init__(self): if self.__class__ is Metro_string2dom: sMessage = _("class %s is a virtual class") % \ str(self.__class__) raise NotImplementedError(sMessage) ## # Redefined method ## def get_receive_type( self ): return Metro_module.DATATYPE_INPUT
from math import pi from math import sin from math import cos import numpy import metro_logger import metro_config import metro_preprocess_sunshadw import Sun from toolbox import metro_physics from toolbox import metro_util from toolbox import metro_date from data_module import metro_data _ = metro_util.init_translation('metro_preprocess_fsint2') class Metro_preprocess_fsint2(Metro_preprocess): ## # Class attribute ## fLat = 0 # Latitude of the station fLon = 0 # Longitude of the station # Date nStartDay = None nStartMonth = None nStartYear = None fSunrise = None
# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_write import Metro_write import metro_config import metro_logger from toolbox import metro_util from toolbox import metro_xml _ = metro_util.init_translation('metro_write_forecast') class Metro_write_forecast(Metro_write): ## # methodes redefinies ## def start(self): Metro_write.start(self) pForecast = self.get_infdata_reference('FORECAST') self.domForecast = pForecast.get_output_information() if self.domForecast != None: sFilename = metro_config.get_value('FILE_FORECAST_OUT_FILENAME') self._write_dom(sFilename,self.domForecast)
Author: Francois Fortin Miguel Tremblay Date: 9 novembre 2004 """ from metro_preprocess import Metro_preprocess import metro_logger import metro_config from toolbox import metro_date from toolbox import metro_util from toolbox import metro_constant import numpy _ = metro_util.init_translation('metro_config') class Metro_preprocess_validate_input(Metro_preprocess): def start(self): Metro_preprocess.start(self) pForecast = self.get_infdata_reference('FORECAST') forecast_data = pForecast.get_data_collection() pObservation = self.get_infdata_reference('OBSERVATION') observation_data = pObservation.get_data_collection() self.__validate_observation_length(observation_data.\ get_controlled_data()) self.__validate_forecast_length(forecast_data.get_controlled_data()) self.__validate_optional_args_forecast(forecast_data.\
Set the last observation time. Authors: Francois Fortin Miguel Tremblay Date: March 5th 2007 """ from metro_read import Metro_read import metro_config import metro_logger from data_module import metro_infdata from toolbox import metro_util from toolbox import metro_xml _ = metro_util.init_translation('metro_read_observation') class Metro_read_observation(Metro_read): ## # Methods overwritten ## def start(self): Metro_read.start(self) if metro_config.key_exist('FILE_OBSERVATION_FILENAME'): sFilename = metro_config.get_value('FILE_OBSERVATION_FILENAME') else: sFilename = ""
# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_write import Metro_write import metro_config import metro_logger from toolbox import metro_util from toolbox import metro_xml _ = metro_util.init_translation('metro_write_roadcast') class Metro_write_roadcast(Metro_write): ## # Redefined methods ## def start(self): Metro_write.start(self) pRoadcast = self.get_infdata_reference('ROADCAST') self.domRoadcast = pRoadcast.get_output_information() if self.domRoadcast != None: sFilename = metro_config.get_value('FILE_ROADCAST_FILENAME') self._write_dom(sFilename, self.domRoadcast)
from metro_module import Metro_module import string import time import numpy import metro_logger import metro_config from toolbox import metro_util from toolbox import metro_date from toolbox import metro_constant from data_module import metro_data_collection_output from data_module import metro_data from data_module import metro_infdata _ = metro_util.init_translation('metro_model') # To call the C function. from model import macadam class Metro_model(Metro_module): def get_receive_type( self ): return Metro_module.DATATYPE_DATA_IN def get_send_type( self ): return Metro_module.DATATYPE_DATA_OUT def start( self ): Metro_module.start(self)
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_module import Metro_module import metro_logger from toolbox import metro_util _ = metro_util.init_translation('metro_read') class Metro_read(Metro_module): def __init__(self): if self.__class__ is Metro_read: sMessage = _("class %s is a virtual class") % \ str(self.__class__) raise NotImplementedError(sMessage) ## # redefined method ## def get_receive_type(self): return Metro_module.DATATYPE_INPUT
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_validate import Metro_validate import metro_logger from toolbox import metro_util _ = metro_util.init_translation('metro_validate_observation_ref') class Metro_validate_observation_ref(Metro_validate): ## # methodes redefinies ## def start(self): Metro_validate.start(self) if self.infdata_exist('OBSERVATION_REF'): self._validate('OBSERVATION_REF') else: sMessage = _("Error, no observation_ref string to validate.\n") +\ _("You can safely remove this module from the ") +\ _("EXECUTION SEQUENCE\nif you don't need it") metro_logger.print_message(metro_logger.LOGGER_MSG_WARNING,
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from data_module import metro_infdata from toolbox import metro_util _ = metro_util.init_translation('metro_infdata_container') # Exception ERROR_INFDATA_CONTAINER = "MetroInfdataContainerError" class Metro_infdata_container: def __init__( self ): self.dContainer = {} def __getitem__( self, index ): return self.dContainer[self.dContainer.keys()[index]] def add_infdata( self, infdata_object ): self.dContainer[infdata_object.get_name()] = infdata_object
# # # """ Name: metro_error Author: Miguel Tremblay Date: 07/05/2010 Description: General error class for METRo. """ from toolbox import metro_util _ = metro_util.init_translation('metro_error') class Metro_error(Exception): """ Base class for exceptions in this module. """ def __init__(self, inst): self.sError = str(inst) class Metro_import_error(Metro_error): """ Error in importing a module """ def __str__(self): """ Put the message in string only if it is a string""" self.sError = _("Error in import: ") + self.sError
# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # import string import metro_logger from data_module import metro_infdata_container from data_module import metro_infdata from toolbox import metro_util _ = metro_util.init_translation('metro_module') class Metro_module: # module I/O type DATATYPE_NONE = 0 DATATYPE_INPUT = 1 DATATYPE_DATA_IN = 2 DATATYPE_DATA_OUT = 3 DATATYPE_DOM_OUT = 4 lData_type_txtid = ["NONE","INPUT", "DATA_IN", "DATA_OUT", "DOM_OUT"] # infdata container infdata_container = metro_infdata_container.Metro_infdata_container() # infdata datatype
Description: Rounding of float value stocked in roadcast matrix Work on : roadcast_data.subsampled_data Notes : Author : Francois Fortin Date : 1 September 2004 """ from metro_postprocess import Metro_postprocess import numpy import metro_config import metro_logger from toolbox import metro_util _ = metro_util.init_translation('metro_postprocess_round_roadcast') class Metro_postprocess_round_roadcast(Metro_postprocess): def start(self): Metro_postprocess.start(self) pRoadcast = self.get_infdata_reference('ROADCAST') roadcast_data = pRoadcast.get_data_collection() iPrecision = \ metro_config.get_value('DEFAULT_ROADCAST_PREDICTION_PRECISION') if roadcast_data != None: self.__round_roadcast_header(roadcast_data.get_subsampled_data()) self.__round_roadcast_data(roadcast_data.get_subsampled_data())
Date: February 28th 2005 """ from metro_preprocess import Metro_preprocess import numpy import fpconst import metro_config import metro_logger import metro_error from toolbox import metro_constant from toolbox import metro_date from toolbox import metro_util _ = metro_util.init_translation('metro_preprocess_qa_qc_forecast') class Metro_preprocess_qa_qc_forecast(Metro_preprocess): def start(self): Metro_preprocess.start(self) try: pForecast = self.get_infdata_reference('FORECAST') forecast_data = pForecast.get_data_collection() Metro_preprocess.start(self) self.__check_if_all_value_are_numbers( forecast_data.get_controlled_data()) self.__check_if_cloud_octal(forecast_data.get_controlled_data()) self.__check_precipitation_well_define\
# along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_string2dom import Metro_string2dom import metro_config import metro_logger import metro_string2dom import metro_error from toolbox import metro_util from toolbox import metro_xml _ = metro_util.init_translation('metro_string2dom_observation') class Metro_string2dom_observation(Metro_string2dom): ## # redefined methods ## def start(self): Metro_string2dom.start(self) self.__string2dom() ## # private methods ## def __string2dom(self):
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_validate import Metro_validate import metro_logger from toolbox import metro_util _ = metro_util.init_translation('metro_validate_observation_ref') class Metro_validate_observation_ref(Metro_validate): ## # methodes redefinies ## def start(self): Metro_validate.start(self) if self.infdata_exist('OBSERVATION_REF'): self._validate('OBSERVATION_REF') else: sMessage = _("Error, no observation_ref string to validate.\n") +\ _("You can safely remove this module from the ") +\ _("EXECUTION SEQUENCE\nif you don't need it") metro_logger.print_message(metro_logger.LOGGER_MSG_WARNING,
Description: Rounding of float value stocked in roadcast matrix Work on : roadcast_data.subsampled_data Notes : Author : Francois Fortin Date : 1 September 2004 """ from metro_postprocess import Metro_postprocess import numpy import metro_config import metro_logger from toolbox import metro_util _ = metro_util.init_translation('metro_postprocess_round_roadcast') class Metro_postprocess_round_roadcast(Metro_postprocess): def start(self): Metro_postprocess.start(self) pRoadcast = self.get_infdata_reference('ROADCAST') roadcast_data = pRoadcast.get_data_collection() iPrecision = \ metro_config.get_value('DEFAULT_ROADCAST_PREDICTION_PRECISION') if roadcast_data != None: self.__round_roadcast_header(roadcast_data.get_subsampled_data()) self.__round_roadcast_data(roadcast_data.get_subsampled_data())
# along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_string2dom import Metro_string2dom import metro_config import metro_logger import metro_error import metro_string2dom from toolbox import metro_util from toolbox import metro_xml _ = metro_util.init_translation('metro_string2dom_forecast') class Metro_string2dom_forecast(Metro_string2dom): ## # methodes redefinies ## def start(self): Metro_string2dom.start(self) self.__string2dom() ## # methodes privees ## def __string2dom(self):
""" Name: metro_xml_libxml2 Description: Wrapper for libxml2 library Notes: Author: François Fortin Date: Somewhere in the summer 2004 """ import libxml2 import metro_logger from toolbox import metro_util _ = metro_util.init_translation('metro_xml_libxml2') def noerr(ctx, str): sMessage = _("XML Error!: %s") % str if metro_logger.is_initialised(): metro_logger.print_message(metro_logger.LOGGER_MSG_DEBUG, sMessage) else: metro_logger.print_init_message(metro_logger.LOGGER_INIT_ERROR, sMessage) #def xml_error_handler(arg,msg,severity,reserved): # print "XML Error: severity=%s, msg=%s" % (severity,msg)
Notes : Author : Francois Fortin Miguel Tremblay Date : March 5th 2007 """ from metro_postprocess import Metro_postprocess import metro_config import metro_logger from toolbox import metro_util from toolbox import metro_constant from toolbox import metro_date _ = metro_util.init_translation('metro_postprocess_subsample_roadcast') class Metro_postprocess_subsample_roadcast(Metro_postprocess): def start(self): Metro_postprocess.start(self) pRoadcast = self.get_infdata_reference('ROADCAST') roadcast_data = pRoadcast.get_data_collection() pObservation = self.get_infdata_reference('OBSERVATION') observation_data = pObservation.get_data_collection() nInitialTimestep = self.__set_first_roadcast_date(observation_data.\ get_controlled_data(), roadcast_data) self.__subsample_roadcast(roadcast_data, nInitialTimestep)
import calendar from math import pi from math import sin from math import cos import numpy import metro_logger import metro_config import metro_preprocess_sunshadw import Sun from toolbox import metro_physics from toolbox import metro_util from toolbox import metro_date from data_module import metro_data _ = metro_util.init_translation('metro_preprocess_fsint2') class Metro_preprocess_fsint2(Metro_preprocess): ## # Class attribute ## fLat = 0 # Latitude of the station fLon = 0 # Longitude of the station # Date nStartDay = None nStartMonth = None nStartYear = None fSunrise = None
Auteur: Miguel Tremblay Date: 4 aout 2004 """ from metro_preprocess import Metro_preprocess import numpy import metro_config import metro_logger import metro_error from toolbox import metro_constant from toolbox import metro_date from toolbox import metro_util _ = metro_util.init_translation('metro_preprocess_qa_qc_observation') class Metro_preprocess_qa_qc_observation(Metro_preprocess): def start(self): Metro_preprocess.start(self) try: pForecast = self.get_infdata_reference('FORECAST') forecast_data = pForecast.get_data_collection() pObservation = self.get_infdata_reference('OBSERVATION') observation_data = pObservation.get_data_collection() Metro_preprocess.start(self)
# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # import string import metro_logger from data_module import metro_infdata_container from data_module import metro_infdata from toolbox import metro_util _ = metro_util.init_translation('metro_module') class Metro_module: # module I/O type DATATYPE_NONE = 0 DATATYPE_INPUT = 1 DATATYPE_DATA_IN = 2 DATATYPE_DATA_OUT = 3 DATATYPE_DOM_OUT = 4 lData_type_txtid = ["NONE","INPUT", "DATA_IN", "DATA_OUT", "DOM_OUT"] # infdata container infdata_container = metro_infdata_container.Metro_infdata_container() # infdata datatype
Auteur: Miguel Tremblay Date: 4 aout 2004 """ from metro_preprocess import Metro_preprocess import numpy import metro_config import metro_logger import metro_error from toolbox import metro_constant from toolbox import metro_date from toolbox import metro_util _ = metro_util.init_translation('metro_preprocess_qa_qc_observation') class Metro_preprocess_qa_qc_observation(Metro_preprocess): def start(self): Metro_preprocess.start(self) try: pForecast = self.get_infdata_reference('FORECAST') forecast_data = pForecast.get_data_collection() pObservation = self.get_infdata_reference('OBSERVATION') observation_data = pObservation.get_data_collection() Metro_preprocess.start(self)
Date: February 28th 2005 """ from metro_preprocess import Metro_preprocess import numpy import fpconst import metro_config import metro_logger import metro_error from toolbox import metro_constant from toolbox import metro_date from toolbox import metro_util _ = metro_util.init_translation('metro_preprocess_qa_qc_forecast') class Metro_preprocess_qa_qc_forecast(Metro_preprocess): def start(self): Metro_preprocess.start(self) try: pForecast = self.get_infdata_reference('FORECAST') forecast_data = pForecast.get_data_collection() Metro_preprocess.start(self) self.__check_if_all_value_are_numbers(forecast_data.get_controlled_data()) self.__check_if_cloud_octal(forecast_data.get_controlled_data()) self.__check_precipitation_well_define\ (forecast_data.get_controlled_data())
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_module import Metro_module import string import metro_config import metro_logger from toolbox import metro_xml from toolbox import metro_util from data_module import metro_data_collection _ = metro_util.init_translation('metro_metro2dom') class Metro_metro2dom(Metro_module): ## # Class attributes ## domForecast = None domRoadcast = None forecast_data = None observation_data = None station_data = None roadcast_data = None
# from metro_module import Metro_module import sys import metro_config import metro_logger import metro_error from toolbox import metro_xml from toolbox import metro_util from data_module import metro_data from data_module import metro_data_station from data_module import metro_data_collection_input _ = metro_util.init_translation('metro_dom2metro') class Metro_dom2metro(Metro_module): ## # attributs de la classe ## domForecast = None domObservation = None domStation = None domHorizon = None ## # Overwritten methodes ##
# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_write import Metro_write import metro_config import metro_logger from toolbox import metro_util from toolbox import metro_xml _ = metro_util.init_translation('metro_write_forecast') class Metro_write_forecast(Metro_write): ## # methodes redefinies ## def start(self): Metro_write.start(self) pForecast = self.get_infdata_reference('FORECAST') self.domForecast = pForecast.get_output_information() if self.domForecast != None: sFilename = metro_config.get_value('FILE_FORECAST_OUT_FILENAME')
# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from toolbox import metro_util _ = metro_util.init_translation('metro_infdata') # Exception ERROR_INFDATA_ITEM = "MetroInfdataError" # DATA TYPE DATATYPE_METRO_DATA = 0 DATATYPE_METRO_DATA_COLLECTION = 1 class Metro_infdata: def __init__( self, sName, iData_type ): self.dItems = {'NAME' : sName, 'XML_FORMAT' : None, 'INPUT_INFORMATION' : None,
# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from toolbox import metro_util _ = metro_util.init_translation('metro_infdata') # Exception ERROR_INFDATA_ITEM = "MetroInfdataError" # DATA TYPE DATATYPE_METRO_DATA = 0 DATATYPE_METRO_DATA_COLLECTION = 1 class Metro_infdata: def __init__(self, sName, iData_type): self.dItems = { 'NAME': sName, 'XML_FORMAT': None, 'INPUT_INFORMATION': None,
Description: Methods to create and manipulate xml DOM Work on : Notes : Author : Francois Fortin Date : 2004 """ import sys import string import metro_config import metro_logger import metro_error from toolbox import metro_util _ = metro_util.init_translation('metro_xml') def init( sMetro_xml_lib = ""): global metro_xml_lib if sMetro_xml_lib != "": try: metro_xml_lib = __import__(sMetro_xml_lib) except metro_error.Metro_import_error: sMessage = _("Fatal error! Can't import '%s' xml library") \ % (sMetro_xml_lib) metro_logger.print_init_message(metro_logger.LOGGER_INIT_ERROR, sMessage) else: metro_logger.print_init_message( \ metro_logger.LOGGER_INIT_SUCCESS, _("XML library '%s' will be use.") % (sMetro_xml_lib))
# # # from metro_read import Metro_read import sys import metro_logger import metro_config from data_module import metro_infdata from toolbox import metro_util from toolbox import metro_xml _ = metro_util.init_translation('metro_read_observation_ref') class Metro_read_observation_ref(Metro_read): ## #methodes redefinies ## def start(self): Metro_read.start(self) if metro_config.key_exist('FILE_OBSERVATION_REF_FILENAME'): sFilename = metro_config.get_value('FILE_OBSERVATION_REF_FILENAME') else: sFilename = "" if sFilename != "": try:
# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_write import Metro_write import metro_config import metro_logger from toolbox import metro_util from toolbox import metro_xml _ = metro_util.init_translation('metro_write_roadcast') class Metro_write_roadcast(Metro_write): ## # Redefined methods ## def start(self): Metro_write.start(self) pRoadcast = self.get_infdata_reference('ROADCAST') self.domRoadcast = pRoadcast.get_output_information() if self.domRoadcast != None: sFilename = metro_config.get_value('FILE_ROADCAST_FILENAME')
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # import metro_logger from toolbox import metro_util _ = metro_util.init_translation('metro_data_collection') #=============================================================================== # # Name: Metro_data_collection # # Description: Classe de base pour les metro_data_collection # Des attributs concernant l'ensemble de la collection peuvent etre # conserve dans l'object. La liste de ces options doit etre passe # au constructeur et leur contenue modifier a l'aide des methodes # (get/set)_attribute. # # Exception: AttributeError #
# You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # import time import sys import string import metro_config from toolbox import metro_date from toolbox import metro_util _ = metro_util.init_translation('metro_logger') """ Name: metro_logger Author: Francois Fortin Date: 30/03/2004 Description: Module used to centralize the writing of METRo error message. This logger as many verbosity level. """ # niveau de verbositer du logger LOGGER_VERBOSE_LEVEL_NOLOG = 9999 # setting special pour desactiver le logger LOGGER_VERBOSE_LEVEL_MINIMAL = 20 LOGGER_VERBOSE_LEVEL_NORMAL = 10 LOGGER_VERBOSE_LEVEL_FULL = 5
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # """ Name: metro_error Author: Miguel Tremblay Date: 07/05/2010 Description: General error class for METRo. """ from toolbox import metro_util _ = metro_util.init_translation('metro_error') class Metro_error(Exception): """ Base class for exceptions in this module. """ def __init__(self, inst): self.sError = str(inst) class Metro_import_error(Metro_error): """ Error in importing a module """ def __str__(self):
Description: Methods to create and manipulate xml DOM Work on : Notes : Author : Francois Fortin Date : 2004 """ import sys import string import metro_config import metro_logger import metro_error from toolbox import metro_util _ = metro_util.init_translation('metro_xml') def init(sMetro_xml_lib=""): global metro_xml_lib if sMetro_xml_lib != "": try: metro_xml_lib = __import__(sMetro_xml_lib) except metro_error.Metro_import_error: sMessage = _("Fatal error! Can't import '%s' xml library") \ % (sMetro_xml_lib) metro_logger.print_init_message(metro_logger.LOGGER_INIT_ERROR, sMessage) else: metro_logger.print_init_message( \ metro_logger.LOGGER_INIT_SUCCESS,
# You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_read import Metro_read import metro_config import metro_logger from toolbox import metro_util from toolbox import metro_xml from data_module import metro_infdata _ = metro_util.init_translation('metro_read_forecast') class Metro_read_forecast(Metro_read): ## # Overwritten methods ## def start(self): Metro_read.start(self) if metro_config.key_exist('FILE_FORECAST_IN_FILENAME'): sFilename = metro_config.get_value('FILE_FORECAST_IN_FILENAME') try: sFile_content = self._read_input_data(sFilename) except IOError:
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_module import Metro_module import metro_logger from toolbox import metro_util _ = metro_util.init_translation('metro_read') class Metro_read(Metro_module): def __init__(self): if self.__class__ is Metro_read: sMessage = _("class %s is a virtual class") % \ str(self.__class__) raise NotImplementedError(sMessage) ## # redefined method ## def get_receive_type(self): return Metro_module.DATATYPE_INPUT
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_module import Metro_module import metro_logger from toolbox import metro_xml from toolbox import metro_util _ = metro_util.init_translation('metro_write') class Metro_write(Metro_module): ## #methodes redefinies ## def start(self): Metro_module.start(self) def stop(self): Metro_module.stop(self) def get_receive_type(self): return Metro_module.DATATYPE_DOM_OUT
# # # # -*- coding: iso-8859-1 -*- import string import sys import metro_config import metro_logger import metro_error from toolbox import metro_util from toolbox import metro_date _ = metro_util.init_translation('metro_config_validation') def config_error_string(sOption, iFrom, sError): if iFrom == metro_config.CFG_INTERNAL: sFrom = _("Internal METRo configuration") elif iFrom == metro_config.CFG_HARDCODED: sFrom = _("Hardcoded value") elif iFrom == metro_config.CFG_CONFIGFILE: sFrom = _("Configuration file") elif iFrom == metro_config.CFG_COMMANDLINE: sFrom = _("Command line parameter") else: sFrom = "Unknown" return _("Configuration error:\n") + \
Author: Francois Fortin Miguel Tremblay Date: 9 novembre 2004 """ from metro_preprocess import Metro_preprocess import metro_logger import metro_config from toolbox import metro_date from toolbox import metro_util from toolbox import metro_constant import numpy _ = metro_util.init_translation('metro_config') class Metro_preprocess_validate_input(Metro_preprocess): def start(self): Metro_preprocess.start(self) pForecast = self.get_infdata_reference('FORECAST') forecast_data = pForecast.get_data_collection() pObservation = self.get_infdata_reference('OBSERVATION') observation_data = pObservation.get_data_collection() self.__validate_observation_length(observation_data.\ get_controlled_data()) self.__validate_forecast_length(forecast_data.get_controlled_data()) self.__validate_optional_args_forecast(forecast_data.\
from metro_module import Metro_module import sys import metro_config import metro_logger import metro_error from toolbox import metro_xml from toolbox import metro_util from data_module import metro_data from data_module import metro_data_station from data_module import metro_data_collection_input _ = metro_util.init_translation('metro_dom2metro') class Metro_dom2metro(Metro_module): ## # attributs de la classe ## domForecast = None domObservation = None domStation = None domHorizon = None ## # Overwritten methodes ##
# # # from metro_string2dom import Metro_string2dom import sys import metro_config import metro_logger import metro_string2dom import metro_error from toolbox import metro_util from toolbox import metro_xml _ = metro_util.init_translation('metro_read_station') class Metro_string2dom_observation_ref(Metro_string2dom): ## # redefined methods ## def start(self): Metro_string2dom.start(self) self.__string2dom() ## # private methods ## def __string2dom(self):
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # import time import os import metro_config import metro_logger import metro_error from toolbox import metro_date from toolbox import metro_util from toolbox import metro_xml _ = metro_util.init_translation('metro_date') def read_integer(sTag,nodeBranch): sRslt = metro_xml.extract_data_from_node(sTag,nodeBranch) return string_to_integer(sRslt) def read_real(sTag,nodeBranch): sRslt = metro_xml.extract_data_from_node(sTag,nodeBranch) return string_to_real(sRslt) def read_string(sTag,nodeBranch): return str(metro_xml.extract_data_from_node(sTag,nodeBranch)) def read_date(sTag,nodeBranch): sDate = metro_xml.extract_data_from_node(sTag,nodeBranch) try:
# You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_read import Metro_read import metro_config import metro_logger from data_module import metro_infdata from toolbox import metro_util from toolbox import metro_xml _ = metro_util.init_translation('metro_read_station') class Metro_read_station(Metro_read): ## # Methodes redefinies ## def start(self): Metro_read.start(self) if metro_config.key_exist('FILE_STATION_FILENAME'): sFilename = metro_config.get_value('FILE_STATION_FILENAME') else: sFilename = ""
Notes : Author : Francois Fortin Miguel Tremblay Date : March 5th 2007 """ from metro_postprocess import Metro_postprocess import metro_config import metro_logger from toolbox import metro_util from toolbox import metro_constant from toolbox import metro_date _ = metro_util.init_translation('metro_postprocess_subsample_roadcast') class Metro_postprocess_subsample_roadcast(Metro_postprocess): def start(self): Metro_postprocess.start(self) pRoadcast = self.get_infdata_reference('ROADCAST') roadcast_data = pRoadcast.get_data_collection() pObservation = self.get_infdata_reference('OBSERVATION') observation_data = pObservation.get_data_collection() nInitialTimestep = self.__set_first_roadcast_date(observation_data.\ get_controlled_data(), roadcast_data) self.__subsample_roadcast(roadcast_data, nInitialTimestep)
# You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_read import Metro_read import metro_config import metro_logger from toolbox import metro_util from toolbox import metro_xml from data_module import metro_infdata _ = metro_util.init_translation('metro_read_forecast') class Metro_read_forecast(Metro_read): ## # Overwritten methods ## def start(self): Metro_read.start(self) if metro_config.key_exist('FILE_FORECAST_IN_FILENAME'): sFilename = metro_config.get_value('FILE_FORECAST_IN_FILENAME') try: sFile_content = self._read_input_data(sFilename) except IOError: sError_message = _("METRo need a valid forecast file.")
Date: August 2nd 2004 """ from metro_preprocess import Metro_preprocess import time import numpy import metro_config import metro_logger import metro_error from toolbox import metro_util from toolbox import metro_date from toolbox import metro_constant _ = metro_util.init_translation('metro_preprocess_interpol_observation') ## # Class attributes ## npTimeInterpolated = None # Array representing the time in seconds. OneObservationException = _("Not enough observation to do the interpolation") NoObservationException = _("No valid observation. Aborting") class Metro_preprocess_interpol_observation(Metro_preprocess): def start(self): Metro_preprocess.start(self) pObservation = self.get_infdata_reference('OBSERVATION') observation_data = pObservation.get_data_collection()
# You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # import time import sys import string import metro_config from toolbox import metro_date from toolbox import metro_util _ = metro_util.init_translation('metro_logger') """ Name: metro_logger Author: Francois Fortin Date: 30/03/2004 Description: Module used to centralize the writing of METRo error message. This logger as many verbosity level. """ # niveau de verbositer du logger LOGGER_VERBOSE_LEVEL_NOLOG = 9999 # setting special pour desactiver le logger LOGGER_VERBOSE_LEVEL_MINIMAL = 20 LOGGER_VERBOSE_LEVEL_NORMAL = 10 LOGGER_VERBOSE_LEVEL_FULL = 5
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_data import Metro_data import metro_logger import metro_config from toolbox import metro_util _ = metro_util.init_translation('metro_data_station') #=============================================================================== # # Name: Metro_dada_station # # Description: Contenue d'un fichier "station" . Les donnees sont contenus # dans un dictionnaire (header). La partie matrix de l'objet # contient les roadlayer. # #=============================================================================== class Metro_data_station(Metro_data): """Specialised class for station data. This class inherit Metro_data. It add some method facilating the
# You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_string2dom import Metro_string2dom import metro_string2dom import metro_config import metro_logger from toolbox import metro_util from toolbox import metro_xml _ = metro_util.init_translation('metro_string2dom_station') class Metro_string2dom_station(Metro_string2dom): ## # methodes redefinies ## def start(self): Metro_string2dom.start(self) self.__string2dom() ## # methodes privees ## def __string2dom(self):
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from data_module import metro_infdata from toolbox import metro_util _ = metro_util.init_translation('metro_infdata_container') # Exception ERROR_INFDATA_CONTAINER = "MetroInfdataContainerError" class Metro_infdata_container: def __init__(self): self.dContainer = {} def __getitem__(self, index): return self.dContainer[self.dContainer.keys()[index]] def add_infdata(self, infdata_object): self.dContainer[infdata_object.get_name()] = infdata_object
# along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_string2dom import Metro_string2dom import metro_config import metro_logger import metro_error import metro_string2dom from toolbox import metro_util from toolbox import metro_xml _ = metro_util.init_translation('metro_string2dom_forecast') class Metro_string2dom_forecast(Metro_string2dom): ## # methodes redefinies ## def start(self): Metro_string2dom.start(self) self.__string2dom() ## # methodes privees ## def __string2dom(self):
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_data import Metro_data import metro_logger import metro_config from toolbox import metro_util _ = metro_util.init_translation('metro_data_station') #=============================================================================== # # Name: Metro_dada_station # # Description: Contenue d'un fichier "station" . Les donnees sont contenus # dans un dictionnaire (header). La partie matrix de l'objet # contient les roadlayer. # #=============================================================================== class Metro_data_station(Metro_data): """Specialised class for station data.
from metro_module import Metro_module import string import time import numpy import metro_logger import metro_config from toolbox import metro_util from toolbox import metro_date from toolbox import metro_constant from data_module import metro_data_collection_output from data_module import metro_data from data_module import metro_infdata _ = metro_util.init_translation('metro_model') # To call the C function. from model import macadam class Metro_model(Metro_module): def get_receive_type( self ): return Metro_module.DATATYPE_DATA_IN def get_send_type( self ): return Metro_module.DATATYPE_DATA_OUT def start( self ): Metro_module.start(self)
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # from metro_module import Metro_module import string import metro_config import metro_logger from toolbox import metro_xml from toolbox import metro_util from data_module import metro_data_collection _ = metro_util.init_translation('metro_metro2dom') class Metro_metro2dom( Metro_module ): ## # Class attributes ## domForecast = None domRoadcast = None forecast_data = None observation_data = None station_data = None roadcast_data = None ##
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # import time import os import metro_config import metro_logger import metro_error from toolbox import metro_date from toolbox import metro_util from toolbox import metro_xml _ = metro_util.init_translation('metro_date') def read_integer(sTag, nodeBranch): sRslt = metro_xml.extract_data_from_node(sTag, nodeBranch) return string_to_integer(sRslt) def read_real(sTag, nodeBranch): sRslt = metro_xml.extract_data_from_node(sTag, nodeBranch) return string_to_real(sRslt) def read_string(sTag, nodeBranch): return str(metro_xml.extract_data_from_node(sTag, nodeBranch))
Date: August 2nd 2004 """ from metro_preprocess import Metro_preprocess import time import numpy import metro_config import metro_logger import metro_error from toolbox import metro_util from toolbox import metro_date from toolbox import metro_constant _ = metro_util.init_translation('metro_preprocess_interpol_observation') ## # Class attributes ## npTimeInterpolated = None # Array representing the time in seconds. OneObservationException = _("Not enough observation to do the interpolation") NoObservationException = _("No valid observation. Aborting") class Metro_preprocess_interpol_observation(Metro_preprocess): def start(self): Metro_preprocess.start(self) pObservation = self.get_infdata_reference('OBSERVATION') observation_data = pObservation.get_data_collection()