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

memory fix for chip-level object down-selection #176

Merged

Conversation

jchiang87
Copy link
Collaborator

No description provided.

Copy link
Member

@cwwalter cwwalter left a comment

Choose a reason for hiding this comment

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

It looks OK, but at least one more person who really loves numpy should look at this since some of the stuff like:

 on_chip = np.where(np.logical_or(mag_norm<max_mag,
                           np.logical_and(xpix>x_min-pix_tol,
                           np.logical_and(xpix<x_max+pix_tol,
                           np.logical_and(ypix>y_min-pix_tol,
                                          ypix<y_max+pix_tol)))))

Are things I don't have that much experience with.

def uss_mem():
"""Return unique set size memory of current process in GB."""
my_process = psutil.Process(os.getpid())
return my_process.memory_full_info().uss/1024.**3
Copy link
Member

Choose a reason for hiding this comment

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

I did some research and it looks like this is also supposed to work on OSX:

http://www.pybloggers.com/2016/02/psutil-4-0-0-and-how-to-get-real-process-memory-and-environ-in-python/

But it might not be bad to double check this doesn't do something crazy if we aren't on Linux.

Copy link
Contributor

Choose a reason for hiding this comment

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

No worries. It works on OSX. (My Mac at least.) And it has both rss and uss attributes as required.

@@ -343,58 +350,77 @@ def sources_from_list(object_lines, obs_md, phot_params, file_name,
message += " %d had n_points <= 0 \n" % n_bad_knots
warnings.warn(message)

wav_int = None
wav_gal = None
target_chips = [target_chip] if target_chip is not None else None
Copy link
Member

Choose a reason for hiding this comment

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

From the doctoring etc if target_chip is None then you should use all sensors. This is accomplished here by having the target_chips=None interpreted in _chip_downselect as meaning you should use all of them with [det.getName() for det in lsst_camera()].

FWIW I found this confusing when I first read the code. This is far enough done in the function that a comment here and in the docstring of _chip_downselect would probably be useful.

@jchiang87
Copy link
Collaborator Author

The code like this

on_chip = np.where(np.logical_or(mag_norm<max_mag,
                           np.logical_and(xpix>x_min-pix_tol,
                           np.logical_and(xpix<x_max+pix_tol,
                           np.logical_and(ypix>y_min-pix_tol,
                                          ypix<y_max+pix_tol)))))

isn't new of course, and so it isn't really part of this PR.

@cwwalter
Copy link
Member

cwwalter commented Oct 8, 2018

isn't new of course, and so it isn't really part of this PR.

Yes, I know...

I was just saying I struggled a bit with some of the code. There were enough changes in the diff that I went over it all again from scratch.

@@ -439,11 +451,8 @@ def sources_from_list(object_lines, obs_md, phot_params, file_name,
np.logical_and(ypix>y_min-pix_tol,
ypix<y_max+pix_tol)))))
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, this is equivalent to the more legible

on_chip = np.where( (mag_norm < max_mag) |
                    ( (xpix > x_min - pix_tol) & (xpix < x_max + pix_tol) &
                      (ypix > y_min - pix_tol) & (ypix < y_max + pix_tol) )
                  )

Copy link
Member

@cwwalter cwwalter Oct 8, 2018

Choose a reason for hiding this comment

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

OK thank you. I

In anycase, I didn't actually find any problems with the code. So, it looks good to me.

@jchiang87
Copy link
Collaborator Author

Unless I hear otherwise, I'll merge this at 12 Noon PT today.

@jchiang87
Copy link
Collaborator Author

jchiang87 commented Oct 11, 2018

@danielsf I had to update the test_instcat_parser.py tests to account for the changes to the chip downselection in sources_from_list. Could you have a look please? I'll hold off on merging until you've given your ok. Thanks!

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) to 73.588% when pulling 75cb598 on u/jchiang/chip_downselection_memory_reduction into ab550a9 on dc2_run2.0_rc.

Copy link
Contributor

@danielsf danielsf left a comment

Choose a reason for hiding this comment

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

Looks good to me

@jchiang87
Copy link
Collaborator Author

Thanks, Scott. I'll merge at 1pm PT today.

@jchiang87 jchiang87 merged commit 97056a3 into dc2_run2.0_rc Oct 15, 2018
@jchiang87 jchiang87 deleted the u/jchiang/chip_downselection_memory_reduction branch November 15, 2018 05:16
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.

5 participants