コード例 #1
0
    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 = ""

        if sFilename != "":

            try:
                sFile_content = self._read_input_data(sFilename)
            except IOError:
                sError_message = _("METRo need a valid station file.")
                metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,
                                           sError_message)
            else:
                # Create and add infdata
                infdata_station = metro_infdata.Metro_infdata(
                    'STATION', metro_infdata.DATATYPE_METRO_DATA)
                infdata_station.set_input_information(sFile_content)
                self.add_infdata(infdata_station)

                if metro_config.get_value('SUNSHADOW'):
                    infdata_horizon = metro_infdata.Metro_infdata(
                        'HORIZON', metro_infdata.DATATYPE_METRO_DATA)
                    self.add_infdata(infdata_horizon)

        else:
            sError_message = _("METRo need a station file, please use the ") +\
                             _("option: '--input-station'")
            metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,
                                       sError_message)
コード例 #2
0
    def __validate_optional_args_forecast(self, forecast_data):
        """
        In the case the user asked to use infra-red and/or solar flux
        as input, check if the values are really in the input files.
        """

        # Check for solar-flux
        if metro_config.get_value('SF') and  \
           'SF' not in forecast_data.lMatrix_col_name:
            sInputAtmosphericForecast = metro_config.\
                                        get_value('FILE_FORECAST_IN_FILENAME')
            sMessage = _("The option '--use-solarflux-forecast' was used\n") +\
                       _("but the information was not in the atmospheric\n") +\
                       _("forecast file. Please check for the tag '<sf>'\n") +\
                       _("in the file: %s") % (sInputAtmosphericForecast)
            metro_logger.print_message(
                metro_logger.LOGGER_MSG_STOP, sMessage)
        # Check for infra-red
        if metro_config.get_value('IR') and  \
           'IR' not in forecast_data.lMatrix_col_name:
            sInputAtmosphericForecast = metro_config.\
                                        get_value('FILE_FORECAST_IN_FILENAME')
            sMessage = _("The option '--use-infrared-forecast' was used\n") +\
                       _("but the information was not in the atmospheric\n") +\
                       _("forecast file. Please check for the tag '<ir>'\n") +\
                       _("in the file: %s") % (sInputAtmosphericForecast)
            metro_logger.print_message(
                metro_logger.LOGGER_MSG_STOP, sMessage)
コード例 #3
0
def metro_execute_module(lObject_execution_sequence):
    """
    Load the module sequence for METRo execution.
    """

    i = 0
    iLen_object_execution_sequence = len(lObject_execution_sequence)
    while i < iLen_object_execution_sequence:
        object = lObject_execution_sequence[i]

        # module execution
        object.start()

        # send the results to the following module
        if i + 1 < iLen_object_execution_sequence:
            target_object = lObject_execution_sequence[i + 1]

            if object.get_send_type() == target_object.get_receive_type():
                object.send_data_to(lObject_execution_sequence[i + 1])
            else:
                sMessage = _("Type mismatch between 2 metro module.\n") + \
                           _("%s is sending %s and\n") %\
                           (string.upper(object.__module__),
                            object.get_send_type_txtid()) + \
                            _("%s want to receive %s.") %\
                            (string.upper(target_object.__module__),
                             target_object.get_receive_type_txtid())
                metro_logger.print_message(metro_logger.LOGGER_MSG_STOP, \
                                           sMessage)

        # module cleanup
        object.stop()
        i = i + 1
コード例 #4
0
    def __validate_forecast_length(self, forecast_data):
        """
        Parameters: controlled forecast data
        
        Description: METRo needs more than one forecast date.
        If there is only one forecast, give an error message an exit.
        """

        # Check the length of forecast.
        npFT = forecast_data.get_matrix_col('FORECAST_TIME')

        nbrHours = metro_date.get_elapsed_time(npFT[-1], \
                                               npFT[0]) + 1

        # At least 2 forecast
        if len(npFT) < 2:
            sMessage = _("METRo needs more than one forecast date! Exiting")
            metro_logger.print_message(metro_logger.LOGGER_MSG_STOP, sMessage)

        # Forecast must be at every hour.
        for i in range(len(npFT)):
            nHourElapsed = metro_date.get_elapsed_time(npFT[i], \
                                                       npFT[0])
            if i != nHourElapsed:
                sMessage = _("Atmospheric forecast must be at every hour.") +\
                           _(" Check file from %d hours after the start time.") \
                           % (i)
                metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,
                                           sMessage)
コード例 #5
0
ファイル: metro.py プロジェクト: akrherz/metro
def metro_execute_module(lObject_execution_sequence):
    """
    Load the module sequence for METRo execution.
    """
    
    i = 0
    iLen_object_execution_sequence = len(lObject_execution_sequence)
    while i < iLen_object_execution_sequence:
        object = lObject_execution_sequence[i]

        # module execution
        object.start()

        # send the results to the following module
        if i+1 < iLen_object_execution_sequence:
            target_object = lObject_execution_sequence[i+1]

            if object.get_send_type() == target_object.get_receive_type():
                object.send_data_to(lObject_execution_sequence[i+1])
            else:
                sMessage = _("Type mismatch between 2 metro module.\n") + \
                           _("%s is sending %s and\n") %\
                           (string.upper(object.__module__),
                            object.get_send_type_txtid()) + \
                            _("%s want to receive %s.") %\
                            (string.upper(target_object.__module__),
                             target_object.get_receive_type_txtid())
                metro_logger.print_message(metro_logger.LOGGER_MSG_STOP, \
                                           sMessage)

        # module cleanup 
        object.stop()
        i = i + 1
