Skip to content

Commit

Permalink
added output directory option to joinup
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Marsh committed May 28, 2021
1 parent 3553b79 commit 5833f12
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions hipercam/scripts/joinup.py
Expand Up @@ -172,6 +172,12 @@ def joinup(args=None):
depend upon the nature of the data. 'none' is fastest. See
astropy.io.fits for further documentation.
odir : str
directory for output files. This routine can produce many
files so it often makes sense to direct them to a specific
directory. '.' for the PWD. [Must exist prior to running
the script.]
.. Note::
Be careful of running this on highly windowed data since it
Expand Down Expand Up @@ -230,6 +236,7 @@ def joinup(args=None):
cl.register("nmax", Cline.LOCAL, Cline.PROMPT)
cl.register("overwrite", Cline.LOCAL, Cline.HIDE)
cl.register("compress", Cline.LOCAL, Cline.PROMPT)
cl.register("odir", Cline.LOCAL, Cline.PROMPT)

# get inputs
default_source = os.environ.get('HIPERCAM_DEFAULT_SOURCE','hl')
Expand Down Expand Up @@ -268,10 +275,16 @@ def joinup(args=None):
)
first = 1

trim = cl.get_value("trim", "do you want to trim edges of windows?", True)
trim = cl.get_value(
"trim", "do you want to trim edges of windows?", True
)
if trim:
ncol = cl.get_value("ncol", "number of columns to trim from windows", 0)
nrow = cl.get_value("nrow", "number of rows to trim from windows", 0)
ncol = cl.get_value(
"ncol", "number of columns to trim from windows", 0
)
nrow = cl.get_value(
"nrow", "number of rows to trim from windows", 0
)

# define the panel grid. first get the labels and maximum dimensions
ccdinf = spooler.get_ccd_pars(source, resource)
Expand All @@ -284,7 +297,9 @@ def joinup(args=None):
ccds = ccd.split()
check = set(ccdinf.keys())
if not set(ccds) <= check:
raise hcam.HipercamError("At least one invalid CCD label supplied")
raise hcam.HipercamError(
"At least one invalid CCD label supplied"
)

else:
ccds = list(ccdinf.keys())
Expand Down Expand Up @@ -349,7 +364,8 @@ def joinup(args=None):

msub = cl.get_value("msub", "subtract median from each window?", True)
ndigit = cl.get_value(
"ndigit", "number of digits to use for frame numbers in output names",
"ndigit",
"number of digits to use for frame numbers in output names",
4, 1
)
dtype = cl.get_value(
Expand Down Expand Up @@ -377,6 +393,10 @@ def joinup(args=None):
'none', 'rice', 'gzip1', 'gzip2'
]
)
odir = cl.get_value(
"odir",
"directory for the output files", '.',
)

################################################################
#
Expand Down Expand Up @@ -599,6 +619,7 @@ def joinup(args=None):
os.path.splitext(mccd.head['FILENAME'])[0]
)
oname = f'{root}_ccd{cnam}.fits'
oname = os.path.join(odir, oname)
hdul.writeto(oname, overwrite=overwrite)
print(f' CCD {cnam}: written to {oname}')
nfile += 1
Expand Down

0 comments on commit 5833f12

Please sign in to comment.