Skip to content

Commit

Permalink
Include mean wavelength in stdout capture filename
Browse files Browse the repository at this point in the history
  • Loading branch information
jsy1001 committed May 5, 2022
1 parent 9aca81f commit 8d562b0
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions oirunner/runbsmem.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@
DEFAULT_MW = 10.0


def _get_outputfile(datafile: str, iteration: int) -> str:
def _get_outputfile(
datafile: str, iteration: int, wav: Optional[Tuple[float, float]]
) -> str:
dirname, basename = os.path.split(datafile)
stem = os.path.splitext(basename)[0]
return os.path.join(dirname, f"bsmem_{iteration}_{stem}.fits")
stem, _ = os.path.splitext(basename)
if wav is None:
return os.path.join(dirname, f"bsmem_{iteration}_{stem}.fits")
else:
meanwav = int((wav[0] + wav[1]) / 2)
return os.path.join(dirname, f"bsmem_{iteration}_{stem}_{meanwav}nm.fits")


def run_bsmem(args: Sequence[str], fullstdout: Optional[str] = None) -> None:
Expand Down Expand Up @@ -180,7 +186,7 @@ def reconst_grey_basic(
Output FITS filename.
"""
outputfile = _get_outputfile(datafile, 1)
outputfile = _get_outputfile(datafile, 1, wav)
run_bsmem_using_model(
datafile,
outputfile,
Expand Down Expand Up @@ -215,7 +221,7 @@ def reconst_grey_basic_using_image(
Output FITS filename.
"""
outputfile = _get_outputfile(datafile, 1)
outputfile = _get_outputfile(datafile, 1, wav)
with fits.open(imagefile) as hdulist:
imagehdu = hdulist[0]
dim = imagehdu.data.shape[0]
Expand Down Expand Up @@ -264,7 +270,7 @@ def reconst_grey_2step(
"""
# TODO: intelligent defaults for uvmax1, fwhm?
out1file = _get_outputfile(datafile, 1)
out1file = _get_outputfile(datafile, 1, wav)
run_bsmem_using_model(
datafile,
out1file,
Expand All @@ -278,7 +284,7 @@ def reconst_grey_2step(
)
with fits.open(out1file) as hdulist:
imagehdu = makesf(hdulist[0], fwhm, threshold)
out2file = _get_outputfile(datafile, 2)
out2file = _get_outputfile(datafile, 2, wav)
run_bsmem_using_image(
datafile, out2file, dim, pixelsize, imagehdu, wav=wav, alpha=alpha
)
Expand Down Expand Up @@ -309,7 +315,7 @@ def reconst_grey_2step_using_image(
Output FITS filename.
"""
out1file = _get_outputfile(datafile, 1)
out1file = _get_outputfile(datafile, 1, wav)
with fits.open(imagefile) as hdulist:
image1hdu = hdulist[0]
dim = image1hdu.data.shape[0]
Expand All @@ -324,7 +330,7 @@ def reconst_grey_2step_using_image(
uvmax=uvmax1,
alpha=alpha,
)
out2file = _get_outputfile(datafile, 2)
out2file = _get_outputfile(datafile, 2, wav)
with fits.open(out1file) as hdulist:
image2hdu = makesf(hdulist[0], fwhm, threshold)
run_bsmem_using_image(
Expand Down

0 comments on commit 8d562b0

Please sign in to comment.