コード例 #6
0
    def __validate_optional_args_forecast(self, forecast_data):
        """
        In the case the user asked to use infra-red and/or solar flux
        as input, check if the values are really in the input files.
        """

        # Check for solar-flux
        if metro_config.get_value('SF') and  \
           'SF' not in forecast_data.lMatrix_col_name:
            sInputAtmosphericForecast = metro_config.\
                                        get_value('FILE_FORECAST_IN_FILENAME')
            sMessage = _("The option '--use-solarflux-forecast' was used\n") +\
                       _("but the information was not in the atmospheric\n") +\
                       _("forecast file. Please check for the tag '<sf>'\n") +\
                       _("in the file: %s") % (sInputAtmosphericForecast)
            metro_logger.print_message(metro_logger.LOGGER_MSG_STOP, sMessage)
        # Check for infra-red
        if metro_config.get_value('IR') and  \
           'IR' not in forecast_data.lMatrix_col_name:
            sInputAtmosphericForecast = metro_config.\
                                        get_value('FILE_FORECAST_IN_FILENAME')
            sMessage = _("The option '--use-infrared-forecast' was used\n") +\
                       _("but the information was not in the atmospheric\n") +\
                       _("forecast file. Please check for the tag '<ir>'\n") +\
                       _("in the file: %s") % (sInputAtmosphericForecast)
            metro_logger.print_message(metro_logger.LOGGER_MSG_STOP, sMessage)
コード例 #7
0
    def set_matrix_col(self, sCol_name, npCol):
        """
        Set matrix column with a new one. Overwrite the old values.

        Parameters:
        sCol_name (string): tag of the column to set
        npCol (numpy array): the array corresponding to this column.
        
        """

        # FFTODO set multi col
        iCol = self.index_of_matrix_col(sCol_name)[0]

        if not self.is_readonly():
            if iCol > len(self.npMatrix[0, :]):
                sOutOfBoundError = _("Array does not contain this indice: %d") \
                                   % iCol
                raise metro_error.Metro_data_error(sOutOfBoundError)
            elif len(self.npMatrix[:, iCol]) != len(npCol):
                sLengthError = _("Array does not have the right lenght.\n") + \
                               _("Array length: %d \n") % len(npCol) + \
                               _("Matrix length: %d \n") % len(self.npMatrix[:,iCol])
                raise metro_error.Metro_data_error(sLengthError)
            else:
                self.npMatrix[:, iCol] = npCol
        else:
            metro_logger.print_message(metro_logger.LOGGER_MSG_DEBUG,
                                       MESSAGE_READONLY)
            raise metro_error.Metro_data_error(MESSAGE_READONLY)
コード例 #8
0
ファイル: metro_model.py プロジェクト: akrherz/metro
    def start( self ):
        Metro_module.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()
        pStation = self.get_infdata_reference('STATION')
        station_data = pStation.get_data()

        if metro_config.get_value('T_BYPASS_CORE') == False:

            self.__send_data_to_metro_core(forecast_data,
                                           observation_data,
                                           station_data )
            
            roadcast_data = self.__create_roadcast_collection(forecast_data,
                                                              observation_data,
                                                              station_data)
        else:
            roadcast_data = None
            metro_logger.print_message(
                metro_logger.LOGGER_MSG_INFORMATIVE,
                _("Bypassing METRo core, roadcast not created."))

        pForecast.set_data_collection(forecast_data)
        pObservation.set_data_collection(observation_data)
        pStation.set_data(station_data)

        # creer et ajouter infdata
        # Creation and adding infdata
        infdata_roadcast = metro_infdata.Metro_infdata(
            'ROADCAST', metro_infdata.DATATYPE_METRO_DATA_COLLECTION)
        infdata_roadcast.set_data_collection(roadcast_data)
        self.add_infdata(infdata_roadcast)
コード例 #9
0
ファイル: metro_model.py プロジェクト: jacobg0/METRoWin
    def start( self ):
        Metro_module.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()
        pStation = self.get_infdata_reference('STATION')
        station_data = pStation.get_data()

        if metro_config.get_value('T_BYPASS_CORE') == False:

            self.__send_data_to_metro_core(forecast_data,
                                           observation_data,
                                           station_data )
            
            roadcast_data = self.__create_roadcast_collection(forecast_data,
                                                              observation_data,
                                                              station_data)
        else:
            roadcast_data = None
            metro_logger.print_message(
                metro_logger.LOGGER_MSG_INFORMATIVE,
                _("Bypassing METRo core, roadcast not created."))

        pForecast.set_data_collection(forecast_data)
        pObservation.set_data_collection(observation_data)
        pStation.set_data(station_data)

        # creer et ajouter infdata
        # Creation and adding infdata
        infdata_roadcast = metro_infdata.Metro_infdata(
            'ROADCAST', metro_infdata.DATATYPE_METRO_DATA_COLLECTION)
        infdata_roadcast.set_data_collection(roadcast_data)
        self.add_infdata(infdata_roadcast)
コード例 #10
0
ファイル: metro_module.py プロジェクト: akrherz/metro
 def send_data_to( self, target_module ):
     sMessage = _("%s module:\nsending data to module %s") \
                % (string.upper(self.__module__),
                   string.upper(target_module.__module__))
     metro_logger.print_message(metro_logger.LOGGER_MSG_EXECSECONDARY,
                                sMessage)
     target_module.receive_data(self.infdata_container)
コード例 #11
0
    def __print_info(self):
        """
        Print the information about the sunrise/sunset computed for this
        day and emplacement.
        """
        if self.fLon < 0:
            sLon = 'W'
        else:
            sLon = 'E'
        if self.fLat > 0:
            sLat = 'N'
        else:
            sLat = 'S'

        tSunset = metro_date.tranform_decimal_hour_in_minutes(\
            self.fSunset)
        tSunrise = metro_date.tranform_decimal_hour_in_minutes(\
            self.fSunrise)      
        sMessage = _("For the date %d-%d-%d,\n") % \
                   ((self.nStartDay,self.nStartMonth,self.nStartYear)) +\
                   _("at the latitude %0.2f ") %(abs(round(self.fLat,2))) + sLat +\
                   _(" and longitude %0.2f ") %(abs(round(self.fLon,2))) + sLon +\
                   _("\nsunrise is at %d:%d:%d UTC\n") \
                   % ((tSunrise[0], tSunrise[1], tSunrise[2])) +\
                   _("sunset  is at %d:%d:%d UTC") \
                  % ((tSunset[0], tSunset[1], tSunset[2])) 
        metro_logger.print_message(metro_logger.LOGGER_MSG_INFORMATIVE,\
                                  sMessage)
