Ejemplo n.º 1
0
void block_obs_measure(const block_obs_type * block_obs, const void * state , node_id_type node_id , meas_data_type * meas_data , const active_list_type * __active_list) {
  block_obs_assert_data( block_obs , state );
  {
    int active_size = active_list_get_active_size( __active_list , block_obs->size );
    meas_block_type * meas_block = meas_data_add_block( meas_data , block_obs->obs_key , node_id.report_step , block_obs->size );
    int iobs;
    
    active_mode_type active_mode = active_list_get_mode( __active_list );
    if (active_mode == ALL_ACTIVE) {
      for (iobs=0; iobs < block_obs->size; iobs++) {
        const point_obs_type * point_obs = block_obs->point_list[iobs];
        double value = point_obs_measure( point_obs , state , iobs , node_id);
        meas_block_iset( meas_block , node_id.iens , iobs , value );
      }
    } else if (active_mode == PARTLY_ACTIVE) {
      const int   * active_list    = active_list_get_active( __active_list ); 
      for (int i =0 ; i < active_size; i++) {
        iobs = active_list[i];
        {
          const point_obs_type * point_obs = block_obs->point_list[iobs];
          double value = point_obs_measure( point_obs , state , iobs , node_id);
          meas_block_iset( meas_block , node_id.iens , point_obs->active_index , value );
        }
      }
    }
  }
}
Ejemplo n.º 2
0
double block_obs_chi2(const block_obs_type * block_obs, const void * state, node_id_type node_id) {
    double sum_chi2 = 0;
    int obs_size = block_obs_get_size( block_obs );
    block_obs_assert_data(block_obs, state);

    for (int i=0; i < obs_size; i++) {
        const point_obs_type * point_obs = block_obs_iget_point_const( block_obs , i );
        double sim_value = point_obs_iget_data( point_obs , state , i, node_id );
        double x = (sim_value - point_obs->value) / point_obs->std;
        sum_chi2 += x*x;
    }
    return sum_chi2;
}