def setUp(self):
        sample_details = SampleDetails(height=4.0,
                                       radius=0.2985,
                                       center=[0, 0, 0],
                                       shape='cylinder')
        sample_details.set_material(chemical_formula='Si')
        self.geometry = {
            'Shape': 'Cylinder',
            'Height': sample_details.height(),
            'Radius': sample_details.radius(),
            'Center': sample_details.center()
        }

        material = sample_details.material_object
        material_json = {'ChemicalFormula': material.chemical_formula}
        if material.number_density:
            material_json["SampleNumberDensity"] = material.number_density
        if material.absorption_cross_section:
            material_json[
                "AttenuationXSection"] = material.absorption_cross_section
        if material.scattering_cross_section:
            material_json[
                "ScatteringXSection"] = material.scattering_cross_section
        self.material = material_json

        self.cal_file_path = "polaris_grouping_file.cal"
    def setUp(self):
        sample_details = SampleDetails(height=4.0, radius=0.2985, center=[0, 0, 0], shape='cylinder')
        sample_details.set_material(chemical_formula='Si')
        self.geometry = {'Shape': 'Cylinder',
                         'Height': sample_details.height(),
                         'Radius': sample_details.radius(),
                         'Center': sample_details.center()}

        material = sample_details.material_object
        material_json = {'ChemicalFormula': material.chemical_formula}
        if material.number_density:
            material_json["SampleNumberDensity"] = material.number_density
        if material.absorption_cross_section:
            material_json["AttenuationXSection"] = material.absorption_cross_section
        if material.scattering_cross_section:
            material_json["ScatteringXSection"] = material.scattering_cross_section
        self.material = material_json

        self.dirpath = tempfile.mkdtemp()
        self.cal_file_path = os.path.join(self.dirpath, "tot_scat.cal")
        file = open(self.cal_file_path, 'w')
        file.write("%i\t%i\t%f\t%i\t%i\n" % (1, 1, 0.0, 1, 1))
        file.write("%i\t%i\t%f\t%i\t%i\n" % (2, 2, 0.0, 1, 1))
        file.write("%i\t%i\t%f\t%i\t%i\n" % (3, 3, 0.0, 1, 2))
        file.write("%i\t%i\t%f\t%i\t%i\n" % (4, 4, 0.0, 1, 2))
        file.close()
Ejemplo n.º 3
0
def run_focus(absorb_corrections):
    run_number = 83605
    sample_empty = 83608  # Use the vanadium empty again to make it obvious
    sample_empty_scale = 0.5  # Set it to 50% scale

    # Copy the required splined file into place first (instead of relying on generated one)
    splined_file_name = "GEM83608_splined.nxs"

    original_splined_path = os.path.join(input_dir, splined_file_name)
    shutil.copy(original_splined_path, spline_path)

    inst_object = setup_inst_object(mode="PDF")
    if absorb_corrections:

        sample = SampleDetails(height=5.0,
                               radius=0.3,
                               center=[0, 0, 0],
                               shape='cylinder')
        sample.set_material(chemical_formula='(Li7)14 Mg1.05 Si2 S12.05',
                            number_density=0.001641)
        inst_object.set_sample_details(sample=sample, mode="Rietveld")

    return inst_object.focus(run_number=run_number,
                             input_mode="Individual",
                             vanadium_normalisation=True,
                             do_absorb_corrections=absorb_corrections,
                             multiple_scattering=False,
                             sample_empty=sample_empty,
                             sample_empty_scale=sample_empty_scale)
Ejemplo n.º 4
0
def run_focus(do_solid_angle_corrections):
    [sample_empty, _, run_number] = gen_required_run_numbers()
    sample_empty_scale = 1

    # Copy the required spline file into place first (instead of relying on the generated one)
    splined_file_name = "HRPD66031_splined.nxs"

    original_splined_path = os.path.join(input_dir, splined_file_name)
    shutil.copy(original_splined_path, spline_path)

    inst_object = setup_inst_object()

    sample = SampleDetails(shape="cylinder",
                           center=[1, 5, 1],
                           height=1,
                           radius=1)
    sample.set_material(chemical_formula="Si")
    inst_object.set_sample_details(sample=sample)

    return inst_object.focus(
        run_number=run_number,
        window=WINDOW,
        sample_empty=sample_empty,
        sample_empty_scale=sample_empty_scale,
        vanadium_normalisation=True,
        do_solid_angle_corrections=do_solid_angle_corrections,
        do_absorb_corrections=True,
        multiple_scattering=False)
Ejemplo n.º 5
0
def setup_inst_object(mode):
    user_name = "Test"
    if mode:
        inst_obj = Polaris(user_name=user_name, calibration_mapping_file=calibration_map_path,
                           calibration_directory=calibration_dir, output_directory=output_dir, mode=mode)
    else:
        inst_obj = Polaris(user_name=user_name, calibration_mapping_file=calibration_map_path,
                           calibration_directory=calibration_dir, output_directory=output_dir)

    sample_details = SampleDetails(height=4.0, radius=0.2985, center=[0, 0, 0], shape='cylinder')
    sample_details.set_material(chemical_formula='Si')
    inst_obj.set_sample_details(sample=sample_details)

    return inst_obj
def main(input_file, output_dir):
    validate(input_file, output_dir)

    params = web_var.standard_vars
    correction_params = web_var.advanced_vars

    mapping_file = r"/archive/NDXPOLARIS/user/scripts/autoreduction/Calibration/polaris_cycle_mapping.yaml"
    calib_dir = r"/archive/NDXPOLARIS/user/scripts/autoreduction/Calibration"

    user = "******"
    # If performing absorption corrections add a workspace suffix of _abs
    output_suffix = '_abs' if params['do_absorb_corrections'] else ''

    instrument_args = {
        'user_name': user,
        'calibration_directory': calib_dir,
        'output_directory': output_dir,
        'calibration_mapping_file': mapping_file,
        'do_absorb_corrections': params['do_absorb_corrections'],
        'do_van_normalisation': params['do_van_normalisation'],
        'input_mode': params['input_mode'],
        'suffix': output_suffix,
        'sample_empty': 113677,
        'sample_empty_scale': 1.0,
    }

    # Only use the mode if specified by the user
    if params['mode']:
        instrument_args['mode'] = params['mode']

    polaris = Polaris(**instrument_args)

    # Add the sample object if we are applying absorption corrections
    if params['do_absorb_corrections']:
        sample_obj = SampleDetails(shape=correction_params['shape'],
                                   center=correction_params['center'],
                                   height=correction_params['height'],
                                   radius=correction_params['radius'])
        sample_obj.set_material(
            chemical_formula=correction_params['composition'],
            number_density=correction_params['number_density'])
        polaris.set_sample_details(sample=sample_obj)

    # Prior to running this script, you need to have created a vanadium for cycle 17_2 like so:
    #polaris.create_vanadium(first_cycle_run_no=83881)

    # Focus run
    run_num = get_run_number(input_file)
    polaris.focus(run_number=run_num, multiple_scattering=False)