コード例 #12
0
    def __validate_forecast_length(self, forecast_data):
        """
        Parameters: controlled forecast data
        
        Description: METRo needs more than one forecast date.
        If there is only one forecast, give an error message an exit.
        """
        
         # Check the length of forecast. 
        npFT = forecast_data.get_matrix_col('FORECAST_TIME')
        
        nbrHours = metro_date.get_elapsed_time(npFT[-1], \
                                               npFT[0]) + 1

        # At least 2 forecast
        if len(npFT) < 2:
            sMessage = _("METRo needs more than one forecast date! Exiting")
            metro_logger.print_message(
                metro_logger.LOGGER_MSG_STOP, sMessage)

        # Forecast must be at every hour.
        for i in range(len(npFT)):
            nHourElapsed = metro_date.get_elapsed_time(npFT[i], \
                                                       npFT[0])
            if i != nHourElapsed:
                sMessage = _("Atmospheric forecast must be at every hour.") +\
                           _(" Check file from %d hours after the start time.") \
                           % (i)
                metro_logger.print_message(
                    metro_logger.LOGGER_MSG_STOP, sMessage)
コード例 #13
0
ファイル: metro_data.py プロジェクト: akrherz/metro
    def set_matrix_col( self, sCol_name, npCol ):
        """
        Set matrix column with a new one. Overwrite the old values.

        Parameters:
        sCol_name (string): tag of the column to set
        npCol (numpy array): the array corresponding to this column.
        
        """

        # FFTODO set multi col
        iCol = self.index_of_matrix_col(sCol_name)[0]

        if not self.is_readonly():
            if iCol > len(self.npMatrix[0,:]):
               sOutOfBoundError = _("Array does not contain this indice: %d") \
                                  % iCol
               raise metro_error.Metro_data_error(sOutOfBoundError)
            elif len(self.npMatrix[:,iCol]) != len(npCol):
                sLengthError = _("Array does not have the right lenght.\n") + \
                               _("Array length: %d \n") % len(npCol) + \
                               _("Matrix length: %d \n") % len(self.npMatrix[:,iCol])
                raise metro_error.Metro_data_error(sLengthError)
            else:
                self.npMatrix[:,iCol] = npCol
        else:
            metro_logger.print_message(metro_logger.LOGGER_MSG_DEBUG,
                                       MESSAGE_READONLY)
            raise metro_error.Metro_data_error(MESSAGE_READONLY)
コード例 #14
0
def read_date(sTag, nodeBranch):
    sDate = metro_xml.extract_data_from_node(sTag, nodeBranch)
    try:
        fDate = metro_date.parse_date_string(sDate)
    except metro_error.Metro_date_error, inst:
        metro_logger.print_message(metro_logger.LOGGER_MSG_WARNING, str(inst))
        fDate = 0.0
コード例 #15
0
    def start(self):
        Metro_preprocess.start(self)

        pObservation = self.get_infdata_reference('OBSERVATION')
        observation_data = pObservation.get_data_collection()
        
        try: 
            self.__set_time(observation_data.get_controlled_data(), \
                            observation_data.get_interpolated_data(), \
                            observation_data)
            self.__interpolate_AT(observation_data.get_controlled_data(), \
                                  observation_data.get_interpolated_data())
            self.__interpolate_TD(observation_data.get_controlled_data(), \
                                  observation_data.get_interpolated_data())
            self.__interpolate_WS(observation_data.get_controlled_data(), \
                                  observation_data.get_interpolated_data())
            self.__interpolate_ST(observation_data.get_controlled_data(), \
                                  observation_data.get_interpolated_data())
            self.__interpolate_SST(observation_data.get_controlled_data(),\
                                   observation_data.get_interpolated_data())
            self.__interpolate_PI(observation_data.get_controlled_data(), \
                                  observation_data.get_interpolated_data())
            self.__interpolate_SC(observation_data.get_controlled_data(), \
                                  observation_data.get_interpolated_data())
            self.__interpolate_validatation(observation_data.\
                                            get_controlled_data(), \
                                            observation_data)      
            
        except metro_error.Metro_input_error, inst:
            metro_logger.print_message(metro_logger.LOGGER_MSG_INFORMATIVE,
                                       str(inst))
コード例 #16
0
    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:
                sFile_content = self._read_input_data(sFilename)
            except IOError:
                sError_message = _("No file was read. METRo may need this ") +\
                                 _("file content later.")
                metro_logger.print_message(metro_logger.LOGGER_MSG_CRITICAL,
                                           sError_message)
            else:
                # creer et ajouter infdata
                infdata_observation_ref = metro_infdata.Metro_infdata( \
                    'OBSERVATION_REF', \
                    metro_infdata.DATATYPE_METRO_DATA_COLLECTION)
                infdata_observation_ref.set_input_information(sFile_content)
                self.add_infdata(infdata_observation_ref)
        else:
            sError_message = _("If you want to read a second observation file,")+\
                             _("\nplease use the option: ") +\
                             _("'--input-observation-ref'.") +\
                             _("\nYou can safely remove this module from the ") +\
                             _("EXECUTION SEQUENCE\nif you don't need it.") 
            metro_logger.print_message(metro_logger.LOGGER_MSG_WARNING,
                                       sError_message)            
コード例 #17
0
    def start(self):
        Metro_preprocess.start(self)

        pObservation = self.get_infdata_reference('OBSERVATION')
        observation_data = pObservation.get_data_collection()

        try:
            self.__set_time(observation_data.get_controlled_data(), \
                            observation_data.get_interpolated_data(), \
                            observation_data)
            self.__interpolate_AT(observation_data.get_controlled_data(), \
                                  observation_data.get_interpolated_data())
            self.__interpolate_TD(observation_data.get_controlled_data(), \
                                  observation_data.get_interpolated_data())
            self.__interpolate_WS(observation_data.get_controlled_data(), \
                                  observation_data.get_interpolated_data())
            self.__interpolate_ST(observation_data.get_controlled_data(), \
                                  observation_data.get_interpolated_data())
            self.__interpolate_SST(observation_data.get_controlled_data(),\
                                   observation_data.get_interpolated_data())
            self.__interpolate_PI(observation_data.get_controlled_data(), \
                                  observation_data.get_interpolated_data())
            self.__interpolate_SC(observation_data.get_controlled_data(), \
                                  observation_data.get_interpolated_data())
            self.__interpolate_validatation(observation_data.\
                                            get_controlled_data(), \
                                            observation_data)

        except metro_error.Metro_input_error, inst:
            metro_logger.print_message(metro_logger.LOGGER_MSG_INFORMATIVE,
                                       str(inst))
