Exemple #1
0
void obs_vector_measure(const obs_vector_type * obs_vector , 
                        enkf_fs_type * fs , 
                        state_enum state , 
                        int report_step , 
                        const int_vector_type * ens_active_list , 
                        meas_data_type * meas_data , 
                        const active_list_type * active_list) {
  
  void * obs_node = vector_iget( obs_vector->nodes , report_step );
  if ( obs_node != NULL ) {
    enkf_node_type * enkf_node = enkf_node_deep_alloc( obs_vector->config_node );

    node_id_type node_id = { .report_step = report_step , 
                             .state       = state , 
                             .iens        = 0 };

    for (int active_iens_index =0; active_iens_index < int_vector_size( ens_active_list ); active_iens_index++) {
      node_id.iens = int_vector_iget( ens_active_list , active_iens_index );
      
      enkf_node_load(enkf_node , fs , node_id);
      node_id.iens = active_iens_index;
      obs_vector->measure(obs_node , enkf_node_value_ptr(enkf_node) , node_id , meas_data , active_list);
    }

    enkf_node_free( enkf_node );
  }
}
Exemple #2
0
void test_container( ert_test_context_type * test_context ) {
  enkf_config_node_type * config_node = enkf_config_node_new_container( "CONTAINER" );
  enkf_config_node_type * wwct1_node = enkf_config_node_alloc_summary( "WWCT:OP_1" , LOAD_FAIL_SILENT);
  enkf_config_node_type * wwct2_node = enkf_config_node_alloc_summary( "WWCT:OP_2" , LOAD_FAIL_SILENT);
  enkf_config_node_type * wwct3_node = enkf_config_node_alloc_summary( "WWCT:OP_3" , LOAD_FAIL_SILENT);


  enkf_config_node_update_container( config_node , wwct1_node );
  enkf_config_node_update_container( config_node , wwct2_node );
  enkf_config_node_update_container( config_node , wwct3_node );
  {
    enkf_node_type * container = enkf_node_deep_alloc( config_node );
    enkf_node_free( container );
  }


  enkf_config_node_free( wwct3_node );
  enkf_config_node_free( wwct2_node );
  enkf_config_node_free( wwct1_node );
  enkf_config_node_free( config_node );
}
Exemple #3
0
double obs_vector_total_chi2(const obs_vector_type * obs_vector , enkf_fs_type * fs , int iens) {
  double sum_chi2 = 0;
  enkf_node_type * enkf_node = enkf_node_deep_alloc( obs_vector->config_node );
  node_id_type node_id = {.report_step = 0, .iens = iens };

  int vec_size = vector_get_size( obs_vector->nodes );
  for (int report_step = 0; report_step < vec_size; report_step++) {
    if (vector_iget(obs_vector->nodes , report_step) != NULL) {
      node_id.report_step = report_step;

      if (enkf_node_try_load( enkf_node , fs , node_id))
        sum_chi2 += obs_vector_chi2__(obs_vector , report_step , enkf_node, node_id);

    }
  }
  enkf_node_free( enkf_node );
  return sum_chi2;
}


/**
   This function will sum up all timesteps of the obs_vector, for all ensemble members.
*/

void obs_vector_ensemble_total_chi2(const obs_vector_type * obs_vector , enkf_fs_type * fs , int ens_size , double * sum_chi2) {
  const bool verbose = true;
  msg_type * msg;
  int report_step;
  int iens;
  char * msg_text = NULL;

  for (iens = 0; iens < ens_size; iens++)
    sum_chi2[iens] = 0;

  if (verbose) {
    msg = msg_alloc("Observation: " , false);
    msg_show(msg);
  }

  {
    node_id_type node_id = {.report_step = 0, .iens = iens };
    enkf_node_type * enkf_node = enkf_node_alloc( obs_vector->config_node );
    int vec_size = vector_get_size( obs_vector->nodes);
    for (report_step = 0; report_step < vec_size; report_step++) {
      if (verbose) {
        msg_text = util_realloc_sprintf( msg_text , "%s[%03d]" , obs_vector->obs_key , report_step);
        msg_update(msg , msg_text);
      }
      if (vector_iget(obs_vector->nodes , report_step) != NULL) {
        node_id.report_step = report_step;
        for (iens = 0; iens < ens_size; iens++) {
          node_id.iens = iens;

          if (enkf_node_try_load( enkf_node , fs , node_id))
            sum_chi2[iens] += obs_vector_chi2__(obs_vector , report_step , enkf_node, node_id);

        }
      }
    }
    enkf_node_free( enkf_node );
  }

  if (verbose) {
    msg_free(msg , true);
    util_safe_free( msg_text );
  }
}

const char * obs_vector_get_obs_key( const obs_vector_type * obs_vector) {
  return obs_vector->obs_key;
}


local_obsdata_node_type * obs_vector_alloc_local_node(const obs_vector_type * obs_vector) {
  local_obsdata_node_type * obs_node = local_obsdata_node_alloc( obs_vector->obs_key , false );
  local_obsdata_node_reset_tstep_list(obs_node, obs_vector->step_list );
  return  obs_node;
}


/*****************************************************************/


VOID_FREE(obs_vector)