示例#1
0
static void ecl_sum_tstep_set_time_info( ecl_sum_tstep_type * tstep , const ecl_smspec_type * smspec ) {
  int date_day_index   = ecl_smspec_get_date_day_index( smspec );
  int date_month_index = ecl_smspec_get_date_month_index( smspec );
  int date_year_index  = ecl_smspec_get_date_year_index( smspec );
  int sim_days_index   = ecl_smspec_get_sim_days_index( smspec );
  time_t sim_start     = ecl_smspec_get_start_time( smspec );

  if (sim_days_index >= 0) {
    float sim_days = tstep->data[ sim_days_index ];
    ecl_sum_tstep_set_time_info_from_days( tstep , sim_start , sim_days );
  } else if ( date_day_index >= 0) {
    int sec  = 0;
    int min  = 0;
    int hour = 0;
    
    int day   = util_roundf(tstep->data[date_day_index]);
    int month = util_roundf(tstep->data[date_month_index]);
    int year  = util_roundf(tstep->data[date_year_index]);
    
    time_t sim_time = util_make_datetime(sec , min , hour , day , month , year);
    ecl_sum_tstep_set_time_info_from_date( tstep , sim_start , sim_time );
  } else
    util_abort("%s: Hmmm - could not extract date/time information from SMSPEC header file? \n",__func__);

}
示例#2
0
ecl_sum_tstep_type * ecl_sum_tstep_alloc_new( int report_step , int ministep , float sim_days , const ecl_smspec_type * smspec ) {
  ecl_sum_tstep_type * tstep = ecl_sum_tstep_alloc( report_step , ministep , smspec );
  const float_vector_type * default_data = ecl_smspec_get_params_default( smspec );
  float_vector_memcpy_data( tstep->data , default_data );

  ecl_sum_tstep_set_time_info_from_days( tstep , ecl_smspec_get_start_time( smspec ) , sim_days );
  ecl_sum_tstep_iset( tstep , ecl_smspec_get_time_index( smspec ) , sim_days );
  return tstep;
}
示例#3
0
static int ecl_sum_data_get_index_from_sim_time( const ecl_sum_data_type * data , time_t sim_time) {
  time_t data_start_time = data->data_start_time;
  
  if ((sim_time < data_start_time) || (sim_time > data->sim_end)) {
    fprintf(stderr , "Simulation start: "); util_fprintf_date( ecl_smspec_get_start_time( data->smspec ) , stderr );
    fprintf(stderr , "Data start......: "); util_fprintf_date( data_start_time , stderr );
    fprintf(stderr , "Simulation end .: "); util_fprintf_date( data->sim_end , stderr );
    fprintf(stderr , "Requested date .: "); util_fprintf_date( sim_time , stderr );
    util_abort("%s: invalid time_t instance:%d  interval:  [%d,%d]\n",__func__, sim_time , data_start_time , data->sim_end);
  }
  
  /* 
     The moment we have passed the intial test we MUST find a valid
     ministep index, however care should be taken that there can
     perfectly well be 'holes' in the time domain, because of e.g. the
     RPTONLY keyword.
  */
  {
    int  low_index      = 0;
    int  high_index     = vector_get_size( data->data );
    int  internal_index = -1;
    

    while (internal_index < 0) {
      if (low_index == high_index)
        internal_index = low_index;
      else {
        int center_index = 0.5*( low_index + high_index );
        const ecl_sum_tstep_type * ministep = ecl_sum_data_iget_ministep( data , center_index );
        
        if ((high_index - low_index) == 1) {
          /* Degenerate special case. */
          if (sim_time < ecl_sum_tstep_get_sim_time( ministep ))
            internal_index = low_index;
          else
            internal_index = high_index;
        } else {
          if (sim_time > ecl_sum_tstep_get_sim_time( ministep ))    /*     Low-----Center---X---High */
            low_index = center_index;
          else {
            time_t prev_time = data_start_time;
            if (center_index > 0) {
              const ecl_sum_tstep_type * prev_step = ecl_sum_data_iget_ministep( data , center_index - 1  );
              prev_time = ecl_sum_tstep_get_sim_time( prev_step );
            }
            
            if (prev_time < sim_time)
              internal_index = center_index; /* Found it */
            else
              high_index = center_index;
          }
        }
      }
    }
    return internal_index;
  }
}
示例#4
0
time_t ecl_sum_data_get_report_time( const ecl_sum_data_type * data , int report_step) {
  if (report_step == 0)
    return ecl_smspec_get_start_time( data->smspec );
  else {
    int internal_index = ecl_sum_data_iget_report_end( data , report_step );
    const ecl_sum_tstep_type * ministep = ecl_sum_data_iget_ministep( data , internal_index );
    return ecl_sum_tstep_get_sim_time( ministep );
  }
}
示例#5
0
void ecl_sum_data_init_data_vector( const ecl_sum_data_type * data , double_vector_type * data_vector , int data_index , bool report_only) {
  double_vector_reset( data_vector );
  double_vector_append( data_vector , ecl_smspec_get_start_time( data->smspec ));
  if (report_only) {
    int report_step;
    for (report_step = data->first_report_step; report_step <= data->last_report_step; report_step++) {
      int last_index = int_vector_iget(data->report_last_index , report_step);
      const ecl_sum_tstep_type * ministep = ecl_sum_data_iget_ministep( data , last_index );
      double_vector_append( data_vector , ecl_sum_tstep_iget( ministep , data_index ));
    }
  } else {
    int i;
    for (i = 0; i < vector_get_size(data->data); i++) {
      const ecl_sum_tstep_type * ministep = ecl_sum_data_iget_ministep( data , i  );
      double_vector_append( data_vector , ecl_sum_tstep_iget( ministep , data_index ));
    }
  }
}
示例#6
0
文件: ecl_sum.c 项目: flikka/ert
time_t ecl_sum_get_start_time( const ecl_sum_type * ecl_sum) {
  return ecl_smspec_get_start_time( ecl_sum->smspec );
}
示例#7
0
文件: ecl_sum.c 项目: flikka/ert
double ecl_sum_days_from_time( const ecl_sum_type * ecl_sum , time_t sim_time ) {
  double seconds_diff = util_difftime( ecl_smspec_get_start_time( ecl_sum->smspec ) , sim_time , NULL , NULL , NULL, NULL);
  return seconds_diff * 1.0 / (3600 * 24.0);
}
示例#8
0
文件: ecl_sum.c 项目: flikka/ert
time_t ecl_sum_time_from_days( const ecl_sum_type * ecl_sum , double sim_days ) {
  time_t t = ecl_smspec_get_start_time( ecl_sum->smspec );
  util_inplace_forward_days( &t , sim_days );
  return t;
}
示例#9
0
void ecl_sum_data_init_interp_from_sim_days( const ecl_sum_data_type * data , double sim_days, int *step1, int *step2 , double * weight1 , double *weight2) {
  time_t sim_time = ecl_smspec_get_start_time( data->smspec );
  util_inplace_forward_days( &sim_time , sim_days );
  ecl_sum_data_init_interp_from_sim_time( data , sim_time , step1 , step2 , weight1 , weight2);
}
示例#10
0
int ecl_sum_data_get_index_from_sim_days( const ecl_sum_data_type * data , double sim_days) {
  time_t sim_time = ecl_smspec_get_start_time( data->smspec );
  util_inplace_forward_days( &sim_time , sim_days );
  return ecl_sum_data_get_index_from_sim_time(data , sim_time );
}