コード例 #18
0
ファイル: metro_read_station.py プロジェクト: akrherz/metro
    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 = ""

        if sFilename != "":

            try:
                sFile_content = self._read_input_data(sFilename)
            except IOError:
                sError_message = _("METRo need a valid station file.") 
                metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,
                                           sError_message)
            else:
                # Create and add infdata
                infdata_station = metro_infdata.Metro_infdata(
                    'STATION', metro_infdata.DATATYPE_METRO_DATA)        
                infdata_station.set_input_information(sFile_content)
                self.add_infdata(infdata_station)

                if metro_config.get_value('SUNSHADOW'):
		    infdata_horizon = metro_infdata.Metro_infdata(
                        'HORIZON', metro_infdata.DATATYPE_METRO_DATA)        
                    self.add_infdata(infdata_horizon)

        else:
            sError_message = _("METRo need a station file, please use the ") +\
                             _("option: '--input-station'") 
            metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,
                                       sError_message)
コード例 #19
0
ファイル: metro_xml.py プロジェクト: jacobg0/METRoWin
def get_handler(sHandlerType, dDefData, dAllDefData=None):

    if dAllDefData == None:
        # Retrieve the informations about the data types
        dStandard_data_type = metro_config.get_value('XML_DATATYPE_STANDARD')
        dExtended_data_type = metro_config.get_value('XML_DATATYPE_EXTENDED')
        dAllDefData = metro_util.join_dictionaries(dStandard_data_type,
                                                   dExtended_data_type)

    sTag = dDefData['NAME']
    sXml_tag = dDefData['XML_TAG']
    sData_type_name = dDefData['DATA_TYPE']

    if sData_type_name not in dAllDefData.keys():
        sMessage = _("Invalid data_type: (%s) for the following ") \
                   % (sData_type_name) +\
                   _("tag:(%s). Default data type will be used.") \
                   % (sTag)
        metro_logger.print_message(metro_logger.LOGGER_MSG_WARNING, sMessage)
        sData_type_name = 'DEFAULT'

    # The data type needs the call of a function to create the node
    sHandler = dAllDefData[sData_type_name][sHandlerType]

    return sHandler
コード例 #20
0
ファイル: metro_xml.py プロジェクト: akrherz/metro
def get_handler(sHandlerType, dDefData, dAllDefData=None):

    if dAllDefData == None:
        # Retrieve the informations about the data types
        dStandard_data_type = metro_config.get_value('XML_DATATYPE_STANDARD')
        dExtended_data_type = metro_config.get_value('XML_DATATYPE_EXTENDED')
        dAllDefData = metro_util.join_dictionaries(dStandard_data_type,
                                              dExtended_data_type)
    
    sTag = dDefData['NAME']
    sXml_tag = dDefData['XML_TAG']
    sData_type_name = dDefData['DATA_TYPE']

    if sData_type_name not in dAllDefData.keys():
        sMessage = _("Invalid data_type: (%s) for the following ") \
                   % (sData_type_name) +\
                   _("tag:(%s). Default data type will be used.") \
                   % (sTag)
        metro_logger.print_message(metro_logger.LOGGER_MSG_WARNING,
                                           sMessage)
        sData_type_name = 'DEFAULT'
                
    # The data type needs the call of a function to create the node
    sHandler = dAllDefData[sData_type_name][sHandlerType]

    return sHandler
コード例 #21
0
 def __check_if_all_value_are_numbers(self, wf_controlled_data):
     """
     Check if all the values in the forecast are numbers.
     """
     for sElement in wf_controlled_data.get_matrix_col_list():
         if sElement.find('TIME') > 0:
             continue
         npElement = wf_controlled_data.get_matrix_col(sElement)
         # In the case of 'CC', only return an error if both SF and IR
         #  are not given
         if sElement is 'CC':
             if metro_config.get_value('SF') and metro_config.get_value(
                     'IR'):
                 continue
         for fElement in npElement:
             if fpconst.isNaN(fElement):
                 if wf_controlled_data.is_standardCol(sElement):
                     sMessage = _("Value in forecast file must be valid.\n") \
                                + _("A value for the element <%s> is invalid")\
                                % (sElement.lower())+\
                                _(" in the file\n'%s'") %\
                                (metro_config.get_value(\
                         "FILE_FORECAST_IN_FILENAME"))
                     raise metro_error.Metro_data_error(sMessage)
                 else:
                     sMessage = _("A value for the extended element <%s> is invalid") % (sElement.lower())+\
                                _(" in the file\n'%s'") %  (metro_config.get_value("FILE_FORECAST_IN_FILENAME"))
                     metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,\
                                                sMessage)
コード例 #22
0
 def __check_if_all_value_are_numbers(self, wf_controlled_data):
     """
     Check if all the values in the forecast are numbers.
     """
     for sElement in wf_controlled_data.get_matrix_col_list():
         if sElement.find('TIME') > 0:
             continue
         npElement = wf_controlled_data.get_matrix_col(sElement)
         # In the case of 'CC', only return an error if both SF and IR
         #  are not given
         if sElement is 'CC':
             if metro_config.get_value('SF') and metro_config.get_value('IR'):
                 continue
         for fElement in npElement:
             if fpconst.isNaN(fElement):
                 if wf_controlled_data.is_standardCol(sElement):
                     sMessage = _("Value in forecast file must be valid.\n") \
                                + _("A value for the element <%s> is invalid")\
                                % (sElement.lower())+\
                                _(" in the file\n'%s'") %\
                                (metro_config.get_value(\
                         "FILE_FORECAST_IN_FILENAME"))
                     raise metro_error.Metro_data_error(sMessage)
                 else:
                     sMessage = _("A value for the extended element <%s> is invalid") % (sElement.lower())+\
                                _(" in the file\n'%s'") %  (metro_config.get_value("FILE_FORECAST_IN_FILENAME"))
                     metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,\
                                                sMessage)
