Skip to content

Commit

Permalink
Added option to allow overwriting of files
Browse files Browse the repository at this point in the history
  • Loading branch information
kfanning committed Mar 16, 2023
1 parent 964596b commit 1ac27a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions bin/downsample_randoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
parser.add_argument('--survey', '-s', default='y1mock', help='Survey to use (typically main or y1mock)')
parser.add_argument('--version', '-v', default=0, help='catalog version, for mocks this is mock number')
parser.add_argument('--impversion', '-i', default=None, help='override version for imputation, default None == same as version')
parser.add_argument('--overwrite', '-o', action='store_true', help='Set flag to allow overwriting of existing files')\

# add dir management
# catdir (for base catalogs for reading, no writing)
# temp dir (intermediate files like logging, nn cats, etc)
Expand Down Expand Up @@ -46,5 +48,5 @@
randcats = Table.read(os.path.join(catdir, f'{uargs.tracer}_S_0_clustering.ran.fits'))
new_randn = cat.downsample_randoms_by_ntile(randcatn, comp_ntile)
new_rands = cat.downsample_randoms_by_ntile(randcats, comp_ntile)
new_rands.write(os.path.join(impute_dir, f'{uargs.tracer}_S_0_clustering.ran.fits'), format='fits')
new_randn.write(os.path.join(impute_dir, f'{uargs.tracer}_N_0_clustering.ran.fits'), format='fits')
new_rands.write(os.path.join(impute_dir, f'{uargs.tracer}_S_0_clustering.ran.fits'), format='fits', overwrite=uargs.overwrite)
new_randn.write(os.path.join(impute_dir, f'{uargs.tracer}_N_0_clustering.ran.fits'), format='fits', overwrite=uargs.overwrite)
10 changes: 6 additions & 4 deletions bin/run_imputation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
parser.add_argument('--version', '-v', default=0, help='catalog version, for mocks this is mock number')
parser.add_argument('--impversion', '-i', default=None, help='override version for imputation, default None == same as version')
parser.add_argument('--nobackground', '-nb', action='store_true', help='Skip imputing "background" (close to random) galaxies.')
parser.add_argument('--overwrite', '-o', action='store_true', help='Set flag to allow overwriting of existing files')\

# add dir management
# catdir (for base catalogs for reading, no writing)
# temp dir (intermediate files like logging, nn cats, etc)
Expand Down Expand Up @@ -46,7 +48,7 @@
imps = impute.ImputeModel(obs_nncat, mis_nncat_s)
imps_cat = imps.run(skip_background=uargs.nobackground)

imps.impute_details.write(os.path.join(stagedir, f'{uargs.tracer}_S_impute_details.fits'))
impn.impute_details.write(os.path.join(stagedir, f'{uargs.tracer}_N_impute_details.fits'))
imps_cat.write(os.path.join(impute_dir, f'{uargs.tracer}_S_clustering.dat.fits'))
impn_cat.write(os.path.join(impute_dir, f'{uargs.tracer}_N_clustering.dat.fits'))
imps.impute_details.write(os.path.join(stagedir, f'{uargs.tracer}_S_impute_details.fits'), overwrite=uargs.overwrite)
impn.impute_details.write(os.path.join(stagedir, f'{uargs.tracer}_N_impute_details.fits'), overwrite=uargs.overwrite)
imps_cat.write(os.path.join(impute_dir, f'{uargs.tracer}_S_clustering.dat.fits'), overwrite=uargs.overwrite)
impn_cat.write(os.path.join(impute_dir, f'{uargs.tracer}_N_clustering.dat.fits'), overwrite=uargs.overwrite)

0 comments on commit 1ac27a2

Please sign in to comment.