Skip to content

Commit

Permalink
v1.2 (#13)
Browse files Browse the repository at this point in the history
* Updates for v1.2

* Oops. Didn't add lsstV1/V2.

* No longer forcing random_state.

* Linting tests.

* Linting
  • Loading branch information
jfcrenshaw committed Feb 29, 2024
1 parent 523c41e commit 8e15499
Show file tree
Hide file tree
Showing 12 changed files with 519 additions and 143 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
fail-fast: true
matrix:
os: ["ubuntu-latest", "macos-latest"]
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.10", "3.11", "3.12"]
runs-on: ${{ matrix.os }}

steps:
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ If you are changing other dictionary-parameters at the same time (e.g. `nVisYr`,

By default, PhotErr tries to use the provided information to calculate limiting magnitudes for you.
If you would like to directly supply your own $5\sigma$ limits, you can do so using the `m5` parameter.
Note that PhotErr assumes these are single-visit limiting magnitudes.
If you want to supply coadded depths, you should also set `nYrObs=1` and `nVisYr={u: 1, g: 1, ...}`, so that the calculated coadded depths are equal to those you provided.
Note PhotErr assumes these are single-visit point-source limiting magnitudes.
If you want to supply coadded depths, you should also set `nYrObs=1` and `nVisYr=1`, so that the calculated coadded depths are equal to those you provided.

### *Handling non-detections*

Expand Down Expand Up @@ -120,12 +120,12 @@ You can also calculate limiting magnitudes for apertures of a given size by pass

### Scaling the errors

If you want to scale up or scale down the errors in any band(s), you can use the keyword `scale`.
If you want to scale up or scale down the errors in any band(s), you can use the keyword `scale`.
For example, `LsstErrorModel(scale={"u": 2, "y": 2})` will have all the same properties of the default error model, except the errors in the `u` and `y` bands will be doubled.
This allows you to answer questions like "what happens to my science if the `u` band errors are doubled."

Note this only scales the band-specific error.
The band-independent systematic error floor, `sigmaSys` is still the same, and so at high-SNR, near the systematic floor, the errors won't scale as you expect.
The band-independent systematic error floor, `sigmaSys` is still the same, and so at high-SNR near the systematic floor, the errors won't scale as you expect.

### *Other error models*

Expand Down Expand Up @@ -169,7 +169,7 @@ In PhotErr, we do not make this approximation so that the error model generalize
In addition, while the high-SNR model assumes photometric errors are Gaussian in magnitude space, we model errors as Gaussian in flux space.
However, both of these high-SNR approximations can be restored with the keyword `highSNR=True`.

The LSST error model uses the parameters from [Ivezic (2019)](https://arxiv.org/abs/0805.2366).
The LSST error model uses parameters from [Ivezic (2019)](https://arxiv.org/abs/0805.2366), [Bianco 2022](https://pstn-054.lsst.io), and from [this Rubin systems engineering notebook](https://github.com/lsst-pst/syseng_throughputs/blob/main/notebooks/EvalReadnoise.ipynb).
The Euclid and Roman error models follow [Graham (2020)](https://arxiv.org/abs/2004.07885) in setting $\gamma = 0.04$, which is nearly identical to the values for Rubin (which are all $\sim 0.039$).

In addition to the random photometric error above, we include a system error of $\sigma_\text{sys} = 0.005$ which is added in quadrature to random error. Note that the system error can be changed using the keyword `sigmaSys`.
Expand Down
12 changes: 11 additions & 1 deletion photerr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@
from importlib import metadata

from .euclid import EuclidErrorModel, EuclidErrorParams
from .lsst import LsstErrorModel, LsstErrorParams
from .lsstV1 import LsstErrorModelV1, LsstErrorParamsV1
from .lsstV2 import LsstErrorModelV2, LsstErrorParamsV2
from .model import ErrorModel
from .params import ErrorParams
from .roman import RomanErrorModel, RomanErrorParams

# set the version number
__version__ = metadata.version(__package__)
del metadata

# alias the latest LSST error model
class LsstErrorParams(LsstErrorParamsV2):
...


class LsstErrorModel(LsstErrorModelV2):
...
21 changes: 5 additions & 16 deletions photerr/euclid.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Photometric error model for Euclid."""

from dataclasses import dataclass, field
from typing import Any, Dict
from typing import Any

from photerr.model import ErrorModel
from photerr.params import ErrorParams, param_docstring
Expand All @@ -18,22 +19,10 @@ class EuclidErrorParams(ErrorParams):
__doc__ += " Graham 2020 - https://arxiv.org/abs/2004.07885"

nYrObs: float = 1.0
nVisYr: Dict[str, float] = field(
default_factory=lambda: {
"Y": 1.0,
"J": 1.0,
"H": 1.0,
}
)
gamma: Dict[str, float] = field(
default_factory=lambda: {
"Y": 0.04,
"J": 0.04,
"H": 0.04,
}
)
nVisYr: dict[str, float] | float = 1.0
gamma: dict[str, float] | float = 0.04

m5: Dict[str, float] = field(
m5: dict[str, float] | float = field(
default_factory=lambda: {
"Y": 24.0,
"J": 24.2,
Expand Down
117 changes: 117 additions & 0 deletions photerr/lsstV1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
"""Photometric error model for LSST using defaults from Ivezic 2019."""

from dataclasses import dataclass, field
from typing import Any

from photerr.model import ErrorModel
from photerr.params import ErrorParams, param_docstring


@dataclass
class LsstErrorParamsV1(ErrorParams):
"""Parameters for the LSST photometric error model.
Default values taken from pages 11, 12, 26 of Ivezic 2019.
"""

__doc__ += param_docstring

nYrObs: float = 10.0
nVisYr: dict[str, float] | float = field(
default_factory=lambda: {
"u": 5.6,
"g": 8.0,
"r": 18.4,
"i": 18.4,
"z": 16.0,
"y": 16.0,
}
)
gamma: dict[str, float] | float = field(
default_factory=lambda: {
"u": 0.038,
"g": 0.039,
"r": 0.039,
"i": 0.039,
"z": 0.039,
"y": 0.039,
}
)

m5: dict[str, float] | float = field(default_factory=lambda: {})

tvis: dict[str, float] | float = 30
airmass: dict[str, float] | float = 1.2
Cm: dict[str, float] | float = field(
default_factory=lambda: {
"u": 23.09,
"g": 24.42,
"r": 24.44,
"i": 24.32,
"z": 24.16,
"y": 23.73,
}
)
dCmInf: dict[str, float] | float = field(
default_factory=lambda: {
"u": 0.62,
"g": 0.18,
"r": 0.10,
"i": 0.07,
"z": 0.05,
"y": 0.04,
}
)
msky: dict[str, float] | float = field(
default_factory=lambda: {
"u": 22.99,
"g": 22.26,
"r": 21.20,
"i": 20.48,
"z": 19.60,
"y": 18.61,
}
)
mskyDark: dict[str, float] | float = field(
default_factory=lambda: {
"u": 22.99,
"g": 22.26,
"r": 21.20,
"i": 20.48,
"z": 19.60,
"y": 18.61,
}
)
theta: dict[str, float] | float = field(
default_factory=lambda: {
"u": 0.92,
"g": 0.87,
"r": 0.83,
"i": 0.80,
"z": 0.78,
"y": 0.76,
}
)
km: dict[str, float] | float = field(
default_factory=lambda: {
"u": 0.491,
"g": 0.213,
"r": 0.126,
"i": 0.096,
"z": 0.069,
"y": 0.170,
}
)

tvisRef: float | None = 30


class LsstErrorModelV1(ErrorModel):
"""Photometric error model for Euclid."""

def __init__(self, **kwargs: Any) -> None:
"""Create an LSST error model.
Keyword arguments override default values in LsstErrorParams.
"""
super().__init__(LsstErrorParamsV1(**kwargs))
138 changes: 138 additions & 0 deletions photerr/lsstV2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
"""Photometric error model for LSST as of Feb 28, 2024."""

from dataclasses import dataclass, field
from typing import Any

from photerr.model import ErrorModel
from photerr.params import ErrorParams, param_docstring


@dataclass
class LsstErrorParamsV2(ErrorParams):
"""Parameters for the LSST photometric error model.
Default values match v1.9 of the official LSST throughputs, including the
silver coatings on all three mirrors. The values for tvis and nVisYr were
taken from one of the OpSim runs that Lynne Jones said is likely to resemble
the final exposure times and visit distributions.
"""

__doc__ += param_docstring

nYrObs: float = 10.0
nVisYr: dict[str, float] | float = field(
default_factory=lambda: {
"u": 6.3,
"g": 6.8,
"r": 18.1,
"i": 18.8,
"z": 16.6,
"y": 16.3,
}
)
gamma: dict[str, float] | float = field(
default_factory=lambda: {
"u": 0.038,
"g": 0.039,
"r": 0.039,
"i": 0.039,
"z": 0.039,
"y": 0.039,
}
)

m5: dict[str, float] | float = field(default_factory=lambda: {})

tvis: dict[str, float] | float = field(
default_factory=lambda: {
"u": 38,
"g": 30,
"r": 30,
"i": 30,
"z": 30,
"y": 30,
}
)
airmass: dict[str, float] | float = field(
default_factory=lambda: {
"u": 1.15,
"g": 1.15,
"r": 1.14,
"i": 1.15,
"z": 1.16,
"y": 1.16,
}
)
Cm: dict[str, float] | float = field(
default_factory=lambda: {
"u": 22.968,
"g": 24.582,
"r": 24.602,
"i": 24.541,
"z": 24.371,
"y": 23.840,
}
)
dCmInf: dict[str, float] | float = field(
default_factory=lambda: {
"u": 0.543,
"g": 0.088,
"r": 0.043,
"i": 0.028,
"z": 0.019,
"y": 0.016,
}
)
msky: dict[str, float] | float = field(
default_factory=lambda: {
"u": 22.65,
"g": 22.07,
"r": 21.10,
"i": 19.99,
"z": 19.04,
"y": 18.28,
}
)
mskyDark: dict[str, float] | float = field(
default_factory=lambda: {
"u": 23.052,
"g": 22.254,
"r": 21.198,
"i": 20.463,
"z": 19.606,
"y": 18.602,
}
)
theta: dict[str, float] | float = field(
default_factory=lambda: {
"u": 1.22,
"g": 1.09,
"r": 1.02,
"i": 0.99,
"z": 1.01,
"y": 0.99,
}
)
km: dict[str, float] | float = field(
default_factory=lambda: {
"u": 0.470,
"g": 0.213,
"r": 0.126,
"i": 0.096,
"z": 0.068,
"y": 0.171,
}
)

tvisRef: float | None = 30


class LsstErrorModelV2(ErrorModel):
"""Photometric error model for Euclid."""

def __init__(self, **kwargs: Any) -> None:
"""Create an LSST error model.
Keyword arguments override default values in LsstErrorParams.
"""
super().__init__(LsstErrorParamsV2(**kwargs))
Loading

0 comments on commit 8e15499

Please sign in to comment.