Skip to content

Commit

Permalink
Merge pull request #63 from des-science/fitvd
Browse files Browse the repository at this point in the history
FTR add fitvd pipeline step
  • Loading branch information
beckermr authored Jan 11, 2024
2 parents 8ad846c + eae6b92 commit a05c8b6
Show file tree
Hide file tree
Showing 6 changed files with 493 additions and 19 deletions.
98 changes: 98 additions & 0 deletions eastlake/config/Y6A1_v1_fitvd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# same config should work for cosmos and SN
parspace: 'ngmix'
hst_band: null

# we don't have id yet
match_field: 'number'

# usually this is to skip the coadd
skip_first_epoch: True

weight_type: 'uberseg'

# gaussian aperture weighted fluxes
gap:
# in arcsec
weight_fwhm: 2.5

# cosmic ray detection is pretty good now, and outlier rejection
# tends to cause problems for brightish stars
reject_outliers: False

image_flagnames_to_mask: [
BPM,
SATURATE,
INTERP,
BADAMP,
CRAY,
TRAIL,
EDGEBLEED,
EDGE,
STREAK,
NEAREDGE,
TAPEBUMP,
]


# this is before adding additional masking, e.g. circular mask
# does not apply for uberseg
max_maskfrac: 0.45

# minimum number of unmasked pixels to be used in an epoch. this is only
# checked if using uberseg, or in _set_weight, if the weight map is being
# modified, e.g. circular mask
min_npix: 9

use_mask: False

radius_column: "iso_radius"

max_fof_size: 25

mof:

model: 'bdf'

subtract_neighbors: False

# number of times to try the fit if it fails
ntry: 2

# for guesses
detband: 2

priors:
cen:
type: 'normal2d'
sigma: 0.263

g:
type: 'ba'
sigma: 0.2

T:
type: 'flat'
pars: [-0.1, 1.e+05]

flux:
type: 'flat'
pars: [-1000.0, 1.0e+09]

fracdev:
type: 'normal'
mean: 0.5
sigma: 0.1
bounds: [0.0, 1.0]

psf:
ntry: 4

model: 'coellip3'

lm_pars:
ftol: 1.0e-5
xtol: 1.0e-5

lm_pars:
ftol: 1.0e-5
xtol: 1.0e-5
37 changes: 37 additions & 0 deletions eastlake/config/Y6A1_v1_shredx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
fofs:
# minimum fof size to process
min_fofsize: 1

data:
# zero weights for pixels with these bits set in the mask plane
zero_weight_badpix: 1

guess:
# the guess for each object will be initially laid out with relative flux and
# sizes for each gaussian based on this model

# dev uses 10 gaussians
model: 'dev'

shredding:
# number of gaussians to represent the psf
psf_ngauss: 5

# tolerance for coadd and flux fitting. For the main fit it is the
# relative change in the log likelihood. For the flux fit it is the
# relative change in the total flux
# tol: 0.001

# min and max number of iterations for the main fit on the coadd of all
# bands
# miniter: 40
# maxiter: 500
# miniter: 40

# min and max number of iterations for the flux only adjustments for each
# band
# flux_miniter: 20
# flux_maxiter: 500

# fill in zero weight pixels with the model on each iteration
# fill_zero_weight: True
2 changes: 2 additions & 0 deletions eastlake/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
StashPrep,
BalrogRunner,
DESDMMEDSRunner,
FitvdRunner,
)
from .utils import get_logger, safe_mkdir, pushd
from .stash import Stash
Expand All @@ -51,6 +52,7 @@
('balrog', BalrogRunner),
('delete_sources', DeleteSources),
('desdm_meds', DESDMMEDSRunner),
('fitvd', FitvdRunner),
])

STEP_IS_GALSIM = set(["galsim"])
Expand Down
1 change: 1 addition & 0 deletions eastlake/steps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
from .balrog import BalrogRunner # noqa
from .delete_sources import DeleteSources # noqa
from .desdm_meds import DESDMMEDSRunner # noqa
from .fitvd import FitvdRunner # noqa
39 changes: 20 additions & 19 deletions eastlake/steps/delete_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,32 +123,33 @@ def execute(self, stash, new_params=None):
self.logger.debug("removing file %s" % t)
safe_rm(t)

self.logger.error("removing psf links for %s" % tilename)
self.logger.error("removing psf links for %s" % tilename)

psf_link = os.path.join(
base_dir, stash["desrun"], tilename, "psfs",
os.path.basename(pyml["psf_path"])
)
safe_rm(psf_link)

for sri in pyml["src_info"]:
psf_link = os.path.join(
base_dir, stash["desrun"], tilename, "psfs",
os.path.basename(pyml["psf_path"])
os.path.basename(sri["psf_path"])
)
safe_rm(psf_link)

for sri in pyml["src_info"]:
psf_link = os.path.join(
base_dir, stash["desrun"], tilename, "psfs",
os.path.basename(sri["psf_path"])
)
safe_rm(psf_link)

psf_path = os.path.join(
base_dir, stash["desrun"], tilename, "psfs",
)
safe_rmdir(psf_path)
psf_path = os.path.join(
base_dir, stash["desrun"], tilename, "psfs",
)
safe_rmdir(psf_path)

self.logger.error("deleting empty dirs")
self.logger.error("deleting empty dirs")

for root, dirs, files in os.walk(base_dir, topdown=False):
for name in dirs:
full_dir = os.path.join(root, name)
if len(os.listdir(full_dir)) == 0:
safe_rmdir(full_dir)
tile_path = os.path.join(base_dir, stash["desrun"], tilename)
for root, dirs, files in os.walk(tile_path, topdown=False):
for name in dirs:
full_dir = os.path.join(root, name)
if len(os.listdir(full_dir)) == 0:
safe_rmdir(full_dir)

return 0, stash
Loading

0 comments on commit a05c8b6

Please sign in to comment.