コード例 #23
0
    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:
                sFile_content = self._read_input_data(sFilename)
            except IOError:
                sError_message = _("No file was read. METRo may need this ") +\
                                 _("file content later.")
                metro_logger.print_message(metro_logger.LOGGER_MSG_CRITICAL,
                                           sError_message)
            else:
                # creer et ajouter infdata
                infdata_observation_ref = metro_infdata.Metro_infdata( \
                    'OBSERVATION_REF', \
                    metro_infdata.DATATYPE_METRO_DATA_COLLECTION)
                infdata_observation_ref.set_input_information(sFile_content)
                self.add_infdata(infdata_observation_ref)
        else:
            sError_message = _("If you want to read a second observation file,")+\
                             _("\nplease use the option: ") +\
                             _("'--input-observation-ref'.") +\
                             _("\nYou can safely remove this module from the ") +\
                             _("EXECUTION SEQUENCE\nif you don't need it.") 
            metro_logger.print_message(metro_logger.LOGGER_MSG_WARNING,
                                       sError_message)            
コード例 #24
0
    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 = ""

        if sFilename != "":

            try:
                sFile_content = self._read_input_data(sFilename)
            except IOError:
                sError_message = _("METRo need a valid observation file.")
                metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,
                                           sError_message)
            else:
                # Create and add infdata
                infdata_observation = metro_infdata.Metro_infdata(
                    'OBSERVATION',
                    metro_infdata.DATATYPE_METRO_DATA_COLLECTION)
                infdata_observation.set_input_information(sFile_content)
                self.add_infdata(infdata_observation)
        else:
            sError_message = _("METRo need an observation file, please use ") +\
                             _("the option: '--input-observation'")
            metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,
                                       sError_message)
コード例 #25
0
 def send_data_to( self, target_module ):
     sMessage = _("%s module:\nsending data to module %s") \
                % (string.upper(self.__module__),
                   string.upper(target_module.__module__))
     metro_logger.print_message(metro_logger.LOGGER_MSG_EXECSECONDARY,
                                sMessage)
     target_module.receive_data(self.infdata_container)
コード例 #26
0
    def __print_info(self):
        """
        Print the information about the sunrise/sunset computed for this
        day and emplacement.
        """
        if self.fLon < 0:
            sLon = 'W'
        else:
            sLon = 'E'
        if self.fLat > 0:
            sLat = 'N'
        else:
            sLat = 'S'

        tSunset = metro_date.tranform_decimal_hour_in_minutes(\
            self.fSunset)
        tSunrise = metro_date.tranform_decimal_hour_in_minutes(\
            self.fSunrise)
        sMessage = _("For the date %d-%d-%d,\n") % \
                   ((self.nStartDay,self.nStartMonth,self.nStartYear)) +\
                   _("at the latitude %0.2f ") %(abs(round(self.fLat,2))) + sLat +\
                   _(" and longitude %0.2f ") %(abs(round(self.fLon,2))) + sLon +\
                   _("\nsunrise is at %d:%d:%d UTC\n") \
                   % ((tSunrise[0], tSunrise[1], tSunrise[2])) +\
                   _("sunset  is at %d:%d:%d UTC") \
                  % ((tSunset[0], tSunset[1], tSunset[2]))
        metro_logger.print_message(metro_logger.LOGGER_MSG_INFORMATIVE,\
                                  sMessage)
コード例 #27
0
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)
コード例 #28
0
def read_date(sTag,nodeBranch):
    sDate = metro_xml.extract_data_from_node(sTag,nodeBranch)
    try:
        fDate = metro_date.parse_date_string(sDate)
    except metro_error.Metro_date_error, inst:
        metro_logger.print_message(metro_logger.LOGGER_MSG_WARNING,
                                   str(inst))
        fDate = 0.0
コード例 #29
0
ファイル: metro_validate.py プロジェクト: jacobg0/METRoWin
 def __validate_xml_string(self, sXml_content):
     if sXml_content != None:
         try:
             return metro_xml.validate_string(sXml_content)
         except metro_error.Metro_xml_error, inst:
             metro_logger.print_message(metro_logger.LOGGER_MSG_DEBUG,
                                        _("Error when validating ") +\
                                        _("XML string."))
             raise metro_error.Metro_xml_error(str(inst))
コード例 #30
0
    def __set_time(self, ro_controlled_data, ro_interpolated_data,
                   observation_data):
        """
        Name: __set_time
        
        Parameters: metro_data controlled_data : controlled forecast data
        
        Returns: None
        
        Functions Called:  numpy.arange, astype
                           numpy.zeros
                           metro_data.set_matrix
                           metro_data.get_matrix_col
                           metro_data.append_matrix_col
                           observation_data.set_attribute
                           metro_config.get_value('FILE_OBSERVATION_FILENAME')

        Description: Set the time array in the interpolated matrix.

        Notes:

        Revision History:
        Author		Date		Reason
        Miguel Tremblay      August 5th 2004
        """

        # Set the time in the interpolated matrix.
        npTime =  ro_controlled_data.get_matrix_col('Time')
        self.npTimeInterpolated = numpy.arange(npTime[0], \
                                               npTime[len(npTime)-1],
                                               metro_constant.fTimeStep)

        # 1.1574e-5 is the conversion from seconds to day.
        #  1/(24*3600) = 1.1574e-5
        self.npTimeInterpolated =  self.npTimeInterpolated/3600 -\
                                  24*((self.npTimeInterpolated*1.1574e-5)\
                                      .astype(numpy.int32))

        # Save the time array
        if len(self.npTimeInterpolated) > 1:
            ro_interpolated_data.append_matrix_col('Time', \
                                                self.npTimeInterpolated)
        # Only one observation, abort interpolation
        elif len(self.npTimeInterpolated) == 1:
            observation_data.set_attribute('NO_OBS',\
                                           [False, False, False, True])
            raise metro_error.Metro_input_error(OneObservationException)
        else:
            observation_data.set_attribute('NO_OBS',\
                                           [True, True, True, True])
            sMessage = _("No valid observation in: ") +\
                       metro_config.get_value('FILE_OBSERVATION_FILENAME')
            metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,
                                       sMessage)

            raise metro_error.Metro_input_error(NoObservationException)
