Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to specify quantisation level #101

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions vast_post_processing/cli/vast_post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ def main(
compress: Optional[bool] = typer.Option(
None, help=("Compress all processed FITS files")
),
compress_quant: Optional[int] = typer.Option(
None, help=("Compression quantisation to use, if compressing.")
),
directory_suffix: Optional[str] = typer.Option(
None, help=("Suffix to use for processed data directories. For "
"example, passing 'PROCESSED' results in images being "
Expand Down Expand Up @@ -116,6 +119,7 @@ def main(
crop_size,
create_moc,
compress,
compress_quant,
directory_suffix,
cat_extension,
fits_extension,
Expand Down
21 changes: 20 additions & 1 deletion vast_post_processing/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def setup_configuration(
crop_size: Optional[float] = None,
create_moc: Optional[bool] = None,
compress: Optional[bool] = None,
compress_quant: Optional[int] = None,
directory_suffix: Optional[str] = None,
cat_extension: Optional[str] = None,
fits_extension: Optional[str] = None,
Expand All @@ -161,6 +162,7 @@ def setup_configuration(
u.Quantity,
bool,
bool,
int,
str,
str,
str,
Expand Down Expand Up @@ -192,6 +194,8 @@ def setup_configuration(
Flag to create MOCs, by default None.
compress : Optional[bool], optional
Flag to compress files, by default None.
compress_quant : Optional[int], optional
Compression quantisation level to use, by default None.
directory_suffix : Optional[str], optional
Suffix to use for processed data directories (for example
`STOKESI_IMAGES_PROCESSED`), by default None.
Expand Down Expand Up @@ -239,6 +243,7 @@ def setup_configuration(
"crop_size": crop_size,
"create_moc": create_moc,
"compress": compress,
"compress_quant": compress_quant,
"directory_suffix": directory_suffix,
"cat_extension": cat_extension,
"fits_extension": fits_extension,
Expand Down Expand Up @@ -468,6 +473,7 @@ def crop_image(
corrected_fits: list[Union[fits.PrimaryHDU, fits.HDUList]],
crop_size: u.Quantity,
compress: bool,
compress_quant: int,
overwrite: bool,
verbose: bool,
debug: bool,
Expand All @@ -494,6 +500,8 @@ def crop_image(
Angular size of crop to be applied.
compress : bool
Flag to compress image data.
compress_quant : int
Compression quantisation to use.
overwrite : bool
Flag to overwrite image data.
verbose : bool
Expand Down Expand Up @@ -544,7 +552,12 @@ def crop_image(
cropped_hdu = crop.crop_hdu(image_hdu, field_centre, size=crop_size)

# Compress image if requested
processed_hdu = compress_hdu(cropped_hdu) if compress else cropped_hdu
if compress:
processed_hdu = compress_hdu(cropped_hdu,
quantize_level=compress_quant
)
else:
processed_hdu = cropped_hdu
fitsutils.update_header_history(processed_hdu.header)

if hdul is not None:
Expand Down Expand Up @@ -729,6 +742,7 @@ def run(
crop_size: Optional[float] = None,
create_moc: Optional[bool] = None,
compress: Optional[bool] = None,
compress_quant: Optional[int] = None,
directory_suffix: Optional[str] = None,
cat_extension: Optional[str] = None,
fits_extension: Optional[str] = None,
Expand Down Expand Up @@ -760,6 +774,8 @@ def run(
Flag to create MOCs, by default None.
compress : Optional[bool], optional
Flag to compress files, by default None.
compress_quant : Optional[int], optional
Compression quantisation to use, by default None.
directory_suffix : Optional[str], optional
Suffix to use for processed data directories (for example
`STOKESI_IMAGES_PROCESSED`), by default None.
Expand All @@ -786,6 +802,7 @@ def run(
crop_size,
create_moc,
compress,
compress_quant,
directory_suffix,
cat_extension,
fits_extension,
Expand All @@ -802,6 +819,7 @@ def run(
crop_size=crop_size,
create_moc=create_moc,
compress=compress,
compress_quant=compress_quant,
directory_suffix=directory_suffix,
cat_extension=cat_extension,
fits_extension=fits_extension,
Expand Down Expand Up @@ -892,6 +910,7 @@ def run(
verbose=verbose,
debug=debug,
compress=compress,
compress_quant=compress_quant,
processed_dir_suffix=directory_suffix,
)
if type(cropped_hdu) == fits.HDUList:
Expand Down
3 changes: 3 additions & 0 deletions vast_post_processing/data/default_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ create_moc: True
# Flag to compress data following pipeline, by default True.
compress: True

# Compression quantisation level to use, by default 1024.
compress_quant: 1024

# Suffix to use for processed data directories
# By default "PROCESSED" which results in e.g. `STOKESI_IMAGES_PROCESSED
directory_suffix: "PROCESSED"
Expand Down