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

functionalize and remove the StampCreator class #761

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

maxwest-uw
Copy link
Collaborator

Removes the StampCreator and leaves all of its methods as functions

resolves #714

(was going through the backlog looking for something to do and couldn't resist the urge to make something more functional)

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Contributor

@jeremykubica jeremykubica left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One blocking change to make (the benchmark) and a bunch of small stylistic fixes to make before merging.

@@ -55,7 +54,6 @@ def run_search_benchmark(params):

# Create an empty search stack.
# im_stack = ImageStack([])
sc = StampCreator()

# Do the timing runs.
tmr = timeit.Timer(stmt="sc.filter_stamp(stamp, params)", globals=locals())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to be changed because sc no longer exists.

StampCreator::StampCreator() {}

std::vector<RawImage> StampCreator::create_stamps(ImageStack& stack, const Trajectory& trj, int radius,
std::vector<RawImage> create_stamps(ImageStack& stack, const Trajectory& trj, int radius,
bool keep_no_data, const std::vector<bool>& use_index) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should moved left to align with the line above.

std::vector<bool> empty_vect;
return create_stamps(stack, t, radius, false /*=keep_no_data*/, empty_vect);
}

// For creating coadded stamps, we do not interpolate the pixel values and keep
// invalid pixels tagged (so we can filter it out of mean/median).
RawImage StampCreator::get_median_stamp(ImageStack& stack, const Trajectory& trj, int radius,
RawImage get_median_stamp(ImageStack& stack, const Trajectory& trj, int radius,
const std::vector<bool>& use_index) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should be moved left to align with the line above.

const std::vector<bool>& use_index) {
return create_median_image(create_stamps(stack, trj, radius, true /*=keep_no_data*/, use_index));
}

// For creating coadded stamps, we do not interpolate the pixel values and keep
// invalid pixels tagged (so we can filter it out of mean/median).
RawImage StampCreator::get_mean_stamp(ImageStack& stack, const Trajectory& trj, int radius,
RawImage get_mean_stamp(ImageStack& stack, const Trajectory& trj, int radius,
const std::vector<bool>& use_index) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should be moved left to align with the line above.

const std::vector<bool>& use_index) {
return create_mean_image(create_stamps(stack, trj, radius, true /*=keep_no_data*/, use_index));
}

// For creating summed stamps, we do not interpolate the pixel values and replace
// invalid pixels with zero (which is the same as filtering it out for the sum).
RawImage StampCreator::get_summed_stamp(ImageStack& stack, const Trajectory& trj, int radius,
RawImage get_summed_stamp(ImageStack& stack, const Trajectory& trj, int radius,
const std::vector<bool>& use_index) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should be moved left to align with the line above.

const std::vector<bool>& use_index) {
return create_summed_image(create_stamps(stack, trj, radius, false /*=keep_no_data*/, use_index));
}

std::vector<RawImage> StampCreator::get_coadded_stamps(ImageStack& stack, std::vector<Trajectory>& t_array,
std::vector<RawImage> get_coadded_stamps(ImageStack& stack, std::vector<Trajectory>& t_array,
std::vector<std::vector<bool>>& use_index_vect,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two lines should be moved left to align with the line above.

@@ -80,7 +78,7 @@ std::vector<RawImage> StampCreator::get_coadded_stamps(ImageStack& stack, std::v
return get_coadded_stamps_cpu(stack, t_array, use_index_vect, params);
}

std::vector<RawImage> StampCreator::get_coadded_stamps_cpu(ImageStack& stack,
std::vector<RawImage> get_coadded_stamps_cpu(ImageStack& stack,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lines below should be moved left to align with this line.

@@ -159,7 +157,7 @@ bool StampCreator::filter_stamp(const RawImage& img, const StampParameters& para
return false;
}

std::vector<RawImage> StampCreator::get_coadded_stamps_gpu(ImageStack& stack,
std::vector<RawImage> get_coadded_stamps_gpu(ImageStack& stack,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lines below should be moved left to align with this line.

@@ -273,7 +271,7 @@ std::vector<RawImage> StampCreator::get_coadded_stamps_gpu(ImageStack& stack,
return results;
}

std::vector<RawImage> StampCreator::create_variance_stamps(ImageStack& stack, const Trajectory& trj,
std::vector<RawImage> create_variance_stamps(ImageStack& stack, const Trajectory& trj,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lines below should be moved left to align with this line.

@@ -295,7 +293,7 @@ std::vector<RawImage> StampCreator::create_variance_stamps(ImageStack& stack, co
return stamps;
}

RawImage StampCreator::get_variance_weighted_stamp(ImageStack& stack, const Trajectory& trj, int radius,
RawImage get_variance_weighted_stamp(ImageStack& stack, const Trajectory& trj, int radius,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line below should be moved left to align with this line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make StampCreator into functions instead of a class of static functions.
2 participants