コード例 #31
0
    def __set_first_roadcast_date(self, observation_data, roadcast_data):
        """
        Name: ___set_first_roadcast_date
        Parameters: Observation and roadcast

        Description: If the date of the first roadcast is not specified in the input
                     (command line or config file), set it to first round 20 minutes after
                     the last observation.

        Author: Miguel Tremblay
        Date: March 5th 2007
        """
        # Check if the value is given as an argument
        if metro_config.get_value('INIT_ROADCAST_START_DATE') != "":
             # Set the xml header value
             controlled_roadcast = roadcast_data.get_subsampled_data()
             controlled_roadcast.set_header_value('FIRST_ROADCAST',\
                                                  metro_config.get_value('INIT_ROADCAST_START_DATE'))
             return 0
        else : # if value of INIT_ROADCAST_START_DATE is not given, fetch the first
            # round 20 minutes.
            naOT = observation_data.get_matrix_col('OBSERVATION_TIME')
            fLast_observation_date = naOT[len(naOT)-1]
            sLast_observation_date = metro_date.seconds2iso8601(fLast_observation_date)

            # Fetch the first 20 minutes value.
            iNb_timesteps = roadcast_data.get_attribute('FORECAST_NB_TIMESTEPS')
            nSecondsForOutput = metro_constant.nMinutesForOutput*60
            lTimeStep = roadcast_data.get_controlled_data().get_matrix_col('HH')
            for i in range(0, iNb_timesteps):
                fCurrentTime = lTimeStep[i]*3600
                # Forecast at every 20 minutes, i.e. 1200 seconds  
                # if current time is a 20 minute interval
                # and roadcast time is >= roadcast start date
                if round(fCurrentTime)%nSecondsForOutput == 0:
                    sLast_observation =  metro_config.\
                                        get_value('DATA_ATTRIBUTE_LAST_OBSERVATION')
                    fLast_observation = metro_date.parse_date_string(sLast_observation)
                    sStart_date = metro_date.seconds2iso8601(fLast_observation + \
                                                             (i+1)*\
                                                             metro_constant.fTimeStep)
                    metro_config.set_value('INIT_ROADCAST_START_DATE', sStart_date)
                    sMessage = _("Roadcast start date set to: ''%s'") % (sStart_date)
                    metro_logger.print_message(metro_logger.LOGGER_MSG_INFORMATIVE,\
                                               sMessage)
                    # Set the xml header value
                    controlled_roadcast = roadcast_data.get_subsampled_data()
                    controlled_roadcast.set_header_value('FIRST_ROADCAST', sStart_date)
                    return i



            #  Something bad hapened.
            sMessage = _("Unable to determine the first time of roadcast!")
            metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,\
                                       sMessage)
コード例 #32
0
 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,
                                    sMessage)            
コード例 #33
0
ファイル: metro_dom2metro.py プロジェクト: jacobg0/METRoWin
 def validate_file_version_number(self, sFilename, sFile_version,
                                  sMin_version, sMax_version):
     try:
         metro_util.validate_version_number(sFile_version, sMin_version,
                                            sMax_version)
     except metro_error.Metro_version_error, inst:
         sMessage =_("An error occured when reading ") +\
                   _("file:\n'%s'.\nThe error is:\n'%s'.") \
                     % (sFilename, str(inst))
         metro_logger.print_message(metro_logger.LOGGER_MSG_STOP, sMessage)
コード例 #34
0
 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,
                                    sMessage)            
コード例 #35
0
    def __set_time(self, ro_controlled_data, ro_interpolated_data,
                   observation_data):
        """
        Name: __set_time
        
        Parameters: metro_data controlled_data : controlled forecast data
        
        Returns: None
        
        Functions Called:  numpy.arange, astype
                           numpy.zeros
                           metro_data.set_matrix
                           metro_data.get_matrix_col
                           metro_data.append_matrix_col
                           observation_data.set_attribute
                           metro_config.get_value('FILE_OBSERVATION_FILENAME')

        Description: Set the time array in the interpolated matrix.

        Notes:

        Revision History:
        Author		Date		Reason
        Miguel Tremblay      August 5th 2004
        """

        # Set the time in the interpolated matrix.
        npTime = ro_controlled_data.get_matrix_col('Time')
        self.npTimeInterpolated = numpy.arange(npTime[0], \
                                               npTime[len(npTime)-1],
                                               metro_constant.fTimeStep)

        # 1.1574e-5 is the conversion from seconds to day.
        #  1/(24*3600) = 1.1574e-5
        self.npTimeInterpolated =  self.npTimeInterpolated/3600 -\
                                  24*((self.npTimeInterpolated*1.1574e-5)\
                                      .astype(numpy.int32))

        # Save the time array
        if len(self.npTimeInterpolated) > 1:
            ro_interpolated_data.append_matrix_col('Time', \
                                                self.npTimeInterpolated)
        # Only one observation, abort interpolation
        elif len(self.npTimeInterpolated) == 1:
            observation_data.set_attribute('NO_OBS',\
                                           [False, False, False, True])
            raise metro_error.Metro_input_error(OneObservationException)
        else:
            observation_data.set_attribute('NO_OBS',\
                                           [True, True, True, True])
            sMessage = _("No valid observation in: ") +\
                       metro_config.get_value('FILE_OBSERVATION_FILENAME')
            metro_logger.print_message(metro_logger.LOGGER_MSG_STOP, sMessage)

            raise metro_error.Metro_input_error(NoObservationException)
コード例 #36
0
ファイル: metro_xml.py プロジェクト: jacobg0/METRoWin
def validate_string(sXml_content):
    if metro_xml_lib.get_name() == "Metro_xml_libxml2":
        metro_xml_lib.validate_xml_string(sXml_content)
    else:
        sMessage = _("Validation is only supported with metro_xml_libxml2")
        if metro_logger.is_initialised():
            metro_logger.print_message(metro_logger.LOGGER_MSG_WARNING,
                                       sMessage)
        else:
            metro_logger.print_init_message(metro_logger.LOGGER_INIT_ERROR,
                                            sMessage)
