void obs_vector_load_from_SUMMARY_OBSERVATION(obs_vector_type * obs_vector , const conf_instance_type * conf_instance , const history_type * history, ensemble_config_type * ensemble_config) { if(!conf_instance_is_of_class(conf_instance, "SUMMARY_OBSERVATION")) util_abort("%s: internal error. expected \"SUMMARY_OBSERVATION\" instance, got \"%s\".\n", __func__, conf_instance_get_class_name_ref(conf_instance) ); { double obs_value = conf_instance_get_item_value_double(conf_instance, "VALUE" ); double obs_error = conf_instance_get_item_value_double(conf_instance, "ERROR" ); double min_error = conf_instance_get_item_value_double(conf_instance, "ERROR_MIN"); const char * error_mode = conf_instance_get_item_value_ref( conf_instance, "ERROR_MODE"); const char * sum_key = conf_instance_get_item_value_ref( conf_instance, "KEY" ); const char * obs_key = conf_instance_get_name_ref(conf_instance); int size = history_get_last_restart( history ); int obs_restart_nr = __conf_instance_get_restart_nr(conf_instance , obs_key , history , size); if (obs_restart_nr == 0) { int day,month,year; time_t start_time = history_get_time_t_from_restart_nr( history , 0 ); util_set_date_values( start_time , &day , &month , &year); fprintf(stderr,"** ERROR: It is unfortunately not possible to use summary observations from the\n"); fprintf(stderr," start of the simulation. Problem with observation:%s at %02d/%02d/%4d\n",obs_key , day,month,year); exit(1); } { if (strcmp( error_mode , "REL") == 0) obs_error *= obs_value; else if (strcmp( error_mode , "RELMIN") == 0) obs_error = util_double_max( min_error , obs_error * obs_value ); obs_vector_add_summary_obs( obs_vector , obs_restart_nr , sum_key , obs_key , obs_value , obs_error , NULL , 0); } } }
static void __sched_file_summarize_line(int restart_nr , time_t start_time , time_t t , FILE * stream) { double days = util_difftime( start_time , t , NULL , NULL , NULL , NULL) / (24 * 3600); int mday , month , year; util_set_date_values(t , &mday , &month , &year); fprintf(stream , "%02d/%02d/%04d %7.1f days %04d \n", mday , month , year , days , restart_nr); }
void ecl_util_append_month_range( time_t_vector_type * date_list , time_t start_date , time_t end_date , bool force_append_end) { start_date = util_make_pure_date( start_date ); end_date = util_make_pure_date( end_date ); if (util_is_first_day_in_month( start_date)) time_t_vector_append( date_list , start_date ); { time_t current_date = start_date; while (true) { int month,year; util_set_date_values( current_date , NULL , &month , &year); if (month == 12) { month = 1; year += 1; } else month += 1; current_date = ecl_util_make_date( 1 , month , year ); if (current_date < end_date) time_t_vector_append( date_list , current_date ); else { if (current_date == end_date) time_t_vector_append( date_list , current_date ); else if (force_append_end) time_t_vector_append( date_list , end_date ); break; } } } }
int sched_file_get_restart_nr_from_time_t(const sched_file_type * sched_file, time_t time) { int num_restart_files = sched_file_get_num_restart_files(sched_file); for( int i=0; i<num_restart_files; i++ ) { time_t block_end_time = sched_file_iget_block_end_time(sched_file, i); if (block_end_time > time) { int mday,year,month; util_set_date_values( time , &mday , &month , &year); util_abort("%s: Date: %02d/%02d/%04d does not cooincide with any report time. Aborting.\n", __func__ , mday , month , year); } else if (block_end_time == time) return i; } // If we are here, time did'nt correspond a restart file. Abort. { int mday,year,month; util_set_date_values( time , &mday , &month , &year); util_abort("%s: Date: %02d/%02d/%04d does not cooincide with any report time. Aborting.\n", __func__ , mday , month , year); } return 0; }
void ecl_sum_data_summarize(const ecl_sum_data_type * data , FILE * stream) { fprintf(stream , "REPORT INDEX DATE DAYS\n"); fprintf(stream , "---------------------------------------------------------------\n"); { int index; for (index = 0; index < vector_get_size( data->data ); index++) { const ecl_sum_tstep_type * ministep = ecl_sum_data_iget_ministep( data , index ); int day,month,year; util_set_date_values( ecl_sum_tstep_get_sim_time( ministep ) , &day, &month , &year); fprintf(stream , "%04d %6d %02d/%02d/%4d %7.2f \n", ecl_sum_tstep_get_report( ministep ) , index , day,month,year, ecl_sum_tstep_get_sim_days( ministep )); } } fprintf(stream , "---------------------------------------------------------------\n"); }