Tuesday, June 7, 2011

oh, cosmic rays

I never thought cosmic rays would ever give me such trouble.

Before I can actually put templates to the M dwarf and white dwarf binary spectra, I have to get rid of the effects of cosmic rays. For about 20 or so pixels out of 3000 for any given spectrum, there is cosmic ray interference, causing the flux values at these wavelengths to be extremely large. In order to have a proper fit with the templates, these flux values need to seem normal for the given dwarf. Luckily there is a category titled 'mask' in the spectra files; if mask =1, then there is cosmic ray interference, if mask = 0, then flux isn't tampered with.

But because we're using templates that need to match the binary spectra, we can't just set the flux to 0 at these points; we need to have it somewhat match the rest of the spectra. To do this, we should be able to take the average of the flux values on either side of the pixel with mask =1 EXCEPT for the fact that there may be two or three pixels in a row with mask =1.

So while this should be an easy task: write a little code that searches for the closest pixel with mask value =0, and take the average, it is proving slightly more difficult.

Maybe it's because I'm having an off day (being sick is the worst), but for the life of me, I can't figure out the way to do this properly. I've ended up kind of screwing around with for, if, while statements in order to get the right code. At the moment, I have it just automated to do the average on each side of the pixel with mask =1. Hopefully tomorrow morning I'll be able to focus more and just quickly get this done.

No comments:

Post a Comment