コード例 #37
0
ファイル: metro_xml.py プロジェクト: akrherz/metro
def validate_string( sXml_content ):
    if metro_xml_lib.get_name() == "Metro_xml_libxml2":
        metro_xml_lib.validate_xml_string(sXml_content)
    else:
        sMessage = _("Validation is only supported with metro_xml_libxml2")
        if metro_logger.is_initialised():
            metro_logger.print_message(metro_logger.LOGGER_MSG_WARNING,
                                       sMessage)
        else:
            metro_logger.print_init_message(metro_logger.LOGGER_INIT_ERROR,
                                            sMessage)
コード例 #38
0
ファイル: metro_dom2metro.py プロジェクト: akrherz/metro
 def validate_file_version_number( self, sFilename, sFile_version,
                                sMin_version, sMax_version ):
     try:
         metro_util.validate_version_number(sFile_version,
                                         sMin_version,
                                         sMax_version)
     except metro_error.Metro_version_error, inst:
         sMessage =_("An error occured when reading ") +\
                   _("file:\n'%s'.\nThe error is:\n'%s'.") \
                     % (sFilename, str(inst))
         metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,
                                    sMessage)
コード例 #39
0
ファイル: metro_read.py プロジェクト: jacobg0/METRoWin
    def _read_input_data(self, sFilename):

        #read forecast
        try:
            input = open(sFilename, 'r')
            inputForecast = input.read()
            input.close()
        except IOError, sError:
            sMessage = _("Error when opening file:\n%s") % (sError)
            metro_logger.print_message(metro_logger.LOGGER_MSG_CRITICAL,
                                       sMessage)
            raise IOError
コード例 #40
0
ファイル: metro_read.py プロジェクト: akrherz/metro
 def _read_input_data(self, sFilename ):
     
     #read forecast
     try:
         input = open(sFilename, 'r')
         inputForecast = input.read()
         input.close()
     except IOError, sError:
         sMessage = _("Error when opening file:\n%s") % (sError)
         metro_logger.print_message(metro_logger.LOGGER_MSG_CRITICAL,
                                    sMessage)
         raise IOError
コード例 #41
0
    def init_matrix(self, iNb_row, iNb_col, fVal=metro_constant.NaN):
        """
        Init a matrix of n row and m column filled with a value.

        
        """
        if not self.is_readonly():
            self.npMatrix = numpy.zeros((iNb_row, iNb_col))
            self.npMatrix = self.npMatrix + fVal
        else:
            metro_logger.print_message(metro_logger.LOGGER_MSG_DEBUG,
                                       MESSAGE_READONLY)
            raise metro_error.Metro_data_error(MESSAGE_READONLY)
コード例 #42
0
    def set_matrix(self, npMatrix):
        """Set the whole matrix with a new one.

        This method should be used with care because the new and old matrix
        must have the same column count. Also column name of the old matrix
        will be the only way to access column of the new one.
        """
        if not self.is_readonly():
            self.npMatrix = npMatrix
        else:
            metro_logger.print_message(metro_logger.LOGGER_MSG_DEBUG,
                                       MESSAGE_READONLY)
            raise metro_error.Metro_data_error(MESSAGE_READONLY)
コード例 #43
0
ファイル: metro_data.py プロジェクト: akrherz/metro
    def init_matrix( self, iNb_row, iNb_col, fVal=metro_constant.NaN ):
        """
        Init a matrix of n row and m column filled with a value.

        
        """
        if not self.is_readonly():
            self.npMatrix = numpy.zeros((iNb_row,iNb_col))
            self.npMatrix = self.npMatrix + fVal
        else:
            metro_logger.print_message(metro_logger.LOGGER_MSG_DEBUG,
                                       MESSAGE_READONLY)
            raise metro_error.Metro_data_error(MESSAGE_READONLY)
コード例 #44
0
ファイル: metro_data.py プロジェクト: akrherz/metro
    def set_matrix( self, npMatrix ):
        """Set the whole matrix with a new one.

        This method should be used with care because the new and old matrix
        must have the same column count. Also column name of the old matrix
        will be the only way to access column of the new one.
        """
        if not self.is_readonly():
            self.npMatrix = npMatrix
        else:
            metro_logger.print_message(metro_logger.LOGGER_MSG_DEBUG,
                                       MESSAGE_READONLY)
            raise metro_error.Metro_data_error(MESSAGE_READONLY)
コード例 #45
0
    def start(self):
        Metro_preprocess.start(self)

        try:
            Metro_preprocess.start(self)

            pStation = self.get_infdata_reference('STATION')

            if self.infdata_exist('HORIZON'):
                self.__check_sunshadow(pStation)

        except metro_error.Metro_data_error, inst:
            metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,\
                                       str(inst))
コード例 #46
0
ファイル: metro_write_forecast.py プロジェクト: akrherz/metro
    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)
        else:
            metro_logger.print_message(metro_logger.LOGGER_MSG_WARNING,
                                       _("no DOM forecast, nothing to write"))

        pForecast.set_output_information(None)
コード例 #47
0
 def __string2dom(self):
     
     if self.infdata_exist('OBSERVATION_REF'):
         pObservation_ref = self.get_infdata_reference('OBSERVATION_REF')
         sObservation_ref = pObservation_ref.get_input_information()
         try:
             domObservation_ref = self._convert_string2dom(sObservation_ref)
         except metro_error.Metro_xml_error, inst:
             sMessage = _("Fatal Error when converting observation_ref ") +\
                        _("string to DOM. The error is:\n%s") % (str(inst))
             metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,
                                        sMessage)
         else:
             pObservation_ref.set_input_information(domObservation_ref)
