Skip to content

Commit

Permalink
Merge pull request #863 from dirac-institute/issue-849
Browse files Browse the repository at this point in the history
providing exposure time to trailing loss calculations
  • Loading branch information
mschwamb authored Mar 27, 2024
2 parents 5098509 + 63bc3e7 commit 5c8d1f9
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 8 deletions.
6 changes: 4 additions & 2 deletions docs/notebooks/demo_TrailingLossPhasecurve.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@
" 'Sun-Ast-Obs(deg)': jpl_eph['alpha_true'],\n",
" 'AstRARate(deg/day)' : jpl_eph['RA_rate'] * 24/3600, # note horizons already applies the cos(dec) term \n",
" 'AstDecRate(deg/day)' : jpl_eph['DEC_rate']* 24/3600,\n",
" 'seeingFwhmEff_arcsec' : 0.8 * np.ones_like(jpl_eph['G'])})"
" 'seeingFwhmEff_arcsec' : 0.8 * np.ones_like(jpl_eph['G']),\n",
" 'visitExposureTime' : 30.0 * np.ones_like(jpl_eph['G']),\n",
" })"
]
},
{
Expand Down Expand Up @@ -236,7 +238,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.11.7"
}
},
"nbformat": 4,
Expand Down
14 changes: 10 additions & 4 deletions docs/notebooks/demo_UncertaintiesAndRandomization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"astRArate = np.ones(len(obj_ids)) + 0.03\n",
"astDecrate = np.ones(len(obj_ids)) - 0.01\n",
"astRA = np.ones(len(obj_ids)) + 260.\n",
"astDec = np.ones(len(obj_ids)) -5."
"astDec = np.ones(len(obj_ids)) -5.\n",
"texp = np.ones(len(obj_ids)) * 30.0"
]
},
{
Expand All @@ -70,7 +71,9 @@
" 'AstRARate(deg/day)': astRArate,\n",
" 'AstDecRate(deg/day)': astDecrate,\n",
" 'AstRA(deg)': astRA,\n",
" 'AstDec(deg)': astDec})"
" 'AstDec(deg)': astDec,\n",
" 'visitExposureTime': texp,\n",
" })"
]
},
{
Expand Down Expand Up @@ -245,7 +248,8 @@
"astRArate = np.ones(len(obj_ids)) + 0.03\n",
"astDecrate = np.ones(len(obj_ids)) - 0.01\n",
"astRA = np.linspace(0, 360, 1000)\n",
"astDec = np.linspace(-90, 0, 1000)"
"astDec = np.linspace(-90, 0, 1000)\n",
"texp = np.ones(len(obj_ids)) * 30.0"
]
},
{
Expand All @@ -262,7 +266,9 @@
" 'AstRARate(deg/day)': astRArate,\n",
" 'AstDecRate(deg/day)': astDecrate,\n",
" 'AstRA(deg)': astRA,\n",
" 'AstDec(deg)': astDec})"
" 'AstDec(deg)': astDec,\n",
" 'visitExposureTime': texp,\n",
" })"
]
},
{
Expand Down
10 changes: 9 additions & 1 deletion src/sorcha/modules/PPAddUncertainties.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def uncertainties(
dra_name="AstRARate(deg/day)",
ddec_name="AstDecRate(deg/day)",
dec_name="AstDec(deg)",
visit_time_name="visitExposureTime",
):
"""
Add astrometric and photometric uncertainties to observations.
Expand Down Expand Up @@ -177,6 +178,10 @@ def uncertainties(
pandas dataframe column name of the object declination
Default = "AstDec(deg)"
visit_time_name : string, optional
pandas dataframe column name for exposure length
Default = "visitExposureTime"
Returns
-----------
astrSigDeg: numpy array
Expand All @@ -191,7 +196,10 @@ def uncertainties(

if configs.get("trailing_losses_on", False):
dMag = PPTrailingLoss.calcTrailingLoss(
detDF[dra_name] * degCos(detDF[dec_name]), detDF[ddec_name], detDF[seeingName]
detDF[dra_name],
detDF[ddec_name],
detDF[seeingName],
texp=detDF[visit_time_name],
)
else:
dMag = 0.0
Expand Down
7 changes: 6 additions & 1 deletion src/sorcha/modules/PPTrailingLoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def calcTrailingLoss(
seeing : float or array of floats
FWHM of the seeing disk. [Units: arcseconds]
texp : float, optional
texp : float or array of floats, optional
Exposure length. [Units: seconds] Default = 30
model : string, optional
Expand Down Expand Up @@ -110,6 +110,7 @@ def PPTrailingLoss(
ddec_name="AstDecRate(deg/day)",
dec_name="AstDec(deg)",
seeing_name_survey="seeingFwhmEff_arcsec",
visit_time_name="visitExposureTime",
):
"""
Calculates detection trailing losses. Wrapper for calcTrailingLoss.
Expand All @@ -136,6 +137,9 @@ def PPTrailingLoss(
seeing_name_survey : string, optional
"oif_df" column name for seeing. Default = "seeingFwhmEff_arcsec"
visit_time_name : string, optional
"oif_df" column name for exposure length. Default = "visitExposureTime"
Returns
-----------
dmag : float or array of floats
Expand All @@ -150,6 +154,7 @@ def PPTrailingLoss(
oif_df[dra_cosdec_name],
oif_df[ddec_name],
oif_df[seeing_name_survey],
texp=oif_df[visit_time_name],
model=model,
)

Expand Down
3 changes: 3 additions & 0 deletions tests/sorcha/test_PPAddUncertainty.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def test_addUncertainties():
astDecrate = [-0.01, -0.01, -0.01, -0.01]
astRA = [260.0, 260.0, 260.0, 260.0]
astDec = [-5.0, -5.0, -5.0, -5]
t_exp = [30.0, 30.0, 30.0, 30.0]

test_data = pd.DataFrame(
{
Expand All @@ -99,6 +100,7 @@ def test_addUncertainties():
"AstDecRate(deg/day)": astDecrate,
"AstRA(deg)": astRA,
"AstDec(deg)": astDec,
"visitExposureTime": t_exp,
}
)

Expand Down Expand Up @@ -162,6 +164,7 @@ def test_uncertainties():
"AstRARate(deg/day)": [0.03],
"AstDecRate(deg/day)": [-0.01],
"AstDec(deg)": [-5.0],
"visitExposureTime": [30.0],
}
)

Expand Down
1 change: 1 addition & 0 deletions tests/sorcha/test_PPTrailingLoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def test_PPTrailingLoss():
}
)

testoifdf["visitExposureTime"] = 30.0
# add cos dec term
testoifdf["AstRARate(deg/day)"] *= np.cos(testoifdf["AstDec(deg)"] * np.pi / 180.0)

Expand Down

0 comments on commit 5c8d1f9

Please sign in to comment.