Пример #1
0
def from_xml_2(cls, ui_holder, xml_root, prefix=None):
    simulation_name = module_xpath(xml_root, '//light-cone/simulation')
    galaxy_model_name = module_xpath(xml_root, '//light-cone/galaxy-model')
    simulation = datasets.simulation_from_xml(simulation_name)
    galaxy_model = datasets.galaxy_model_from_xml(galaxy_model_name)
    data_set = datasets.dataset_find_from_xml(simulation_name, galaxy_model_name)
    geometry = module_xpath(xml_root, '//light-cone/geometry')
    simulation_id = None
    if simulation is not None: simulation_id = simulation.id
    galaxy_model_id = None
    if galaxy_model is not None: galaxy_model_id = galaxy_model.id
    if not (geometry in [Form.CONE, Form.BOX]):
        geometry = None
    params = {
        prefix+'-catalogue_geometry': geometry,
        prefix+'-galaxy_model': galaxy_model_id,
        prefix+'-dark_matter_simulation': simulation_id,
        }

    if geometry == Form.BOX:

        redshift = module_xpath(xml_root, '//light-cone/redshift')
        snapshot = datasets.snapshot_from_xml(data_set, redshift)
        if snapshot is not None:
            params.update({prefix+'-snapshot':snapshot.id})
        box_size = module_xpath(xml_root, '//light-cone/query-box-size')
        params.update({prefix+'-box_size': box_size})
        rng_seed_param = module_xpath(xml_root, '//light-cone/rng-seed')
        rng_seed = rng_seed_param if rng_seed_param else ''
        params.update({prefix + '-rng_seed': rng_seed})


    else: ## == Form.CONE

        light_cone_type = module_xpath(xml_root, '//light-cone/box-repetition')
        num_cones = module_xpath(xml_root, '//light-cone/num-cones')
        redshift_min = module_xpath(xml_root, '//light-cone/redshift-min')
        redshift_max = module_xpath(xml_root, '//light-cone/redshift-max')
        ra_max = module_xpath(xml_root, '//light-cone/ra-max')
        dec_max = module_xpath(xml_root, '//light-cone/dec-max')
        if light_cone_type == 'random':
            rng_seeds = []
            rng_seeds_params = [elem for elem in module_xpath_iterate(xml_root, '//light-cone/rng-seeds/*', False)]
            if rng_seeds_params:
                rng_seeds_dict = dict((rng_seed.tag.split('}')[1], rng_seed.text) for rng_seed in rng_seeds_params)
                rng_seeds = rng_seeds_dict
            params.update({prefix + '-rng_seeds': rng_seeds})
        params.update({
            prefix+'-light_cone_type': light_cone_type,
            prefix+'-number_of_light_cones': num_cones,
            prefix+'-redshift_min': redshift_min,
            prefix+'-redshift_max': redshift_max,
            prefix+'-ra_opening_angle': ra_max,
            prefix+'-dec_opening_angle': dec_max,
            })
    params.update({prefix+'-output_properties': [dsp.id for dsp in Form._map_elems(xml_root, data_set)]})
    return cls(ui_holder, params, prefix=prefix)
Пример #2
0
def from_xml_2(cls, ui_holder, xml_root, prefix=None):
    query = module_xpath(xml_root, '//sql/query')
    simulation_name = module_xpath(xml_root, '//sql/simulation')
    galaxy_model_name = module_xpath(xml_root, '//sql/galaxy-model')
    simulation = datasets.simulation_from_xml(simulation_name)
    galaxy_model = datasets.galaxy_model_from_xml(galaxy_model_name)
    data_set = datasets.dataset_find_from_xml(simulation, galaxy_model)
    output_properties = [dsp for dsp in SQLJobForm._map_elems(xml_root)]
    if data_set is not None: query = query.replace('-table-', data_set.database)
    simulation_id = None
    if simulation is not None: simulation_id = simulation.id
    galaxy_model_id = None
    if galaxy_model is not None: galaxy_model_id = galaxy_model.id
    params = {
        prefix+'-galaxy_model': galaxy_model_id,
        prefix+'-dark_matter_simulation': simulation_id,
        prefix+'-query': query,
        prefix+'-output_properties': output_properties,
        }
    return cls(ui_holder, params, prefix=prefix)