コード例 #48
0
    def __string2dom(self):

        if self.infdata_exist('FORECAST'):
            pForecast = self.get_infdata_reference('FORECAST')
            sForecast = pForecast.get_input_information()
            try:
                domForecast = self._convert_string2dom(sForecast)
            except metro_error.Metro_xml_error, inst:
                sMessage = _("Fatal Error when converting forecast ") +\
                           _("string to DOM. The error is:\n%s") % (str(inst))
                metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,
                                           sMessage)
            else:
                pForecast.set_input_information(domForecast)
コード例 #49
0
    def __string2dom(self):

        if self.infdata_exist('FORECAST'):
            pForecast = self.get_infdata_reference('FORECAST')
            sForecast = pForecast.get_input_information()
            try:            
                domForecast = self._convert_string2dom(sForecast)
            except metro_error.Metro_xml_error, inst:
                sMessage = _("Fatal Error when converting forecast ") +\
                           _("string to DOM. The error is:\n%s") % (str(inst))
                metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,
                                           sMessage)
            else:
                pForecast.set_input_information(domForecast)
コード例 #50
0
    def start(self):
        Metro_preprocess.start(self)

        try:        
            Metro_preprocess.start(self)

            pStation = self.get_infdata_reference('STATION')

            if self.infdata_exist('HORIZON'):
                self.__check_sunshadow(pStation)

        except metro_error.Metro_data_error, inst:
            metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,\
                                       str(inst))
コード例 #51
0
 def __string2dom(self):
     
     if self.infdata_exist('OBSERVATION_REF'):
         pObservation_ref = self.get_infdata_reference('OBSERVATION_REF')
         sObservation_ref = pObservation_ref.get_input_information()
         try:
             domObservation_ref = self._convert_string2dom(sObservation_ref)
         except metro_error.Metro_xml_error, inst:
             sMessage = _("Fatal Error when converting observation_ref ") +\
                        _("string to DOM. The error is:\n%s") % (str(inst))
             metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,
                                        sMessage)
         else:
             pObservation_ref.set_input_information(domObservation_ref)
コード例 #52
0
    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)
        else:
            metro_logger.print_message(metro_logger.LOGGER_MSG_WARNING,
                                       _("no DOM forecast, nothing to write"))

        pForecast.set_output_information(None)
コード例 #53
0
def roadlayer_type_to_roadlayer_code(sLayerType):
    dValidLayerType = metro_config.get_value(\
        'XML_STATION_ROADLAYER_VALID_TYPE')

    sLayerType = sLayerType.upper()
    if sLayerType in dValidLayerType:
        iLayer_code = dValidLayerType[sLayerType]
    else:
        # raise an error
        sMessage = _("'%s' is not a valid road layer type. ") % (sLayerType) +\
                   _("Valid type are %s " ) % (dValidLayerType.keys()) +\
                   _("Check the station configuration file")
        metro_logger.print_message(metro_logger.LOGGER_MSG_STOP, sMessage)
        
    return iLayer_code
コード例 #54
0
def roadlayer_type_to_roadlayer_code(sLayerType):
    dValidLayerType = metro_config.get_value(\
        'XML_STATION_ROADLAYER_VALID_TYPE')

    sLayerType = sLayerType.upper()
    if sLayerType in dValidLayerType:
        iLayer_code = dValidLayerType[sLayerType]
    else:
        # raise an error
        sMessage = _("'%s' is not a valid road layer type. ") % (sLayerType) +\
                   _("Valid type are %s " ) % (dValidLayerType.keys()) +\
                   _("Check the station configuration file")
        metro_logger.print_message(metro_logger.LOGGER_MSG_STOP, sMessage)

    return iLayer_code
コード例 #55
0
    def __string2dom(self):

        if self.infdata_exist('STATION'):
            pStation = self.get_infdata_reference('STATION')
            sStation = pStation.get_input_information()

            try:
                domStation = self._convert_string2dom(sStation)
            except metro_string2dom.ERROR_METRO_CONVERT, sError:
                sMessage = _("Fatal Error when converting station ") +\
                           _("string to DOM. The error is:\n%s") % (sError)
                metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,
                                       sMessage)
            else:
                pStation.set_input_information(domStation)
コード例 #56
0
    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())
        except metro_error.Metro_data_error, inst:
            metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,\
                                       str(inst))
コード例 #57
0
ファイル: metro_data.py プロジェクト: akrherz/metro
    def set_header( self, dComplete_header ):
        """
        Set complete header

        Parameters:
        dComplete_header (dictionnary): dictionnary containing the tag of the
        elements (the keys) and their corresponding value.

        """
        if not self.is_readonly():
            self.dHeader = dComplete_header
        else:
            metro_logger.print_message(metro_logger.LOGGER_MSG_DEBUG,
                                       MESSAGE_READONLY)
            raise metro_error.Metro_data_error(MESSAGE_READONLY)
コード例 #58
0
ファイル: metro_data.py プロジェクト: akrherz/metro
    def set_header_value( self, sKey, value ):
        """
        Set/add a value to the header

        Parameters:
          sKey (string): element to set this value to
          value (??): value of the element sKey

        """
        if not self.is_readonly():
            self.dHeader[sKey] = value
        else:
            metro_logger.print_message(metro_logger.LOGGER_MSG_DEBUG,
                                       MESSAGE_READONLY)
            raise metro_error.Metro_data_error(MESSAGE_READONLY)
コード例 #59
0
    def set_header(self, dComplete_header):
        """
        Set complete header

        Parameters:
        dComplete_header (dictionnary): dictionnary containing the tag of the
        elements (the keys) and their corresponding value.

        """
        if not self.is_readonly():
            self.dHeader = dComplete_header
        else:
            metro_logger.print_message(metro_logger.LOGGER_MSG_DEBUG,
                                       MESSAGE_READONLY)
            raise metro_error.Metro_data_error(MESSAGE_READONLY)
コード例 #60
0
    def set_header_value(self, sKey, value):
        """
        Set/add a value to the header

        Parameters:
          sKey (string): element to set this value to
          value (??): value of the element sKey

        """
        if not self.is_readonly():
            self.dHeader[sKey] = value
        else:
            metro_logger.print_message(metro_logger.LOGGER_MSG_DEBUG,
                                       MESSAGE_READONLY)
            raise metro_error.Metro_data_error(MESSAGE_READONLY)