diff --git a/day_integration_test.yaml b/day_integration_test.yaml index f7a6257..fbb3e16 100644 --- a/day_integration_test.yaml +++ b/day_integration_test.yaml @@ -39,7 +39,7 @@ modules: c_y: 5.11194838e+02 mask_filepath: "data/mask.npy" - + sun_apparent_size: 0.54 cloud_map: threshold: 3.5 diff --git a/example.yaml b/example.yaml index c263da0..a70f474 100644 --- a/example.yaml +++ b/example.yaml @@ -50,6 +50,9 @@ pipelines: # Under which color ratio a pixel is considered cloudy (blue/red + blue/green) threshold: 3.5 + # Apparent size of the sun in the allsky image in degree + sun_apparent_size: 0.54 + coverage_info: # Altitude which is considered to be the lower boundary of the zenith to average for the zenith cloud fraction measurement (in degree) zenith_altitude: 80 diff --git a/pyobs_cloudcover/pipeline/day/pipeline_factory.py b/pyobs_cloudcover/pipeline/day/pipeline_factory.py index 4e5defb..a5e7a20 100644 --- a/pyobs_cloudcover/pipeline/day/pipeline_factory.py +++ b/pyobs_cloudcover/pipeline/day/pipeline_factory.py @@ -20,7 +20,7 @@ def __call__(self, options: DayPipelineOptions) -> DayPipeline: mask = np.load(options.mask_filepath) alt_az_generator = AltAzMapGenerator(model, 0) cloud_map_generator_factory = CloudMapGeneratorFactory(options.cloud_map) - sun_masker = SunMasker(self._observer) + sun_masker = SunMasker(options.sun_apparent_size, self._observer) coverage_info_calculator_factory = CloudInfoCalculatorFactory(options.coverage_info) return DayPipeline(mask, alt_az_generator, cloud_map_generator_factory(), sun_masker, coverage_info_calculator_factory()) diff --git a/pyobs_cloudcover/pipeline/day/pipeline_options.py b/pyobs_cloudcover/pipeline/day/pipeline_options.py index dcc25f6..10333ff 100644 --- a/pyobs_cloudcover/pipeline/day/pipeline_options.py +++ b/pyobs_cloudcover/pipeline/day/pipeline_options.py @@ -7,17 +7,19 @@ class DayPipelineOptions: - def __init__(self, model_options: Dict[str, Any], mask_filepath: str, cloud_map: CloudMapGeneratorOptions, coverage_info: CloudInfoCalculatorOptions) -> None: + def __init__(self, model_options: Dict[str, Any], mask_filepath: str, sun_apparent_size: float, cloud_map: CloudMapGeneratorOptions, coverage_info: CloudInfoCalculatorOptions) -> None: self.model_options = model_options self.coverage_info = coverage_info self.cloud_map = cloud_map self.mask_filepath = mask_filepath + self.sun_apparent_size = sun_apparent_size @classmethod def from_dict(cls, options: Dict[str, Dict[str, Any]]) -> DayPipelineOptions: model_options = options.get("world_model", {}) mask_filepath = cast(str, options.get('mask_filepath')) + sun_apparent_size = float(cast(float, options.get('sun_apparent_size'))) cloud_map = CloudMapGeneratorOptions.from_dict(cast(Dict[str, Any], options.get('cloud_map'))) coverage_info = CloudInfoCalculatorOptions.from_dict(cast(Dict[str, Any], options.get('coverage_info'))) - return DayPipelineOptions(model_options, mask_filepath, cloud_map, coverage_info) + return DayPipelineOptions(model_options, mask_filepath, sun_apparent_size, cloud_map, coverage_info) diff --git a/pyobs_cloudcover/pipeline/day/sun_masker.py b/pyobs_cloudcover/pipeline/day/sun_masker.py index 53b8938..f359498 100644 --- a/pyobs_cloudcover/pipeline/day/sun_masker.py +++ b/pyobs_cloudcover/pipeline/day/sun_masker.py @@ -7,13 +7,12 @@ class SunMasker: - SUN_APPARENT_SIZE = np.deg2rad(0.54) - - def __init__(self, observer: Observer): + def __init__(self, sun_apparent_size: float, observer: Observer): + self._sun_apparent_size = sun_apparent_size self._observer = observer def __call__(self, sky_query: SkyPixelQuery, obs_time: datetime.datetime) -> SkyPixelQuery: sun_alt_az = self._observer.sun_altaz(obs_time) - sky_query.mask_radius(AltAzCoord(sun_alt_az.alt.rad, sun_alt_az.az.rad), self.SUN_APPARENT_SIZE) + sky_query.mask_radius(AltAzCoord(sun_alt_az.alt.rad, sun_alt_az.az.rad), np.deg2rad(self._sun_apparent_size)) return sky_query diff --git a/tests/integration/test_day_pipeline.py b/tests/integration/test_day_pipeline.py index 947c132..4920cd4 100644 --- a/tests/integration/test_day_pipeline.py +++ b/tests/integration/test_day_pipeline.py @@ -27,7 +27,7 @@ def test_day_pipeline() -> None: alt_az_generator = AltAzMapGenerator(model, 20) cloud_map_gen = CloudMapGenerator(3.0) - sun_masker = SunMasker(observer) + sun_masker = SunMasker(0.54, observer) coverage_change_calculator = CoverageChangeCalculator() zenith_masker = ZenithCloudCoverageCalculator(80) diff --git a/tests/integration/test_day_pipeline_factory.py b/tests/integration/test_day_pipeline_factory.py index f0f525e..78cd032 100644 --- a/tests/integration/test_day_pipeline_factory.py +++ b/tests/integration/test_day_pipeline_factory.py @@ -31,6 +31,7 @@ def test_day_pipeline() -> None: "c_y": 5.11194838e+01 }, "mask_filepath": "tests/integration/small_dummy_mask.npy", + "sun_apparent_size": 0.54, "cloud_map": { "threshold": 3.5 },