Esempio n. 1
0
    def run_enki(self,options, starttime, endtime):
        '''
        options is a runconfiguration dict for overiding the default parameters from the json file.
        '''


        enkiRunConfig = EnkiRc(self.enkiModelJsonPath, **options)
        enkiRunConfig.initiate_options(self.operation)
        enkiRunConfig.initiate_datasets()
        enkiService = enki.EnkiApiService(False)
        enkiService.setRootPath(self.enkiModelPath)
    
        result = enkiService.run(enkiRunConfig.rc)


        if result.success:
            rs = EnkiResult(result, enkiRunConfig)
            rs.write_results()

        saver = Saver.save_to_server(enkiRunConfig,self.operation,endtime,starttime)
        saver.save_state(rs,self.enkiStatePath)
        saver.save_input_database(self.enkiModelPath)
        saver.save_output_database(self.enkiModelPath)
        # New enki::core run
        eca = EnkiCoreAdapter(enkiRunConfig.rc.regionXml,enkiRunConfig.rc.stateXml,enkiRunConfig.rc.ts)
        eca.test_build_and_run_model(enkiRunConfig.rc.Tstart,enkiRunConfig.rc.deltaT,enkiRunConfig.rc.nSteps)


        return result
Esempio n. 2
0
def run_enki(options, starttime, endtime):
    '''
    options is a runconfiguration dict for overiding the default parameters from the json file.
    '''
    # path management
    enkiRootPath = path.abspath(r"D:/enki")
    enkiBinPath = path.join(enkiRootPath, 'bin')
    enkiModelPath = path.join(enkiRootPath, 'Data', 'Tokke_Prod')
    enkiModelJsonPath = path.join(enkiModelPath, 'Tokke_Prod_fullnetwork.json')  # 'Tokke_Prod.json'

    enkiRunConfig = EnkiRc(enkiModelJsonPath, **options)
    enkiRunConfig.initiate_options()
    enkiRunConfig.initiate_datasets()
    enkiService = enki.EnkiApiService(False)
    enkiService.setRootPath(enkiModelPath)
    
    result = enkiService.run(enkiRunConfig.rc)
    stateFile = os.path.join(enkiModelPath, str.format("{0}.state.{1}-{2:02d}-{3:02d}_{4:02d}.stx", 'ENKI', 
                                                       endtime.year, endtime.month, endtime.day, endtime.hour))
    if result.success:
        rs = EnkiResult(result, enkiRunConfig)
        rs.write_results()
        
        rs.save_statefile(stateFile)
        
    return result