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)
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)
def from_xml_2(cls, ui_holder, xml_root, prefix=None): simulation = module_xpath(xml_root, '//light-cone/simulation') galaxy_model = module_xpath(xml_root, '//light-cone/galaxy-model') data_set = datasets.dataset_find_from_xml(simulation, galaxy_model) filter_attribute = module_xpath(xml_root, '//record-filter/filter/filter-attribute') filter_min = module_xpath(xml_root, '//record-filter/filter/filter-min') filter_max = module_xpath(xml_root, '//record-filter/filter/filter-max') filter_units = module_xpath(xml_root, '//record-filter/filter/filter-min', attribute='units') if filter_min == 'None': filter_min = None if filter_max == 'None': filter_max = None data_set_id = 0 if data_set is not None: data_set_id = data_set.id kind, record_id = datasets.filter_find_from_xml(data_set_id, filter_attribute, filter_units) if filter_attribute == None: kind = 'X' record_id = NO_FILTER attrs = {prefix+'-filter': kind + '-' + str(record_id), prefix+'-min': filter_min, prefix+'-max': filter_max, } return cls(ui_holder, attrs, prefix=prefix)