diff options
author | Thomas White <taw@physics.org> | 2012-05-30 17:17:11 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-05-30 17:17:11 +0200 |
commit | 4e0fe58f0d35f2a73f718917b2b99dc17fb9f7dd (patch) | |
tree | 4b1279360d9d4de28825e4608f554c187ed6ee0d /libcrystfel | |
parent | 781b32aa84eb9fb3092636beb3f6e4fee43add6c (diff) |
Formatting
Diffstat (limited to 'libcrystfel')
-rw-r--r-- | libcrystfel/src/cell.c | 28 | ||||
-rw-r--r-- | libcrystfel/src/dirax.c | 22 | ||||
-rw-r--r-- | libcrystfel/src/hdf5-file.c | 15 | ||||
-rw-r--r-- | libcrystfel/src/index.c | 52 | ||||
-rw-r--r-- | libcrystfel/src/mosflm.c | 20 | ||||
-rw-r--r-- | libcrystfel/src/render.c | 69 | ||||
-rw-r--r-- | libcrystfel/src/statistics.c | 37 |
7 files changed, 139 insertions, 104 deletions
diff --git a/libcrystfel/src/cell.c b/libcrystfel/src/cell.c index 8412fc62..31d3b9b1 100644 --- a/libcrystfel/src/cell.c +++ b/libcrystfel/src/cell.c @@ -424,7 +424,7 @@ int cell_get_parameters(UnitCell *cell, double *a, double *b, double *c, switch ( cell->rep ) { - case CELL_REP_CRYST: + case CELL_REP_CRYST: /* Direct response */ *a = cell->a; *b = cell->b; @@ -434,7 +434,7 @@ int cell_get_parameters(UnitCell *cell, double *a, double *b, double *c, *gamma = cell->gamma; return 0; - case CELL_REP_CART: + case CELL_REP_CART: /* Convert cartesian -> crystallographic */ *a = modulus(cell->ax, cell->ay, cell->az); *b = modulus(cell->bx, cell->by, cell->bz); @@ -448,7 +448,7 @@ int cell_get_parameters(UnitCell *cell, double *a, double *b, double *c, cell->bx, cell->by, cell->bz); return 0; - case CELL_REP_RECIP: + case CELL_REP_RECIP: /* Convert reciprocal -> crystallographic. * Start by converting reciprocal -> cartesian */ cell_invert(cell->axs, cell->ays, cell->azs, @@ -480,21 +480,21 @@ int cell_get_cartesian(UnitCell *cell, switch ( cell->rep ) { - case CELL_REP_CRYST: + case CELL_REP_CRYST: /* Convert crystallographic -> cartesian. */ return cell_crystallographic_to_cartesian(cell, ax, ay, az, bx, by, bz, cx, cy, cz); - case CELL_REP_CART: + case CELL_REP_CART: /* Direct response */ *ax = cell->ax; *ay = cell->ay; *az = cell->az; *bx = cell->bx; *by = cell->by; *bz = cell->bz; *cx = cell->cx; *cy = cell->cy; *cz = cell->cz; return 0; - case CELL_REP_RECIP: + case CELL_REP_RECIP: /* Convert reciprocal -> cartesian */ return cell_invert(cell->axs, cell->ays, cell->azs, cell->bxs, cell->bys, cell->bzs, @@ -518,7 +518,7 @@ int cell_get_reciprocal(UnitCell *cell, switch ( cell->rep ) { - case CELL_REP_CRYST: + case CELL_REP_CRYST: /* Convert crystallographic -> reciprocal */ r = cell_crystallographic_to_cartesian(cell, &ax, &ay, &az, @@ -528,7 +528,7 @@ int cell_get_reciprocal(UnitCell *cell, return cell_invert(ax, ay, az,bx, by, bz, cx, cy, cz, asx, asy, asz, bsx, bsy, bsz, csx, csy, csz); - case CELL_REP_CART: + case CELL_REP_CART: /* Convert cartesian -> reciprocal */ cell_invert(cell->ax, cell->ay, cell->az, cell->bx, cell->by, cell->bz, @@ -536,7 +536,7 @@ int cell_get_reciprocal(UnitCell *cell, asx, asy, asz, bsx, bsy, bsz, csx, csy, csz); return 0; - case CELL_REP_RECIP: + case CELL_REP_RECIP: /* Direct response */ *asx = cell->axs; *asy = cell->ays; *asz = cell->azs; *bsx = cell->bxs; *bsy = cell->bys; *bsz = cell->bzs; @@ -569,12 +569,16 @@ const char *cell_get_spacegroup(UnitCell *cell) static const char *cell_rep(UnitCell *cell) { switch ( cell->rep ) { - case CELL_REP_CRYST: + + case CELL_REP_CRYST: return "crystallographic, direct space"; - case CELL_REP_CART: + + case CELL_REP_CART: return "cartesian, direct space"; - case CELL_REP_RECIP: + + case CELL_REP_RECIP: return "cartesian, reciprocal space"; + } return "unknown"; diff --git a/libcrystfel/src/dirax.c b/libcrystfel/src/dirax.c index 20f48bd3..43de6c6e 100644 --- a/libcrystfel/src/dirax.c +++ b/libcrystfel/src/dirax.c @@ -226,37 +226,37 @@ static void dirax_send_next(struct image *image, struct dirax_data *dirax) switch ( dirax->step ) { - case 1 : + case 1 : dirax_sendline("\\echo off\n", dirax); break; - case 2 : + case 2 : snprintf(tmp, 31, "read xfel-%i.drx\n", image->id); dirax_sendline(tmp, dirax); break; - case 3 : + case 3 : dirax_sendline("dmax 1000\n", dirax); break; - case 4 : + case 4 : dirax_sendline("indexfit 2\n", dirax); break; - case 5 : + case 5 : dirax_sendline("levelfit 1000\n", dirax); break; - case 6 : + case 6 : dirax_sendline("go\n", dirax); dirax->finished_ok = 1; break; - case 7 : + case 7 : dirax_sendline("acl\n", dirax); break; - case 8 : + case 8 : if ( dirax->best_acl_nh == 0 ) { /* At this point, DirAx is presenting its ACL prompt * and waiting for a single number. Use an extra @@ -270,11 +270,11 @@ static void dirax_send_next(struct image *image, struct dirax_data *dirax) dirax_sendline(tmp, dirax); break; - case 9 : + case 9 : dirax_sendline("cell\n", dirax); break; - case 10 : + case 10 : if ( dirax->n_acls_tried == MAX_DIRAX_CELL_CANDIDATES ) { dirax_sendline("exit\n", dirax); } else { @@ -285,7 +285,7 @@ static void dirax_send_next(struct image *image, struct dirax_data *dirax) } break; - default: + default: dirax_sendline("exit\n", dirax); return; diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c index 88d11bff..9924e665 100644 --- a/libcrystfel/src/hdf5-file.c +++ b/libcrystfel/src/hdf5-file.c @@ -719,6 +719,9 @@ char *hdfile_get_string_value(struct hdfile *f, const char *name) hsize_t max_size; hid_t type; hid_t class; + herr_t r; + int buf; + char *tmp; dh = H5Dopen2(f->fh, name, H5P_DEFAULT); if ( dh < 0 ) return NULL; @@ -761,11 +764,8 @@ char *hdfile_get_string_value(struct hdfile *f, const char *name) } switch ( class ) { - case H5T_FLOAT : { - herr_t r; - double buf; - char *tmp; + case H5T_FLOAT : r = H5Dread(dh, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &buf); @@ -776,12 +776,8 @@ char *hdfile_get_string_value(struct hdfile *f, const char *name) return tmp; - } - case H5T_INTEGER : { + case H5T_INTEGER : - herr_t r; - int buf; - char *tmp; r = H5Dread(dh, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &buf); @@ -791,6 +787,7 @@ char *hdfile_get_string_value(struct hdfile *f, const char *name) snprintf(tmp, 255, "%d", buf); return tmp; + } default : { goto fail; diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c index 3d0f164b..f4bc9d6c 100644 --- a/libcrystfel/src/index.c +++ b/libcrystfel/src/index.c @@ -83,18 +83,23 @@ IndexingPrivate **prepare_indexing(IndexingMethod *indm, UnitCell *cell, for ( n=0; n<nm; n++ ) { switch ( indm[n] ) { - case INDEXING_NONE : + + case INDEXING_NONE : ERROR("Tried to prepare INDEXING_NONE!\n"); break; - case INDEXING_DIRAX : + + case INDEXING_DIRAX : iprivs[n] = indexing_private(indm[n]); break; - case INDEXING_MOSFLM : + + case INDEXING_MOSFLM : iprivs[n] = indexing_private(indm[n]); break; - case INDEXING_REAX : + + case INDEXING_REAX : iprivs[n] = reax_prepare(); break; + } } @@ -113,18 +118,23 @@ void cleanup_indexing(IndexingPrivate **priv) while ( priv[n] != NULL ) { switch ( priv[n]->indm ) { - case INDEXING_NONE : + + case INDEXING_NONE : free(priv[n]); break; - case INDEXING_DIRAX : + + case INDEXING_DIRAX : free(priv[n]); break; - case INDEXING_MOSFLM : + + case INDEXING_MOSFLM : free(priv[n]); break; - case INDEXING_REAX : + + case INDEXING_REAX : reax_cleanup(priv[n]); break; + } n++; @@ -173,17 +183,22 @@ void index_pattern(struct image *image, UnitCell *cell, IndexingMethod *indm, /* Index as appropriate */ switch ( indm[n] ) { - case INDEXING_NONE : + + case INDEXING_NONE : return; - case INDEXING_DIRAX : + + case INDEXING_DIRAX : run_dirax(image); break; - case INDEXING_MOSFLM : + + case INDEXING_MOSFLM : run_mosflm(image, cell); break; - case INDEXING_REAX : + + case INDEXING_REAX : reax_index(ipriv[n], image, cell); break; + } if ( image->ncells == 0 ) { n++; @@ -205,20 +220,25 @@ void index_pattern(struct image *image, UnitCell *cell, IndexingMethod *indm, /* Match or reduce the cell as appropriate */ switch ( cellr ) { - case CELLR_NONE : + + case CELLR_NONE : new_cell = cell_new_from_cell(cand); break; - case CELLR_REDUCE : + + case CELLR_REDUCE : new_cell = match_cell(cand, cell, verbose, ltl, 1); break; - case CELLR_COMPARE : + + case CELLR_COMPARE : new_cell = match_cell(cand, cell, verbose, ltl, 0); break; - case CELLR_COMPARE_AB : + + case CELLR_COMPARE_AB : new_cell = match_cell_ab(cand, cell); break; + } /* No cell? Move on to the next candidate */ diff --git a/libcrystfel/src/mosflm.c b/libcrystfel/src/mosflm.c index 3e29a4f8..410b779a 100644 --- a/libcrystfel/src/mosflm.c +++ b/libcrystfel/src/mosflm.c @@ -283,13 +283,13 @@ static void mosflm_send_next(struct image *image, struct mosflm_data *mosflm) switch ( mosflm->step ) { - case 1 : + case 1 : mosflm_sendline("DETECTOR ROTATION HORIZONTAL" " ANTICLOCKWISE ORIGIN LL FAST HORIZONTAL" " RECTANGULAR\n", mosflm); break; - case 2 : + case 2 : if ( mosflm->target_cell != NULL ) { cell_get_parameters(mosflm->target_cell, &a, &b, &c, &alpha, &beta, &gamma); @@ -303,7 +303,7 @@ static void mosflm_send_next(struct image *image, struct mosflm_data *mosflm) } break; - case 3 : + case 3 : if ( mosflm->target_cell != NULL ) { sg = cell_get_spacegroup(mosflm->target_cell); /* Remove white space from space group */ @@ -321,31 +321,31 @@ static void mosflm_send_next(struct image *image, struct mosflm_data *mosflm) } break; - case 4 : + case 4 : mosflm_sendline("DISTANCE 67.8\n", mosflm); break; - case 5 : + case 5 : mosflm_sendline("BEAM 0.0 0.0\n", mosflm); break; - case 6 : + case 6 : wavelength = image->lambda*1e10; snprintf(tmp, 255, "WAVELENGTH %10.5f\n", wavelength); mosflm_sendline(tmp, mosflm); break; - case 7 : + case 7 : snprintf(tmp, 255, "NEWMAT %s\n", mosflm->newmatfile); mosflm_sendline(tmp, mosflm); break; - case 8 : + case 8 : snprintf(tmp, 255, "IMAGE %s phi 0 0\n", mosflm->imagefile); mosflm_sendline(tmp, mosflm); break; - case 9 : + case 9 : snprintf(tmp, 255, "AUTOINDEX DPS FILE %s" " IMAGE 1 MAXCELL 1000 REFINE\n", mosflm->sptfile); @@ -357,7 +357,7 @@ static void mosflm_send_next(struct image *image, struct mosflm_data *mosflm) mosflm_sendline(tmp, mosflm); break; - case 10 : + case 10 : mosflm_sendline("GO\n", mosflm); mosflm->finished_ok = 1; break; diff --git a/libcrystfel/src/render.c b/libcrystfel/src/render.c index c9e1f01e..5d0cf9e8 100644 --- a/libcrystfel/src/render.c +++ b/libcrystfel/src/render.c @@ -64,34 +64,35 @@ static void render_rgb(double val, double max, s = 6; } switch ( s ) { - case 0 : { /* Black to blue */ - r = 0; g = 0; b = p; - break; - } - case 1 : { /* Blue to pink */ - r = p; g = 0; b = 1.0; - break; - } - case 2 : { /* Pink to red */ - r = 1.0; g = 0; b = (1.0-p)*1.0; - break; - } - case 3 : { /* Red to Orange */ - r = 1.0; g = 0.5*p; b = 0; - break; - } - case 4 : { /* Orange to Yellow */ - r = 1.0; g = 0.5 + 0.5*p; b = 0; - break; - } - case 5 : { /* Yellow to White */ - r = 1.0; g = 1.0; b = 1.0*p; - break; - } - case 6 : { /* Pixel has hit the maximum value */ - r = 1.0; g = 1.0; b = 1.0; - break; - } + + case 0 : /* Black to blue */ + r = 0; g = 0; b = p; + break; + + case 1 : /* Blue to pink */ + r = p; g = 0; b = 1.0; + break; + + case 2 : /* Pink to red */ + r = 1.0; g = 0; b = (1.0-p)*1.0; + break; + + case 3 : /* Red to Orange */ + r = 1.0; g = 0.5*p; b = 0; + break; + + case 4 : /* Orange to Yellow */ + r = 1.0; g = 0.5 + 0.5*p; b = 0; + break; + + case 5 : /* Yellow to White */ + r = 1.0; g = 1.0; b = 1.0*p; + break; + + case 6 : /* Pixel has hit the maximum value */ + r = 1.0; g = 1.0; b = 1.0; + break; + } *rp = r; @@ -144,16 +145,20 @@ void render_scale(double val, double max, int scale, double *rp, double *gp, double *bp) { switch ( scale ) { - case SCALE_COLOUR : + + case SCALE_COLOUR : render_rgb(val, max, rp, gp, bp); break; - case SCALE_MONO : + + case SCALE_MONO : render_mono(val, max, rp, gp, bp); break; - case SCALE_INVMONO : + + case SCALE_INVMONO : render_invmono(val, max, rp, gp, bp); break; - case SCALE_RATIO : + + case SCALE_RATIO : render_ratio(val, max, rp, gp, bp); break; } diff --git a/libcrystfel/src/statistics.c b/libcrystfel/src/statistics.c index 6ddf2850..56273fdb 100644 --- a/libcrystfel/src/statistics.c +++ b/libcrystfel/src/statistics.c @@ -407,22 +407,28 @@ static double calc_r(double scale, void *params) struct r_params *rp = params; switch ( rp->fom ) { - case R_1_ZERO : + + case R_1_ZERO : return internal_r1_negstozero(rp->list1, rp->list2, scale); - case R_1_IGNORE : + + case R_1_IGNORE : return internal_r1_ignorenegs(rp->list1, rp->list2, scale); - case R_2 : + + case R_2 : return internal_r2(rp->list1, rp->list2, scale); - case R_1_I : + case R_1_I : return internal_r_i(rp->list1, rp->list2, scale); - case R_DIFF_ZERO : + case R_DIFF_ZERO : return internal_rdiff_negstozero(rp->list1, rp->list2,scale); - case R_DIFF_IGNORE : + + case R_DIFF_IGNORE : return internal_rdiff_ignorenegs(rp->list1, rp->list2, scale); - case R_DIFF_INTENSITY : + + case R_DIFF_INTENSITY : return internal_rdiff_intensity(rp->list1, rp->list2, scale); + } ERROR("No such FoM!\n"); @@ -457,17 +463,20 @@ static double r_minimised(RefList *list1, RefList *list2, double *scalep, int fo /* Initial guess */ switch ( fom ) { - case R_1_ZERO : - case R_1_IGNORE : - case R_DIFF_ZERO : - case R_DIFF_IGNORE : + + case R_1_ZERO : + case R_1_IGNORE : + case R_DIFF_ZERO : + case R_DIFF_IGNORE : scale = stat_scale_sqrti(list1, list2); break; - case R_2 : - case R_1_I : - case R_DIFF_INTENSITY : + + case R_2 : + case R_1_I : + case R_DIFF_INTENSITY : scale = stat_scale_intensity(list1, list2); break; + } //STATUS("Initial scale factor estimate: %5.2e\n", scale); |