void write_chunk(Stream *st, struct image *i, struct hdfile *hdfile, int include_peaks, int include_reflections) { int j; char *indexer; fprintf(st->fh, CHUNK_START_MARKER"\n"); fprintf(st->fh, "Image filename: %s\n", i->filename); indexer = indexer_str(i->indexed_by); fprintf(st->fh, "indexed_by = %s\n", indexer); free(indexer); fprintf(st->fh, "photon_energy_eV = %f\n", J_to_eV(ph_lambda_to_en(i->lambda))); fprintf(st->fh, "beam_divergence = %.5f mrad\n", i->div*1e3); fprintf(st->fh, "beam_bandwidth = %.5f %%\n", i->bw*100.0); copy_hdf5_fields(hdfile, i->copyme, st->fh); if ( i->det != NULL ) { int j; double tclen = 0.0; for ( j=0; j<i->det->n_panels; j++ ) { tclen += i->det->panels[j].clen; } fprintf(st->fh, "average_camera_length = %f m\n", tclen / i->det->n_panels); for ( j=0; j<i->det->n_rigid_groups; j++ ) { struct rigid_group *rg = i->det->rigid_groups[j]; if ( !rg->have_deltas ) continue; fprintf(st->fh, "rg_delta_%s_fsx = %f\n", rg->name, rg->d_fsx); fprintf(st->fh, "rg_delta_%s_ssx = %f\n", rg->name, rg->d_ssx); fprintf(st->fh, "rg_delta_%s_cnx = %f\n", rg->name, rg->d_cnx); fprintf(st->fh, "rg_delta_%s_fsy = %f\n", rg->name, rg->d_fsy); fprintf(st->fh, "rg_delta_%s_ssy = %f\n", rg->name, rg->d_ssy); fprintf(st->fh, "rg_delta_%s_cny = %f\n", rg->name, rg->d_cny); } } fprintf(st->fh, "num_peaks = %lli\n", i->num_peaks); fprintf(st->fh, "num_saturated_peaks = %lli\n", i->num_saturated_peaks); if ( include_peaks ) { write_peaks(i, st->fh); } for ( j=0; j<i->n_crystals; j++ ) { write_crystal(st, i->crystals[j], include_reflections); } fprintf(st->fh, CHUNK_END_MARKER"\n"); fflush(st->fh); }
int write_chunk(Stream *st, struct image *i, struct hdfile *hdfile, int include_peaks, int include_reflections, struct event* ev) { int j; char *indexer; int ret = 0; fprintf(st->fh, CHUNK_START_MARKER"\n"); fprintf(st->fh, "Image filename: %s\n", i->filename); if ( i->event != NULL ) { fprintf(st->fh, "Event: %s\n", get_event_string(i->event)); } fprintf(st->fh, "Image serial number: %i\n", i->serial); indexer = indexer_str(i->indexed_by); fprintf(st->fh, "indexed_by = %s\n", indexer); free(indexer); fprintf(st->fh, "photon_energy_eV = %f\n", J_to_eV(ph_lambda_to_en(i->lambda))); fprintf(st->fh, "beam_divergence = %.2e rad\n", i->div); fprintf(st->fh, "beam_bandwidth = %.2e (fraction)\n", i->bw); copy_hdf5_fields(hdfile, i->copyme, st->fh, ev); if ( i->det != NULL ) { int j; double tclen = 0.0; for ( j=0; j<i->det->n_panels; j++ ) { tclen += i->det->panels[j].clen; } fprintf(st->fh, "average_camera_length = %f m\n", tclen / i->det->n_panels); for ( j=0; j<i->det->n_rigid_groups; j++ ) { struct rigid_group *rg = i->det->rigid_groups[j]; if ( !rg->have_deltas ) continue; fprintf(st->fh, "rg_delta_%s_fsx = %f\n", rg->name, rg->d_fsx); fprintf(st->fh, "rg_delta_%s_ssx = %f\n", rg->name, rg->d_ssx); fprintf(st->fh, "rg_delta_%s_cnx = %f\n", rg->name, rg->d_cnx); fprintf(st->fh, "rg_delta_%s_fsy = %f\n", rg->name, rg->d_fsy); fprintf(st->fh, "rg_delta_%s_ssy = %f\n", rg->name, rg->d_ssy); fprintf(st->fh, "rg_delta_%s_cny = %f\n", rg->name, rg->d_cny); } } fprintf(st->fh, "num_peaks = %lli\n", i->num_peaks); fprintf(st->fh, "num_saturated_peaks = %lli\n", i->num_saturated_peaks); if ( include_peaks ) { if ( AT_LEAST_VERSION(st, 2, 3) ) { ret = write_peaks_2_3(i, st->fh); } else { ret = write_peaks(i, st->fh); } } for ( j=0; j<i->n_crystals; j++ ) { if ( crystal_get_user_flag(i->crystals[j]) == 0 ) { ret = write_crystal(st, i->crystals[j], include_reflections); } } fprintf(st->fh, CHUNK_END_MARKER"\n"); fflush(st->fh); return ret; }