Skip to content

Commit

Permalink
ffa tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsh-um committed Apr 2, 2024
1 parent 01ad554 commit fe8d998
Show file tree
Hide file tree
Showing 7 changed files with 2,196 additions and 11 deletions.
12 changes: 10 additions & 2 deletions py/LSS/cosmodesi_io_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,18 @@ def get_clustering_positions_weights(catalog, distance, zlim=(0., np.inf),maglim
print('multiplying weights by WEIGHT_focal')

if name == 'data' and 'bitwise' in weight_type:
weights /= catalog['WEIGHT_COMP'][mask]
print('dividing weights by WEIGHT_COMP')
if 'default' in weight_type:
weights /= catalog['WEIGHT_COMP'][mask]
print('dividing weights by WEIGHT_COMP')
weights = _format_bitweights(catalog['BITWEIGHTS'][mask]) + [weights]

if name == 'randoms':
#if 'default' in weight_type:
# weights *= catalog['WEIGHT'][mask]
if 'bitwise' in weight_type and 'default' in weight_type:
weights /= catalog['FRAC_TLOBS_TILES'][mask]
print('dividing weights by FRAC_TLOBS_TILES')

# if name == 'randoms':
# if 'default' in weight_type:
# weights *= catalog['WEIGHT'][mask]
Expand Down
25 changes: 16 additions & 9 deletions scripts/Combined_Emulator_AbV3.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
DESIwemu_indir = args.base_output + add_string + "SecondGenMocks/" + subdir +"/"
DESIwemu_outdir = args.emulator_dir + "fof_v1.0/in/"

cmd_string3 = "python /global/homes/s/sikandar/PerlmutterLSS/LSS/scripts/mock_tools/NTILE_assign.py --indir %s --tracer %s --tileloc_add y --prog %s"%(NTILE_assign_indir, tracer_string, args.prog.upper())
cmd_string3 = "python /global/common/software/desi/users/sikandar/LSS/scripts/mock_tools/NTILE_assign.py --indir %s --tracer %s --tileloc_add y --prog %s"%(NTILE_assign_indir, tracer_string, args.prog.upper())

cmd_string4 = {}
for i in range(len(tracer_arr)):
Expand Down Expand Up @@ -195,9 +195,9 @@
errorfn = emulator_basedir + "fof_v1.0/log/" + "ERR_" + args.mockver + "_fof_" + new_target + "_llen0.02_" + args.galcap + "_m" + args.real + "_datatrain.txt"
print(cmd_string5)
print(cmd_string6)
with open(outputfn, "w+") as output, open(errorfn, "w+") as errorf:
subprocess.run(cmd_string5, shell=True)
subprocess.run(cmd_string6, shell=True, stdout=output, stderr = errorf)
# with open(outputfn, "w+") as output, open(errorfn, "w+") as errorf:
# subprocess.run(cmd_string5, shell=True)
# subprocess.run(cmd_string6, shell=True, stdout=output, stderr = errorf)
print("done fof")


Expand All @@ -208,9 +208,9 @@
errorfnemu = emulator_basedir + "emulate_bitw_v1.1/log/" + "ERR_" + args.mockver + "_emu_" + new_target + "_llen0.02_" + args.galcap + "_m" + args.real + "_datatrain.txt"
print(cmd_string7)
print(cmd_string8)
with open(outputfnemu, "w+") as output, open(errorfnemu, "w+") as errorf:
subprocess.run(cmd_string7, shell=True)
subprocess.run(cmd_string8, shell=True, stdout=output, stderr = errorf)
# with open(outputfnemu, "w+") as output, open(errorfnemu, "w+") as errorf:
# subprocess.run(cmd_string7, shell=True)
# subprocess.run(cmd_string8, shell=True, stdout=output, stderr = errorf)
print("done emulation")


Expand Down Expand Up @@ -499,11 +499,18 @@ def unpack_bitweights_BP2017(we):
target_write_name = new_target
unred_path = args.base_output + add_string + pathstr + "mock" + str(args.real) + "/"
emu_in = Table.read(emu_out_dir + args.mockver + '_corr_clustering_cat_FAemu_m' + args.real + '_' + args.galcap + '_' + new_target + '_llen0.02_truent_cfc.fits')
unreduced = Table.read(unred_path + '/pota-' + args.prog.upper() + '_joined_unreduced_%s.fits'%new_target)
unreduced_tab_path = unred_path + '/pota-' + args.prog.upper() + '_joined_unreduced_%s.fits'%new_target
print("unreduced_tab_path = ", unreduced_tab_path)
unreduced = Table.read(unreduced_tab_path)
print("Unreduced length = ", len(unreduced))
print("emu_in length = ", len(emu_in))
emu_in.remove_columns(['RA', 'DEC', 'RSDZ', 'TRUEZ', 'NTILE'])
cat_join = join(unreduced, emu_in, keys = 'TARGETID', join_type='left')
outdir_data = unred_path + "ffa_full_" + target_write_name + ".fits"
print("cat_join length = ", len(cat_join))
#outdir_data = unred_path + "ffa_full_" + target_write_name + ".fits"
outdir_data = "/pscratch/sd/s/sikandar/AbacusV3Dump/" + "mock" + str(args.real) + "/" + "ffa_full_old" + target_write_name + ".fits"
join_red = cat_join[np.unique(cat_join["TARGETID"], return_index=True)[1]]
print("cat_join length after unique cut = ", len(join_red))
join_red = ct.addNS(join_red)
join_red.filled().write(outdir_data, overwrite = True)

Expand Down
Loading

0 comments on commit fe8d998

Please sign in to comment.