-
Notifications
You must be signed in to change notification settings - Fork 2
Various fixes #71
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
Draft
bhazelton
wants to merge
14
commits into
main
Choose a base branch
from
various_fixes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+136
−52
Draft
Various fixes #71
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8984df9
Fix a couple things I stumbled on in the contribution guide
bhazelton 5b9747f
remove defaults from the conda env
bhazelton cf3d8f4
fix path handling and a numpy bug
bhazelton 3c65109
fix errors in uvfits reader
bhazelton b31ae2a
fix checkpointing to work properly
bhazelton 5682be6
fix vis_model_transfer to handle standard FHD folder structure
bhazelton b1aebe0
fix misspelled calibration checkpoint option in yamls
bhazelton c39fe3f
fix shape error in vis_baseline_hist caused by flagged data
bhazelton 925f6cd
Add more prominent explanation of passing None via yamls.
bhazelton ac4c51a
fix more checkpointing errors
bhazelton e5934c7
fix keyerror caused by not checking for key existence
bhazelton 7e4f250
fix a bug in image plotting
bhazelton 60ea3c1
fix a keyerror and numpy indexing errors in beam_image
bhazelton 4788b58
fix defaulting of baseline_threshold in dirty_image_generate
bhazelton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -144,6 +144,45 @@ def main(): | |
| ) | ||
| pyfhd_config["checkpoint_dir"].mkdir(exist_ok=True) | ||
|
|
||
| obs_checkpoint_file = Path( | ||
| pyfhd_config["checkpoint_dir"], | ||
| f"{checkpoint_name}_obs_checkpoint.h5", | ||
| ) | ||
| if ( | ||
| pyfhd_config["obs_checkpoint"] is not None | ||
| and not obs_checkpoint_file.exists() | ||
| ): | ||
| logger.warning( | ||
| "obs_checkpoint is set but obs checkpoint file does not exist. Recalculating obs." | ||
| ) | ||
| pyfhd_config["obs_checkpoint"] = None | ||
|
|
||
| cal_checkpoint_file = Path( | ||
| pyfhd_config["checkpoint_dir"], | ||
| f"{checkpoint_name}_calibrate_checkpoint.h5", | ||
| ) | ||
| if ( | ||
| pyfhd_config["calibrate_checkpoint"] is not None | ||
| and not cal_checkpoint_file.exists() | ||
| ): | ||
| logger.warning( | ||
| "calibrate_checkpoint is set but cal checkpoint file does not exist. Recalculating cal." | ||
| ) | ||
| pyfhd_config["calibrate_checkpoint"] = None | ||
|
|
||
| grid_checkpoint_file = Path( | ||
| pyfhd_config["checkpoint_dir"], | ||
| f"{checkpoint_name}_gridding_checkpoint.h5", | ||
| ) | ||
| if ( | ||
| pyfhd_config["gridding_checkpoint"] is not None | ||
| and not grid_checkpoint_file.exists() | ||
| ): | ||
| logger.warning( | ||
| "gridding_checkpoint is set but grid checkpoint file does not exist. Recalculating grid." | ||
| ) | ||
| pyfhd_config["gridding_checkpoint"] = None | ||
|
|
||
| if ( | ||
| pyfhd_config["obs_checkpoint"] is None | ||
| and pyfhd_config["calibrate_checkpoint"] is None | ||
|
|
@@ -217,10 +256,7 @@ def main(): | |
| "vis_weights": vis_weights, | ||
| } | ||
| save( | ||
| Path( | ||
| pyfhd_config["checkpoint_dir"], | ||
| f"{checkpoint_name}_obs_checkpoint.h5", | ||
| ), | ||
| obs_checkpoint_file, | ||
| checkpoint, | ||
| "obs_checkpoint", | ||
| logger=logger, | ||
|
|
@@ -231,11 +267,8 @@ def main(): | |
| ) | ||
| else: | ||
| # Load the checkpoint and initialize the required variables | ||
| if ( | ||
| pyfhd_config["obs_checkpoint"] | ||
| and Path(pyfhd_config["obs_checkpoint"]).exists() | ||
| ): | ||
| obs_checkpoint = load(pyfhd_config["obs_checkpoint"], logger=logger) | ||
| if pyfhd_config["obs_checkpoint"]: | ||
| obs_checkpoint = load(obs_checkpoint_file, logger=logger) | ||
| obs = obs_checkpoint["obs"] | ||
| params = obs_checkpoint["params"] | ||
| vis_arr = obs_checkpoint["vis_arr"] | ||
|
|
@@ -249,9 +282,9 @@ def main(): | |
| # to get the observation metadata and visibility parameters | ||
| if ( | ||
| pyfhd_config["calibrate_checkpoint"] is not None | ||
| and Path(pyfhd_config["calibrate_checkpoint"]).exists() | ||
| and cal_checkpoint_file.exists() | ||
| ): | ||
| cal_checkpoint = load(pyfhd_config["calibrate_checkpoint"], logger=logger) | ||
| cal_checkpoint = load(cal_checkpoint_file, logger=logger) | ||
| obs = cal_checkpoint["obs"] | ||
| params = cal_checkpoint["params"] | ||
| vis_arr = cal_checkpoint["vis_arr"] | ||
|
|
@@ -272,7 +305,10 @@ def main(): | |
| ) | ||
|
|
||
| # Check if the calibrate checkpoint has been used, if not run the calibration steps | ||
| if pyfhd_config["calibrate_checkpoint"] is None: | ||
| if ( | ||
| pyfhd_config["calibrate_checkpoint"] is None | ||
| or not cal_checkpoint_file.exists() | ||
| ): | ||
| if pyfhd_config["deproject_w_term"] is not None: | ||
| w_term_start = time.time() | ||
| vis_arr = simple_deproject_w_term( | ||
|
|
@@ -394,10 +430,7 @@ def main(): | |
| "cal": cal, | ||
| } | ||
| save( | ||
| Path( | ||
| pyfhd_config["checkpoint_dir"], | ||
| f"{checkpoint_name}_calibrate_checkpoint.h5", | ||
| ), | ||
| cal_checkpoint_file, | ||
| checkpoint, | ||
| "calibrate_checkpoint", | ||
| logger=logger, | ||
|
|
@@ -461,7 +494,7 @@ def main(): | |
| pyfhd_successful = True | ||
| sys.exit(0) | ||
|
|
||
| if ( | ||
| if "image_info" not in psf or ( | ||
| psf["image_info"]["image_power_beam_arr"] is not None | ||
| and psf["image_info"]["image_power_beam_arr"].shape == 1 | ||
| ): | ||
|
|
@@ -471,7 +504,8 @@ def main(): | |
|
|
||
| if ( | ||
| pyfhd_config["recalculate_grid"] | ||
| and pyfhd_config["gridding_checkpoint"] is None | ||
| or pyfhd_config["gridding_checkpoint"] is None | ||
| or not grid_checkpoint_file.exists() | ||
| ): | ||
| grid_start = time.time() | ||
| image_uv = np.empty( | ||
|
|
@@ -535,6 +569,8 @@ def main(): | |
| if vis_model_arr is not None: | ||
| model_uv = crosspol_reformat(model_uv) | ||
| if pyfhd_config["gridding_plots"]: | ||
| # TODO: move this after the checkpointing so an error in plotting | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ohhh agreed. |
||
| # doesn't require rerunning gridding. | ||
| logger.info( | ||
| f"Plotting the continuum gridding outputs into {pyfhd_config['output_dir']/'plots'/'gridding'}" | ||
| ) | ||
|
|
@@ -557,10 +593,7 @@ def main(): | |
| if vis_model_arr is not None: | ||
| checkpoint["model_uv"] = model_uv | ||
| save( | ||
| Path( | ||
| pyfhd_config["checkpoint_dir"], | ||
| f"{checkpoint_name}_gridding_checkpoint.h5", | ||
| ), | ||
| grid_checkpoint_file, | ||
| checkpoint, | ||
| "gridding_checkpoint", | ||
| logger=logger, | ||
|
|
@@ -573,9 +606,7 @@ def main(): | |
| _print_time_diff(grid_start, grid_end, "Visibilities gridded", logger) | ||
| else: | ||
| if pyfhd_config["gridding_checkpoint"]: | ||
| grid_checkpoint = load( | ||
| pyfhd_config["gridding_checkpoint"], logger=logger | ||
| ) | ||
| grid_checkpoint = load(grid_checkpoint_file, logger=logger) | ||
| image_uv = grid_checkpoint["image_uv"] | ||
| weights_uv = grid_checkpoint["weights_uv"] | ||
| variance_uv = grid_checkpoint["variance_uv"] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth linking the memo here for the uninitiated? Or putting it in the repo somewhere