-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make it possible to replace seeing, clouds, downtime in ModelObservatory
- Loading branch information
Showing
2 changed files
with
111 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import numpy as np | ||
import unittest | ||
|
||
from rubin_sim.scheduler.model_observatory import ModelObservatory | ||
|
||
|
||
class KindaClouds(object): | ||
"""Dummy class that always sets the clouds level to a unique float""" | ||
|
||
def __call__(self, mjd): | ||
return 0.23659 | ||
|
||
|
||
class ArbSeeing(object): | ||
"""Dummy class to always return a specific seeing value""" | ||
|
||
def __call__(self, mjd): | ||
fwhm_500 = 1.756978 | ||
return fwhm_500 | ||
|
||
|
||
class TestModelObservatory(unittest.TestCase): | ||
def test_replace(self): | ||
"""test that we can replace default downtimes, seeing, and clouds""" | ||
|
||
mjd_start = 60796.0 | ||
mo_default = ModelObservatory(mjd_start=mjd_start) | ||
cond_default = mo_default.return_conditions() | ||
|
||
# Define new downtimes | ||
downtimes = np.zeros(2, dtype=list(zip(["start", "end"], [float, float]))) | ||
downtimes["start"] = np.array([1, 10]) + mjd_start | ||
downtimes["end"] = np.array([2, 11]) + mjd_start | ||
|
||
seeing_data = ArbSeeing() | ||
cloud_data = KindaClouds() | ||
|
||
mo_new = ModelObservatory( | ||
mjd_start=mjd_start, | ||
seeing_data=seeing_data, | ||
cloud_data=cloud_data, | ||
downtimes=downtimes, | ||
) | ||
cond_new = mo_new.return_conditions() | ||
|
||
# Make sure the internal downtimes are different | ||
assert np.all(mo_default.downtimes != mo_new.downtimes) | ||
|
||
# Make sure seeing is not the same | ||
diff = cond_default.fwhm_eff["r"] - cond_new.fwhm_eff["r"] | ||
assert np.nanmin(np.abs(diff)) > 0 | ||
|
||
# Make sure cloudyness level is not the same | ||
assert cond_default.bulk_cloud != cond_new.bulk_cloud | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |