コード例 #1
0
ファイル: fit.c プロジェクト: reflectometry/garefl
static void calc_magnitude(fitinfo *fit)
{
  /* _write_profile(fit,"prof.out"); */

  if (fit->datatype == FIT_POLARIZED) {
#ifdef HAVE_MAGNETIC
    /* We've got polarized data: use magnetic calculations */
    magnetic_reflectivity(fit->p.n, fit->p.d, fit->p.rho,
			  fit->p.mu,fit->beam.lambda, fit->beam.alignment,
			  fit->p.P, fit->p.expth,
			  fit->beam.Aguide, fit->nQ, fit->fitQ,
			  fit->fitA, fit->fitB, fit->fitC, fit->fitD);

	  if (fit->number_incoherent > 0) incoherent_polarized_theory(fit);

    /* _write_refl(fit,"reflA.out"); */
    apply_beam_parameters(fit,fit->fitA,&fit->dataA);
    apply_beam_parameters(fit,fit->fitB,&fit->dataB);
    apply_beam_parameters(fit,fit->fitC,&fit->dataC);
    apply_beam_parameters(fit,fit->fitD,&fit->dataD);
    /* _write_refl(fit,"reflB.out"); */
#else  /* !HAVE_MAGNETIC */
    fprintf(stderr,"Need to configure with --enable-magnetic\n");
    exit(1);
#endif /* !HAVE_MAGNETIC */
  } else {
		/* Generate reflectivity amplitude from the profile */
  	if (fit->m.is_magnetic) {
#ifdef HAVE_MAGNETIC
	    int k;
	    magnetic_reflectivity(fit->p.n, fit->p.d, fit->p.rho,
				  fit->p.mu,fit->beam.lambda, fit->beam.alignment,
				  fit->p.P, fit->p.expth,
				  fit->beam.Aguide, fit->nQ, fit->fitQ,
				  fit->fitA, fit->fitB, fit->fitC, fit->fitD);
			for (k=0; k < fit->nQ; k++) {
				fit->fitA[k] = (fit->fitA[k]+fit->fitB[k]+fit->fitC[k]+fit->fitD[k])/2.;
			}
#else
            fprintf(stderr,"Need to configure with --enable-magnetic\n");
            exit(1);
#endif
  	} else {
 	  	reflectivity(fit->p.n, fit->p.d, fit->p.rho,
					fit->p.mu, fit->beam.lambda,
					fit->beam.alignment,
					fit->nQ, fit->fitQ, fit->fitA);
  	}

	  if (fit->number_incoherent > 0) incoherent_unpolarized_theory(fit);

    /* _write_refl(fit,"reflA.out"); */
    apply_beam_parameters(fit,fit->fitA,&fit->dataA);
    /* _write_refl(fit,"reflB.out"); */
  }

}
コード例 #2
0
ファイル: fit.c プロジェクト: reflectometry/garefl
/* Incoherent sum of multiple models for unpolarized reflectometry */
static void incoherent_unpolarized_theory(fitinfo *fit)
{
	Real total_weight; /* Total weight of all models */
	int i, k;
	profile p; /* Incoherent model profile */
	Real *A, *B, *C, *D;

	/* Make space for incoherent models. */
 	extend_work(fit,4*fit->nQ);
 	A = fit->work;
	B = fit->work + fit->nQ;
	C = fit->work + 2*fit->nQ;
	D = fit->work + 3*fit->nQ;

	/* Incoherent sum of the theory functions. */
  profile_init(&p);
	for (i=0; i < fit->number_incoherent; i++) {
		profile_reset(&p);
	  model_profile(fit->incoherent_models[i], &p);
	  /* profile_print(&p,NULL); */
  	if (fit->m.is_magnetic) {
#ifdef HAVE_MAGNETIC
	    magnetic_reflectivity(p.n, p.d, p.rho,
				  p.mu,fit->beam.lambda, fit->beam.alignment,
				  p.P, p.expth,
				  fit->beam.Aguide, fit->nQ, fit->fitQ,
				  A, B, C, D);
			for (k=0; k < fit->nQ; k++) {
				A[k] = (A[k]+B[k]+C[k]+D[k])/2.;
			}
#else
            fprintf(stderr,"Need to configure with --enable-magnetic\n");
            exit(1);
#endif
  	} else {
 	  	reflectivity(p.n, p.d, p.rho, p.mu, fit->beam.lambda,
 	  	             fit->beam.alignment,
					fit->nQ, fit->fitQ, A);
  	}
  	for (k=0; k < fit->nQ; k++) {
  		fit->fitA[k] += A[k] * fit->incoherent_weights[i];
  	}
	}
  profile_destroy(&p);

	/* Incoherent sum of models requires relative model weighting.
	 * The base model is assumed to have weight 1.  The remaining
	 * models can have their weights adjusted, with the result
	 * normalized by the total weight. */
	total_weight = 1.;
	for (i=0; i < fit->number_incoherent; i++) {
		total_weight += fit->incoherent_weights[i];
	}
	for (k=0; k < fit->nQ; k++) {
		fit->fitA[k] /= total_weight;
	}
}
コード例 #3
0
Texture::Visualization::Visualization(const Any& a) {
    *this = Visualization();
    if (a.type() == Any::ARRAY) {
        if (a.nameEquals("bumpInAlpha")) {
            *this = bumpInAlpha();
        } else if (a.nameEquals("defaults")) {
            *this = defaults();
        } else if (a.nameEquals("linearRGB")) {
            *this = linearRGB();
        } else if (a.nameEquals("depthBuffer")) {
            *this = depthBuffer();
        } else if (a.nameEquals("packedUnitVector")) {
            *this = packedUnitVector();
        } else if (a.nameEquals("radiance")) {
            *this = radiance();
        } else if (a.nameEquals("reflectivity")) {
            *this = reflectivity();
        } else if (a.nameEquals("sRGB")) {
            *this = sRGB();
        } else if (a.nameEquals("unitVector")) {
            *this = unitVector();
        } else {
            a.verify(false, "Unrecognized Visualization factory method");
        }
    } else {
        a.verifyName("Texture::Visualization", "Visualization");

        AnyTableReader r(a);
        String c;

        if (r.getIfPresent("channels", c)) {
            channels = toChannels(c);
        }

        r.getIfPresent("documentGamma", documentGamma);
        r.getIfPresent("invertIntensity", invertIntensity);
        r.getIfPresent("max", max);
        r.getIfPresent("min", min);
        r.getIfPresent("layer", layer);
        r.getIfPresent("mipLevel", mipLevel);

        r.verifyDone();
    }
}