pyobs-allsky-cloudcover 2.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. pyobs_allsky_cloudcover-2.0.2.dist-info/METADATA +70 -0
  2. pyobs_allsky_cloudcover-2.0.2.dist-info/RECORD +91 -0
  3. pyobs_allsky_cloudcover-2.0.2.dist-info/WHEEL +4 -0
  4. pyobs_allsky_cloudcover-2.0.2.dist-info/entry_points.txt +3 -0
  5. pyobs_cloudcover/__init__.py +0 -0
  6. pyobs_cloudcover/application.py +311 -0
  7. pyobs_cloudcover/calibration/__init__.py +0 -0
  8. pyobs_cloudcover/calibration/astrometry.py +547 -0
  9. pyobs_cloudcover/calibration/catalog.py +51 -0
  10. pyobs_cloudcover/calibration/darks.py +77 -0
  11. pyobs_cloudcover/calibration/mask.py +84 -0
  12. pyobs_cloudcover/calibration/pointed.py +284 -0
  13. pyobs_cloudcover/calibration/replay.py +186 -0
  14. pyobs_cloudcover/camera/__init__.py +5 -0
  15. pyobs_cloudcover/camera/bayer.py +102 -0
  16. pyobs_cloudcover/camera/orientation.py +43 -0
  17. pyobs_cloudcover/camera/profile.py +286 -0
  18. pyobs_cloudcover/camera/reader.py +146 -0
  19. pyobs_cloudcover/cli.py +328 -0
  20. pyobs_cloudcover/cloud_cover.py +88 -0
  21. pyobs_cloudcover/cloud_coverage_info.py +44 -0
  22. pyobs_cloudcover/config.py +49 -0
  23. pyobs_cloudcover/data/__init__.py +26 -0
  24. pyobs_cloudcover/data/catalog_v50.csv +8988 -0
  25. pyobs_cloudcover/evaluation.py +164 -0
  26. pyobs_cloudcover/overlay.py +124 -0
  27. pyobs_cloudcover/pipeline/__init__.py +0 -0
  28. pyobs_cloudcover/pipeline/day/__init__.py +0 -0
  29. pyobs_cloudcover/pipeline/day/altaz_map_generator.py +28 -0
  30. pyobs_cloudcover/pipeline/day/color_ratio_calculation.py +10 -0
  31. pyobs_cloudcover/pipeline/day/pipeline.py +103 -0
  32. pyobs_cloudcover/pipeline/day/pipeline_options.py +27 -0
  33. pyobs_cloudcover/pipeline/day/sun_masker.py +18 -0
  34. pyobs_cloudcover/pipeline/interval.py +39 -0
  35. pyobs_cloudcover/pipeline/night/__init__.py +0 -0
  36. pyobs_cloudcover/pipeline/night/aligner.py +161 -0
  37. pyobs_cloudcover/pipeline/night/altaz_grid_generator/__init__.py +0 -0
  38. pyobs_cloudcover/pipeline/night/altaz_grid_generator/altaz_grid_options.py +10 -0
  39. pyobs_cloudcover/pipeline/night/altaz_grid_generator/spherical_alt_az_generator.py +30 -0
  40. pyobs_cloudcover/pipeline/night/catalog/__init__.py +0 -0
  41. pyobs_cloudcover/pipeline/night/catalog/altaz_catalog.py +23 -0
  42. pyobs_cloudcover/pipeline/night/catalog/altaz_catalog_loader.py +42 -0
  43. pyobs_cloudcover/pipeline/night/catalog/catalog_constructor.py +29 -0
  44. pyobs_cloudcover/pipeline/night/catalog/catalog_constructor_options.py +16 -0
  45. pyobs_cloudcover/pipeline/night/catalog/pixel_catalog.py +125 -0
  46. pyobs_cloudcover/pipeline/night/cloud_map_generator/__init__.py +0 -0
  47. pyobs_cloudcover/pipeline/night/cloud_map_generator/cloud_map_generator.py +14 -0
  48. pyobs_cloudcover/pipeline/night/cloud_map_generator/cloud_map_generator_options.py +7 -0
  49. pyobs_cloudcover/pipeline/night/lim_magnitude_map_generator/__init__.py +0 -0
  50. pyobs_cloudcover/pipeline/night/lim_magnitude_map_generator/border_magnitude.py +185 -0
  51. pyobs_cloudcover/pipeline/night/lim_magnitude_map_generator/lim_magnitude_map_generator.py +47 -0
  52. pyobs_cloudcover/pipeline/night/lim_magnitude_map_generator/lim_magnitude_map_generator_options.py +15 -0
  53. pyobs_cloudcover/pipeline/night/moon_masker.py +18 -0
  54. pyobs_cloudcover/pipeline/night/photometry.py +204 -0
  55. pyobs_cloudcover/pipeline/night/pipeline.py +189 -0
  56. pyobs_cloudcover/pipeline/night/pipeline_options.py +55 -0
  57. pyobs_cloudcover/pipeline/night/preprocessor/__init__.py +0 -0
  58. pyobs_cloudcover/pipeline/night/preprocessor/image_binner.py +19 -0
  59. pyobs_cloudcover/pipeline/night/preprocessor/preprocessor.py +29 -0
  60. pyobs_cloudcover/pipeline/night/star_reverse_matcher/__init__.py +0 -0
  61. pyobs_cloudcover/pipeline/night/star_reverse_matcher/aperture_matcher.py +103 -0
  62. pyobs_cloudcover/pipeline/night/star_reverse_matcher/create_star_matcher.py +15 -0
  63. pyobs_cloudcover/pipeline/night/star_reverse_matcher/detector/__init__.py +0 -0
  64. pyobs_cloudcover/pipeline/night/star_reverse_matcher/detector/detector.py +10 -0
  65. pyobs_cloudcover/pipeline/night/star_reverse_matcher/detector/sigma_threshold_detector.py +29 -0
  66. pyobs_cloudcover/pipeline/night/star_reverse_matcher/star_reverse_matcher.py +29 -0
  67. pyobs_cloudcover/pipeline/night/star_reverse_matcher/star_reverse_matcher_options.py +29 -0
  68. pyobs_cloudcover/pipeline/night/star_reverse_matcher/window.py +26 -0
  69. pyobs_cloudcover/pipeline/option_types.py +13 -0
  70. pyobs_cloudcover/pipeline/pipeline.py +9 -0
  71. pyobs_cloudcover/pipeline/pipeline_controller.py +64 -0
  72. pyobs_cloudcover/simulation/__init__.py +22 -0
  73. pyobs_cloudcover/simulation/cli.py +131 -0
  74. pyobs_cloudcover/simulation/clouds.py +105 -0
  75. pyobs_cloudcover/simulation/control.py +217 -0
  76. pyobs_cloudcover/simulation/headers.py +92 -0
  77. pyobs_cloudcover/simulation/profile.py +277 -0
  78. pyobs_cloudcover/simulation/render.py +512 -0
  79. pyobs_cloudcover/simulation/scene.py +215 -0
  80. pyobs_cloudcover/simulation/truth.py +116 -0
  81. pyobs_cloudcover/sky_query.py +99 -0
  82. pyobs_cloudcover/status.py +44 -0
  83. pyobs_cloudcover/world_model/__init__.py +9 -0
  84. pyobs_cloudcover/world_model/aligned_model.py +68 -0
  85. pyobs_cloudcover/world_model/fisheye_model.py +145 -0
  86. pyobs_cloudcover/world_model/hour_angle_converter.py +18 -0
  87. pyobs_cloudcover/world_model/pointed_model.py +159 -0
  88. pyobs_cloudcover/world_model/scaled_model.py +36 -0
  89. pyobs_cloudcover/world_model/simple_model.py +31 -0
  90. pyobs_cloudcover/world_model/wcs_model.py +52 -0
  91. pyobs_cloudcover/world_model/world_model.py +17 -0
