/***************************************************************** * Name of source file: j_ima_iros_main.c * Version of source file: 4.0.7 * Parent component: None * Programmer: Niels Lund & Niels J. Westergaard * Affiliation: Danish National Space Center * Contact address: Juliane Maries Vej 30 * DK-2100 Copenhagen, Denmark * Phone: +45 35325705 FAX: +45 35362475 * njw@dnsc.dk * Purpose: Read a number of shadowgrams for a science window * and image reconstruction by backprojection * IROS and flux determination * Origin date: 041122 * Update history: 1.0.0 041122 First version * 1.0.4 050126 Test version for undue crash * 1.1.0 050131 Now reading FITS sky/backproj files * 1.1.1 050211 Keywords adapted to needs of j_ima_mosaic * 1.1.2 050303 Extra keyw:RLIMIDX, new cleaning * 1.1.3 050307 New DMAP: 51 radii * 1.1.4 050407 New clean, etc. * 1.1.4 050407 New clean, etc. * 1.1.5 050415 New clean again, updated flux determination * 1.1.6 050418 Now uses JMXi-DBKG-MOD as default for empty field shds * 1.2.0 050425 Deals with SPR 4102,4108 and reduces RAM requirement * 1.3.0 050503 Deals with SPR 4120 and copes with up to 6 shadowgrams * 1.3.1 050517 Deals with SPR 4143 and initializes ima_sigma properly * 1.3.2 050519 Closes SPR 4157 - bad size of three arrays * 1.3.3 050602 Changes some arrays to static (SPR 4202) * 1.4.0 050609 Introduction of pre-selected sources, correction of blindspot error * 1.4.0 050620 Include user defined sources (SCREW 1740) * 1.5.0 050620 Changes in connection with j_src_properties * 1.5.1 051129 Separating functions to jmx_lib_pif * 1.5.2 051202 Separating functions to jmx_lib_pif (2) * 1.5.3 051202 Give offX, x2x values in mm in IMOD-GRP * 1.5.4 060104 Bug in sh_depth corrected, detectmap now in mm * 1.5.5 060106 Introduced one more digit in logfile for src position * 1.5.6 060228 Removed parameter detMapFile and some obsolete variables * 1.5.7 060606 Shifted detCondMap to struct jmx_id and status_map * 1.6.0 060725 Reduce collimator height and disregard collimator thickness in b.proj-lists * 1.5.8 060807 SPR 04551 Bad assignment of RLIMIDX corrected * 1.5.9 060807 SPR 04533 Resetting status variable has been removed * 1.5.10 060807 SPR 04523 Declaring testsum as float iso. int * 1.5.11 060807 SPR 04458 A warning log line has been added * 1.5.12 060907 SPR 04301 A relative VIGNDOL path is given * 1.6.0 060911 SCREW 1918 Image correction map and parameters introduced * 1.6.1 060912 SPR 4441 Shadowgrams with too few counts are excluded * 1.6.2 060915 SCREW 1842 A significance map can now be obtained * 1.6.3 060915 An exposure (vignetting) map is now a product * 1.6.4 060928 Included test for zero divisor in peaktransfer.c * 1.6.5 061002 New defaults for par. skyImagesOut * 1.7.0 061110 Produces images with few or zero events (SPR 4594) * 1.7.1 061114 SPR 4603 Image unit (BUNIT) is now cts/dm2/s * 1.8.0 061213 SPR 4640 Error in findpeak has been corrected * 1.8.1 070123 SPR 4590 int changed to long for 64 bit code * 2.1.0 070730 Active use of input source catalog * 2.1.0 070809 SCREWs 2021-2023 * 2.1.1 070918 SPR 4729: Floating Point Exception * 2.1.2 070920 SPR 4731: Missing inialization fixed * 2.1.3 070920 SPR 4734: Another issing inialization fixed * 2.1.4 070921 SPR 4736: Fixing use of isnan function * 2.1.5 070925 SPR 4737: Bad array dimensioning fixed * 2.2.2 081111 Makes trigger rates from JEM-X HK available * 3.0.0 081111 SCREW 2080+1918 Electronic eff. corrections * 3.0.1 090114 SCREW 2098+2102+2105 and SPR 4812 * 3.0.2 090121 New table of sigma(PSF) is read * 3.0.X 090312 Catch exceptions for illegal aritmetic operations * 3.0.3 090324 SPR 4837 Floating point exceptions removed * 3.1.0 090401 SPR 4737,4846 floating exceptions and negative fluxes * 3.2.0 090422 SCREW 2135 Better time correction implemented * 3.2.1 090507 SPR 4863 Bug fix in interpolation algorithm * 3.2.2 090514 SPR 4866+4869 Uninitialized variable problem * 3.2.3 090602 SPR 4875 Error in peak reintroduction * 3.2.4 090720 SPR 4886 Fix a divide by zero (BEO) * 3.2.6 091204 SCREW 2180/2181 Improve source finding/remove ghosts * 4.0.3 120423 SPR ?: Better flux error, 100 flag sources allowed * 4.0.3 120423 SPR ?: Better flux error, 100 flag sources allowed * 4.0.4 120430 SPR ?: Still better flux error estimation * 4.0.5 120607 SPR ?: Still better flux error estimation * 4.0.6 120628 SPR ?: Reduced memory allocation demands * 4.0.7 120710 SPR ?: Flux error estimates as in version 3.2.7 * Type of element: Executable * Part of package: j_ima_iros * Name: j_ima_iros_main * Calls: * Returns: * Required components: DAL, PIL, RIL, DAL3GEN Basic error code offset: J_ERROR_CODE_START + J_IMA_IROS_ERR J_IIR_WRONG_JEMX_NUM (-1): Called with illegal value of jemxNum J_IIR_NOT_IN_SMODE (-2): Started when not in ISDC_SINGLE_MODE J_IIR_MEMB_WRONG_NUM (-3): Inconsistency: numbers of members J_IIR_SHDIDEN_ERROR (-4): Problem with shadowgram identifications J_IIR_IGNORE_ERROR (-5): Incorrect number of ignored anodes *****************************************************************/ /* Enable catching exceptions for illegal aritmetic operations */ /* Bruce O'Neel/NielsLund 20090314 */ /* But only for Linux */ #ifdef linux #include #endif #include long STRUCT_SIZE(void); int main (int argc, char *argv[]) { static struct instr_data JID; static struct log_con LOG; /* static struct imagerec IR; */ Events *bufevents = NULL; /* Created in j_ima_iros_prepare */ long numEvents = 0; /* Number of events in event list */ timeslices *Tslices = NULL; /* structure containing information about light curve time bins */ goodsrc *GOODSRC = NULL; /* structure containing information about source candidates found */ userbin *USERBIN = NULL; /* structure containing information about user defined energy bins */ static struct scwlist SCW[2]; int status = ISDC_OK; int mode = 0; /* Running mode of this executable */ int chatter = 0; /* Level of debugging/monitoring output */ int showtime = 1; /* only used to control output of time spending in various functions */ Instrument jemxNum=JMX1; /* Number of JEM-X unit, should be JMX1 or JMX2 */ dal_element *theSWG = NULL; /* Pointer to SWG group */ char resultxt[150]; char instMod[DAL_FILE_NAME_STRING]; char bkgShdDOL[DAL_FILE_NAME_STRING]; int i=0, j=0, k, crabfound=0; int useDeadAnodes = 0; int yes2all=0; int images_out_control; int develop_control; int search_images_out; int mosaic_images_out; long GSRClength = 0; long USERlength = 0; long Tsliceslength = 0; float diff_RA=0.0, diff_dec=0.0, diff=0.0, oldRA=0.0, olddec=0.0; double testG_L, testG_B, testRA, testdec; float tid=0.0; FILE *trace; struct instr_data *jmx_id = {&JID}; struct log_con *logger = {&LOG}; struct backpro *backproj; struct shadowgrams *sh; struct backpro_lists *bp; swg_pointing point; Auxdata auxdata; /* Auxiliary data such as gain, deadtime, greyfilter, and GTI */ Shd_adhoc shd_adhoc; /* A struct to hold the current working shadowgram */ static int func_local=-1, local_calling_num=0; clock_t calling_TT, TT_now; /* Enable catching exceptions for illegal aritmetic operations Bruce O'Neel/NielsLund 20090314 */ /* but only for Linux */ #ifdef linux feenableexcept(FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW); #endif logger->trace = 1; logger->i5 = 5; images_out_control = 1; develop_control = 1; search_images_out = 1; mosaic_images_out = 1; if (logger->trace == 1) { trace = fopen("imatrace.txt", "w"); fprintf(trace, " main %d\n", 0); fprintf(trace, "j_ima_iros successfully started\n"); fclose(trace); } for (i=0; idontUseShdg[i] = 0; do { /* Use a once-only do/while loop to force program termination whenever status returned is not ISDC_OK */ /* * * Initialisation * */ mode = CommonInit(COMPONENT_NAME, COMPONENT_VERSION,argc,argv); if (mode != ISDC_SINGLE_MODE) { RILlogMessage(NULL, Error_2, "Not started in ISDC_SINGLE_MODE, mode = %d", mode); status = J_ERROR_CODE_START + J_IMA_IROS_ERR + J_IIR_NOT_IN_SMODE; continue; } RILlogMessage( NULL, Log_0, "##000## of j_ima_iros_main" ); for (i=0; ifunc_times[i] = 0.0; /* function entry timing start */ if (func_local < 0) { func_local = 0; logger->func_used_num = 1; logger->func_calling_num = 0; sprintf(logger->func_names[func_local], "main"); if (logger->func_used_num >= J_IIR_MAX_NUM_FUNCS) { RILlogMessage( NULL, Error_1,"##1## func_used_num too large"); sprintf(logger->tmptxt, "func_used_num >= %d\n", J_IIR_MAX_NUM_FUNCS); logger->func_used_num--; logger->logstat = logprint(logger, logger->tmptxt, 6); logger->func_used_num = J_IIR_MAX_NUM_FUNCS; } } logger->func_calls[func_local]++; logger->TT = TT_now = clock(); calling_TT = logger->TT; local_calling_num = logger->func_calling_num; logger->func_calling_num = func_local; /* function entry timing end */ RILlogMessage( NULL, Log_0, "##2## of j_ima_iros_main" ); /* initialisation */ logger->develop = 8192; /* disable time_slope corrections */ logger->develop = 5123; /* disable off-axis corrections, disable all obs-period corrections */ /* no corrections active, call update, output calibout */ logger->develop = 4099; /* disable off-axis corrections */ /* obs. per. corrections active, call update, output calibout */ logger->develop = 2051; /* disable all obs-period corrections except for JMX1 Carls period */ /* off_axis corrections active, call update, output calibout */ logger->develop = 3; /* all corrections active, call update, output calibout */ logger->develop = 1; /* all corrections active, DO NOT call update, output calibout */ logger->develop = 0; /* OSA configuration */ /* |= 1: output of 'calibout.bin' and 'par_chk.txt' files */ /* |= 2: call of 'jmx_lib_pif/update_imod_data.c' */ /* |= 1024: Disable orbit efficiency correction for all observation periods */ /* |= 2048: Disable orbit efficiency correction for all periods except JMX1 after rev 170 */ /* |= 4096: Disable calls to off_axis_corretion subroutines */ /********* SHOW TIME ************/ showtime = 1; if (develop_control) logger->develop = 1; /* all corrections active, DO NOT call update, output calibout */ else logger->develop = 0; /* OSA configuration, all corrections active, DO NOT call update, DO NOT output calibout */ logger->len_jmx_id = sizeof(JID); sprintf(logger->tmptxt, "sizeof(instr_data): %10d", logger->len_jmx_id); logger->logstat = logprint(logger, logger->tmptxt, 0); sprintf(logger->tmptxt, "sizeof(log_con): %10d", sizeof(LOG)); logger->logstat = logprint(logger, logger->tmptxt, 0); sprintf(logger->tmptxt, "sizeof(backpro_lists): %10d", sizeof(struct backpro_lists)); logger->logstat = logprint(logger, logger->tmptxt, 0); if ((bp = (struct backpro_lists*)(malloc(sizeof(struct backpro_lists)))) == NULL) { RILlogMessage( NULL, Error_1, "##20## Not enough memory for 'backpro_lists' malloc (%d bytes)", sizeof(struct backpro_lists)); continue; } sprintf(logger->tmptxt, "sizeof(backpro): %10d", sizeof(struct backpro)); logger->logstat = logprint(logger, logger->tmptxt, 0); if ((backproj = (struct backpro*)(malloc(sizeof(struct backpro)))) == NULL) { RILlogMessage( NULL, Error_1, "##20## Not enough memory for 'backpro' malloc (%d bytes)", sizeof(struct backpro)); continue; } sprintf(logger->tmptxt, "sizeof(shadowgrams): %10d", sizeof(struct shadowgrams)); logger->logstat = logprint(logger, logger->tmptxt, 0); if ((sh = (struct shadowgrams*)(malloc(sizeof(struct shadowgrams)))) == NULL) { RILlogMessage( NULL, Error_1, "##20## Not enough memory for 'shadowgram' malloc (%d bytes)", sizeof(struct shadowgrams)); continue; } for (i=0; ifitsimage[j][0][i] = 0.0; backproj->fitsimage[j][1][i] = 0.0; backproj->fitsimage[j][2][i] = 0.0; backproj->fitsimage[j][3][i] = 0.0; backproj->fitsimage[j][4][i] = 0.0; backproj->fitsimage[j][5][i] = 0.0; } backproj->skyim_r[i] = 0.0; backproj->skyeff[i] = 0.0; } RILlogMessage( NULL, Log_0, "##2a# of j_ima_iros_main" ); for (i=0; id_allow_st[i] = 0; bp->d_allow_p[i] = 0; bp->d_allow_l[i] = 0; bp->o_allow_subl[i] = 0; bp->o_allow_st[i] = 0; bp->bad_pix_shdg[i] = 0.0; logger->resid1[i] = 0.0; backproj->soft_gr[i] = 0.0; backproj->shadw[i] = 0.0; backproj->effic[i] = 0.0; backproj->src_only_map[i] = 0.0; backproj->empty_norm[i] = 0.0; backproj->current_src_map[i] = 0.0; for (j=0; jpif_maps[j][i] = 0.0; backproj->pifeff_maps[j][i] = 0.0; } for (j=0; jempty[j][i] = 0.0; sh->soft_shdgr[j][i] = 0.0; } sh->common_select_map[i] = 0; } RILlogMessage( NULL, Log_0, "##2b# of j_ima_iros_main" ); bp->d_allow = NULL; for (i=0; i<150; i++) resultxt[i] = 0; strcpy( resultxt, "Content of resultxt"); /* * * Get the parameters, get instrument data, and prepare access to * data structures (open the connections) * */ backproj->makeNewBPL = 0; sprintf(backproj->newBackProjFile, ""); status = j_ima_iros_params( &theSWG, /* Pointer to the SWG */ &jemxNum, instMod, /* Instrument Model DOL */ bkgShdDOL, /* DOL of empty field shadowgrams */ logger, backproj, bp, sh, &useDeadAnodes, /* same as 'dead_ano' in orig. version */ &yes2all, /* same as 'yes2all' in orig. version */ &chatter, status ); if (images_out_control) { /* NL 2012_05_24 */ logger->detImagesOut = search_images_out; /* NL 2010_04_21 */ logger->userImagesOut = mosaic_images_out; /* NL 2012_05_24 */ } /* NL 2012_05_24 */ if (status != ISDC_OK) { RILlogMessage(NULL, Error_2, "##3## Problem getting parameters etc., status = %d\n", status); continue; } if( chatter > J_CHATTY_VERBOSE ) { RILlogMessage( NULL, Log_0, "##4## returned from j_ima_iros_params"); RILlogMessage( NULL, Log_0, "##5## useDeadAnodes: %d", useDeadAnodes); RILlogMessage( NULL, Log_0, "##6## yes2all: %d", yes2all); RILlogMessage( NULL, Log_0, "##7## drl_par[3] = %f", logger->drl_par[3]); } logger->N_SCW = 0; logger->N_SRC = logger->N_SRC2 = 0; backproj->sky_version = 'n'; /* printf("##7777## After params: logger->edge: %f\n", logger->edge); */ /* logger->userImagesOut = 1; */ j = getNumShds(theSWG, jemxNum, sh, logger, chatter, status); /* get number of shadowgrams to process */ /* printf("##7777## After getNumShds: logger->edge: %f\n", logger->edge); */ sh->numShds = j; backproj->ee_max = sh->numShds; if (sh->numShds > 256) sh->numShds = 256; USERlength = sh->numShds * sizeof(userbin); RILlogMessage( NULL, Log_0, "##2534## USERBIN: no of bins: %3d, length of userbin: %ld, length of USERBIN: %d", sh->numShds, sizeof(userbin), USERlength); if ((USERBIN = (userbin*)(malloc(USERlength))) == NULL) { RILlogMessage( NULL, Error_1, "##20## Not enough memory for 'USERBIN' malloc (%ld bytes)", USERlength); continue; } RILlogMessage( NULL, Log_0, "##2d## of j_ima_iros_main" ); for (i=0; inumShds; j++) { USERBIN[j].variance[i] = 0.0; USERBIN[j].fst_imag[i] = 0.0; USERBIN[j].eff_imag[i] = 0.0; USERBIN[j].illumnew[i] = 0; } } for (i=0; inumShds; j++) { USERBIN[j].shadow[i] = 0.0; USERBIN[j].soft_gr[i] = 0.0; USERBIN[j].f_shadgram[i] = 0.0; USERBIN[j].effic_shdg[i] = 0.0; } } RILlogMessage( NULL, Log_0, "##2e## of j_ima_iros_main" ); if( chatter > J_CHATTY_NORMAL ) { RILlogMessage( NULL, Log_0, "##8## just before j_ima_iros_prepare"); } status = j_ima_iros_prepare( theSWG, jemxNum, instMod, resultxt, bkgShdDOL, /* DOL of empty field shadowgrams */ &bufevents, &numEvents, &auxdata, /* such as gain, GTI, and grey filter */ jmx_id, logger, /* struct log_con */ backproj, /* struct backpro */ sh, /* struct shadowgrams */ bp, /* struct backpro_lists */ USERBIN, /* struct userbin (with shadowgrams) */ &(SCW[logger->N_SCW]), &point, useDeadAnodes, chatter, status); if (status != ISDC_OK) { RILlogMessage( NULL, Error_1, "##9## After j_ima_iros_prepare, status = %d", status); continue; } /* fits output for Niels Landvad. Start */ status = fits_test_output("shadow_", USERBIN[0].shadow, 256, logger, chatter, status); status = fits_test_output("soft_gr_", USERBIN[0].soft_gr, 256, logger, chatter, status); status = fits_test_output("effic_shdg_", USERBIN[0].effic_shdg, 256, logger, chatter, status); status = fits_test_output("f_shadgram_", USERBIN[0].f_shadgram, 256, logger, chatter, status); /* fits output for Niels Landvad. End */ if( chatter > J_CHATTY_NORMAL ) { RILlogMessage( NULL, Log_0, "##10## after j_ima_iros_prepare"); } RILlogMessage(NULL,Log_0,"##7777## After prepare: logger->edge: %f, c_tiltx/y: %f %f", logger->edge, jmx_id->c_tiltx, jmx_id->c_tilty); /* QQQQQ 20080930 Niels Lund. Test print of eeff parameters */ sprintf(logger->tmptxt, "orbit: %3d, eeff_pha vals: ", backproj->aux_orbit); for (i=0; i<16; i++) { sprintf(logger->tmptxt2, " %5.1f", jmx_id->eeff_pha[i]); if ((strlen(logger->tmptxt) + strlen(logger->tmptxt2)) < MAX_STR_LEN) strcat(logger->tmptxt, logger->tmptxt2); } logger->logstat = logprint(logger, logger->tmptxt, 0); sprintf(logger->tmptxt, "orbit: %3d, eeff_pha vals: ", backproj->aux_orbit); for (i=0; i<16; i++) { sprintf(logger->tmptxt2, " %5.1f", jmx_id->eeff_pha[i]); if ((strlen(logger->tmptxt) + strlen(logger->tmptxt2)) < MAX_STR_LEN) strcat(logger->tmptxt, logger->tmptxt2); } logger->logstat = logprint(logger, logger->tmptxt, 0); sprintf(logger->tmptxt, "orbit: %3d, XvsE[0][i] : ", backproj->aux_orbit); for (i=0; i<16; i++) { sprintf(logger->tmptxt2, " %5.3f", jmx_id->XvsE[0][i] ); if ((strlen(logger->tmptxt) + strlen(logger->tmptxt2)) < MAX_STR_LEN) strcat(logger->tmptxt, logger->tmptxt2); } logger->logstat = logprint(logger, logger->tmptxt, 0); sprintf(logger->tmptxt, "orbit: %3d, YvsE[0][i] : ", backproj->aux_orbit); for (i=0; i<16; i++) { sprintf(logger->tmptxt2, " %5.3f", jmx_id->YvsE[0][i]); if ((strlen(logger->tmptxt) + strlen(logger->tmptxt2)) < MAX_STR_LEN) strcat(logger->tmptxt, logger->tmptxt2); } logger->logstat = logprint(logger, logger->tmptxt, 0); /* QQQQQ 20080512 Niels Lund. Modify Crab-like sources in catalog to JEM-X Crab coordinates */ crabfound = 0; for (j=0; jpreset_src; j++) { diff_RA = backproj->preset_src_RA[j] - 83.6308; diff_dec = backproj->preset_src_dec[j] - 22.0170; diff = diff_RA * diff_RA + diff_dec * diff_dec; diff = sqrt(diff); oldRA = backproj->preset_src_RA[j]; olddec = backproj->preset_src_dec[j]; if (diff < 0.01) { if (crabfound) { backproj->preset_src_RA[j] = 83.6308; backproj->preset_src_dec[j] = 92.0170; /* dummy value for all furter crab like sources */ } else { backproj->preset_src_RA[j] = 83.6308; /* mean JEM-X1/-X2 Crab position 20080512, Niels Lund */ backproj->preset_src_dec[j] = 22.0170; crabfound = 1; } RILlogMessage(NULL,Log_0,"##7777## After prepare: Old Crab position: %8.4f %8.4f, new: %8.4f %8.4f, crab# %1d", oldRA, olddec, backproj->preset_src_RA[j], backproj->preset_src_dec[j], crabfound); } } /* Erased 080731/NJW * * get_CURTAIN_array(jmx_id->jmx_unit, jmx_id, logger); * * jmx_id->num_eeff_vals = get_EEFF_array(backproj, jmx_id, logger); * printf("Number of table entries in EEFF-array: %3d, first values: %f %f %f\n", * jmx_id->num_eeff_vals, jmx_id->eeff[0], jmx_id->eeff[1], jmx_id->eeff[2]); */ /* status = report_arr("##11## f_shadgram[0]", USERBIN[0].f_shadgram, detdim, status); status = report_arr("##12## f_shadgram[1]", USERBIN[1].f_shadgram, detdim, status); status = report_arr("##13## f_shadgram[2]", USERBIN[2].f_shadgram, detdim, status); status = report_arr("##14## bp empty[0]", backproj->empty[0], detdim, status); status = report_arr("##15## bp empty[1]", backproj->empty[1], detdim, status); status = report_arr("##16## bp empty[2]", backproj->empty[2], detdim, status); status = report_arr("##17## soft_shdgr[0]", USERBIN[0].soft_shdgr, detdim, status); status = report_arr("##18## soft_shdgr[1]", USERBIN[1].soft_shdgr, detdim, status); status = report_arr("##19## soft_shdgr[2]", USERBIN[2].soft_shdgr, detdim, status); */ /* * If a name has been given for a new backprojection file (newBackProjFile) * and the Boolean parameter 'makeNewBPL' has been set to 'yes' * then create that but skip the remainder under the assumption that if the * user wants to create a new one then it is for use afterwards */ /* * skymap_init(backproj, jmx_id, logger, bp); * status = mask_test( logger, jmx_id, bp ); */ if( strlen(backproj->newBackProjFile) > 0 && backproj->makeNewBPL ) { if ((bp->d_allow = malloc(max_sky_bytes)) == NULL) { RILlogMessage( NULL, Error_1, "##20## Not enough memory for 'd_allow' malloc (%ld bytes)", max_sky_bytes); continue; } sprintf(logger->tmptxt, "Before calling 'skymap_gen': mask_height: %f", jmx_id->mask_height); logger->logstat = logprint(logger, logger->tmptxt, 5); status = skymap_gen( jmx_id, logger, backproj, bp, sh, chatter, status); /* The filename is handed over via 'backproj' */ if( status != ISDC_OK ) { RILlogMessage( NULL, Error_1, "##21## After skymap_gen, status = %d", status); continue; } } else { /* backproj->preset_src = 0; */ /* ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ */ if (backproj->preset_src > 100) backproj->preset_src = 100; GSRClength = (backproj->preset_src + SCW_SRCMAX) * sizeof(goodsrc); Tsliceslength = 2 * sizeof(goodsrc); RILlogMessage(NULL,Log_0, "##6231## GOODSRC: preset_src: %3d, SCW_SRCMAX: %4d, goodsrc lngth: %d, GOODSRC lngth: %ld, timeslice: %ld", backproj->preset_src, SCW_SRCMAX, sizeof(goodsrc), GSRClength, sizeof(timeslices)); if ((GOODSRC = (goodsrc*)(malloc(GSRClength))) == NULL) { RILlogMessage( NULL, Error_1, "##20## Not enough memory for 'GOODSRC' malloc (%ld bytes)", GSRClength); continue; } if ((Tslices = (timeslices*)(malloc(Tsliceslength))) == NULL) { RILlogMessage( NULL, Error_1, "##20## Not enough memory for 'Tslices' malloc (%ld bytes)", Tsliceslength); continue; } for (i=0; ipreset_src_N_SRC2[i] = -1; if( strstr( logger->skyImagesOut, "RAW_I" ) != NULL || strstr( logger->skyImagesOut, "RAWIN" ) != NULL || strstr( logger->skyImagesOut, "RAW_R" ) != NULL || strstr( logger->skyImagesOut, "RECTI" ) != NULL || strstr( logger->skyImagesOut, "VARIA" ) != NULL || strstr( logger->skyImagesOut, "RESID" ) != NULL || strstr( logger->skyImagesOut, "RES+S" ) != NULL || strstr( logger->skyImagesOut, "RECON" ) != NULL || strstr( logger->skyImagesOut, "EXPOS" ) != NULL || strstr( logger->skyImagesOut, "SIGNI" ) != NULL) logger->skyImaOut = 1; else logger->skyImaOut = 0; RILlogMessage(NULL,Log_0,"##7777## Before work: preset_src: %d", backproj->preset_src); status = j_ima_iros_work( theSWG, auxdata, jmx_id, logger, &point, bufevents, backproj, sh, bp, &(SCW[logger->N_SCW]), GOODSRC, USERBIN, Tslices, /* shd_adhoc, */ chatter, status ); if (logger->trace) traces(func_local, 10, logger); if (status != ISDC_OK) { RILlogMessage( NULL, Error_1, "##22## After j_ima_iros_work, status = %d", status); continue; } if( chatter > J_CHATTY_NORMAL ) { RILlogMessage( NULL, Log_0, "##23## after j_ima_iros_work"); } if (logger->trace) traces(func_local, 20, logger); logger->N_SCW++; if (logger->trace) traces(func_local, 30, logger); /* * status = j_ima_iros_analysis(jmx_id, * logger, backproj, GOODSRC, SUM_list, SCW, chatter, status); * if (status != ISDC_OK) { * RILlogMessage( NULL, Error_1, "##25## After j_ima_iros_analysis," * " status = %d", status); * continue; * } */ if (logger->trace) traces(func_local, 40, logger); /* * Write the JMXi-SRCL-RES data structure */ status = j_iir_write_srclres( theSWG, jemxNum, logger, GOODSRC, sh, backproj, chatter, status ); if( status != ISDC_OK ) { RILlogMessage( NULL, Error_1, "##27## After j_iir_write_srclres" " status = %d", status ); continue; } if (logger->trace) traces(func_local, 50, logger); } if (bp->d_allow != NULL) free(bp->d_allow); if (bufevents != NULL) free((Events*)bufevents); if (GOODSRC != NULL) free((goodsrc*)GOODSRC); if (USERBIN != NULL) free((userbin*)USERBIN); if (sh != NULL) free((struct shadowgrams*)(sh)); if (bp != NULL) free((struct backpro_lists*)(bp)); if (backproj != NULL) free((struct backpro*)(backproj)); /* function exit timing start */ TT_now = clock(); logger->func_times[func_local] += difftime(TT_now, logger->TT); logger->TT = TT_now; logger->func_calling_num = local_calling_num; /* function exit timing end */ if( showtime ) { tid = 0.0; for (i=0; ifunc_used_num; i++) { logger->func_times[i] /= CLOCKS_PER_SEC; sprintf(logger->tmptxt, "##28## %3d %30s: calls: %8d, total time: %8.3f s", i, logger->func_names[i], logger->func_calls[i], logger->func_times[i]); logger->logstat = logprint(logger, logger->tmptxt, 0); tid += logger->func_times[i]; } if (logger->trace > 0) sprintf(logger->tmptxt, "##29## Total time used: %9.1f s (trace was active)\n", tid); else sprintf(logger->tmptxt, "##29## Total time used: %9.1f s (trace was not active)\n", tid); logger->logstat = logprint(logger, logger->tmptxt, 0); } /* ******************************************************************** */ } while (0); if( status != ISDC_OK ) { RILlogMessage( NULL, Error_1,"##30## After one-pass-loop, status = %d", status ); /* status = ISDC_OK; SPR 4533 Removed 2006-08-07/NJW */ } status = CommonCloseSWG(theSWG, status); if (status != ISDC_OK) { RILlogMessage(NULL, Error_2, "##31## Failed to close the SWG"); } CommonExit(status); }