spacetelescope / ullyses

Code to create products for the ULLYSES program
https://ullyses.stsci.edu/
BSD 3-Clause "New" or "Revised" License
2 stars 6 forks source link

Error calculation in coadd.coadd #2

Open jotaylor opened 3 years ago

jotaylor commented 3 years ago

Do we need this logic?

        self.output_errors[nonzeros] = np.sqrt(self.output_sumweight[nonzeros])
        self.signal_to_noise[nonzeros] = self.output_sumweight[nonzeros] / self.output_errors[nonzeros]
        self.output_errors[nonzeros] = np.abs(self.output_flux[nonzeros] / self.signal_to_noise[nonzeros])

Specifically the second redefinition of the error array?

stscirij commented 3 years ago

Hmm. self.output_errors in counts should be equal to sqrt(total counts). Then signal to noise (as a ratio) should be total counts / errors (both in counts). But then you have to convert the error to flux units, so you can get that by dividing the flux (in erg /cm^2 /sec /angstrom) by the signal to noise. So it makes sense, it's just that it should read

   `self.output_errors[nonzeros] = np.sqrt(self.output_sumgcounts[nonzeros])
    self.signal_to_noise[nonzeros] = self.output_sumgcounts[nonzeros] / self.output_errors[nonzeros]
    self.output_errors[nonzeros] = np.abs(self.output_flux[nonzeros] / self.signal_to_noise[nonzeros])`

The first line uses the total counts in each pixel to calculate the error on those counts by just calculating the sqrt. The second line calculates the S/N as the total counts/error in counts. The S/N is the same whether the fluxes and errors are measured in counts or flux units, so this ratio is used to calculate the error in flux units by dividing the flux in flux units by the S/N.

-

stscirij commented 3 years ago

This should be valid for COS and STIS MAMA data

jotaylor commented 2 years ago

There was some discussion for DR5 about improving the STIS error measurements. We should investigate this after DR5.

jotaylor commented 9 months ago

The perils of time mean that I don't quite remember what we had discussed after DR5. @stscirij, any recollection?