@@ -0,0 +1,70 @@
1
+ Metadata-Version: 2.5
2
+ Name: pyobs-allsky-cloudcover
3
+ Version: 2.0.2
4
+ Summary: pyobs module that estimates cloud cover from all-sky camera images
5
+ Author-email: germanhydrogen <admin@germanhydrogen.org>
6
+ Requires-Python: >=3.11
7
+ Requires-Dist: astroplan<0.11,>=0.10.1
8
+ Requires-Dist: astropy<9,>=7.0.1
9
+ Requires-Dist: numpy<3,>=2.2.5
10
+ Requires-Dist: opencv-python-headless>=4.10.0.84
11
+ Requires-Dist: pillow>=11.3.0
12
+ Requires-Dist: pydantic>=2.12.5
13
+ Requires-Dist: pyobs-core<3,>=2.36
14
+ Requires-Dist: scipy<2,>=1.15.2
15
+ Provides-Extra: catalog
16
+ Requires-Dist: astroquery>=0.4.10; extra == 'catalog'
17
+ Provides-Extra: influx
18
+ Requires-Dist: pyobs-core[influx]>=2.36; extra == 'influx'
19
+ Provides-Extra: plots
20
+ Requires-Dist: matplotlib>=3.9; extra == 'plots'
21
+ Description-Content-Type: text/markdown
22
+
23
+ # pyobs allsky cloudcover
24
+ [![pytest](https://github.com/pyobs/pyobs-allsky-cloudcover/actions/workflows/pytest.yml/badge.svg)](https://github.com/pyobs/pyobs-allsky-cloudcover/actions/workflows/pytest.yml)
25
+ [![ruff](https://github.com/pyobs/pyobs-allsky-cloudcover/actions/workflows/ruff.yml/badge.svg)](https://github.com/pyobs/pyobs-allsky-cloudcover/actions/workflows/ruff.yml)
26
+ [![mypy](https://github.com/pyobs/pyobs-allsky-cloudcover/actions/workflows/mypy.yml/badge.svg)](https://github.com/pyobs/pyobs-allsky-cloudcover/actions/workflows/mypy.yml)
27
+
28
+ A [pyobs](https://www.pyobs.org) module that estimates cloud cover from all-sky camera images, for any camera
29
+ (Raspberry Pi HQ to cooled ZWO, mono or colour, any resolution, bit depth, Bayer pattern, orientation and lens).
30
+ It takes images from a pyobs camera module (e.g. an `ImageWatcherCamera` watching the directory your capture
31
+ software writes into), answers cloud cover queries and publishes its state (cloud fraction, limiting magnitude,
32
+ sky brightness) through the pyobs interface `ICloudCover`, can write an overlay image with the cloud maps, and can
33
+ write the numbers to InfluxDB through core's publishers (`influx` extra).
34
+
35
+ - Night: stars from a catalogue are looked for in the image; the limiting magnitude around each sky position
36
+ tells clear from cloudy.
37
+ - Day: the colour of the sky (blue = clear, white/grey = cloud).
38
+
39
+ ## Installation
40
+
41
+ Pure Python (3.11+), with [uv](https://docs.astral.sh/uv/):
42
+
43
+ uv sync
44
+ uv run pytest
45
+
46
+ Run it with `pyobs config.yaml`; `deploy/` has a systemd unit.
47
+
48
+ ## Setting up a camera
49
+
50
+ Zenith-centred fisheyes use a `FisheyeModel`; wide-angle or tilted cameras without a lens circle (e.g. a Raspberry
51
+ Pi Camera Module 3 Wide) use a `PointedModel` from `pyobs-cloudcover calibrate --pointed`. Cameras that get
52
+ bumped can be followed per frame with `pipelines.night.options.align` (see
53
+ [examples/rpi-cm3-wide-indi-allsky.yaml](examples/rpi-cm3-wide-indi-allsky.yaml), which also shows how to feed
54
+ it from indi-allsky's raw exports).
55
+
56
+ `pyobs-cloudcover calibrate | mask | darks | hot-pixels | replay | catalog` fit the lens, build the sky mask and
57
+ hot-pixel map and help choose thresholds from your own images: see
58
+ [docs/source/calibration.rst](docs/source/calibration.rst). Start from [example.yaml](example.yaml) or one of
59
+ the [examples](examples/).
60
+
61
+ ## Simulator
62
+
63
+ `pyobs-cloudcover-sim` renders realistic all-sky FITS images with ground truth (stars, moon, sun, clouds,
64
+ noise, several camera presets); all tests run on it. See [docs/source/simulator.rst](docs/source/simulator.rst)
65
+ and the accuracy it gives: [docs/source/accuracy.rst](docs/source/accuracy.rst).
66
+
67
+ ## Documentation
68
+
69
+ [docs/source/index.rst](docs/source/index.rst) (Sphinx: `cd docs && uv run --with sphinx --with sphinx-rtd-theme make html`).
70
+ Upgrading from 1.x: [docs/source/migration.rst](docs/source/migration.rst).
@@ -0,0 +1,91 @@
1
+ pyobs_cloudcover/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ pyobs_cloudcover/application.py,sha256=ashzz5_vGoTESEgq6e30CTrLJnK0dT7aVLMVtcTyieI,14903
3
+ pyobs_cloudcover/cli.py,sha256=LA5x_elLtDIJYRU3WI7zLg17RgaIPqozetOA2Ad8SvI,13832
4
+ pyobs_cloudcover/cloud_cover.py,sha256=4E7ePom45Sz4jm7IgfF8l0jOp3I6m9Nqk8QLMZr0Fho,3582
5
+ pyobs_cloudcover/cloud_coverage_info.py,sha256=A5M3rXOlEwMqL8U_EUkOV-4vMSDX_dxUpUPQL0sL4e4,1985
6
+ pyobs_cloudcover/config.py,sha256=fKmohJtGjcdkZjEShWOEvoJmS9kdiZuASIXuFeHnkJA,1585
7
+ pyobs_cloudcover/evaluation.py,sha256=KOCsr7RYGgCCoq2Va-vJ3xy3LfEZuL7BYMdaqxVN5_4,6354
8
+ pyobs_cloudcover/overlay.py,sha256=zJGr8e22svk8rsamNG-ZZdItAhfuRCB6xj8I0DW4tUE,5898
9
+ pyobs_cloudcover/sky_query.py,sha256=zxDbhxGHXTlaOwihOu7ceqkXYiy1ZYAZZ2h3fskc13E,3764
10
+ pyobs_cloudcover/status.py,sha256=BjK3XXOtju7snS3cWL-q_T2LdAGb0ODydBcXr05hf2Y,1850
11
+ pyobs_cloudcover/calibration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ pyobs_cloudcover/calibration/astrometry.py,sha256=ka1XiBCGE-o7dxQEJZ-L6QscxJeRbbuqPfuyKiBZolI,23815
13
+ pyobs_cloudcover/calibration/catalog.py,sha256=Vzej8sf5OKj-THFIMPZhaeGlxXxkaxIMyBMKGpYyjFA,2285
14
+ pyobs_cloudcover/calibration/darks.py,sha256=9gA6STsaxgI2XzjIZt6UtVSybjK0vAf050WTtkB-b70,3523
15
+ pyobs_cloudcover/calibration/mask.py,sha256=KAqv_s37hdVF2kW2m4oj7N-05s9Ql1mM302WSCFizqg,3722
16
+ pyobs_cloudcover/calibration/pointed.py,sha256=EQlGvbUpX5DWmfhDTJfzj-tjhIP1DjXPwAjGuDqBAUI,12404
17
+ pyobs_cloudcover/calibration/replay.py,sha256=wa4jiX_AkrMqxTv_JpYTD5bAh8_3n5u5eqWAwYrdeiQ,7650
18
+ pyobs_cloudcover/camera/__init__.py,sha256=AlDvWE4t_xWX6vhhxg8F8PJig2DyvFu7S5nDYbDwI0Y,298
19
+ pyobs_cloudcover/camera/bayer.py,sha256=eVnz7pp-EkovPOmPSwDXa2ybdA5g67d3W3Bx_UlXovA,4274
20
+ pyobs_cloudcover/camera/orientation.py,sha256=7tz1AOZ6PoSvLItEY63ol9rpfgfE2LbnJ_pt2uwaIFA,1375
21
+ pyobs_cloudcover/camera/profile.py,sha256=P2wew4sb7mhvQy4gvhyFTn3vRrqcR5FXhfeHn1kWC1k,12266
22
+ pyobs_cloudcover/camera/reader.py,sha256=uRWoS3RZqY4BXoR2OrBFJbBt-A7jhcrbreGljNbmWzI,5381
23
+ pyobs_cloudcover/data/__init__.py,sha256=NgkzrM7AMvCQ88h5zmVmVqKnXg0d3Izfs1W8xtT0LrM,952
24
+ pyobs_cloudcover/data/catalog_v50.csv,sha256=UCU4LUCVPzF4jBSOXvU_Ni4_x2PtXL_2LSaIKmCcUAU,467216
25
+ pyobs_cloudcover/pipeline/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
+ pyobs_cloudcover/pipeline/interval.py,sha256=M3dJfuEdjXYUaUfCgIAL_T9EtFDCT2Utlb19tduqLQ4,1056
27
+ pyobs_cloudcover/pipeline/option_types.py,sha256=_i6JlF_urqaAhVChPoVOh6XzqJ73owLxmi36h3Aqygs,322
28
+ pyobs_cloudcover/pipeline/pipeline.py,sha256=4O4xpmNHymAuzL5-zrD_h8wMIr8m94uu6YXratPSRyg,264
29
+ pyobs_cloudcover/pipeline/pipeline_controller.py,sha256=_EhmGfqErdjizbvM1TOLvHEIyJsdio6lqyKwX4MtIXQ,2779
30
+ pyobs_cloudcover/pipeline/day/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
+ pyobs_cloudcover/pipeline/day/altaz_map_generator.py,sha256=l5oGlD0NVWw-4Gk_ve_jRPQPE8TTNDt9tKKsJoFRSAs,1070
32
+ pyobs_cloudcover/pipeline/day/color_ratio_calculation.py,sha256=vpoG6CN7W7LWayDlYdl_dZp06_V4DVXxQEtc5lgdFN8,272
33
+ pyobs_cloudcover/pipeline/day/pipeline.py,sha256=51BN6H5b0-knaRREk5k62XjVcsVIPGnNDj6AXFa09fE,4600
34
+ pyobs_cloudcover/pipeline/day/pipeline_options.py,sha256=0xK7qOQkD1_TVX8X2GLTT-JQSP1FD3RfFr7qGd3kgHo,1021
35
+ pyobs_cloudcover/pipeline/day/sun_masker.py,sha256=HZJSLKA-a0xB3L2Muf-n1t82t5EvdNnw8iloc9Ur6es,581
36
+ pyobs_cloudcover/pipeline/night/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
+ pyobs_cloudcover/pipeline/night/aligner.py,sha256=Ri8b0eoyXzGv5Q16iHGhozwAkwBIy0Qpup_mrBKBdN8,7616
38
+ pyobs_cloudcover/pipeline/night/moon_masker.py,sha256=QevkQc96JPFI19kZTwr-JOjP-5TuiToa1nlhFQ4Y99c,590
39
+ pyobs_cloudcover/pipeline/night/photometry.py,sha256=S4rJlsz9tL4WLl3QEUfoRYJSW_nTBO6VmXYg3v6Gwgo,9532
40
+ pyobs_cloudcover/pipeline/night/pipeline.py,sha256=wf6MJ3Y11oJF1_2uW87kDrpGod9IyzMfLyRficAhcTg,9684
41
+ pyobs_cloudcover/pipeline/night/pipeline_options.py,sha256=6QaQCn5I8bURhc51xfDaRoiWDbZ3l2Fj-0qK7veAHoI,2648
42
+ pyobs_cloudcover/pipeline/night/altaz_grid_generator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
+ pyobs_cloudcover/pipeline/night/altaz_grid_generator/altaz_grid_options.py,sha256=t1CwWJfyt_kQ9rmacZ4jmlqODe45UW1caFLG0mUhmSE,260
44
+ pyobs_cloudcover/pipeline/night/altaz_grid_generator/spherical_alt_az_generator.py,sha256=UTwlh-w64vhA90JPg7sk4Q7PCK15pyDzqI68xxUDcnY,990
45
+ pyobs_cloudcover/pipeline/night/catalog/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
+ pyobs_cloudcover/pipeline/night/catalog/altaz_catalog.py,sha256=vfr8oS_DaSZ7gcLoCE_TZKINNAm5c6hfsOt4Pm9x42c,729
47
+ pyobs_cloudcover/pipeline/night/catalog/altaz_catalog_loader.py,sha256=RBfLybIAZ9cFCd8F62QzQNk7CL-LNyZsa2tnfYOQSzs,1447
48
+ pyobs_cloudcover/pipeline/night/catalog/catalog_constructor.py,sha256=-931Mm1lon7VQUz2ZgcW-RFf_2CR0Wl9Nzdxg_uH5Uk,1213
49
+ pyobs_cloudcover/pipeline/night/catalog/catalog_constructor_options.py,sha256=VaGx9Uf9Zgxy5df7XM2wwpVHHZZGCcm6f7SyW6sPPgs,404
50
+ pyobs_cloudcover/pipeline/night/catalog/pixel_catalog.py,sha256=7zrAODB9v3h5We4kHFDwjckD12y805ZEYMG1WwLd1Ws,4504
51
+ pyobs_cloudcover/pipeline/night/cloud_map_generator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
+ pyobs_cloudcover/pipeline/night/cloud_map_generator/cloud_map_generator.py,sha256=uXEUANTvJMaZRLax985Eb450hRlcjg5kweJouN_L73Y,536
53
+ pyobs_cloudcover/pipeline/night/cloud_map_generator/cloud_map_generator_options.py,sha256=Rmy2VkioPupZlhAhqsa5JVzh3EdX-dXXQ_9iAMIxfM8,156
54
+ pyobs_cloudcover/pipeline/night/lim_magnitude_map_generator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
+ pyobs_cloudcover/pipeline/night/lim_magnitude_map_generator/border_magnitude.py,sha256=vXqfVDl_3VL75N7WcDvuHGI6T18VnPY8b1kvb5JAH_g,7992
56
+ pyobs_cloudcover/pipeline/night/lim_magnitude_map_generator/lim_magnitude_map_generator.py,sha256=Gtc3-bWSae2r1X4EksFXU7waPvzlxn_UZK7wZbfnyyI,1973
57
+ pyobs_cloudcover/pipeline/night/lim_magnitude_map_generator/lim_magnitude_map_generator_options.py,sha256=HbgAU57PpmmAZfwz-B4m1Bt7IOqO9x0wvgzttFillOs,456
58
+ pyobs_cloudcover/pipeline/night/preprocessor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
+ pyobs_cloudcover/pipeline/night/preprocessor/image_binner.py,sha256=LD06VLC8hYMr6pLmzFZQim3kmXhmqpSsrH-Me4V2MEI,736
60
+ pyobs_cloudcover/pipeline/night/preprocessor/preprocessor.py,sha256=kIvdxbNL8COXefmoLQGN_y7aSxQdoGuraUwuU2gxOkk,1034
61
+ pyobs_cloudcover/pipeline/night/star_reverse_matcher/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
+ pyobs_cloudcover/pipeline/night/star_reverse_matcher/aperture_matcher.py,sha256=VNhr1gx1H3PCEBEpbIdgnlP5ebqO6UooQWTTTNlTc1E,4839
63
+ pyobs_cloudcover/pipeline/night/star_reverse_matcher/create_star_matcher.py,sha256=NxyJNFpPt4eNgZkqYAH1jwkWWBp8qcJ5KpfYPkpsTBk,1027
64
+ pyobs_cloudcover/pipeline/night/star_reverse_matcher/star_reverse_matcher.py,sha256=ToaIACBX4LitN8CDaPZjMpeeaJU2TXnnrfoM64rK82M,1268
65
+ pyobs_cloudcover/pipeline/night/star_reverse_matcher/star_reverse_matcher_options.py,sha256=ixhd3h5Q1LKwNxp8UnHYjCCO1TPB8SkhHBaMArykgM4,1187
66
+ pyobs_cloudcover/pipeline/night/star_reverse_matcher/window.py,sha256=6Sq9zjaR7lpnbZmXh5SBC6S_1wSf5YQ2cwdEMgof5E4,787
67
+ pyobs_cloudcover/pipeline/night/star_reverse_matcher/detector/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
68
+ pyobs_cloudcover/pipeline/night/star_reverse_matcher/detector/detector.py,sha256=bWGhnsPHSvovLE79OJh0BPF5EjB0BgGzMr0BwSNbXpw,332
69
+ pyobs_cloudcover/pipeline/night/star_reverse_matcher/detector/sigma_threshold_detector.py,sha256=BT4B-virxtbPqYwOm0E1zFT221UzlA9rAbJuwHEtnto,1075
70
+ pyobs_cloudcover/simulation/__init__.py,sha256=mZmQMz8UiaqA3ZCwRfGo_NU6Lq_V67uuN1mhOHfGVT0,707
71
+ pyobs_cloudcover/simulation/cli.py,sha256=khZC3lZgXxbw4YliPmwLpO7hM9UwJnZxVBWr7gmI9MU,5800
72
+ pyobs_cloudcover/simulation/clouds.py,sha256=US8P4DaYtB3_nGm0Ekpc8bjJzZh2RM-YwE2G8LE3Cgs,4313
73
+ pyobs_cloudcover/simulation/control.py,sha256=waAIwpwbJlT6pwhHP6hEyIEcn3DRz2CURt2pxllYl8g,9430
74
+ pyobs_cloudcover/simulation/headers.py,sha256=HHiPqE8DWgtlHGTZJNB3Uh1YTkxDJ-DswFAsApvKIg4,4037
75
+ pyobs_cloudcover/simulation/profile.py,sha256=VfLjAndRekLwfWnKbQnqDXK1i1JmkZtaIfNUCvJFDpo,10097
76
+ pyobs_cloudcover/simulation/render.py,sha256=hK3er-HbgG8WCE_FAzEVZSSVZRGtMTCIrtNSVtdKCkk,23372
77
+ pyobs_cloudcover/simulation/scene.py,sha256=2tj6pqgqX-emCausJidmrnyYoAtfmby9zGGQ8pVRzVY,9136
78
+ pyobs_cloudcover/simulation/truth.py,sha256=DKUt7AzKBqpHR0KF7B6k44t-tcqbqzb0aoDrwpVkeNQ,4503
79
+ pyobs_cloudcover/world_model/__init__.py,sha256=XkwF4H0DSMUNJ4iUDfOn3ndKPlxKuRVijWEeuMCGWkY,576
80
+ pyobs_cloudcover/world_model/aligned_model.py,sha256=bXq-xYOIcrLSbBojFJWDQuTrOk-KtDpZTmU6B2dO8WQ,2900
81
+ pyobs_cloudcover/world_model/fisheye_model.py,sha256=cFHYyAZCE6TsZa_yXTLYPYb2RegbxaTU7EcBzLz3Xu4,6468
82
+ pyobs_cloudcover/world_model/hour_angle_converter.py,sha256=9P-E35QPAPLdCLLkFzBNKIV-WBmRVDb5OTvzrnUfbDA,546
83
+ pyobs_cloudcover/world_model/pointed_model.py,sha256=ORmbnmVp_zdvpaaRuuEojLwZ08HTzbYsJRqDArr429Q,6878
84
+ pyobs_cloudcover/world_model/scaled_model.py,sha256=cP4ujULixpS3ROAB2ysO_4M7Z_0kDPeDZF-UZ0nhAcg,1278
85
+ pyobs_cloudcover/world_model/simple_model.py,sha256=tQemjDqigPyCbNvLmW6u5fdko40wSarOXvRvXsFnUsY,1143
86
+ pyobs_cloudcover/world_model/wcs_model.py,sha256=Qz7TWUHlFHHRkAA4BsJx5Em8rSxtjNkBliFv0XIA3NQ,2220
87
+ pyobs_cloudcover/world_model/world_model.py,sha256=aZK3G0YcnnG4QkgpcdcjMcs9CZLNNd-M4qC9J4oeLsc,568
88
+ pyobs_allsky_cloudcover-2.0.2.dist-info/METADATA,sha256=2Lx3wW-aJVc3E70GrTAbuBScTLJY553ooM7bStYC2PA,3663
89
+ pyobs_allsky_cloudcover-2.0.2.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
90
+ pyobs_allsky_cloudcover-2.0.2.dist-info/entry_points.txt,sha256=HHSJBRDESsy6cO6zHGlHFbTFZjO-nlFs0mlxVQ5aomg,123
91
+ pyobs_allsky_cloudcover-2.0.2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ pyobs-cloudcover = pyobs_cloudcover.cli:main
3
+ pyobs-cloudcover-sim = pyobs_cloudcover.simulation.cli:main
File without changes
@@ -0,0 +1,311 @@
1
+ import asyncio
2
+ import concurrent.futures
3
+ import datetime
4
+ import logging
5
+ from pathlib import Path
6
+ from typing import Any, Literal
7
+
8
+ from astropy.io import fits
9
+ from pyobs.events import Event, NewBitmapEvent, NewImageEvent
10
+ from pyobs.interfaces import CloudCoverState, ICloudCover
11
+ from pyobs.modules import Module
12
+ from pyobs.utils.enums import ModuleState
13
+ from pyobs.utils.exceptions import InvalidArgumentError
14
+ from pyobs.utils.publisher import Publisher
15
+
16
+ from pyobs_cloudcover.camera.profile import CameraProfile, Frame
17
+ from pyobs_cloudcover.camera.reader import RawImage, decode_image, from_fits_hdu
18
+ from pyobs_cloudcover.cloud_cover import build_state, fraction, state_fields
19
+ from pyobs_cloudcover.cloud_coverage_info import CloudCoverageInfo
20
+ from pyobs_cloudcover.config import PipelinesConfig
21
+ from pyobs_cloudcover.overlay import OverlayConfig, build_product
22
+ from pyobs_cloudcover.pipeline.pipeline_controller import PipelineController
23
+ from pyobs_cloudcover.status import ModuleStatus
24
+
25
+ log = logging.getLogger(__name__)
26
+
27
+ ImageKind = Literal["fits", "bitmap"]
28
+
29
+
30
+ class Application(Module, ICloudCover): # type: ignore[misc] # Module itself mixes IModule and IConfig capabilities
31
+ """Estimates cloud cover from all-sky images.
32
+
33
+ Images come from a pyobs camera module (``image_sender``), e.g. an ``ImageWatcherCamera`` watching the
34
+ directory the capture software writes into: FITS files as ``NewImageEvent``, JPEG/PNG/TIFF as
35
+ ``NewBitmapEvent``. A bitmap event's ``obs_time`` takes precedence over ``camera.timestamp`` (its ``offset``
36
+ still applies). ``camera`` describes the camera (see ``CameraConfig``).
37
+ """
38
+
39
+ def __init__(
40
+ self,
41
+ pipelines: dict[str, dict[str, Any]],
42
+ publisher: Publisher | dict[str, Any] | None = None,
43
+ camera: dict[str, Any] | None = None,
44
+ image_sender: str = "",
45
+ error_after_failures: int = 3,
46
+ stale_after: float | None = None,
47
+ zenith_radius: float = 20.0,
48
+ min_coverage: float = 0.5,
49
+ overlay: dict[str, Any] | None = None,
50
+ *args: Any,
51
+ **kwargs: Any,
52
+ ) -> None:
53
+ """
54
+ Args:
55
+ image_sender: Name of the module whose ``NewImageEvent`` and ``NewBitmapEvent`` are analysed.
56
+ error_after_failures: Set the module state to ERROR after this many frames in a row failed.
57
+ stale_after: Set the module state to ERROR if no new image arrived for this many seconds. Off if not
58
+ set, since some setups stop the camera during the day. Also the age after which ``get_cloud_cover``
59
+ returns None.
60
+ zenith_radius: Radius in degrees around the zenith for the ``zenith`` field of the state.
61
+ min_coverage: Share of the positions in an area that must have a value for ``get_cloud_cover`` (and the
62
+ state) to return a cloud fraction, otherwise None.
63
+ publisher: Publisher for the numbers of each result (``total``, ``zenith``, ``sky_brightness``,
64
+ ``extinction``, ``limiting_magnitude``), with the image time as ``time``. Wrap an unreliable one,
65
+ like ``InfluxPublisher``, in a ``BufferedPublisher``. Off if not set.
66
+ overlay: Write an overlay product (the frame with the cloud maps in its pixels, see ``OverlayConfig``)
67
+ per result and announce it with a ``NewImageEvent``. Off if not set.
68
+ """
69
+
70
+ if "watch" in kwargs:
71
+ raise ValueError(
72
+ "'watch' was removed: run an ImageWatcherCamera on the directory and set 'image_sender' to it "
73
+ "(see examples/*.camera.yaml)."
74
+ )
75
+ if "measurement_log" in kwargs:
76
+ raise ValueError(
77
+ "'measurement_log' was removed: use 'publisher', e.g. a pyobs.utils.publisher.BufferedPublisher around "
78
+ "a pyobs.utils.publisher.InfluxPublisher (see example.yaml)."
79
+ )
80
+ super().__init__(*args, **kwargs)
81
+
82
+ if not image_sender:
83
+ raise ValueError("Configure an image source: 'image_sender' (a camera module, e.g. ImageWatcherCamera).")
84
+ if error_after_failures < 1:
85
+ raise ValueError("error_after_failures must be at least 1.")
86
+ if stale_after is not None and stale_after <= 0:
87
+ raise ValueError("stale_after must be positive.")
88
+ if not 0.0 < zenith_radius <= 90.0:
89
+ raise ValueError("zenith_radius must be in (0, 90].")
90
+ if not 0.0 <= min_coverage <= 1.0:
91
+ raise ValueError("min_coverage must be in [0, 1].")
92
+ self._zenith_radius = zenith_radius
93
+ self._min_coverage = min_coverage
94
+ self._error_after_failures = error_after_failures
95
+ self._stale_after = stale_after
96
+ self._health_error = ""
97
+ self._image_sender = image_sender
98
+ self._camera = CameraProfile(camera)
99
+ self._overlay = OverlayConfig.model_validate(overlay) if overlay is not None else None
100
+
101
+ self._measurement: CloudCoverageInfo | None = None
102
+
103
+ # e.g. a BufferedPublisher around an InfluxPublisher; opened and closed with the module
104
+ self._publisher: Publisher | None = None
105
+ if publisher is not None:
106
+ self._publisher = self.add_child_object(publisher, Publisher) # type: ignore[type-abstract]
107
+
108
+ pipeline_config = PipelinesConfig.model_validate(pipelines)
109
+ self._pipeline_controller = PipelineController.from_config(pipeline_config, self.observer, self._camera)
110
+ # the pipelines keep state between frames, so they run one at a time, off the event loop
111
+ self._executor = concurrent.futures.ThreadPoolExecutor(max_workers=1, thread_name_prefix="cloudcover")
112
+ # newest image not analysed yet: filename, kind, observation time from the event
113
+ self._latest: tuple[str, ImageKind, datetime.datetime | None] | None = None
114
+ self._new_image = asyncio.Event()
115
+
116
+ self._status = ModuleStatus()
117
+
118
+ self.add_background_task(self._process_images)
119
+ self.add_background_task(self._watch_health)
120
+
121
+ async def open(self) -> None:
122
+ await super().open()
123
+ # Module.startup() complains about a stateful interface without published state
124
+ await self.comm.set_state(ICloudCover, CloudCoverState())
125
+
126
+ await self.comm.register_event(NewImageEvent, self.process_new_image)
127
+ await self.comm.register_event(NewBitmapEvent, self.process_new_image)
128
+
129
+ async def close(self) -> None:
130
+ await super().close()
131
+ self._executor.shutdown(wait=False, cancel_futures=True)
132
+
133
+ async def get_cloud_cover(self, alt: float, az: float, radius: float = 0.0, **kwargs: Any) -> float | None:
134
+ info = self._measurement
135
+ if info is not None and self._stale_after is not None:
136
+ if (datetime.datetime.now(datetime.UTC) - info.obs_time).total_seconds() > self._stale_after:
137
+ info = None
138
+ if info is None:
139
+ # still check the arguments, so a bad call fails the same way before the first result
140
+ if not -90.0 <= alt <= 90.0 or radius < 0.0:
141
+ raise InvalidArgumentError("alt must be in [-90, 90] and radius must not be negative.")
142
+ return None
143
+ return fraction(info.cloud_cover_query, alt, az, radius, self._min_coverage)
144
+
145
+ async def _publish_state(self, state: CloudCoverState) -> None:
146
+ try:
147
+ await self.comm.set_state(ICloudCover, state)
148
+ except Exception:
149
+ log.exception("Publishing the cloud cover state failed.")
150
+
151
+ async def _publish(self, state: CloudCoverState, obs_time: datetime.datetime) -> None:
152
+ if self._publisher is None:
153
+ return
154
+ try:
155
+ await self._publisher(time=obs_time, **state_fields(state))
156
+ except Exception:
157
+ log.exception("Publishing the measurement failed.")
158
+
159
+ async def process_new_image(self, event: Event, sender: str) -> bool:
160
+ if sender != self._image_sender:
161
+ return False
162
+
163
+ if isinstance(event, NewImageEvent):
164
+ self.submit_image(event.filename)
165
+ elif isinstance(event, NewBitmapEvent):
166
+ obs_time = event.obs_time
167
+ self.submit_image(
168
+ event.filename, "bitmap", obs_time.to_datetime(timezone=datetime.UTC) if obs_time else None
169
+ )
170
+ else:
171
+ return False
172
+ return True
173
+
174
+ def submit_image(
175
+ self, filename: str, kind: ImageKind = "fits", obs_time: datetime.datetime | None = None
176
+ ) -> None:
177
+ """Queue an image (a pyobs VFS path) for analysis. Only the newest image is kept: if analysis falls
178
+ behind, older images that haven't been started yet are skipped.
179
+
180
+ Args:
181
+ filename: VFS path of the image.
182
+ kind: "fits" (read with ``vfs.read_image``) or "bitmap" (JPEG/PNG/TIFF, decoded here).
183
+ obs_time: Observation time (aware), if the sender knows it. Overrides ``camera.timestamp``.
184
+ """
185
+ self._status.received += 1
186
+ self._status.last_received_at = datetime.datetime.now(datetime.UTC)
187
+ if self._latest is not None:
188
+ log.info("Skipping %s, a newer image arrived before it was analysed.", self._latest[0])
189
+ self._status.skipped += 1
190
+ self._latest = (filename, kind, obs_time)
191
+ self._new_image.set()
192
+
193
+ async def _process_images(self) -> None:
194
+ while True:
195
+ await self._new_image.wait()
196
+ self._new_image.clear()
197
+ latest, self._latest = self._latest, None
198
+ if latest is not None:
199
+ await self.analyse(*latest)
200
+ await self._update_state()
201
+
202
+ async def _watch_health(self) -> None:
203
+ # analysis updates the state itself; this catches images that stop arriving
204
+ while True:
205
+ await asyncio.sleep(10)
206
+ await self._update_state()
207
+
208
+ async def _update_state(self) -> None:
209
+ """Switch between READY and ERROR depending on the status. Leaves other states (closed, starting, local)
210
+ alone. A manual reset_error() goes back to READY; the next check sets ERROR again if the cause is still
211
+ there."""
212
+ error = "; ".join(self._status.health_errors(self._error_after_failures, self._stale_after))
213
+ state = await self.get_state()
214
+ if error:
215
+ if state == ModuleState.READY or (state == ModuleState.ERROR and error != self._health_error):
216
+ log.error("Module unhealthy: %s", error)
217
+ await self.set_state(ModuleState.ERROR, error)
218
+ elif self._health_error and state == ModuleState.ERROR:
219
+ log.info("Module healthy again.")
220
+ await self.set_state(ModuleState.READY, "")
221
+ self._health_error = error
222
+
223
+ async def _load(
224
+ self, filename: str, kind: ImageKind = "fits", obs_time: datetime.datetime | None = None
225
+ ) -> RawImage:
226
+ if kind == "bitmap":
227
+ async with self.vfs.open_file(filename, "rb") as f:
228
+ data = await f.read()
229
+ if isinstance(data, str):
230
+ raise ValueError(f"{filename} was read as text, not bytes.")
231
+ raw = await asyncio.to_thread(decode_image, data, filename)
232
+ else:
233
+ image = await self.vfs.read_image(filename)
234
+ raw = from_fits_hdu(image.data, image.header)
235
+ raw.path = filename
236
+ raw.obs_time = obs_time
237
+ return raw
238
+
239
+ async def analyse(
240
+ self, filename: str, kind: ImageKind = "fits", obs_time: datetime.datetime | None = None
241
+ ) -> bool:
242
+ """Analyse one image; errors are logged, never raised. See :meth:`submit_image` for the arguments."""
243
+ try:
244
+ log.info("Analysing %s.", filename)
245
+ raw = await self._load(filename, kind, obs_time)
246
+ loop = asyncio.get_running_loop()
247
+ frame, result = await loop.run_in_executor(self._executor, self._run_pipeline, raw)
248
+ except Exception as e:
249
+ log.exception("Analysing %s failed.", filename)
250
+ self._status.failed += 1
251
+ self._status.consecutive_failures += 1
252
+ self._status.last_error = f"{Path(filename).name}: {type(e).__name__}: {e}"
253
+ self._status.last_error_at = datetime.datetime.now(datetime.UTC)
254
+ return False
255
+
256
+ self._status.consecutive_failures = 0
257
+ self._status.last_file = filename
258
+ if result is None:
259
+ reason = getattr(self._pipeline_controller, "last_reason", "") or "no result"
260
+ log.info("No result for %s: %s.", filename, reason)
261
+ self._status.without_result += 1
262
+ self._status.last_reason = reason
263
+ return False
264
+
265
+ measurement, state, product = result
266
+ self._measurement = measurement
267
+ await self._publish(state, measurement.obs_time)
268
+ await self._publish_state(state)
269
+ if product is not None:
270
+ await self._write_product(product, measurement.obs_time)
271
+ self._status.analysed += 1
272
+ self._status.last_obs_time = measurement.obs_time
273
+ self._status.last_result_at = datetime.datetime.now(datetime.UTC)
274
+ self._status.last_pipeline = measurement.pipeline
275
+ self._status.last_reason = ""
276
+ log.info("Finished %s.", filename)
277
+ return True
278
+
279
+ async def _write_product(self, product: fits.HDUList, obs_time: datetime.datetime) -> None:
280
+ """Write the overlay product and announce it; errors are logged, the result counts anyway."""
281
+ if self._overlay is None:
282
+ return
283
+ filename = obs_time.astimezone(datetime.UTC).strftime(self._overlay.filename)
284
+ try:
285
+ await self.vfs.write_fits(filename, product, overwrite=True)
286
+ await self.comm.send_event(NewImageEvent(filename))
287
+ except Exception:
288
+ log.exception("Writing the overlay product %s failed.", filename)
289
+
290
+ def _build_product(self, frame: Frame, measurement: CloudCoverageInfo) -> fits.HDUList | None:
291
+ if self._overlay is None:
292
+ return None
293
+ try:
294
+ return build_product(frame, measurement, self._overlay.binning)
295
+ except Exception:
296
+ log.exception("Building the overlay product failed.")
297
+ return None
298
+
299
+ def prepare(self, raw: RawImage) -> Frame:
300
+ return self._camera.prepare(raw)
301
+
302
+ def _run_pipeline(
303
+ self, raw: RawImage
304
+ ) -> tuple[Frame, tuple[CloudCoverageInfo, CloudCoverState, fits.HDUList | None] | None]:
305
+ frame = self.prepare(raw)
306
+ measurement = self._pipeline_controller(frame)
307
+ if measurement is None:
308
+ return frame, None
309
+ state = build_state(measurement, self._zenith_radius, self._min_coverage)
310
+ # here, not later: the night pipeline's world model changes with the next frame
311
+ return frame, (measurement, state, self._build_product(frame, measurement))
File without changes