#! /usr/bin/env python # # DATABASE OF FirstLight SIMULATIONS # # by Daniel Ceverino, Heidelberg, September 2017 # read the database # extract all values (all runs, all snapshots) from three fields # generate table with 5 columns: a , run , field1, field2, field3 import json # import database: ff=open('FirstLight_database.dat', 'r') database = json.load(ff) ff.close() # generate keys for query extract_keys_base=[ 'FL633', 'FL634', 'FL635', 'FL637', 'FL638', 'FL639', 'FL640', 'FL641', 'FL642', 'FL643', 'FL644', 'FL645', 'FL646', 'FL647', 'FL648', 'FL649', 'FL650', 'FL651', 'FL653', 'FL655', 'FL656', 'FL657', 'FL658', 'FL659', 'FL660', 'FL661', 'FL662', 'FL664', 'FL665', 'FL666', 'FL667', 'FL668', 'FL669', 'FL670', 'FL671', 'FL673', 'FL675', 'FL676', 'FL678', 'FL679', 'FL680', 'FL681', 'FL682', 'FL683', 'FL684', 'FL685', 'FL686', 'FL687', 'FL688', 'FL689', 'FL690', 'FL691', 'FL692', 'FL693', 'FL694', 'FL695', 'FL696', 'FL697', 'FL698', 'FL700', 'FL701', 'FL702', 'FL703', 'FL704', 'FL705', 'FL706', 'FL707', 'FL708', 'FL709', 'FL710', 'FL711', 'FL712', 'FL713', 'FL714', 'FL715', 'FL716', 'FL717', 'FL718', 'FL719', 'FL720', 'FL721', 'FL722', 'FL723', 'FL724', 'FL725', 'FL726', 'FL727', 'FL728', 'FL729', 'FL730', 'FL731', 'FL732', 'FL733', 'FL734', 'FL735', 'FL736', 'FL739', 'FL740', 'FL744', 'FL745', 'FL746', 'FL747', 'FL748', 'FL750', 'FL752', 'FL753', 'FL754', 'FL755', 'FL756', 'FL757', 'FL758', 'FL760', 'FL761', 'FL763', 'FL767', 'FL768', 'FL769', 'FL770', 'FL771', 'FL772', 'FL773', 'FL774', 'FL775', 'FL777', 'FL778', 'FL779', 'FL780', 'FL781', 'FL782', 'FL783', 'FL784', 'FL788', 'FL789', 'FL792', 'FL793', 'FL794', 'FL796', 'FL800', 'FL801', 'FL802', 'FL803', 'FL805', 'FL806', 'FL808', 'FL809', 'FL810', 'FL811', 'FL814', 'FL815', 'FL816', 'FL818', 'FL819', 'FL823', 'FL824', 'FL825', 'FL826', 'FL827', 'FL829', 'FL652', 'FL654', 'FL699', 'FL738', 'FL741', 'FL742', 'FL749', 'FL762', 'FL764', 'FL766', 'FL776', 'FL785', 'FL786', 'FL787', 'FL790', 'FL795', 'FL797', 'FL798', 'FL799', 'FL804', 'FL807', 'FL812', 'FL813', 'FL817', 'FL820', 'FL822', 'FL828', 'FL839', 'FL850', 'FL855', 'FL862', 'FL870', 'FL874', 'FL879', 'FL882', 'FL891', 'FL896', 'FL898', 'FL903', 'FL904', 'FL906', 'FL915', 'FL916', 'FL917', 'FL918', 'FL919', 'FL921', 'FL922', 'FL923', 'FL924', 'FL925', 'FL926', 'FL928', 'FL930', 'FL932', 'FL934', 'FL935', 'FL765', 'FL835', 'FL836', 'FL841', 'FL843', 'FL844', 'FL845', 'FL846', 'FL847', 'FL848', 'FL849', 'FL851', 'FL856', 'FL857', 'FL858', 'FL859', 'FL860', 'FL861', 'FL865', 'FL866', 'FL867', 'FL868', 'FL871', 'FL877', 'FL881', 'FL884', 'FL885', 'FL887', 'FL888', 'FL893', 'FL895', 'FL897', 'FL899', 'FL900', 'FL901', 'FL907', 'FL908', 'FL909', 'FL911', 'FL912', 'FL837', 'FL838', 'FL840', 'FL852', 'FL853', 'FL863', 'FL864', 'FL869', 'FL872', 'FL873', 'FL883', 'FL890', 'FL894', 'FL902', 'FL834', 'FL854', 'FL876', 'FL913', 'FL927', 'FL931', 'FL933', 'FL938', 'FL939', 'FL940', 'FL942', 'FL943', 'FL946', 'FL947', 'FL914', 'FL920', 'FL929', 'FL936', 'FL937', 'FL941', 'FL944' ] extract_a='a' extract_run='run' extract_field1='Mvir' extract_field2='Ms' extract_field3='SFR' s='_' #a=['0.10', '0.11','0.12','0.13','0.14','0.15','0.16','0.17','0.18','0.19', # '0.20', '0.21','0.22','0.23','0.24','0.25','0.26','0.27','0.28','0.29', # '0.30', '0.31','0.32','0.33','0.34','0.35','0.36','0.37','0.38','0.39', # '0.40', '0.41','0.42','0.43','0.44','0.45','0.46','0.47','0.48','0.49', # '0.50', '0.51','0.52','0.53','0.54','0.55','0.56' ] a= ['0.160'] # ['0.059'] # ['0.060'] # ['0.062'] # ['0.064'] # ['0.067'] # ['0.069'] # ['0.071'] # ['0.074'] # ['0.077'] # ['0.080'] # ['0.083'] # ['0.087'] # ['0.090'] # ['0.095'] # ['0.100'] # ['0.105'] # ['0.111'] # ['0.118'] # ['0.125'] # ['0.133'] # ['0.142'] # ['0.154'] # ['0.160'] # ['0.094'] # ['0.142'] # ['0.077'] # ['0.111'] # ['0.092'] # a=['0.085'] # # z=1./float(a[0]) -1. #print 'selected redshift=', z, a print extract_a, extract_run, extract_field1 , extract_field2, extract_field3, 'selected redshift=', z, a for j in range(len(a)): extract_a_value = a[j] for i in range(len(extract_keys_base)): extract_keys_run= extract_keys_base[i] + s + extract_a_value + s + extract_run extract_keys_a= extract_keys_base[i] + s + extract_a_value + s + extract_a extract_keys_field1= extract_keys_base[i] + s + extract_a_value + s + extract_field1 extract_keys_field2= extract_keys_base[i] + s + extract_a_value + s + extract_field2 extract_keys_field3= extract_keys_base[i] + s + extract_a_value + s + extract_field3 if (database.has_key(extract_keys_field1) & database.has_key(extract_keys_field2)): print database[extract_keys_a], database[extract_keys_run], "%.2e" % database[extract_keys_field1], "%.2e" % database[extract_keys_field2], database[extract_keys_field3]