Пример #1
0
void enkf_tui_ranking_menu(void * arg) {
    
  enkf_main_type  * enkf_main  = enkf_main_safe_cast( arg );  
  {
    menu_type * menu = menu_alloc("Ranking of results" , "Back" , "bB");
    menu_item_type * obs_item;
    {
      arg_pack_type * arg_pack = arg_pack_alloc();
      arg_pack_append_ptr( arg_pack , enkf_main );
      menu_add_item(menu , "Create/update misfit table" , "cC"  , enkf_tui_ranking_make_misfit_ensemble   , arg_pack , arg_pack_free__);
      menu_add_separator( menu );
      obs_item = menu_add_item(menu , "New observation based ranking" , "nN" , enkf_tui_ranking_create_obs  , enkf_main , NULL);
      arg_pack_append_ptr( arg_pack , obs_item );
    }
    menu_add_item(menu , "New data based ranking (Sort: increasing)" , "iI" , enkf_tui_ranking_create_data_increasing , enkf_main , NULL);
    menu_add_item(menu , "New data based ranking (Sort: decreasing)" , "dD" , enkf_tui_ranking_create_data_decreasing , enkf_main , NULL);
    menu_add_item(menu , "Show ranking" , "sS" , enkf_tui_ranking_display , enkf_main , NULL);
    {
      enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
      misfit_ensemble_type * misfit_ensemble = enkf_fs_get_misfit_ensemble( fs );
      if (!misfit_ensemble_initialized( misfit_ensemble ))
        menu_item_disable( obs_item );
    }
    menu_add_item(menu , "Help" , "hH" , enkf_tui_help_menu_rank , enkf_main , NULL);
    menu_run(menu);
    menu_free(menu);
  }
  
}
Пример #2
0
void * enkf_main_init_misfit_table_JOB(void * self, const stringlist_type * args) {
  enkf_main_type * enkf_main   = enkf_main_safe_cast( self );
  int history_length           = enkf_main_get_history_length(enkf_main);
  enkf_obs_type * enkf_obs     = enkf_main_get_obs(enkf_main);
  int ens_size                 = enkf_main_get_ensemble_size(enkf_main);
  enkf_fs_type * fs            = enkf_main_get_fs(enkf_main);
  bool force_update            = true;
  const ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main);


  misfit_ensemble_type * misfit_ensemble = enkf_fs_get_misfit_ensemble( fs );
  misfit_ensemble_initialize( misfit_ensemble , ensemble_config , enkf_obs , fs , ens_size , history_length, force_update);

  return NULL;
}
Пример #3
0
void test_init_misfit_table(ert_test_context_type * test_context , const char * job_name , const char * job_file) {
  stringlist_type * args = stringlist_alloc_new();
  ert_test_context_install_workflow_job( test_context , job_name , job_file );

  enkf_main_type * enkf_main = ert_test_context_get_main(test_context);
  enkf_fs_type               * fs              = enkf_main_get_fs(enkf_main);

  misfit_ensemble_type * misfit_ensemble = enkf_fs_get_misfit_ensemble( fs );
  test_assert_false(misfit_ensemble_initialized(misfit_ensemble));

  test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) );

  test_assert_true(misfit_ensemble_initialized(misfit_ensemble));

  stringlist_free( args );
}
Пример #4
0
static void enkf_tui_ranking_create_obs( void * arg ) {
  enkf_main_type    * enkf_main       = enkf_main_safe_cast( arg );  
  enkf_obs_type     * enkf_obs        = enkf_main_get_obs( enkf_main );
  enkf_fs_type      * fs              = enkf_main_get_fs( enkf_main );
  misfit_ensemble_type * misfit_ensemble    = enkf_fs_get_misfit_ensemble( fs );
  
  if (!misfit_ensemble_initialized( misfit_ensemble )) {
    fprintf(stderr,"Sorry: must initialzie the misfit table first \n");
    return;
  } else {
    ranking_table_type * ranking_table = enkf_main_get_ranking_table( enkf_main );
    const int history_length    = enkf_main_get_history_length( enkf_main );
    const int    prompt_len = 50;
    const char * prompt1      = "Observations to use for ranking";
    const char * prompt2      = "Name to store ranking under";
    const char * store_prompt = "Name of file to store ranking";
    int step1,step2;
    stringlist_type * ranking_keys;
    char * obs_keys_input;
    char * ranking_key;
    char * ranking_file;
    util_printf_prompt(prompt1 , prompt_len , '=' , "=> ");
    obs_keys_input = util_alloc_stdin_line();
    ranking_keys   = enkf_obs_alloc_matching_keylist( enkf_obs , obs_keys_input );
    enkf_tui_util_scanf_report_steps(history_length , prompt_len , &step1 , &step2);

    util_printf_prompt(prompt2 , prompt_len , '=' , "=> ");
    ranking_key = util_alloc_stdin_line();
    if (ranking_key == NULL) 
      ranking_key = util_alloc_string_copy( MISFIT_DEFAULT_RANKING_KEY );
    
    util_printf_prompt(store_prompt , prompt_len , '=' , "=> ");
    ranking_file = util_alloc_stdin_line();
        
    if (stringlist_get_size( ranking_keys ) > 0) {
      ranking_table_add_misfit_ranking( ranking_table , misfit_ensemble , ranking_keys , step1 , step2 , ranking_key );
      ranking_table_display_ranking( ranking_table , ranking_key);
    } else
      fprintf(stderr,"The input string : \"%s\" did not resolve to any valid observation keys \n", obs_keys_input);
    
    free( obs_keys_input );
    stringlist_free( ranking_keys );
    free( ranking_key );
    util_safe_free( ranking_file );
  }
}
Пример #5
0
static void enkf_tui_ranking_make_misfit_ensemble( void * arg) {
  arg_pack_type * arg_pack                     = arg_pack_safe_cast( arg );
  enkf_main_type  * enkf_main                  = arg_pack_iget_ptr( arg_pack , 0 );

  enkf_fs_type               * fs              = enkf_main_get_fs(enkf_main);
  enkf_obs_type              * enkf_obs        = enkf_main_get_obs( enkf_main );
  const ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main);
  const int history_length                     = enkf_main_get_history_length( enkf_main );
  const int ens_size                           = enkf_main_get_ensemble_size( enkf_main );
  
    
  misfit_ensemble_type * misfit_ensemble = enkf_fs_get_misfit_ensemble( fs );
  misfit_ensemble_update( misfit_ensemble , ensemble_config , enkf_obs , fs , ens_size , history_length );
  {
    menu_item_type * obs_item                    = arg_pack_iget_ptr( arg_pack , 1 ); 
    menu_item_enable( obs_item );
  }
}