void read_scan_header(FILE *fp, struct scan_header *hp) { char st[32]; int int_in; float float_in; do{ fscanf(fp, "%s", &st); if(strcmp(st, "Instrument") == 0) fscanf(fp, "%s", hp->inst); if(strcmp(st, "Source") == 0) fscanf(fp, "%s", hp->source); if(strcmp(st, "Location") == 0) fscanf(fp, "%s",hp->locat); if(strcmp(st, "Environment") == 0) fscanf(fp, "%s", hp->envir); if(strcmp(st, "Year") == 0){ fscanf(fp, "%d", &int_in); hp->year = int_in; } if(strcmp(st, "Day") == 0){ fscanf(fp, "%d", &int_in); hp->day = int_in; } if(strcmp(st, "Date") == 0) fscanf(fp, "%s", hp->date); if(strcmp(st, "Operation") == 0) fscanf(fp, "%s", hp->operat); if(strcmp(st, "Measurement_type") == 0) fscanf(fp, "%s", hp->meas_type); if(strcmp(st, "Measurement_purpose") == 0) fscanf(fp, "%s", hp->meas_purp); if(strcmp(st, "Number_of_scans") == 0){ fscanf(fp, "%d", &int_in); hp->n_scan = int_in; } if(strcmp(st, "Number_of_columns") == 0){ fscanf(fp, "%d", &int_in); hp->n_col = int_in; } if(strcmp(st, "Number_of_rows") == 0){ fscanf(fp, "%d", &int_in); hp->n_row = int_in; } if(strcmp(st, "Number_of_channels") == 0){ fscanf(fp, "%d", &int_in); hp->n_chan = int_in; } if(strcmp(st, "Start_time") == 0){ fscanf(fp, "%f%s", &float_in, hp->start_time_unit); hp->start_time = float_in; } if(strcmp(st, "Stop_time") == 0){ fscanf(fp, "%f%s", &float_in, hp->stop_time_unit); hp->stop_time = float_in; } if(strcmp(st, "Start_wavelength") == 0){ fscanf(fp, "%f%s", &float_in, hp->start_wl_unit); hp->start_wl = float_in; } if(strcmp(st, "Stop_wavelength") == 0){ fscanf(fp, "%f%s", &float_in, hp->stop_wl_unit); hp->stop_wl = float_in; } if(strcmp(st, "Increment_wavelength") == 0){ fscanf(fp, "%f%s", &float_in, hp->inc_wl_unit); hp->inc_wl = float_in; } if(strcmp(st, "Lamp_housing") == 0) fscanf(fp, "%s", hp->lamp_hs); if(strcmp(st, "Lamp_power_supply") == 0) fscanf(fp, "%s", hp->lamp_ps); if(strcmp(st, "Dark_signal") == 0){ fscanf(fp, "%f%s", &float_in, hp->dark_sig_unit); hp->dark_sig = float_in; } if(strcmp(st, "Filter_temperature") == 0){ fscanf(fp, "%f%s", &float_in, hp->filter_temp_unit); hp->filter_temp = float_in; } if(strcmp(st, "Detector_temperature") == 0){ fscanf(fp, "%f%s", &float_in, hp->detect_temp_unit); hp->detect_temp = float_in; } if(strcmp(st, "Motor_temperature") == 0){ fscanf(fp, "%f%s", &float_in, hp->motor_temp_unit); hp->motor_temp = float_in; } if(strcmp(st, "Housing_temperature") == 0){ fscanf(fp, "%f%s", &float_in, hp->housing_temp_unit); hp->housing_temp = float_in; } if(strcmp(st, "PMT_voltage") == 0){ fscanf(fp, "%f%s", &float_in, hp->pmt_volt_unit); hp->pmt_volt = float_in; } if(strcmp(st, "Integration_time") == 0){ fscanf(fp, "%f%s", &float_in, hp->int_time_unit); hp->int_time = float_in; } if(strcmp(st, "Dead_time") == 0){ fscanf(fp, "%f%s", &float_in, hp->dead_time_unit); hp->dead_time = float_in; } if(strcmp(st, "Stray_light_wavelength") == 0){ fscanf(fp, "%f%s", &float_in, hp->stray_wl_unit); hp->stray_wl = float_in; } if(strcmp(st, "Stray_light_signal") == 0){ fscanf(fp, "%f%s", &float_in, hp->stray_sig_unit); hp->stray_sig = float_in; } if(strcmp(st, "Comments") == 0) fscanf(fp, "%s", hp->comments); if(strcmp(st, "Data_file") == 0) fscanf(fp, "%s", hp->data_file); if(strcmp(st, "Format_program") == 0) fscanf(fp, "%s", hp->format_prog); if(strcmp(st, "Format_date") == 0) fscanf(fp, "%s", hp->format_date); if(strcmp(st, "Diffuse_file") == 0) fscanf(fp, "%s", hp->diffuse_file); if(strcmp(st, "Total_file") == 0) fscanf(fp, "%s", hp->total_file); if(strcmp(st, "Wavelength_file") == 0) fscanf(fp, "%s", hp->wl_file); if(strcmp(st, "Responsivity_file") == 0) fscanf(fp, "%s", hp->resp_file); if(strcmp(st, "Irradiance_file") == 0) fscanf(fp, "%s", hp->irrad_file); if(strcmp(st, "Uncertainty_file") == 0) fscanf(fp, "%s", hp->unc_file); if(strcmp(st, "Analysis_program") == 0) fscanf(fp, "%s", hp->analy_prog); if(strcmp(st, "Analysis_date") == 0) fscanf(fp, "%s", hp->analy_date); } while(strcmp(st, "Labels:") != 0); } /* ---------------------------------------------------------- */ void read_lamp_header(FILE *fp, struct lamp_header *hp) { char st[32]; int int_in; float float_in; do{ fscanf(fp, "%s", &st); if(strcmp(st, "Lamp") == 0) fscanf(fp, "%s", hp->lamp); if(strcmp(st, "Lamp_current") == 0){ fscanf(fp, "%f%s", &float_in, hp->cur_unit); hp->cur = float_in; } if(strcmp(st, "Lamp_voltage") == 0){ fscanf(fp, "%f%s", &float_in, hp->volt_unit); hp->volt = float_in; } if(strcmp(st, "Lamp_distance") == 0){ fscanf(fp, "%f%s", &float_in, hp->dist_unit); hp->dist = float_in; } if(strcmp(st, "Lamp_max_goniometry") == 0){ fscanf(fp, "%f", &float_in); hp->max_gonio = float_in; } if(strcmp(st, "Lamp_avg_goniometry") == 0){ fscanf(fp, "%f", &float_in); hp->avg_gonio = float_in; } if(strcmp(st, "Lamp_orientation") == 0) fscanf(fp, "%s", hp->orient); if(strcmp(st, "Lamp_housing") == 0) fscanf(fp, "%s", hp->lamp_hs); if(strcmp(st, "Calibration_date") == 0) fscanf(fp, "%s", hp->cal_date); if(strcmp(st, "Number_of_columns") == 0){ fscanf(fp, "%d", &int_in); hp->n_col = int_in; } if(strcmp(st, "Number_of_rows") == 0){ fscanf(fp, "%d", &int_in); hp->n_row = int_in; } } while(strcmp(st, "Labels:") != 0); } /* ---------------------------------------------------------- */ int read_labels(FILE *fp, int n_col, int **label, struct label_unit *unit) { int i, j; int *unit_flg; char st[64], stu[64]; unit_flg = ivector(1, n_col); for(i = 1; i <= n_col; i++){ unit_flg[i] = 0; } for(i = 1; i <= n_col; i++){ fscanf(fp, "%s", &st); if(strcmp(st, "Wavelength") == 0) unit_flg[i] = 1; if(strcmp(st, "Time") == 0) unit_flg[i] = 1; if(strcmp(st, "Signal") == 0) unit_flg[i] = 1; if(strcmp(st, "Irradiance") == 0) unit_flg[i] = 1; if(strcmp(st, "Responsivity") == 0) unit_flg[i] = 1; if(strcmp(st, "Dark_J") == 0) unit_flg[i] = 1; if(strcmp(st, "Dark_T") == 0) unit_flg[i] = 1; if(strcmp(st, "Dark_signal") == 0) unit_flg[i] = 1; if(strcmp(st, "Filter_temperature") == 0) unit_flg[i] = 1; if(strcmp(st, "Full_scale_counts") == 0) unit_flg[i] = 1; if(strcmp(st, "Integration_time") == 0) unit_flg[i] = 1; j = 0; while(st[j] != '\0'){ label[i][j+1] = st[j]; j++; } label[i][j+1] = '\0'; } for(i = 1; i <= n_col; i++){ if(unit_flg[i] == 1){ fscanf(fp, "%s", &st); j= 0; while(label[i][j+1] != '\0'){ stu[j] = label[i][j+1]; j++; } stu[j] = '\0'; if(strcmp(stu, "Wavelength") == 0) strcpy(unit->wl_unit, st); if(strcmp(stu, "Time") == 0) strcpy(unit->time_unit, st); if(strcmp(stu, "Signal") == 0) strcpy(unit->sig_unit, st); if(strcmp(stu, "Irradiance") == 0) strcpy(unit->irrad_unit, st); if(strcmp(stu, "Responsivity") == 0) strcpy(unit->resp_unit, st); if(strcmp(stu, "Dark_signal") == 0) strcpy(unit->dark_sig_unit, st); if(strcmp(stu, "Dark_J") == 0) strcpy(unit->darkj_sig_unit, st); if(strcmp(stu, "Dark_T") == 0) strcpy(unit->darkt_sig_unit, st); if(strcmp(stu, "Filter_temperature") == 0) strcpy(unit->filt_temp_unit, "[C]"); if(strcmp(stu, "Integration_time") == 0) strcpy(unit->int_time_unit, "[s]"); } } return 0; } /* ---------------------------------------------------------- */ void read_data(FILE *fp, int n_row, int n_col, float **data) { int i, j; char st[32]; do{ fscanf(fp, "%s", &st); } while(strcmp(st, "Data:") != 0); for(i = 1; i <= n_row; i++){ for(j = 1; j <= n_col; j++){ fscanf(fp, "%f", data[i] + j); } } } /* ---------------------------------------------------------- */ void read_unc(char file[], struct unc_data *unc) { int i; int n_row, n_col; float float_in; char st[80], unit[8], prob_dist[24]; FILE *fp; fp = fopen(file, "r"); do{ fscanf(fp, "%s", &st); } while(strcmp(st, "Number_of_columns") != 0); fscanf(fp, "%d", &n_col); do{ fscanf(fp, "%s", &st); } while(strcmp(st, "Number_of_rows") != 0); fscanf(fp, "%d", &n_row); do{ fscanf(fp, "%s", &st); } while(strcmp(st, "Data:") != 0); for(i = 1; i <= n_row; i++){ fscanf(fp, "%s", &st); if(strcmp(st, "Diffuser_radius") == 0){ fscanf(fp, "%f", &float_in); unc->radius = float_in; fscanf(fp, "%s%s", &unit, &prob_dist); } if(strcmp(st, "Lamp_current_systematic") == 0){ fscanf(fp, "%f", &float_in); unc->curr_sys = float_in; fscanf(fp, "%s%s", &unit, &prob_dist); } if(strcmp(st, "Lamp_current_random") == 0){ fscanf(fp, "%f", &float_in); unc->curr_rand = float_in; fscanf(fp, "%s%s", &unit, &prob_dist); } if(strcmp(st, "Wavelength_unc_c0") == 0){ fscanf(fp, "%f", &float_in); unc->wl_c0 = float_in; fscanf(fp, "%s%s", &unit, &prob_dist); } if(strcmp(st, "Wavelength_unc_c1") == 0){ fscanf(fp, "%e", &float_in); unc->wl_c1 = float_in; fscanf(fp, "%s%s", &unit, &prob_dist); } if(strcmp(st, "Wavelength_unc_c2") == 0){ fscanf(fp, "%e", &float_in); unc->wl_c2 = float_in; fscanf(fp, "%s%s", &unit, &prob_dist); } if(strcmp(st, "Alignment_perpendicular") == 0){ fscanf(fp, "%f", &float_in); unc->perp = float_in; fscanf(fp, "%s%s", &unit, &prob_dist); } if(strcmp(st, "Alignment_center") == 0){ fscanf(fp, "%f", &float_in); unc->center = float_in; fscanf(fp, "%s%s", &unit, &prob_dist); } if(strcmp(st, "Alignment_distance") == 0){ fscanf(fp, "%f", &float_in); unc->dist = float_in; fscanf(fp, "%s%s", &unit, &prob_dist); } } fclose(fp); }