diff --git a/src/HFS_API.cpp b/src/HFS_API.cpp index 5f316dfb2b87abf03ea468eb69d63b272891c873..7faab3e1f51e2cc3b832f384da0f062e0196c6ac 100644 --- a/src/HFS_API.cpp +++ b/src/HFS_API.cpp @@ -1,18 +1,9 @@ /** * @file HFS_API.cpp * @author Gerald Mösenlechner (gerald.moesenlechner@univie.ac.at) -* @date July, 2024 -* @version 1.3 +* @date November, 2024 +* @version 1.3.3 * -* @copyright -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, -* version 2, as published by the Free Software Foundation. -* -* This program is distributed in the hope it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. * @brief Functions for the generation of detector features, such as bias, dark and flats. * * @@ -36,6 +27,7 @@ const char* MODE_STBY = "Standby"; double smear_kernel_os[XDIM_KERNEL*5*YDIM_KERNEL*5]; double smear_kernel[XDIM_KERNEL*YDIM_KERNEL]; double bias_sample[128]; +double reset_sample[128]; double bias[XDIM*YDIM]; double dark[XDIM*YDIM]; double flat[XDIM*YDIM]; @@ -60,7 +52,6 @@ unsigned short reference_cal_master_FGS1[XDIM*YDIM]; unsigned short reference_cal_master_FGS2[XDIM*YDIM]; unsigned short reference_cal[XDIM*YDIM]; - /** * @brief resets all HFS parameters based on the provided configuration file * @@ -77,7 +68,7 @@ unsigned short reference_cal[XDIM*YDIM]; int FGS :: reset_fgs(const char* config_file, int hard_reset) { unsigned int i; - std::ifstream psf1_if, psf2_if, hp_if, flat_if, smear_if, ramp_if, img_if, reference_if; + std::ifstream psf1_if, psf2_if, hp_if, flat_if, smear_if, ramp_if, img_if, reference_if, queue_if; tinyxml2::XMLDocument config; config.LoadFile(config_file); tinyxml2::XMLElement *cRootElement = config.RootElement(); @@ -88,27 +79,31 @@ int FGS :: reset_fgs(const char* config_file, int hard_reset) const char* smear_buffer; const char* ramp_buffer; const char* img_buffer; + const char* queue_buffer; const char* psf1_buffer; const char* psf2_buffer; const char* catalogue_buffer; const char* modeInput; const char* reference_buffer1; const char* reference_buffer2; + struct coord centroid_buffer; + targets -> number = 0; /* Initialise smearing points and counters*/ x_smear_0 = 0.; y_smear_0 = 0.; sync_ctr = 0; - send_cent = 0; sim_time = 0.; trf_x = 0; trf_y = 0; sat_counter = 0; - + input_file = config_file; + /*parse xml file*/ if (NULL != cRootElement){ if(hard_reset == 1){ cRootElement -> FirstChildElement("simulation_time") -> QueryDoubleText(&sim_time); + cRootElement -> FirstChildElement("internal_time") -> QueryDoubleText(&internal_time); cRootElement -> FirstChildElement("timestep") -> QueryDoubleText(×tep); cRootElement -> FirstChildElement("random_seed") -> QueryUnsignedText(&rand_seed); cRootElement -> FirstChildElement("integration_start") -> QueryDoubleText(&start_exposure); @@ -130,6 +125,8 @@ int FGS :: reset_fgs(const char* config_file, int hard_reset) cRootElement -> FirstChildElement("reset_duration") -> QueryDoubleText(&reset_duration); cRootElement -> FirstChildElement("reset_end") -> QueryDoubleText(&reset_end); cRootElement -> FirstChildElement("timing_tolerance") -> QueryDoubleText(&timing_tolerance); + cRootElement -> FirstChildElement("timing_jitter") -> QueryDoubleText(&timing_jitter); + cRootElement -> FirstChildElement("timing_drift") -> QueryDoubleText(&timing_drift); /*Set random seed*/ srand(rand_seed); @@ -304,16 +301,22 @@ int FGS :: reset_fgs(const char* config_file, int hard_reset) cTracking -> FirstChildElement("iterations") -> QueryUnsignedText(&iter_track); cTracking -> FirstChildElement("median_filter") -> QueryUnsignedText(&med_track); cTracking -> FirstChildElement("thresholding") -> QueryUnsignedText(&threshold_track); - cTracking -> FirstChildElement("delay") -> QueryDoubleText(&delay_track); + cTracking -> FirstChildElement("delay_mean") -> QueryDoubleText(&delay_mean_track); + cTracking -> FirstChildElement("delay_std") -> QueryDoubleText(&delay_std_track); + cTracking -> FirstChildElement("delay_max") -> QueryDoubleText(&delay_max_track); + cTracking -> FirstChildElement("delay_min") -> QueryDoubleText(&delay_min_track); cTracking -> FirstChildElement("exposure_time") -> QueryDoubleText(&exp_track); cTracking -> FirstChildElement("tolerance") -> QueryUnsignedText(&tolerance_track); cTracking -> FirstChildElement("dim") -> QueryUnsignedText(&track_dim); - + //TDOD add delay jitter tinyxml2::XMLElement *cAcquisition = cRootElement -> FirstChildElement("Acquisition"); cAcquisition -> FirstChildElement("iterations") -> QueryUnsignedText(&iter_acq); cAcquisition -> FirstChildElement("median_filter") -> QueryUnsignedText(&med_acq); cAcquisition -> FirstChildElement("thresholding") -> QueryUnsignedText(&threshold_acq); - cAcquisition -> FirstChildElement("delay") -> QueryDoubleText(&delay_acq); + cAcquisition -> FirstChildElement("delay_mean") -> QueryDoubleText(&delay_mean_acq); + cAcquisition -> FirstChildElement("delay_std") -> QueryDoubleText(&delay_std_acq); + cAcquisition -> FirstChildElement("delay_max") -> QueryDoubleText(&delay_max_acq); + cAcquisition -> FirstChildElement("delay_min") -> QueryDoubleText(&delay_min_acq); cAcquisition -> FirstChildElement("exposure_time") -> QueryDoubleText(&exp_acq); cAcquisition -> FirstChildElement("tolerance") -> QueryUnsignedText(&tolerance_acq); cAcquisition -> FirstChildElement("FGS1_dim") -> QueryUnsignedText(&acq_dim_fgs1); @@ -331,15 +334,11 @@ int FGS :: reset_fgs(const char* config_file, int hard_reset) smear_buffer = cRootElement -> FirstChildElement("smear") -> GetText(); ramp_buffer = cRootElement -> FirstChildElement("ramp") -> GetText(); img_buffer = cRootElement -> FirstChildElement("previous_image") -> GetText(); + queue_buffer = cRootElement -> FirstChildElement("centroid_queue") -> GetText(); cRootElement -> FirstChildElement("smear_x") -> QueryDoubleText(&x_smear_0); cRootElement -> FirstChildElement("smear_y") -> QueryDoubleText(&y_smear_0); - cRootElement -> FirstChildElement("centroid_x") -> QueryFloatText(¢roid.x); - cRootElement -> FirstChildElement("centroid_y") -> QueryFloatText(¢roid.y); - cRootElement -> FirstChildElement("centroid_time") -> QueryFloatText(¢roid.time); - cRootElement -> FirstChildElement("centroid_valid") -> QueryIntText(¢roid.validity.flag); - cRootElement -> FirstChildElement("centroid_index") -> QueryFloatText(¢roid.validity.index); - cRootElement -> FirstChildElement("centroid_mag") -> QueryUnsignedText(¢roid.validity.magnitude); - cRootElement -> FirstChildElement("centroid_send") -> QueryUnsignedText(&send_cent); + cRootElement -> FirstChildElement("trf_x") -> QueryIntText(&trf_x); + cRootElement -> FirstChildElement("trf_y") -> QueryIntText(&trf_y); /*reset all image buffers*/ if(hard_reset){ reset_arrays(1); @@ -373,7 +372,12 @@ int FGS :: reset_fgs(const char* config_file, int hard_reset) if(strcmp(mode, MODE_ACQU) == 0){ exposure_time = exp_acq; - delay = delay_acq; + delay_mean = delay_mean_acq; + delay_std = delay_std_acq; + delay_max = delay_max_acq; + delay_min = delay_min_acq; + trf_x = 0; + trf_y = 0; if(channel == 1){ dim_x = acq_dim_fgs1; dim_y = acq_dim_fgs1; @@ -385,7 +389,10 @@ int FGS :: reset_fgs(const char* config_file, int hard_reset) } else if(strcmp(mode, MODE_TRAC) == 0){ exposure_time = exp_track; - delay = delay_track; + delay_mean = delay_mean_track; + delay_std = delay_std_track; + delay_max = delay_max_track; + delay_min = delay_min_track; /*Tracking uses 64x64 for both channels*/ dim_x = track_dim; dim_y = track_dim; @@ -393,7 +400,10 @@ int FGS :: reset_fgs(const char* config_file, int hard_reset) else{ /*Initialize values for Tracking if Standby is configured as default*/ exposure_time = exp_track; - delay = delay_track; + delay_mean = delay_mean_track; + delay_std = delay_std_track; + delay_max = delay_max_track; + delay_min = delay_min_track; /*Tracking uses 64x64 for both channels*/ dim_x = track_dim; dim_y = track_dim; @@ -482,6 +492,15 @@ int FGS :: reset_fgs(const char* config_file, int hard_reset) } img_if.close(); + + queue_if.open(queue_buffer, std::ifstream::in); + if (queue_if.is_open()){ + while(queue_if >> centroid_buffer.x >> centroid_buffer.y >> centroid_buffer.time >> centroid_buffer.integration_start >> centroid_buffer.validity.flag >> centroid_buffer.validity.index >> centroid_buffer.validity.magnitude){ + centroid_queue.push_front(centroid_buffer); + } + } + + queue_if.close(); } } else{ @@ -604,8 +623,6 @@ int FGS :: generate_image() previous_image[i] = tmp_image[i]; } } - - return 0; } @@ -619,7 +636,7 @@ int FGS :: generate_image() * */ -int FGS :: perform_algorithm() +struct coord FGS :: perform_algorithm() { unsigned int min = 0; struct coord output; @@ -667,10 +684,7 @@ int FGS :: perform_algorithm() } } - centroid.x = output.x; - centroid.y = output.y; - centroid.validity = output.validity; - return 0; + return output; } @@ -742,7 +756,10 @@ int FGS :: set_mode(const char* new_mode) /* Target Acquisition, 22 arcsec */ if(strcmp(mode, MODE_ACQU) == 0){ exposure_time = exp_acq; - delay = delay_acq; + delay_mean = delay_mean_acq; + delay_std = delay_std_acq; + delay_max = delay_max_acq; + delay_min = delay_min_acq; trf_x = 0; trf_y = 0; if(channel == 1){ @@ -756,7 +773,10 @@ int FGS :: set_mode(const char* new_mode) } else if(strcmp(mode, MODE_TRAC) == 0){ exposure_time = exp_track; - delay = delay_track; + delay_mean = delay_mean_track; + delay_std = delay_std_track; + delay_max = delay_max_track; + delay_min = delay_min_track; /*Tracking uses 64x64 for both channels*/ dim_x = track_dim; dim_y = track_dim; @@ -812,6 +832,7 @@ char flat_save[128]; char smear_save[128]; char ramp_save[128]; char img_save[128]; +char queue_save[128]; /** * @brief Creates an xml file based on the current HFS state @@ -827,8 +848,10 @@ char img_save[128]; int FGS :: generate_config(const char* output_file) { - std::ofstream flat_of, smear_of, ramp_of, img_of; + std::ofstream flat_of, smear_of, ramp_of, img_of, queue_of; unsigned int i; + std::deque<struct coord> centroid_queue_copy = centroid_queue; + tinyxml2::XMLDocument config; @@ -840,6 +863,10 @@ int FGS :: generate_config(const char* output_file) cTime->SetText(sim_time); cRoot->InsertEndChild(cTime); + tinyxml2::XMLElement* cIntTime = config.NewElement("internal_time"); + cIntTime->SetText(internal_time); + cRoot->InsertEndChild(cIntTime); + tinyxml2::XMLElement* cTimeStep = config.NewElement("timestep"); cTimeStep->SetText(timestep); cRoot->InsertEndChild(cTimeStep); @@ -903,6 +930,14 @@ int FGS :: generate_config(const char* output_file) tinyxml2::XMLElement* cTimingTol = config.NewElement("timing_tolerance"); cTimingTol->SetText(timing_tolerance); cRoot->InsertEndChild(cTimingTol); + + tinyxml2::XMLElement* cTimingJit = config.NewElement("timing_jitter"); + cTimingJit->SetText(timing_jitter); + cRoot->InsertEndChild(cTimingJit); + + tinyxml2::XMLElement* cTimingDrft = config.NewElement("timing_drift"); + cTimingDrft->SetText(timing_drift); + cRoot->InsertEndChild(cTimingDrft); tinyxml2::XMLElement* cFGSPSF1 = config.NewElement("FGS1_Psf"); cFGSPSF1->SetText(psf_fgs1.c_str()); @@ -1059,10 +1094,22 @@ int FGS :: generate_config(const char* output_file) cTrackThresh->SetText(threshold_track); cTracking->InsertEndChild(cTrackThresh); - tinyxml2::XMLElement* cTrackDelay = config.NewElement("delay"); - cTrackDelay->SetText(delay_track); + tinyxml2::XMLElement* cTrackDelay = config.NewElement("delay_mean"); + cTrackDelay->SetText(delay_mean_track); cTracking->InsertEndChild(cTrackDelay); + tinyxml2::XMLElement* cTrackDelayStd = config.NewElement("delay_std"); + cTrackDelayStd->SetText(delay_std_track); + cTracking->InsertEndChild(cTrackDelayStd); + + tinyxml2::XMLElement* cTrackDelayMax = config.NewElement("delay_max"); + cTrackDelayMax->SetText(delay_max_track); + cTracking->InsertEndChild(cTrackDelayMax); + + tinyxml2::XMLElement* cTrackDelayMin = config.NewElement("delay_min"); + cTrackDelayMin->SetText(delay_min_track); + cTracking->InsertEndChild(cTrackDelayMin); + tinyxml2::XMLElement* cTrackExp = config.NewElement("exposure_time"); cTrackExp->SetText(exp_track); cTracking->InsertEndChild(cTrackExp); @@ -1090,9 +1137,21 @@ int FGS :: generate_config(const char* output_file) cAcqThresh->SetText(threshold_acq); cAcquisition->InsertEndChild(cAcqThresh); - tinyxml2::XMLElement* cAcqDelay = config.NewElement("delay"); - cAcqDelay->SetText(delay_acq); + tinyxml2::XMLElement* cAcqDelay = config.NewElement("delay_mean"); + cAcqDelay->SetText(delay_mean_acq); cAcquisition->InsertEndChild(cAcqDelay); + + tinyxml2::XMLElement* cAcqDelayStd = config.NewElement("delay_std"); + cAcqDelayStd->SetText(delay_std_acq); + cAcquisition->InsertEndChild(cAcqDelayStd); + + tinyxml2::XMLElement* cAcqDelayMax = config.NewElement("delay_max"); + cAcqDelayMax->SetText(delay_max_acq); + cAcquisition->InsertEndChild(cAcqDelayMax); + + tinyxml2::XMLElement* cAcqDelayMin = config.NewElement("delay_min"); + cAcqDelayMin->SetText(delay_min_acq); + cAcquisition->InsertEndChild(cAcqDelayMin); tinyxml2::XMLElement* cAcqExp = config.NewElement("exposure_time"); cAcqExp->SetText(exp_acq); @@ -1134,6 +1193,8 @@ int FGS :: generate_config(const char* output_file) snprintf(img_save, sizeof(img_save), "./Previous_image_%.0f.txt", sim_time); + snprintf(queue_save, sizeof(queue_save), "./Centroid_queue_%.0f.txt", sim_time); + tinyxml2::XMLElement* cFlat = config.NewElement("flat"); cFlat->SetText(flat_save); cRoot->InsertEndChild(cFlat); @@ -1150,6 +1211,10 @@ int FGS :: generate_config(const char* output_file) cImage->SetText(img_save); cRoot->InsertEndChild(cImage); + tinyxml2::XMLElement* cQueue = config.NewElement("centroid_queue"); + cQueue->SetText(queue_save); + cRoot->InsertEndChild(cQueue); + tinyxml2::XMLElement* cSmearX = config.NewElement("smear_x"); cSmearX->SetText(x_smear_0); cRoot->InsertEndChild(cSmearX); @@ -1158,33 +1223,13 @@ int FGS :: generate_config(const char* output_file) cSmearY->SetText(y_smear_0); cRoot->InsertEndChild(cSmearY); - tinyxml2::XMLElement* cCenX = config.NewElement("centroid_x"); - cCenX->SetText(centroid.x); - cRoot->InsertEndChild(cCenX); - - tinyxml2::XMLElement* cCenY = config.NewElement("centroid_y"); - cCenY->SetText(centroid.y); - cRoot->InsertEndChild(cCenY); - - tinyxml2::XMLElement* cCenT = config.NewElement("centroid_time"); - cCenT->SetText(centroid.time); - cRoot->InsertEndChild(cCenT); - - tinyxml2::XMLElement* cCenVal = config.NewElement("centroid_valid"); - cCenVal->SetText(centroid.validity.flag); - cRoot->InsertEndChild(cCenVal); - - tinyxml2::XMLElement* cCenInd = config.NewElement("centroid_index"); - cCenInd->SetText(centroid.validity.index); - cRoot->InsertEndChild(cCenInd); - - tinyxml2::XMLElement* cCenMag = config.NewElement("centroid_mag"); - cCenMag->SetText(centroid.validity.magnitude); - cRoot->InsertEndChild(cCenMag); + tinyxml2::XMLElement* cTRFX = config.NewElement("trf_x"); + cTRFX->SetText(trf_x); + cRoot->InsertEndChild(cTRFX); - tinyxml2::XMLElement* cCenSen = config.NewElement("centroid_send"); - cCenSen->SetText(send_cent); - cRoot->InsertEndChild(cCenSen); + tinyxml2::XMLElement* cTRFY = config.NewElement("trf_y"); + cTRFY->SetText(trf_y); + cRoot->InsertEndChild(cTRFY); config.SaveFile(output_file); /*Write output files*/ @@ -1214,6 +1259,13 @@ int FGS :: generate_config(const char* output_file) } img_of.close(); + queue_of.open(queue_save, std::ofstream::out); + while(!centroid_queue_copy.empty()){ + queue_of << centroid_queue_copy.front().x << " " << centroid_queue_copy.front().y << " " << centroid_queue_copy.front().time << " " << centroid_queue_copy.front().integration_start << " " << centroid_queue_copy.front().validity.flag << " " << centroid_queue_copy.front().validity.index << " " << centroid_queue_copy.front().validity.magnitude << "\n"; + centroid_queue_copy.pop_front(); + } + queue_of.close(); + return 0; } @@ -1235,6 +1287,7 @@ struct hfs_state FGS :: get_hfs_state() output.gain = gain; output.exposure_time = exposure_time; output.sim_time = sim_time; + output.internal_time = internal_time; output.timestep = timestep; output.flat_mean = flat_mean; output.flat_sigma = flat_sigma; @@ -1251,12 +1304,12 @@ struct hfs_state FGS :: get_hfs_state() output.dim_y = dim_y; output.start_exposure = start_exposure; output.focal_length = focal_length; - output.delay = delay; + output.delay = delay_mean; output.x_smear_0 = x_smear_0; output.y_smear_0 = y_smear_0; output.jitter_error = jitter_error; - output.delay_track = delay_track; - output.delay_acq = delay_acq; + output.delay_track = delay_mean_track; + output.delay_acq = delay_mean_acq; output.transition_delay_channel = transition_delay_channel; output.transition_delay_mode = transition_delay_mode; output.transition_end = transition_end; @@ -1290,7 +1343,6 @@ struct hfs_state FGS :: get_hfs_state() output.full_well_cap = full_well_cap; output.med_threshold = med_threshold; output.sync_ctr = sync_ctr; - output.send_cent = send_cent; output.track_dim = track_dim; output.acq_dim_fgs1 = acq_dim_fgs1; output.acq_dim_fgs2 = acq_dim_fgs2; @@ -1315,7 +1367,6 @@ struct hfs_state FGS :: get_hfs_state() output.input_file = input_file; output.catalogue = catalogue; output.targets = targets; - output.centroid = centroid; return output; } @@ -1428,14 +1479,16 @@ int FGS :: transform_star_coordinates(double (&quaternion)[4], double (&velocity int FGS :: generate_centroid(hfs_parameters update) { - + std::ofstream outfile; + struct coord queue_in; + double delay = 0.; rand_seed = rand_seed * 1103515245 + 12345; transform_star_coordinates(update.position_quat, update.scVelocity); srand(rand_seed); random_normal_trm(bias_sample, 0, read_noise, 128); generate_image(); ramp_counter = ramp_counter + 1; - perform_algorithm(); + queue_in = perform_algorithm(); reset_arrays(0); if(ramp_counter >= ramp_length){ @@ -1444,25 +1497,35 @@ int FGS :: generate_centroid(hfs_parameters update) } x_smear_0 = 0.; y_smear_0 = 0.; - centroid.time = sim_time + delay; - calc_error(centroid.x, centroid.y); + + delay = random_normal_number(delay_mean, delay_std); + + if(delay < delay_min){ + delay = delay_min; + } + if(delay > delay_max){ + delay = delay_max; + } + + queue_in.time = internal_time + delay; + calc_error(queue_in.x, queue_in.y); /* Convert centroid to mas in FBT frame*/ - centroid.x = (centroid.x - dim_x/2) * plate_scale; - centroid.y = (centroid.y - dim_y/2) * plate_scale; + queue_in.x = (queue_in.x - dim_x/2) * plate_scale; + queue_in.y = (queue_in.y - dim_y/2) * plate_scale; - centroid.x = (centroid.x + random_normal_number(0, jitter_error) + ((double) update.add_shift_x)) * update.mult_shift_x; - centroid.y = (centroid.y + random_normal_number(0, jitter_error) + ((double) update.add_shift_y)) * update.mult_shift_y; + queue_in.x = (queue_in.x + random_normal_number(0, jitter_error) + ((double) update.add_shift_x)) * update.mult_shift_x; + queue_in.y = (queue_in.y + random_normal_number(0, jitter_error) + ((double) update.add_shift_y)) * update.mult_shift_y; - if(centroid.validity.index > 100 && centroid.validity.index < 106){ - centroid.x = 0; - centroid.y = 0; + if(queue_in.validity.index > 100 && queue_in.validity.index < 106){ + queue_in.x = 0; + queue_in.y = 0; } if(sat_counter >= sat_limit && strcmp(mode, MODE_ACQU) != 0){ - centroid.validity.flag = 0; - centroid.validity.index = 109; + queue_in.validity.flag = 109; + queue_in.validity.index = 0.; } - send_cent = 1; - + queue_in.integration_start = start_exposure; + centroid_queue.push_back(queue_in); return 0; } @@ -1471,14 +1534,14 @@ int FGS :: generate_centroid(hfs_parameters update) * * @return 0 on success */ -double tmp[XDIM*YDIM]; int FGS :: reset_ramp() { - unsigned int i; - random_normal_trm(tmp, bias_value*gain, reset_noise, XDIM*YDIM); + unsigned int i, index; + random_normal_trm(reset_sample, bias_value*gain, reset_noise, 128); for(i = 0; i < XDIM*YDIM; i++){ previous_image[i] = reference_cal[i]; - image_ramp[i] = (unsigned int) tmp[i]; + index = (unsigned int) (random() * (1. / RAND_MAX) * 128); + image_ramp[i] = (unsigned int) reset_sample[index]; } return 0; @@ -1493,20 +1556,25 @@ int FGS :: reset_ramp() int FGS :: send_centroid(hfs_parameters update, outputHfs *outPacket) { + struct coord queue_out; + + queue_out = centroid_queue.front(); + centroid_queue.pop_front(); + if(failed == 1){ outPacket -> failedState = failed; } else{ - outPacket -> x = centroid.x; - outPacket -> y = centroid.y; - outPacket -> validity_flag = centroid.validity.flag; - outPacket -> validity_index = centroid.validity.index; - outPacket -> magnitude = centroid.validity.magnitude; - outPacket -> time = centroid.time; + outPacket -> x = queue_out.x; + outPacket -> y = queue_out.y; + outPacket -> validity_flag = queue_out.validity.flag; + outPacket -> validity_index = queue_out.validity.index; + outPacket -> magnitude = queue_out.validity.magnitude; + outPacket -> time = queue_out.time; + outPacket -> integration_start = queue_out.integration_start; outPacket -> channel = channel; outPacket -> xErr = error.xErr; outPacket -> yErr = error.yErr; - send_cent = 0; if(strcmp(mode, MODE_TRAC) == 0){ outPacket -> mode = 2; @@ -1517,12 +1585,11 @@ int FGS :: send_centroid(hfs_parameters update, outputHfs *outPacket) } if(update.set_invalid != 0){ - outPacket -> validity_index = 100.; + outPacket -> validity_index = 0.; outPacket -> validity_flag = 0; } if(update.set_error != 0){ - outPacket -> validity_index = update.set_error; - outPacket -> validity_flag = 0; + outPacket -> validity_flag = update.set_error; } outPacket -> failedState = failed; } @@ -1577,7 +1644,7 @@ char string_buffer[64]; int FGS :: set_params(hfs_parameters update, outputHfs *outPacket) { const char* update_mode_char; - + if(update.save == 1){ snprintf(string_buffer, sizeof(string_buffer), "HFS_config_%.0f.xml", sim_time); generate_config(string_buffer); @@ -1592,27 +1659,17 @@ int FGS :: set_params(hfs_parameters update, outputHfs *outPacket) else update_mode_char = MODE_STBY; + if (update.time != 0 && update.time != sim_time){ + internal_time = internal_time + timestep + random_normal_number(timing_drift, timing_jitter); + } sim_time = update.time; + if(update.validation_signal != target_signal){ target_signal = update.validation_signal; calculate_ramp_length(); reset_ramp(); } - if((trf_x != update.target_pos_x || trf_y != update.target_pos_y) && (strcmp(mode, MODE_ACQU) != 0)){ - trf_x = update.target_pos_x; - trf_y = update.target_pos_y; - if(channel == 1){ - get_hp(hot_pixels, hot_pixel_master_FGS1, dim_x, dim_y, XDIM, YDIM, trf_x, trf_y); - get_calibration(reference_cal, reference_cal_master_FGS1, dim_x, dim_y, XDIM, YDIM, trf_x, trf_y); - } - else{ - get_hp(hot_pixels, hot_pixel_master_FGS2, dim_x, dim_y, XDIM, YDIM, trf_x, trf_y); - get_calibration(reference_cal, reference_cal_master_FGS2, dim_x, dim_y, XDIM, YDIM, trf_x, trf_y); - } - reset_ramp(); - } - if(update.set_error == 111 && failed == 0){ failed = 1; send_centroid(update, outPacket); @@ -1621,65 +1678,69 @@ int FGS :: set_params(hfs_parameters update, outputHfs *outPacket) /*Check if centroid shall be generated*/ if((strcmp(mode, MODE_ACQU) == 0 || strcmp(mode, MODE_TRAC) == 0) && reset_end == 0){ - if((start_exposure + exposure_time - timing_tolerance) < sim_time && transition_end == 0){ + if((start_exposure + exposure_time - timing_tolerance) < internal_time && transition_end == 0){ generate_smear(update.ang_rate, timestep); generate_centroid(update); - start_exposure = sim_time; + start_exposure = internal_time; } else if(transition_end == 0){ generate_smear(update.ang_rate, timestep); } if(transition_end == 0){ if((strcmp(mode, update_mode_char) != 0) && (channel != update.channel)){ - transition_end = sim_time + transition_delay_mode + transition_delay_channel; + transition_end = internal_time + transition_delay_mode + transition_delay_channel; } else if(strcmp(mode, update_mode_char) != 0){ - transition_end = sim_time + transition_delay_mode; + transition_end = internal_time + transition_delay_mode; } else if(channel != update.channel){ - transition_end = sim_time + transition_delay_channel; + transition_end = internal_time + transition_delay_channel; } } } else{ if(transition_end == 0){ if((strcmp(mode, update_mode_char) != 0) && (channel != update.channel)){ - transition_end = sim_time + transition_delay_mode + transition_delay_channel; + transition_end = internal_time + transition_delay_mode + transition_delay_channel; } else if(strcmp(mode, update_mode_char) != 0){ - transition_end = sim_time + transition_delay_mode; + transition_end = internal_time + transition_delay_mode; } else if(channel != update.channel){ - transition_end = sim_time + transition_delay_channel; + transition_end = internal_time + transition_delay_channel; } } } /* Check if centroid shall be sent*/ - if((centroid.time - timing_tolerance) < sim_time && send_cent == 1 && reset_end == 0){ + if((centroid_queue.front().time - timing_tolerance) < internal_time && (centroid_queue.front().time - timing_tolerance) > 0 && reset_end == 0 && !centroid_queue.empty()){ send_centroid(update, outPacket); } - if(transition_end != 0 && (transition_end - timing_tolerance) < sim_time && reset_end == 0){ + if(transition_end != 0 && (transition_end - timing_tolerance) < internal_time && reset_end == 0){ + if((trf_x != update.target_pos_x || trf_y != update.target_pos_y) && (strcmp(update_mode_char, MODE_TRAC) == 0)){ + trf_x = update.target_pos_x; + trf_y = update.target_pos_y; + } set_mode(update_mode_char); set_channel(update.channel); reset_arrays(0); x_smear_0 = 0.; y_smear_0 = 0.; transition_end = 0; - start_exposure = sim_time; + start_exposure = internal_time; } if(update.reset != 0){ - reset_end = sim_time + reset_duration; + reset_end = internal_time + reset_duration; } - if(reset_end != 0 && (reset_end - timing_tolerance) < sim_time){ - reset_fgs(input_file, 0); + if(reset_end != 0 && (reset_end - timing_tolerance) < internal_time){ + reset_fgs(input_file.c_str(), 0); reset_end = 0.; } if(failed == 1 && update.set_error != 111){ - reset_fgs(input_file, 0); + reset_fgs(input_file.c_str(), 0); failed = 0; } diff --git a/src/HFS_API.hpp b/src/HFS_API.hpp index f4c50834c686988c4ba5e959c825726ab513e036..b9e49d3ce1f5c16afa398930bde27f79dc69d1e2 100644 --- a/src/HFS_API.hpp +++ b/src/HFS_API.hpp @@ -1,18 +1,9 @@ /** * @file HFS_API.hpp * @author Gerald Mösenlechner (gerald.moesenlechner@univie.ac.at) -* @date July, 2024 -* @version 1.3 +* @date November, 2024 +* @version 1.3.3 * -* @copyright -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, -* version 2, as published by the Free Software Foundation. -* -* This program is distributed in the hope it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. * * * ## Overview @@ -29,6 +20,7 @@ #include <math.h> #include <stddef.h> #include <limits> +#include <queue> #include "./utilities.h" #include "./detector_features.h" #include "./fcu_algorithms.h" @@ -71,6 +63,7 @@ struct hfs_state double gain; double exposure_time; double sim_time; + double internal_time; double timestep; double flat_mean; double flat_sigma; @@ -114,7 +107,6 @@ struct hfs_state unsigned int full_well_cap; unsigned int med_threshold; unsigned int sync_ctr; - unsigned int send_cent; unsigned int track_dim; unsigned int acq_dim_fgs1; unsigned int acq_dim_fgs2; @@ -139,10 +131,9 @@ struct hfs_state int target_pos_y; std::string psf_fgs1; std::string psf_fgs2; - const char* input_file; + std::string input_file; std::string catalogue; struct stars* targets = new stars(); - struct coord centroid; }; /** @@ -187,23 +178,13 @@ typedef struct{ * * @param x,y: Position measurement in mas * @param time: time tag of the measurement - * @param last_sync: time tag of the last sync pulse + * @param integration_start: time tag of the beginning of the integration * @param validity_flag: Flag for the validity of the measurement * @param validity_index: quality index of the measurement (-1 to 1 or error code) * @param magnitude: signal of the measured star in ADU * @param channel: configured channel * @param mode: configured operational mode */ -typedef struct{ - double x; - double y; - double time; - int validity_flag; - double validity_index; - unsigned int magnitude; - unsigned int channel; - unsigned int mode; -}centroid_packet; typedef struct{ double xErr; @@ -214,6 +195,7 @@ typedef struct{ double x; double y; double time; + double integration_start; int validity_flag; double validity_index; unsigned int magnitude; @@ -264,6 +246,7 @@ class FGS{ double gain; double exposure_time; double sim_time; + double internal_time; double timestep; double flat_mean; double flat_sigma; @@ -280,12 +263,21 @@ class FGS{ double dim_y; double start_exposure; double focal_length; - double delay; + double delay_mean; + double delay_std; + double delay_max; + double delay_min; double x_smear_0; double y_smear_0; double jitter_error; - double delay_track; - double delay_acq; + double delay_mean_track; + double delay_std_track; + double delay_max_track; + double delay_min_track; + double delay_mean_acq; + double delay_std_acq; + double delay_max_acq; + double delay_min_acq; double transition_delay_mode; double transition_delay_channel; double transition_end; @@ -294,6 +286,8 @@ class FGS{ double reset_duration; double reset_end; double timing_tolerance; + double timing_jitter; + double timing_drift; double reset_noise; double fov_radius; int trf_x; @@ -311,7 +305,6 @@ class FGS{ unsigned int full_well_cap; unsigned int med_threshold; unsigned int sync_ctr; - unsigned int send_cent; unsigned int track_dim; unsigned int acq_dim_fgs1; unsigned int acq_dim_fgs2; @@ -336,21 +329,19 @@ class FGS{ const char* mode; std::string psf_fgs1; std::string psf_fgs2; - const char* input_file; + std::string input_file; std::string catalogue; std::string reference_data_fgs1; std::string reference_data_fgs2; std::string hp_map_fgs1; std::string hp_map_fgs2; struct stars* targets = new stars(); - struct coord centroid; + std::deque<struct coord> centroid_queue; centroidError error; public: FGS(const char* config_file){ - - input_file = config_file; reset_fgs(config_file, 1); }; @@ -361,7 +352,7 @@ public: int generate_image(); - int perform_algorithm(); + struct coord perform_algorithm(); int set_params(hfs_parameters, outputHfs*); diff --git a/src/HFS_Wrapper.cpp b/src/HFS_Wrapper.cpp index ba0b13ab330089ad7a3635239d997754cbb33f63..ddef6bb5120b08380eace41ecb1c15cffe853a5e 100644 --- a/src/HFS_Wrapper.cpp +++ b/src/HFS_Wrapper.cpp @@ -1,18 +1,9 @@ /** * @file HFS_Wrapper.cpp * @author Gerald Mösenlechner (gerald.moesenlechner@univie.ac.at) -* @date July, 2024 -* @version 1.3 +* @date November, 2024 +* @version 1.3.3 * -* @copyright -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, -* version 2, as published by the Free Software Foundation. -* -* This program is distributed in the hope it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. * @brief Code for the Matlab Simulink S-function implementation example * * diff --git a/src/HFS_config.xml b/src/HFS_config.xml index a7ab8d423b862be623b17ceee2c523e8ee02ccb2..d9fdf61c10ee594e8cd76823fb2a9e04b4dea480 100644 --- a/src/HFS_config.xml +++ b/src/HFS_config.xml @@ -1,6 +1,8 @@ <HFS_MetaInfo> <simulation_time>0.0</simulation_time> + <internal_time>0.0</internal_time> + <!-- Global timestep of the matlab simulink model. Default: 0.0125 (80Hz)--> <timestep>0.0125</timestep> @@ -59,6 +61,12 @@ and transitions, Default: 0.005--> <timing_tolerance>0.005</timing_tolerance> + <!-- Mean Timing Drift of the DCU Clock, Default: 1.8e-5--> + <timing_jitter>0.05</timing_jitter> + + <!-- Timing Drift Jitter of the DCU Clock, Default: 2e-6--> + <timing_drift>0.005</timing_drift> + <!-- relative path of the Psf input files. The psfs are given as 40x40px arrays that are stored in the C array format --> @@ -127,7 +135,7 @@ <!-- Threshold for the Pearson correlation used as the validity index. Index can range from -1 to 1. A value of 0.5 to 0.6 serves as a decent cutoff for invalid measurements--> - <validation_pearson_limit>0.5</validation_pearson_limit> + <validation_pearson_limit>0.6</validation_pearson_limit> <!-- default failed status of the HFS --> <failed_status>0</failed_status> @@ -172,9 +180,14 @@ <median_filter>1</median_filter> <!-- Toogle thresholding --> <thresholding>2</thresholding> - <!-- Delay of the centroid packet in seconds. - Note: must be lower than the integration time (0.125 s), worst case: 20ms --> - <delay>0.02</delay> + <!-- Mean Delay of the centroid packet in seconds, worst case: 50ms, Default: 40 --> + <delay_mean>0.05</delay_mean> + <!-- Std Delay of the centroid packet in seconds, Default: 10ms --> + <delay_std>0.01</delay_std> + <!-- Minumum Delay of the centroid packet in seconds, Default 35ms --> + <delay_min>0.03</delay_min> + <!-- Maximum Delay of the centroid packet in seconds, Default: 50ms --> + <delay_max>0.07</delay_max> <!-- Exposure time for mode Tracking in s, default: 0.1 --> <exposure_time>0.1</exposure_time> <!-- Brightness tolerance for Validation default is 30% --> @@ -191,9 +204,14 @@ <median_filter>1</median_filter> <!-- Toogle thresholding --> <thresholding>2</thresholding> - <!-- Delay of the centroid packet in seconds. - Note: must be lower than the integration time (0.5 s), worst case 150ms --> - <delay>0.15</delay> + <!-- Mean Delay of the centroid packet in seconds, worst case: 150ms, Default 125 --> + <delay_mean>0.05</delay_mean> + <!-- Std Delay of the centroid packet in seconds, Default 50ms --> + <delay_std>0.01</delay_std> + <!-- Minimum Delay of the centroid packet in seconds, Default: 100ms --> + <delay_min>0.03</delay_min> + <!-- Maximum Delay of the centroid packet in seconds, Default: 150ms --> + <delay_max>0.07</delay_max> <!-- Exposure time for mode Acquisition in s, default: 0.5 --> <exposure_time>0.5</exposure_time> <!-- Brightness tolerance for target identification default is 30% --> @@ -223,15 +241,12 @@ <previous_image>./previous_image.txt</previous_image> + <centroid_queue>./centroid_queue.txt</centroid_queue> + <smear_x>0.0</smear_x> <smear_y>0.0</smear_y> - <centroid_x>0</centroid_x> - <centroid_y>0</centroid_y> - <centroid_time>0</centroid_time> - <centroid_valid>0</centroid_valid> - <centroid_index>0</centroid_index> - <centroid_mag>0</centroid_mag> - <centroid_send>0</centroid_send> + <trf_x>0</trf_x> + <trf_y>0</trf_y> </HFS_MetaInfo> diff --git a/src/detector_features.c b/src/detector_features.c index 6133e394b752ee58332c6cd7a482aa81ca586849..6705b6b55e3e13ab77fef89aadbb33647edd55b2 100644 --- a/src/detector_features.c +++ b/src/detector_features.c @@ -1,18 +1,9 @@ /** * @file detector_features.c * @author Gerald Mösenlechner (gerald.moesenlechner@univie.ac.at) -* @date July, 2024 -* @version 1.3 +* @date November, 2024 +* @version 1.3.3 * -* @copyright -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, -* version 2, as published by the Free Software Foundation. -* -* This program is distributed in the hope it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. * @brief Functions for the generation of detector features, such as bias, dark and flats. * * @@ -161,9 +152,9 @@ void generate_flat(double *flatfield, double flat_mean, double flat_sigma, unsig */ void set_star_in_image(double *image, unsigned int width, unsigned int height, double x, double y, double signal) { - unsigned int px_x_low, px_y_low, px_x_high, px_y_high; double x_orig, y_orig; - + unsigned int i, j; + int x_pos[2], y_pos[2]; /*Starmask must be flipped due to origin change from convolution*/ x_orig = x; y_orig = y; @@ -171,17 +162,20 @@ void set_star_in_image(double *image, unsigned int width, unsigned int height, d x = x_orig + 0.5; y = y_orig + 0.5; - px_x_low = (int) (x - 0.5); - px_y_low = (int) (y - 0.5); - px_x_high = (int) (x + 0.5); - px_y_high = (int) (y + 0.5); - - - SET_PIXEL_SMEAR(image, height, px_x_low, px_y_low, (1.0-fabs((x_orig-px_x_low))) * (1.0-fabs((y_orig-px_y_low))) * signal); - SET_PIXEL_SMEAR(image, height, px_x_high, px_y_high, (1.0-fabs((x_orig-px_x_high))) * (1.0-fabs((y_orig-px_y_high))) * signal); - SET_PIXEL_SMEAR(image, height, px_x_low, px_y_high, (1.0-fabs((x_orig-px_x_low))) * (1.0-fabs((y_orig-px_y_high))) * signal); - SET_PIXEL_SMEAR(image, height, px_x_high, px_y_low, (1.0-fabs((x_orig-px_x_high))) * (1.0-fabs((y_orig-px_y_low))) * signal); + x_pos[0] = (int) (x - 0.5); + y_pos[0] = (int) (y - 0.5); + x_pos[1] = (int) (x + 0.5); + y_pos[1] = (int) (y + 0.5); + for(i = 0; i < 2; i++){ + for(j = 0; j < 2; j++){ + if(x_pos[i] >= 0 && x_pos[i] < width){ + if(y_pos[j] >= 0 && y_pos[j] < height){ + SET_PIXEL_SMEAR(image, height, x_pos[i], y_pos[j], (1.0-fabs((x_orig-x_pos[i]))) * (1.0-fabs((y_orig-y_pos[j])))*signal); + } + } + } + } } /* @@ -601,7 +595,6 @@ void apply_fov_mask(double *image, double *fov_mask, unsigned int width_img, uns y_start = (int) height_fov/2 - ((int) height_img/2 - y_img); for(i = 0; i < width_img; i++){ for(j = 0; j < height_img; j++){ - //printf("X: %d, Y: %d\n", x_start + i, y_start + j); if((x_start + i) >= 0 && (x_start + i) < width_fov){ if((y_start + j) >= 0 && (y_start + j) < height_fov){ tmp = (GET_PIXEL(image, width_img, i, j)) * (GET_PIXEL(fov_mask, width_fov, (x_start + i), (y_start + j))); diff --git a/src/fcu_algorithms.c b/src/fcu_algorithms.c index e089f9230aeeadc87c701637311edd61466247c1..17eb981816ac8c1632b596b40c19c65e35a0b25f 100644 --- a/src/fcu_algorithms.c +++ b/src/fcu_algorithms.c @@ -1,18 +1,9 @@ /** * @file fcu_algorithms.c * @author Gerald Mösenlechner (gerald.moesenlechner@univie.ac.at) -* @date July, 2024 -* @version 1.3 +* @date November, 2024 +* @version 1.3.3 * -* @copyright -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, -* version 2, as published by the Free Software Foundation. -* -* This program is distributed in the hope it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. *@brief Engineering algorithms for the DPU simulation. contains @ref Centroiding and @ref TargetAcquisition. * They are used in different situations and provide a centroid packet to the spacecraft. * @@ -135,18 +126,16 @@ void get_2D_gaussian (float *img, unsigned int cols, unsigned int rows, float ce float value; float xdist, ydist; float sigx, sigy; - float fval; + sigx = fwhm_x * SIGDIVFWHM; sigy = fwhm_y * SIGDIVFWHM; - fval = 1 / (sigx * sigy * TWO_PI); - for (y = 0; y < rows; y++){ for (x = 0; x < cols; x++){ xdist = x - center_x; ydist = y - center_y; - value = fval*exp(-((xdist*xdist)/(2*sigx*sigx)+(ydist*ydist)/(2*sigy*sigy))); + value = exp(-((xdist*xdist)/(2*sigx*sigx)+(ydist*ydist)/(2*sigy*sigy))); SET_PIXEL(img, cols, x, y, value); } } @@ -771,13 +760,15 @@ struct valpack CheckRoiForStar (unsigned int *data, unsigned int x_dim, unsigned binnedheight = y_dim / VALBINNING; } else{ - package.index = 111; + package.flag = 111; + package.index = 0.; package.magnitude = 0; return package; } if ((binnedwidth == 0) || (binnedheight == 0)){ - package.index = 111; + package.flag = 111; + package.index = 0.; package.magnitude = 0; return package; } @@ -821,28 +812,32 @@ struct valpack CheckRoiForStar (unsigned int *data, unsigned int x_dim, unsigned /* rule 1: the image must not be constant */ if (minimum == maximum){ - package.index = 101; + package.flag = 101; + package.index = 0.; package.magnitude = 0; return package; } /* rule 2: there must be a star */ if (mean < median){ - package.index = 102; + package.flag = 102; + package.index = 0.; package.magnitude = 0; return package; } /* rule 3: the star must be sharp */ if ((median + 2*sigma) > maximum){ - package.index = 103; + package.flag = 103; + package.index = 0.; package.magnitude = 0; return package; } /* rule 4: there must be a signal */ if ((maximum - minimum) < CenSignalLimit){ - package.index = 104; + package.flag = 104; + package.index = 0.; package.magnitude = 0; return package; } @@ -864,7 +859,8 @@ struct valpack CheckRoiForStar (unsigned int *data, unsigned int x_dim, unsigned mag = sum; if((abs(targetSignal - mag) > targetSignal*((float)signalTolerance/100)) && acq != 1){ - package.index = 107; + package.flag = 107; + package.index = 0.; package.magnitude = mag; return package; } @@ -887,10 +883,12 @@ struct valpack CheckRoiForStar (unsigned int *data, unsigned int x_dim, unsigned pearson_y = pearson_r(y_strip, ref_y, 25); if ((pearson_x*pearson_y) < PearsonLimit || pearson_x <= 0.0 || pearson_y <= 0.0){ - package.index = 106; + package.flag = 106; + package.index = 0.; } else{ package.index = pearson_x*pearson_y; + package.flag = 1; } package.magnitude = mag; return package; @@ -1142,12 +1140,6 @@ struct coord ArielCoG (unsigned int *img, unsigned int rows, unsigned int cols, res.validity = CheckRoiForStar (img, rows, cols, CenSignalLimit, PearsonLimit,fgs , res.x, res.y, signalTolerance, targetSignal, acq); - if(res.validity.index > 99){ - res.validity.flag = 0; - } - else{ - res.validity.flag = 1; - } return res; } @@ -1198,16 +1190,16 @@ struct coord SourceDetection(unsigned int *data, unsigned int xdim, unsigned int else{ result.x = 0; result.y = 0; - result.validity.index = 111; - result.validity.flag = 0; + result.validity.flag = 111; + result.validity.index = 0.; return result; } if ((binnedwidth == 0) || (binnedheight == 0)){ result.x = 0; result.y = 0; - result.validity.index = 111; - result.validity.flag = 0; + result.validity.flag = 111; + result.validity.index = 0.; return result; } @@ -1286,12 +1278,6 @@ struct coord SourceDetection(unsigned int *data, unsigned int xdim, unsigned int result.x = result.x + (float) (pos_x*BIN); result.y = result.y + (float) (pos_y*BIN); - if(result.validity.index > 99){ - result.validity.flag = 0; - } - else{ - result.validity.flag = 1; - } } else{ for(i=0; i < target_number; i++){ @@ -1300,16 +1286,19 @@ struct coord SourceDetection(unsigned int *data, unsigned int xdim, unsigned int pos_y = (source_pos[i] / binnedwidth); result.validity.magnitude = source_br[i]; if(ext_ctr[i] <= 6){ - result.validity.index = 108; + result.validity.flag = 108; + result.validity.index = 0.; break; } else{; - result.validity.index = 107; + result.validity.flag = 107; + result.validity.index = 0.; break; } } else{ - result.validity.index = 104; + result.validity.flag = 104; + result.validity.index = 0.; pos_x = 0; pos_y = 0; result.validity.magnitude = 0; @@ -1317,7 +1306,6 @@ struct coord SourceDetection(unsigned int *data, unsigned int xdim, unsigned int } result.x = (float) pos_x * BIN; result.y = (float) pos_y * BIN; - result.validity.flag = 0; } result.time = 0.; return result; diff --git a/src/fcu_algorithms.h b/src/fcu_algorithms.h index e6954da088389aeceb1431ec06364811b9b8e882..4515962051f02e7dfa44ab0e0c3a1221c18f047f 100644 --- a/src/fcu_algorithms.h +++ b/src/fcu_algorithms.h @@ -21,6 +21,7 @@ struct coord{ float x; float y; float time; + float integration_start; struct valpack validity; }; diff --git a/src/utilities.c b/src/utilities.c index 3e372bc6a8fe4286ad9bbc1bcc8a38278aeebf22..310166459a136dfa02f216b367bb61d7e8af9aa8 100644 --- a/src/utilities.c +++ b/src/utilities.c @@ -1,18 +1,9 @@ /** * @file utilities.c * @author Gerald Mösenlechner (gerald.moesenlechner@univie.ac.at) -* @date May, 2024 -* @version 1.2 +* @date November, 2024 +* @version 1.3.3 * -* @copyright -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, -* version 2, as published by the Free Software Foundation. -* -* This program is distributed in the hope it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. * @brief Utility functions for the data simulator for the ARIEL space mission. * *