# =================================================================== # Example code: how to construct a catalogue of extragalactic objects # =================================================================== # to ensure compatibility in Python versions 2.x and 3.x from __future__ import print_function # import the CosmoBolognaLib import CosmoBolognaLib as cbl from CosmoBolognaLib import StringVector as sv # define a std::vector of input files (in this case with dim=1) file_cat = "cat.dat" file_cat_vec = sv(1, file_cat) # create a catalogue of galaxies, retrieving their comoving coordinates from an input file catalogue = cbl.Catalogue(cbl.ObjectType__Galaxy_, cbl.CoordinateType__comoving_, file_cat_vec) catalogue2 = cbl.Catalogue(catalogue) # print the coordinates of the first object print("The coordinates of the first galaxy in the catalogue are:", catalogue[0].xx(), catalogue[0].yy(), catalogue[0].zz())
] attrAv = [ cbl.Var__X_, cbl.Var__Y_, cbl.Var__Z_, cbl.Var__Radius_, cbl.Var__CentralDensity_, cbl.Var__DensityContrast_ ] for ii in range(len(attrNames)): if param.findBool(attrNames[ii]): cast.append(attrAv[ii]) clmn.append(param.findInt(attrNames[ii] + '_clmn')) clmn, cast = (list(x) for x in zip(*sorted(zip(clmn, cast))) ) # orders clmn and cast according to column order attr = cbl.VarCast(cast) vdcat = cbl.Catalogue(cbl.ObjectType__Void_, coordinates, attr, clmn, [param.findString('inputVoidCatalogue')], param.findInt('vd_comments')) if (param.findDouble('boxside') < 0.): boxside = abs(vdcat.Max(cbl.Var__X_) - vdcat.Min(cbl.Var__X_)) else: boxside = param.findDouble('boxside') vdcat.compute_catalogueProperties(boxside) ########################################################## # load the input tracers catalogue if param.findBool('Gadget'): if not param.findBool('comovingCoordinates'): ErrorCBL('Observed coordinates not available for Gadget snapshot.') else: