Skip to content

Commit b9c1282

Browse files
Added option for apparent sun size
1 parent d9af2e9 commit b9c1282

File tree

7 files changed

+14
-9
lines changed

7 files changed

+14
-9
lines changed

day_integration_test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ modules:
3939
c_y: 5.11194838e+02
4040

4141
mask_filepath: "data/mask.npy"
42-
42+
sun_apparent_size: 0.54
4343
cloud_map:
4444
threshold: 3.5
4545

example.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ pipelines:
5050
# Under which color ratio a pixel is considered cloudy (blue/red + blue/green)
5151
threshold: 3.5
5252

53+
# Apparent size of the sun in the allsky image in degree
54+
sun_apparent_size: 0.54
55+
5356
coverage_info:
5457
# Altitude which is considered to be the lower boundary of the zenith to average for the zenith cloud fraction measurement (in degree)
5558
zenith_altitude: 80

pyobs_cloudcover/pipeline/day/pipeline_factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __call__(self, options: DayPipelineOptions) -> DayPipeline:
2020
mask = np.load(options.mask_filepath)
2121
alt_az_generator = AltAzMapGenerator(model, 0)
2222
cloud_map_generator_factory = CloudMapGeneratorFactory(options.cloud_map)
23-
sun_masker = SunMasker(self._observer)
23+
sun_masker = SunMasker(options.sun_apparent_size, self._observer)
2424
coverage_info_calculator_factory = CloudInfoCalculatorFactory(options.coverage_info)
2525

2626
return DayPipeline(mask, alt_az_generator, cloud_map_generator_factory(), sun_masker, coverage_info_calculator_factory())

pyobs_cloudcover/pipeline/day/pipeline_options.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@
77

88

99
class DayPipelineOptions:
10-
def __init__(self, model_options: Dict[str, Any], mask_filepath: str, cloud_map: CloudMapGeneratorOptions, coverage_info: CloudInfoCalculatorOptions) -> None:
10+
def __init__(self, model_options: Dict[str, Any], mask_filepath: str, sun_apparent_size: float, cloud_map: CloudMapGeneratorOptions, coverage_info: CloudInfoCalculatorOptions) -> None:
1111
self.model_options = model_options
1212
self.coverage_info = coverage_info
1313
self.cloud_map = cloud_map
1414
self.mask_filepath = mask_filepath
15+
self.sun_apparent_size = sun_apparent_size
1516

1617
@classmethod
1718
def from_dict(cls, options: Dict[str, Dict[str, Any]]) -> DayPipelineOptions:
1819
model_options = options.get("world_model", {})
1920
mask_filepath = cast(str, options.get('mask_filepath'))
21+
sun_apparent_size = float(cast(float, options.get('sun_apparent_size')))
2022
cloud_map = CloudMapGeneratorOptions.from_dict(cast(Dict[str, Any], options.get('cloud_map')))
2123
coverage_info = CloudInfoCalculatorOptions.from_dict(cast(Dict[str, Any], options.get('coverage_info')))
2224

23-
return DayPipelineOptions(model_options, mask_filepath, cloud_map, coverage_info)
25+
return DayPipelineOptions(model_options, mask_filepath, sun_apparent_size, cloud_map, coverage_info)

pyobs_cloudcover/pipeline/day/sun_masker.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77

88

99
class SunMasker:
10-
SUN_APPARENT_SIZE = np.deg2rad(0.54)
11-
12-
def __init__(self, observer: Observer):
10+
def __init__(self, sun_apparent_size: float, observer: Observer):
11+
self._sun_apparent_size = sun_apparent_size
1312
self._observer = observer
1413

1514
def __call__(self, sky_query: SkyPixelQuery, obs_time: datetime.datetime) -> SkyPixelQuery:
1615
sun_alt_az = self._observer.sun_altaz(obs_time)
17-
sky_query.mask_radius(AltAzCoord(sun_alt_az.alt.rad, sun_alt_az.az.rad), self.SUN_APPARENT_SIZE)
16+
sky_query.mask_radius(AltAzCoord(sun_alt_az.alt.rad, sun_alt_az.az.rad), np.deg2rad(self._sun_apparent_size))
1817

1918
return sky_query

tests/integration/test_day_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_day_pipeline() -> None:
2727

2828
alt_az_generator = AltAzMapGenerator(model, 20)
2929
cloud_map_gen = CloudMapGenerator(3.0)
30-
sun_masker = SunMasker(observer)
30+
sun_masker = SunMasker(0.54, observer)
3131

3232
coverage_change_calculator = CoverageChangeCalculator()
3333
zenith_masker = ZenithCloudCoverageCalculator(80)

tests/integration/test_day_pipeline_factory.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def test_day_pipeline() -> None:
3131
"c_y": 5.11194838e+01
3232
},
3333
"mask_filepath": "tests/integration/small_dummy_mask.npy",
34+
"sun_apparent_size": 0.54,
3435
"cloud_map": {
3536
"threshold": 3.5
3637
},

0 commit comments

Comments
 (0)