Coverage for phenomena/tests/test_rayleigh.py: 100%

1"""Define the unit tests for the :mod:`colour.phenomena.rayleigh` module."""

2

3 from __future__ import annotations

4

5 import numpy as np

6

7 from colour.constants import TOLERANCE_ABSOLUTE_TESTS

8 from colour.phenomena import (

9 rayleigh_optical_depth,

10 scattering_cross_section,

11 sd_rayleigh_scattering,

12)

13 from colour.phenomena.rayleigh import (

14 F_air_Bates1984,

15 F_air_Bodhaine1999,

16 F_air_Penndorf1957,

17 F_air_Young1981,

18 N2_depolarisation,

19 O2_depolarisation,

20 air_refraction_index_Bodhaine1999,

21 air_refraction_index_Edlen1966,

22 air_refraction_index_Peck1972,

23 air_refraction_index_Penndorf1957,

24 gravity_List1968,

25 mean_molecular_weights,

26 molecular_density,

27)

28 from colour.utilities import ignore_numpy_errors

29

30 __author__ = "Colour Developers"

31 __copyright__ = "Copyright 2013 Colour Developers"

32 __license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"

33 __maintainer__ = "Colour Developers"

34 __email__ = "colour-developers@colour-science.org"

35 __status__ = "Production"

36

37 __all__ = [

38 "DATA_SD_RAYLEIGH_SCATTERING",

39 "TestAirRefractionIndexPenndorf1957",

40 "TestAirRefractionIndexEdlen1966",

41 "TestAirRefractionIndexPeck1972",

42 "TestAirRefractionIndexBodhaine1999",

43 "TestN2Depolarisation",

44 "TestO2Depolarisation",

45 "TestF_airPenndorf1957",

46 "TestF_airYoung1981",

47 "TestF_airBates1984",

48 "TestF_airBodhaine1999",

49 "TestMolecularDensity",

50 "TestMeanMolecularWeights",

51 "TestGravityList1968",

52 "TestScatteringCrossSection",

53 "TestRayleighOpticalDepth",

54 "TestSdRayleighScattering",

55]

56

57 DATA_SD_RAYLEIGH_SCATTERING: tuple = (

58 0.56024658,

59 0.55374814,

60 0.54734469,

61 0.54103456,

62 0.53481611,

63 0.52868771,

64 0.52264779,

65 0.51669481,

66 0.51082726,

67 0.50504364,

68 0.49934250,

69 0.49372243,

70 0.48818203,

71 0.48271993,

72 0.47733480,

73 0.47202532,

74 0.46679021,

75 0.46162820,

76 0.45653807,

77 0.45151861,

78 0.44656862,

79 0.44168694,

80 0.43687245,

81 0.43212401,

82 0.42744053,

83 0.42282094,

84 0.41826419,

85 0.41376924,

86 0.40933507,

87 0.40496071,

88 0.40064516,

89 0.39638749,

90 0.39218673,

91 0.38804199,

92 0.38395236,

93 0.37991695,

94 0.37593489,

95 0.37200533,

96 0.36812743,

97 0.36430038,

98 0.36052337,

99 0.35679561,

100 0.35311633,

101 0.34948475,

102 0.34590015,

103 0.34236177,

104 0.33886891,

105 0.33542085,

106 0.33201690,

107 0.32865638,

108 0.32533863,

109 0.32206298,

110 0.31882879,

111 0.31563542,

112 0.31248226,

113 0.30936870,

114 0.30629412,

115 0.30325795,

116 0.30025961,

117 0.29729852,

118 0.29437413,

119 0.29148588,

120 0.28863325,

121 0.28581570,

122 0.28303270,

123 0.28028376,

124 0.27756836,

125 0.27488601,

126 0.27223623,

127 0.26961854,

128 0.26703247,

129 0.26447756,

130 0.26195335,

131 0.25945941,

132 0.25699529,

133 0.25456057,

134 0.25215482,

135 0.24977762,

136 0.24742857,

137 0.24510727,

138 0.24281331,

139 0.24054632,

140 0.23830590,

141 0.23609169,

142 0.23390332,

143 0.23174041,

144 0.22960262,

145 0.22748959,

146 0.22540097,

147 0.22333643,

148 0.22129563,

149 0.21927825,

150 0.21728395,

151 0.21531242,

152 0.21336335,

153 0.21143642,

154 0.20953135,

155 0.20764781,

156 0.20578553,

157 0.20394422,

158 0.20212358,

159 0.20032334,

160 0.19854323,

161 0.19678297,

162 0.19504230,

163 0.19332095,

164 0.19161866,

165 0.18993519,

166 0.18827027,

167 0.18662367,

168 0.18499514,

169 0.18338444,

170 0.18179134,

171 0.18021561,

172 0.17865701,

173 0.17711532,

174 0.17559033,

175 0.17408181,

176 0.17258954,

177 0.17111333,

178 0.16965296,

179 0.16820822,

180 0.16677892,

181 0.16536485,

182 0.16396583,

183 0.16258165,

184 0.16121212,

185 0.15985707,

186 0.15851631,

187 0.15718965,

188 0.15587691,

189 0.15457793,

190 0.15329252,

191 0.15202052,

192 0.15076176,

193 0.14951607,

194 0.14828329,

195 0.14706325,

196 0.14585580,

197 0.14466079,

198 0.14347805,

199 0.14230744,

200 0.14114881,

201 0.14000200,

202 0.13886688,

203 0.13774330,

204 0.13663112,

205 0.13553019,

206 0.13444039,

207 0.13336158,

208 0.13229362,

209 0.13123639,

210 0.13018974,

211 0.12915357,

212 0.12812773,

213 0.12711210,

214 0.12610657,

215 0.12511101,

216 0.12412531,

217 0.12314934,

218 0.12218298,

219 0.12122614,

220 0.12027869,

221 0.11934052,

222 0.11841152,

223 0.11749159,

224 0.11658061,

225 0.11567849,

226 0.11478512,

227 0.11390040,

228 0.11302422,

229 0.11215649,

230 0.11129711,

231 0.11044599,

232 0.10960302,

233 0.10876811,

234 0.10794118,

235 0.10712212,

236 0.10631086,

237 0.10550729,

238 0.10471133,

239 0.10392290,

240 0.10314191,

241 0.10236828,

242 0.10160191,

243 0.10084274,

244 0.10009067,

245 0.09934563,

246 0.09860754,

247 0.09787633,

248 0.09715190,

249 0.09643420,

250 0.09572314,

251 0.09501864,

252 0.09432065,

253 0.09362907,

254 0.09294386,

255 0.09226492,

256 0.09159220,

257 0.09092562,

258 0.09026512,

259 0.08961063,

260 0.08896209,

261 0.08831943,

262 0.08768258,

263 0.08705149,

264 0.08642609,

265 0.08580631,

266 0.08519210,

267 0.08458341,

268 0.08398016,

269 0.08338229,

270 0.08278976,

271 0.08220251,

272 0.08162047,

273 0.08104360,

274 0.08047183,

275 0.07990512,

276 0.07934340,

277 0.07878663,

278 0.07823475,

279 0.07768772,

280 0.07714548,

281 0.07660798,

282 0.07607516,

283 0.07554699,

284 0.07502342,

285 0.07450438,

286 0.07398985,

287 0.07347976,

288 0.07297408,

289 0.07247276,

290 0.07197575,

291 0.07148301,

292 0.07099449,

293 0.07051016,

294 0.07002996,

295 0.06955386,

296 0.06908181,

297 0.06861378,

298 0.06814971,

299 0.06768958,

300 0.06723333,

301 0.06678094,

302 0.06633236,

303 0.06588755,

304 0.06544648,

305 0.06500910,

306 0.06457539,

307 0.06414530,

308 0.06371879,

309 0.06329584,

310 0.06287640,

311 0.06246044,

312 0.06204793,

313 0.06163883,

314 0.06123310,

315 0.06083072,

316 0.06043165,

317 0.06003586,

318 0.05964332,

319 0.05925399,

320 0.05886783,

321 0.05848484,

322 0.05810496,

323 0.05772817,

324 0.05735443,

325 0.05698373,

326 0.05661603,

327 0.05625130,

328 0.05588951,

329 0.05553063,

330 0.05517464,

331 0.05482150,

332 0.05447120,

333 0.05412370,

334 0.05377897,

335 0.05343699,

336 0.05309773,

337 0.05276117,

338 0.05242728,

339 0.05209604,

340 0.05176742,

341 0.05144139,

342 0.05111793,

343 0.05079701,

344 0.05047862,

345 0.05016273,

346 0.04984931,

347 0.04953835,

348 0.04922981,

349 0.04892367,

350 0.04861992,

351 0.04831853,

352 0.04801948,

353 0.04772275,

354 0.04742831,

355 0.04713614,

356 0.04684623,

357 0.04655855,

358 0.04627308,

359 0.04598980,

360 0.04570870,

361 0.04542974,

362 0.04515291,

363 0.04487820,

364 0.04460557,

365 0.04433502,

366 0.04406653,

367 0.04380007,

368 0.04353562,

369 0.04327318,

370 0.04301271,

371 0.04275421,

372 0.04249765,

373 0.04224301,

374 0.04199029,

375 0.04173946,

376 0.04149050,

377 0.04124341,

378 0.04099815,

379 0.04075472,

380 0.04051310,

381 0.04027327,

382 0.04003522,

383 0.03979893,

384 0.03956438,

385 0.03933157,

386 0.03910047,

387 0.03887106,

388 0.03864335,

389 0.03841730,

390 0.03819290,

391 0.03797015,

392 0.03774902,

393 0.03752951,

394 0.03731159,

395 0.03709525,

396 0.03688049,

397 0.03666728,

398 0.03645561,

399 0.03624547,

400 0.03603685,

401 0.03582973,

402 0.03562410,

403 0.03541995,

404 0.03521726,

405 0.03501602,

406 0.03481622,

407 0.03461785,

408 0.03442089,

409 0.03422534,

410 0.03403117,

411 0.03383838,

412 0.03364696,

413 0.03345690,

414 0.03326817,

415 0.03308078,

416 0.03289471,

417 0.03270995,

418 0.03252649,

419 0.03234432,

420 0.03216342,

421 0.03198379,

422 0.03180541,

423 0.03162828,

424 0.03145238,

425 0.03127771,

426 0.03110425,

427 0.03093199,

428 0.03076093,

429 0.03059105,

430 0.03042234,

431 0.03025480,

432 0.03008842,

433 0.02992318,

434 0.02975907,

435 0.02959609,

436 0.02943422,

437 0.02927347,

438 0.02911381,

439 0.02895524,

440 0.02879776,

441 0.02864134,

442 0.02848599,

443 0.02833169,

444 0.02817843,

445 0.02802622,

446 0.02787503,

447 0.02772486,

448 0.02757571,

449 0.02742756,

450 0.02728040,

451 0.02713423,

452 0.02698905,

453 0.02684483,

454 0.02670158,

455 0.02655928,

456 0.02641794,

457 0.02627753,

458 0.02613806,

459 0.02599951,

460 0.02586188,

461 0.02572517,

462 0.02558936,

463 0.02545444,

464 0.02532041,

465 0.02518727,

466 0.02505501,

467 0.02492361,

468 0.02479307,

469 0.02466339,

470 0.02453456,

471 0.02440657,

472 0.02427941,

473 0.02415309,

474 0.02402758,

475 0.02390290,

476 0.02377902,

477 0.02365594,

478 0.02353366,

479)

480

481

482 class TestAirRefractionIndexPenndorf1957:

483 """

484 Define :func:`colour.phenomena.rayleigh.\

485 air_refraction_index_Penndorf1957` definition unit tests methods.

486 """

487

488 def test_air_refraction_index_Penndorf1957(self) -> None:

489 """

490 Test :func:`colour.phenomena.rayleigh.\

491 air_refraction_index_Penndorf1957` definition.

492 """

493

494 np.testing.assert_allclose(

495 air_refraction_index_Penndorf1957(0.360),

496 1.000285316795146,

497 atol=TOLERANCE_ABSOLUTE_TESTS,

498 )

499

500 np.testing.assert_allclose(

501 air_refraction_index_Penndorf1957(0.555),

502 1.000277729533864,

503 atol=TOLERANCE_ABSOLUTE_TESTS,

504 )

505

506 np.testing.assert_allclose(

507 air_refraction_index_Penndorf1957(0.830),

508 1.000274856640486,

509 atol=TOLERANCE_ABSOLUTE_TESTS,

510 )

511

512 def test_n_dimensional_air_refraction_index_Penndorf1957(self) -> None:

513 """

514 Test :func:`colour.phenomena.rayleigh.\

515 air_refraction_index_Penndorf1957` definition n-dimensional arrays support.

516 """

517

518 wl = 0.360

519 n = air_refraction_index_Penndorf1957(wl)

520

521 wl = np.tile(wl, 6)

522 n = np.tile(n, 6)

523 np.testing.assert_allclose(

524 air_refraction_index_Penndorf1957(wl),

525 n,

526 atol=TOLERANCE_ABSOLUTE_TESTS,

527 )

528

529 wl = np.reshape(wl, (2, 3))

530 n = np.reshape(n, (2, 3))

531 np.testing.assert_allclose(

532 air_refraction_index_Penndorf1957(wl),

533 n,

534 atol=TOLERANCE_ABSOLUTE_TESTS,

535 )

536

537 wl = np.reshape(wl, (2, 3, 1))

538 n = np.reshape(n, (2, 3, 1))

539 np.testing.assert_allclose(

540 air_refraction_index_Penndorf1957(wl),

541 n,

542 atol=TOLERANCE_ABSOLUTE_TESTS,

543 )

544

545 @ignore_numpy_errors

546 def test_nan_air_refraction_index_Penndorf1957(self) -> None:

547 """

548 Test :func:`colour.phenomena.rayleigh.\

549 air_refraction_index_Penndorf1957` definition nan support.

550 """

551

552 air_refraction_index_Penndorf1957(

553 np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])

554 )

555

556

557 class TestAirRefractionIndexEdlen1966:

558 """

559 Define :func:`colour.phenomena.rayleigh.air_refraction_index_Edlen1966`

560 definition unit tests methods.

561 """

562

563 def test_air_refraction_index_Edlen1966(self) -> None:

564 """

565 Test :func:`colour.phenomena.\

566 rayleigh.air_refraction_index_Edlen1966` definition.

567 """

568

569 np.testing.assert_allclose(

570 air_refraction_index_Edlen1966(0.360),

571 1.000285308809879,

572 atol=TOLERANCE_ABSOLUTE_TESTS,

573 )

574

575 np.testing.assert_allclose(

576 air_refraction_index_Edlen1966(0.555),

577 1.000277727690364,

578 atol=TOLERANCE_ABSOLUTE_TESTS,

579 )

580

581 np.testing.assert_allclose(

582 air_refraction_index_Edlen1966(0.830),

583 1.000274862218835,

584 atol=TOLERANCE_ABSOLUTE_TESTS,

585 )

586

587 def test_n_dimensional_air_refraction_index_Edlen1966(self) -> None:

588 """

589 Test :func:`colour.phenomena.rayleigh.\

590 air_refraction_index_Edlen1966` definition n-dimensional arrays support.

591 """

592

593 wl = 0.360

594 n = air_refraction_index_Edlen1966(wl)

595

596 wl = np.tile(wl, 6)

597 n = np.tile(n, 6)

598 np.testing.assert_allclose(

599 air_refraction_index_Edlen1966(wl),

600 n,

601 atol=TOLERANCE_ABSOLUTE_TESTS,

602 )

603

604 wl = np.reshape(wl, (2, 3))

605 n = np.reshape(n, (2, 3))

606 np.testing.assert_allclose(

607 air_refraction_index_Edlen1966(wl),

608 n,

609 atol=TOLERANCE_ABSOLUTE_TESTS,

610 )

611

612 wl = np.reshape(wl, (2, 3, 1))

613 n = np.reshape(n, (2, 3, 1))

614 np.testing.assert_allclose(

615 air_refraction_index_Edlen1966(wl),

616 n,

617 atol=TOLERANCE_ABSOLUTE_TESTS,

618 )

619

620 @ignore_numpy_errors

621 def test_nan_air_refraction_index_Edlen1966(self) -> None:

622 """

623 Test :func:`colour.phenomena.rayleigh.\

624 air_refraction_index_Edlen1966` definition nan support.

625 """

626

627 air_refraction_index_Edlen1966(

628 np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])

629 )

630

631

632 class TestAirRefractionIndexPeck1972:

633 """

634 Define :func:`colour.phenomena.rayleigh.air_refraction_index_Peck1972`

635 definition unit tests methods.

636 """

637

638 def test_air_refraction_index_Peck1972(self) -> None:

639 """

640 Test :func:`colour.phenomena.rayleigh.air_refraction_index_Peck1972`

641 definition.

642 """

643

644 np.testing.assert_allclose(

645 air_refraction_index_Peck1972(0.360),

646 1.000285310285056,

647 atol=TOLERANCE_ABSOLUTE_TESTS,

648 )

649

650 np.testing.assert_allclose(

651 air_refraction_index_Peck1972(0.555),

652 1.000277726541484,

653 atol=TOLERANCE_ABSOLUTE_TESTS,

654 )

655

656 np.testing.assert_allclose(

657 air_refraction_index_Peck1972(0.830),

658 1.000274859144804,

659 atol=TOLERANCE_ABSOLUTE_TESTS,

660 )

661

662 def test_n_dimensional_air_refraction_index_Peck1972(self) -> None:

663 """

664 Test :func:`colour.phenomena.rayleigh.air_refraction_index_Peck1972`

665 definition n-dimensional arrays support.

666 """

667

668 wl = 0.360

669 n = air_refraction_index_Peck1972(wl)

670

671 wl = np.tile(wl, 6)

672 n = np.tile(n, 6)

673 np.testing.assert_allclose(

674 air_refraction_index_Peck1972(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

675 )

676

677 wl = np.reshape(wl, (2, 3))

678 n = np.reshape(n, (2, 3))

679 np.testing.assert_allclose(

680 air_refraction_index_Peck1972(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

681 )

682

683 wl = np.reshape(wl, (2, 3, 1))

684 n = np.reshape(n, (2, 3, 1))

685 np.testing.assert_allclose(

686 air_refraction_index_Peck1972(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

687 )

688

689 @ignore_numpy_errors

690 def test_nan_air_refraction_index_Peck1972(self) -> None:

691 """

692 Test :func:`colour.phenomena.rayleigh.air_refraction_index_Peck1972`

693 definition nan support.

694 """

695

696 air_refraction_index_Peck1972(

697 np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])

698 )

699

700

701 class TestAirRefractionIndexBodhaine1999:

702 """

703 Define :func:`colour.phenomena.rayleigh.\

704 air_refraction_index_Bodhaine1999` definition unit tests methods.

705 """

706

707 def test_air_refraction_index_Bodhaine1999(self) -> None:

708 """

709 Test :func:`colour.phenomena.rayleigh.\

710 air_refraction_index_Bodhaine1999` definition.

711 """

712

713 np.testing.assert_allclose(

714 air_refraction_index_Bodhaine1999(0.360),

715 1.000285310285056,

716 atol=TOLERANCE_ABSOLUTE_TESTS,

717 )

718

719 np.testing.assert_allclose(

720 air_refraction_index_Bodhaine1999(0.555),

721 1.000277726541484,

722 atol=TOLERANCE_ABSOLUTE_TESTS,

723 )

724

725 np.testing.assert_allclose(

726 air_refraction_index_Bodhaine1999(0.830),

727 1.000274859144804,

728 atol=TOLERANCE_ABSOLUTE_TESTS,

729 )

730

731 np.testing.assert_allclose(

732 air_refraction_index_Bodhaine1999(0.360, 0),

733 1.000285264064789,

734 atol=TOLERANCE_ABSOLUTE_TESTS,

735 )

736

737 np.testing.assert_allclose(

738 air_refraction_index_Bodhaine1999(0.555, 360),

739 1.000277735539824,

740 atol=TOLERANCE_ABSOLUTE_TESTS,

741 )

742

743 np.testing.assert_allclose(

744 air_refraction_index_Bodhaine1999(0.830, 620),

745 1.000274906640464,

746 atol=TOLERANCE_ABSOLUTE_TESTS,

747 )

748

749 def test_n_dimensional_air_refraction_index_Bodhaine1999(self) -> None:

750 """

751 Test :func:`colour.phenomena.rayleigh.\

752 air_refraction_index_Bodhaine1999` definition n-dimensional arrays support.

753 """

754

755 wl = 0.360

756 n = air_refraction_index_Bodhaine1999(wl)

757

758 wl = np.tile(wl, 6)

759 n = np.tile(n, 6)

760 np.testing.assert_allclose(

761 air_refraction_index_Bodhaine1999(wl),

762 n,

763 atol=TOLERANCE_ABSOLUTE_TESTS,

764 )

765

766 wl = np.reshape(wl, (2, 3))

767 n = np.reshape(n, (2, 3))

768 np.testing.assert_allclose(

769 air_refraction_index_Bodhaine1999(wl),

770 n,

771 atol=TOLERANCE_ABSOLUTE_TESTS,

772 )

773

774 wl = np.reshape(wl, (2, 3, 1))

775 n = np.reshape(n, (2, 3, 1))

776 np.testing.assert_allclose(

777 air_refraction_index_Bodhaine1999(wl),

778 n,

779 atol=TOLERANCE_ABSOLUTE_TESTS,

780 )

781

782 @ignore_numpy_errors

783 def test_nan_air_refraction_index_Bodhaine1999(self) -> None:

784 """

785 Test :func:`colour.phenomena.rayleigh.\

786 air_refraction_index_Bodhaine1999` definition nan support.

787 """

788

789 cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]

790 air_refraction_index_Bodhaine1999(cases, cases)

791

792

793 class TestN2Depolarisation:

794 """

795 Define :func:`colour.phenomena.rayleigh.N2_depolarisation` definition

796 unit tests methods.

797 """

798

799 def test_N2_depolarisation(self) -> None:

800 """Test :func:`colour.phenomena.rayleigh.N2_depolarisation` definition."""

801

802 np.testing.assert_allclose(

803 N2_depolarisation(0.360),

804 1.036445987654321,

805 atol=TOLERANCE_ABSOLUTE_TESTS,

806 )

807

808 np.testing.assert_allclose(

809 N2_depolarisation(0.555),

810 1.035029137245354,

811 atol=TOLERANCE_ABSOLUTE_TESTS,

812 )

813

814 np.testing.assert_allclose(

815 N2_depolarisation(0.830),

816 1.034460153868486,

817 atol=TOLERANCE_ABSOLUTE_TESTS,

818 )

819

820 def test_n_dimensional_N2_depolarisation(self) -> None:

821 """

822 Test :func:`colour.phenomena.rayleigh.N2_depolarisation`

823 definition n-dimensional arrays support.

824 """

825

826 wl = 0.360

827 n = N2_depolarisation(wl)

828

829 wl = np.tile(wl, 6)

830 n = np.tile(n, 6)

831 np.testing.assert_allclose(

832 N2_depolarisation(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

833 )

834

835 wl = np.reshape(wl, (2, 3))

836 n = np.reshape(n, (2, 3))

837 np.testing.assert_allclose(

838 N2_depolarisation(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

839 )

840

841 wl = np.reshape(wl, (2, 3, 1))

842 n = np.reshape(n, (2, 3, 1))

843 np.testing.assert_allclose(

844 N2_depolarisation(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

845 )

846

847 @ignore_numpy_errors

848 def test_nan_N2_depolarisation(self) -> None:

849 """

850 Test :func:`colour.phenomena.rayleigh.N2_depolarisation` definition

851 nan support.

852 """

853

854 N2_depolarisation(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

855

856

857 class TestO2Depolarisation:

858 """

859 Define :func:`colour.phenomena.rayleigh.O2_depolarisation` definition

860 unit tests methods.

861 """

862

863 def test_O2_depolarisation(self) -> None:

864 """Test :func:`colour.phenomena.rayleigh.O2_depolarisation` definition."""

865

866 np.testing.assert_allclose(

867 O2_depolarisation(0.360),

868 1.115307746532541,

869 atol=TOLERANCE_ABSOLUTE_TESTS,

870 )

871

872 np.testing.assert_allclose(

873 O2_depolarisation(0.555),

874 1.102022536201071,

875 atol=TOLERANCE_ABSOLUTE_TESTS,

876 )

877

878 np.testing.assert_allclose(

879 O2_depolarisation(0.830),

880 1.098315561269013,

881 atol=TOLERANCE_ABSOLUTE_TESTS,

882 )

883

884 def test_n_dimensional_O2_depolarisation(self) -> None:

885 """

886 Test :func:`colour.phenomena.rayleigh.O2_depolarisation` definition

887 n-dimensional arrays support.

888 """

889

890 wl = 0.360

891 n = O2_depolarisation(wl)

892

893 wl = np.tile(wl, 6)

894 n = np.tile(n, 6)

895 np.testing.assert_allclose(

896 O2_depolarisation(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

897 )

898

899 wl = np.reshape(wl, (2, 3))

900 n = np.reshape(n, (2, 3))

901 np.testing.assert_allclose(

902 O2_depolarisation(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

903 )

904

905 wl = np.reshape(wl, (2, 3, 1))

906 n = np.reshape(n, (2, 3, 1))

907 np.testing.assert_allclose(

908 O2_depolarisation(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

909 )

910

911 @ignore_numpy_errors

912 def test_nan_O2_depolarisation(self) -> None:

913 """

914 Test :func:`colour.phenomena.rayleigh.O2_depolarisation` definition

915 nan support.

916 """

917

918 O2_depolarisation(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

919

920

921 class TestF_airPenndorf1957:

922 """

923 Define :func:`colour.phenomena.rayleigh.F_air_Penndorf1957` definition

924 unit tests methods.

925 """

926

927 def test_F_air_Penndorf1957(self) -> None:

928 """

929 Test :func:`colour.phenomena.rayleigh.F_air_Penndorf1957`

930 definition.

931 """

932

933 assert F_air_Penndorf1957(0.360) == 1.0608

934

935 def test_n_dimensional_F_air_Penndorf1957(self) -> None:

936 """

937 Test :func:`colour.phenomena.rayleigh.F_air_Penndorf1957` definition

938 n-dimensional arrays support.

939 """

940

941 wl = 0.360

942 n = F_air_Penndorf1957(wl)

943

944 wl = np.tile(wl, 6)

945 n = np.tile(n, 6)

946 np.testing.assert_allclose(

947 F_air_Penndorf1957(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

948 )

949

950 wl = np.reshape(wl, (2, 3))

951 n = np.reshape(n, (2, 3))

952 np.testing.assert_allclose(

953 F_air_Penndorf1957(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

954 )

955

956 wl = np.reshape(wl, (2, 3, 1))

957 n = np.reshape(n, (2, 3, 1))

958 np.testing.assert_allclose(

959 F_air_Penndorf1957(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

960 )

961

962 @ignore_numpy_errors

963 def test_nan_F_air_Penndorf1957(self) -> None:

964 """

965 Test :func:`colour.phenomena.rayleigh.F_air_Penndorf1957` definition

966 nan support.

967 """

968

969 F_air_Penndorf1957(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

970

971

972 class TestF_airYoung1981:

973 """

974 Define :func:`colour.phenomena.rayleigh.F_air_Young1981` definition

975 unit tests methods.

976 """

977

978 def test_F_air_Young1981(self) -> None:

979 """Test :func:`colour.phenomena.rayleigh.F_air_Young1981` definition."""

980

981 assert F_air_Young1981(0.360) == 1.0480

982

983 def test_n_dimensional_F_air_Young1981(self) -> None:

984 """

985 Test :func:`colour.phenomena.rayleigh.F_air_Young1981` definition

986 n-dimensional arrays support.

987 """

988

989 wl = 0.360

990 n = F_air_Young1981(wl)

991

992 wl = np.tile(wl, 6)

993 n = np.tile(n, 6)

994 np.testing.assert_allclose(

995 F_air_Young1981(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

996 )

997

998 wl = np.reshape(wl, (2, 3))

999 n = np.reshape(n, (2, 3))

1000 np.testing.assert_allclose(

1001 F_air_Young1981(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

1002 )

1003

1004 wl = np.reshape(wl, (2, 3, 1))

1005 n = np.reshape(n, (2, 3, 1))

1006 np.testing.assert_allclose(

1007 F_air_Young1981(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

1008 )

1009

1010 @ignore_numpy_errors

1011 def test_nan_F_air_Young1981(self) -> None:

1012 """

1013 Test :func:`colour.phenomena.rayleigh.F_air_Young1981` definition

1014 nan support.

1015 """

1016

1017 F_air_Young1981(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

1018

1019

1020 class TestF_airBates1984:

1021 """

1022 Define :func:`colour.phenomena.rayleigh.F_air_Bates1984` definition unit

1023 tests methods.

1024 """

1025

1026 def test_F_air_Bates1984(self) -> None:

1027 """Test :func:`colour.phenomena.rayleigh.F_air_Bates1984` definition."""

1028

1029 np.testing.assert_allclose(

1030 F_air_Bates1984(0.360),

1031 1.051997277711708,

1032 atol=TOLERANCE_ABSOLUTE_TESTS,

1033 )

1034

1035 np.testing.assert_allclose(

1036 F_air_Bates1984(0.555),

1037 1.048153579718658,

1038 atol=TOLERANCE_ABSOLUTE_TESTS,

1039 )

1040

1041 np.testing.assert_allclose(

1042 F_air_Bates1984(0.830),

1043 1.046947068600589,

1044 atol=TOLERANCE_ABSOLUTE_TESTS,

1045 )

1046

1047 def test_n_dimensional_F_air_Bates1984(self) -> None:

1048 """

1049 Test :func:`colour.phenomena.rayleigh.F_air_Bates1984` definition

1050 n-dimensional arrays support.

1051 """

1052

1053 wl = 0.360

1054 n = F_air_Bates1984(wl)

1055

1056 wl = np.tile(wl, 6)

1057 n = np.tile(n, 6)

1058 np.testing.assert_allclose(

1059 F_air_Bates1984(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

1060 )

1061

1062 wl = np.reshape(wl, (2, 3))

1063 n = np.reshape(n, (2, 3))

1064 np.testing.assert_allclose(

1065 F_air_Bates1984(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

1066 )

1067

1068 wl = np.reshape(wl, (2, 3, 1))

1069 n = np.reshape(n, (2, 3, 1))

1070 np.testing.assert_allclose(

1071 F_air_Bates1984(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

1072 )

1073

1074 @ignore_numpy_errors

1075 def test_nan_F_air_Bates1984(self) -> None:

1076 """

1077 Test :func:`colour.phenomena.rayleigh.F_air_Bates1984` definition

1078 nan support.

1079 """

1080

1081 F_air_Bates1984(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

1082

1083

1084 class TestF_airBodhaine1999:

1085 """

1086 Define :func:`colour.phenomena.rayleigh.F_air_Bodhaine1999` definition

1087 unit tests methods.

1088 """

1089

1090 def test_F_air_Bodhaine1999(self) -> None:

1091 """

1092 Test :func:`colour.phenomena.rayleigh.F_air_Bodhaine1999`

1093 definition.

1094 """

1095

1096 np.testing.assert_allclose(

1097 F_air_Bodhaine1999(0.360),

1098 1.052659005129014,

1099 atol=TOLERANCE_ABSOLUTE_TESTS,

1100 )

1101

1102 np.testing.assert_allclose(

1103 F_air_Bodhaine1999(0.555),

1104 1.048769718142427,

1105 atol=TOLERANCE_ABSOLUTE_TESTS,

1106 )

1107

1108 np.testing.assert_allclose(

1109 F_air_Bodhaine1999(0.830),

1110 1.047548896943893,

1111 atol=TOLERANCE_ABSOLUTE_TESTS,

1112 )

1113

1114 np.testing.assert_allclose(

1115 F_air_Bodhaine1999(0.360, 0),

1116 1.052629792313939,

1117 atol=TOLERANCE_ABSOLUTE_TESTS,

1118 )

1119

1120 np.testing.assert_allclose(

1121 F_air_Bodhaine1999(0.555, 360),

1122 1.048775791959338,

1123 atol=TOLERANCE_ABSOLUTE_TESTS,

1124 )

1125

1126 np.testing.assert_allclose(

1127 F_air_Bodhaine1999(0.830, 620),

1128 1.047581672775155,

1129 atol=TOLERANCE_ABSOLUTE_TESTS,

1130 )

1131

1132 def test_n_dimensional_F_air_Bodhaine1999(self) -> None:

1133 """

1134 Test :func:`colour.phenomena.rayleigh.F_air_Bodhaine1999` definition

1135 n-dimensional arrays support.

1136 """

1137

1138 wl = 0.360

1139 n = F_air_Bodhaine1999(wl)

1140

1141 wl = np.tile(wl, 6)

1142 n = np.tile(n, 6)

1143 np.testing.assert_allclose(

1144 F_air_Bodhaine1999(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

1145 )

1146

1147 wl = np.reshape(wl, (2, 3))

1148 n = np.reshape(n, (2, 3))

1149 np.testing.assert_allclose(

1150 F_air_Bodhaine1999(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

1151 )

1152

1153 wl = np.reshape(wl, (2, 3, 1))

1154 n = np.reshape(n, (2, 3, 1))

1155 np.testing.assert_allclose(

1156 F_air_Bodhaine1999(wl), n, atol=TOLERANCE_ABSOLUTE_TESTS

1157 )

1158

1159 @ignore_numpy_errors

1160 def test_nan_F_air_Bodhaine1999(self) -> None:

1161 """

1162 Test :func:`colour.phenomena.rayleigh.F_air_Bodhaine1999` definition

1163 nan support.

1164 """

1165

1166 cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]

1167 F_air_Bodhaine1999(cases, cases)

1168

1169

1170 class TestMolecularDensity:

1171 """

1172 Define :func:`colour.phenomena.rayleigh.molecular_density` definition

1173 unit tests methods.

1174 """

1175

1176 def test_molecular_density(self) -> None:

1177 """Test :func:`colour.phenomena.rayleigh.molecular_density` definition."""

1178

1179 np.testing.assert_allclose(

1180 molecular_density(200), 3.669449208173649e19, atol=10000

1181 )

1182

1183 np.testing.assert_allclose(

1184 molecular_density(300), 2.4462994721157665e19, atol=10000

1185 )

1186

1187 np.testing.assert_allclose(

1188 molecular_density(400), 1.834724604086825e19, atol=10000

1189 )

1190

1191 def test_n_dimensional_molecular_density(self) -> None:

1192 """

1193 Test :func:`colour.phenomena.rayleigh.molecular_density` definition

1194 n-dimensional arrays support.

1195 """

1196

1197 temperature = 200

1198 N_s = molecular_density(temperature)

1199

1200 temperature = np.tile(temperature, 6)

1201 N_s = np.tile(N_s, 6)

1202 np.testing.assert_allclose(

1203 molecular_density(temperature), N_s, atol=TOLERANCE_ABSOLUTE_TESTS

1204 )

1205

1206 temperature = np.reshape(temperature, (2, 3))

1207 N_s = np.reshape(N_s, (2, 3))

1208 np.testing.assert_allclose(

1209 molecular_density(temperature), N_s, atol=TOLERANCE_ABSOLUTE_TESTS

1210 )

1211

1212 temperature = np.reshape(temperature, (2, 3, 1))

1213 N_s = np.reshape(N_s, (2, 3, 1))

1214 np.testing.assert_allclose(

1215 molecular_density(temperature), N_s, atol=TOLERANCE_ABSOLUTE_TESTS

1216 )

1217

1218 @ignore_numpy_errors

1219 def test_nan_molecular_density(self) -> None:

1220 """

1221 Test :func:`colour.phenomena.rayleigh.molecular_density` definition

1222 nan support.

1223 """

1224

1225 molecular_density(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

1226

1227

1228 class TestMeanMolecularWeights:

1229 """

1230 Define :func:`colour.phenomena.rayleigh.mean_molecular_weights`

1231 definition unit tests methods.

1232 """

1233

1234 def test_mean_molecular_weights(self) -> None:

1235 """

1236 Test :func:`colour.phenomena.rayleigh.mean_molecular_weights`

1237 definition.

1238 """

1239

1240 np.testing.assert_allclose(

1241 mean_molecular_weights(0), 28.9595, atol=TOLERANCE_ABSOLUTE_TESTS

1242 )

1243

1244 np.testing.assert_allclose(

1245 mean_molecular_weights(360),

1246 28.964920015999997,

1247 atol=TOLERANCE_ABSOLUTE_TESTS,

1248 )

1249

1250 np.testing.assert_allclose(

1251 mean_molecular_weights(620),

1252 28.968834471999998,

1253 atol=TOLERANCE_ABSOLUTE_TESTS,

1254 )

1255

1256 def test_n_dimensional_mean_molecular_weights(self) -> None:

1257 """

1258 Test :func:`colour.phenomena.rayleigh.mean_molecular_weights`

1259 definition n-dimensional arrays support.

1260 """

1261

1262 CO2_c = 300

1263 m_a = mean_molecular_weights(CO2_c)

1264

1265 CO2_c = np.tile(CO2_c, 6)

1266 m_a = np.tile(m_a, 6)

1267 np.testing.assert_allclose(

1268 mean_molecular_weights(CO2_c), m_a, atol=TOLERANCE_ABSOLUTE_TESTS

1269 )

1270

1271 CO2_c = np.reshape(CO2_c, (2, 3))

1272 m_a = np.reshape(m_a, (2, 3))

1273 np.testing.assert_allclose(

1274 mean_molecular_weights(CO2_c), m_a, atol=TOLERANCE_ABSOLUTE_TESTS

1275 )

1276

1277 CO2_c = np.reshape(CO2_c, (2, 3, 1))

1278 m_a = np.reshape(m_a, (2, 3, 1))

1279 np.testing.assert_allclose(

1280 mean_molecular_weights(CO2_c), m_a, atol=TOLERANCE_ABSOLUTE_TESTS

1281 )

1282

1283 @ignore_numpy_errors

1284 def test_nan_mean_molecular_weights(self) -> None:

1285 """

1286 Test :func:`colour.phenomena.rayleigh.mean_molecular_weights`

1287 definition nan support.

1288 """

1289

1290 mean_molecular_weights(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

1291

1292

1293 class TestGravityList1968:

1294 """

1295 Define :func:`colour.phenomena.rayleigh.gravity_List1968` definition

1296 unit tests methods.

1297 """

1298

1299 def test_gravity_List1968(self) -> None:

1300 """Test :func:`colour.phenomena.rayleigh.gravity_List1968` definition."""

1301

1302 np.testing.assert_allclose(

1303 gravity_List1968(0.0, 0.0),

1304 978.03560706,

1305 atol=TOLERANCE_ABSOLUTE_TESTS,

1306 )

1307

1308 np.testing.assert_allclose(

1309 gravity_List1968(45.0, 1500.0),

1310 980.15334386,

1311 atol=TOLERANCE_ABSOLUTE_TESTS,

1312 )

1313

1314 np.testing.assert_allclose(

1315 gravity_List1968(48.8567, 35.0),

1316 980.95241784,

1317 atol=TOLERANCE_ABSOLUTE_TESTS,

1318 )

1319

1320 def test_n_dimensional_gravity_List1968(self) -> None:

1321 """

1322 Test :func:`colour.phenomena.rayleigh.gravity_List1968`

1323 definition n-dimensional arrays support.

1324 """

1325

1326 g = 978.03560706

1327 np.testing.assert_allclose(gravity_List1968(), g, atol=TOLERANCE_ABSOLUTE_TESTS)

1328

1329 g = np.tile(g, 6)

1330 np.testing.assert_allclose(gravity_List1968(), g, atol=TOLERANCE_ABSOLUTE_TESTS)

1331

1332 g = np.reshape(g, (2, 3))

1333 np.testing.assert_allclose(gravity_List1968(), g, atol=TOLERANCE_ABSOLUTE_TESTS)

1334

1335 g = np.reshape(g, (2, 3, 1))

1336 np.testing.assert_allclose(gravity_List1968(), g, atol=TOLERANCE_ABSOLUTE_TESTS)

1337

1338 @ignore_numpy_errors

1339 def test_nan_gravity_List1968(self) -> None:

1340 """

1341 Test :func:`colour.phenomena.rayleigh.gravity_List1968` definition

1342 nan support.

1343 """

1344

1345 cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]

1346 gravity_List1968(cases, cases)

1347

1348

1349 class TestScatteringCrossSection:

1350 """

1351 Define :func:`colour.phenomena.rayleigh.scattering_cross_section`

1352 definition unit tests methods.

1353 """

1354

1355 def test_scattering_cross_section(self) -> None:

1356 """

1357 Test :func:`colour.phenomena.rayleigh.scattering_cross_section`

1358 definition.

1359 """

1360

1361 np.testing.assert_allclose(

1362 scattering_cross_section(360 * 10e-8),

1363 2.600908533851937e-26,

1364 atol=1e-30,

1365 )

1366

1367 np.testing.assert_allclose(

1368 scattering_cross_section(555 * 10e-8),

1369 4.346669248087624e-27,

1370 atol=1e-30,

1371 )

1372

1373 np.testing.assert_allclose(

1374 scattering_cross_section(830 * 10e-8),

1375 8.501515434751428e-28,

1376 atol=1e-30,

1377 )

1378

1379 np.testing.assert_allclose(

1380 scattering_cross_section(555 * 10e-8, 0),

1381 4.346543336839102e-27,

1382 atol=1e-30,

1383 )

1384

1385 np.testing.assert_allclose(

1386 scattering_cross_section(555 * 10e-8, 360),

1387 4.346694421271718e-27,

1388 atol=1e-30,

1389 )

1390

1391 np.testing.assert_allclose(

1392 scattering_cross_section(555 * 10e-8, 620),

1393 4.346803470171720e-27,

1394 atol=1e-30,

1395 )

1396

1397 np.testing.assert_allclose(

1398 scattering_cross_section(555 * 10e-8, temperature=200),

1399 2.094012829135068e-27,

1400 atol=1e-30,

1401 )

1402

1403 np.testing.assert_allclose(

1404 scattering_cross_section(555 * 10e-8, temperature=300),

1405 4.711528865553901e-27,

1406 atol=1e-30,

1407 )

1408

1409 np.testing.assert_allclose(

1410 scattering_cross_section(555 * 10e-8, temperature=400),

1411 8.376051316540270e-27,

1412 atol=1e-30,

1413 )

1414

1415 def test_n_dimensional_scattering_cross_section(self) -> None:

1416 """

1417 Test :func:`colour.phenomena.rayleigh.scattering_cross_section`

1418 definition n-dimensional arrays support.

1419 """

1420

1421 wl = 360 * 10e-8

1422 sigma = scattering_cross_section(wl)

1423

1424 sigma = np.tile(sigma, 6)

1425 np.testing.assert_allclose(

1426 scattering_cross_section(wl), sigma, atol=TOLERANCE_ABSOLUTE_TESTS

1427 )

1428

1429 sigma = np.reshape(sigma, (2, 3))

1430 np.testing.assert_allclose(

1431 scattering_cross_section(wl), sigma, atol=TOLERANCE_ABSOLUTE_TESTS

1432 )

1433

1434 sigma = np.reshape(sigma, (2, 3, 1))

1435 np.testing.assert_allclose(

1436 scattering_cross_section(wl), sigma, atol=TOLERANCE_ABSOLUTE_TESTS

1437 )

1438

1439 @ignore_numpy_errors

1440 def test_nan_scattering_cross_section(self) -> None:

1441 """

1442 Test :func:`colour.phenomena.rayleigh.scattering_cross_section`

1443 definition nan support.

1444 """

1445

1446 cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]

1447 scattering_cross_section(cases, cases, cases)

1448

1449

1450 class TestRayleighOpticalDepth:

1451 """

1452 Define :func:`colour.phenomena.rayleigh.rayleigh_optical_depth`

1453 definition unit tests methods.

1454 """

1455

1456 def test_rayleigh_optical_depth(self) -> None:

1457 """

1458 Test :func:`colour.phenomena.rayleigh.rayleigh_optical_depth`

1459 definition.

1460 """

1461

1462 np.testing.assert_allclose(

1463 rayleigh_optical_depth(360 * 10e-8),

1464 0.560246579231107,

1465 atol=TOLERANCE_ABSOLUTE_TESTS,

1466 )

1467

1468 np.testing.assert_allclose(

1469 rayleigh_optical_depth(555 * 10e-8),

1470 0.093629074056042,

1471 atol=TOLERANCE_ABSOLUTE_TESTS,

1472 )

1473

1474 np.testing.assert_allclose(

1475 rayleigh_optical_depth(830 * 10e-8),

1476 0.018312619911882,

1477 atol=TOLERANCE_ABSOLUTE_TESTS,

1478 )

1479

1480 np.testing.assert_allclose(

1481 rayleigh_optical_depth(555 * 10e-8, 0),

1482 0.093640964348049,

1483 atol=TOLERANCE_ABSOLUTE_TESTS,

1484 )

1485

1486 np.testing.assert_allclose(

1487 rayleigh_optical_depth(555 * 10e-8, 360),

1488 0.093626696247360,

1489 atol=TOLERANCE_ABSOLUTE_TESTS,

1490 )

1491

1492 np.testing.assert_allclose(

1493 rayleigh_optical_depth(555 * 10e-8, 620),

1494 0.093616393371777,

1495 atol=TOLERANCE_ABSOLUTE_TESTS,

1496 )

1497

1498 np.testing.assert_allclose(

1499 rayleigh_optical_depth(555 * 10e-8, temperature=200),

1500 0.045105912380991,

1501 atol=TOLERANCE_ABSOLUTE_TESTS,

1502 )

1503

1504 np.testing.assert_allclose(

1505 rayleigh_optical_depth(555 * 10e-8, temperature=300),

1506 0.101488302857230,

1507 atol=TOLERANCE_ABSOLUTE_TESTS,

1508 )

1509

1510 np.testing.assert_allclose(

1511 rayleigh_optical_depth(555 * 10e-8, temperature=400),

1512 0.180423649523964,

1513 atol=TOLERANCE_ABSOLUTE_TESTS,

1514 )

1515

1516 np.testing.assert_allclose(

1517 rayleigh_optical_depth(555 * 10e-8, pressure=101325),

1518 0.093629074056042,

1519 atol=TOLERANCE_ABSOLUTE_TESTS,

1520 )

1521

1522 np.testing.assert_allclose(

1523 rayleigh_optical_depth(555 * 10e-8, pressure=100325),

1524 0.092705026939772,

1525 atol=TOLERANCE_ABSOLUTE_TESTS,

1526 )

1527

1528 np.testing.assert_allclose(

1529 rayleigh_optical_depth(555 * 10e-8, pressure=99325),

1530 0.091780979823502,

1531 atol=TOLERANCE_ABSOLUTE_TESTS,

1532 )

1533

1534 np.testing.assert_allclose(

1535 rayleigh_optical_depth(555 * 10e-8, latitude=0, altitude=0),

1536 0.093629074056041,

1537 atol=TOLERANCE_ABSOLUTE_TESTS,

1538 )

1539

1540 np.testing.assert_allclose(

1541 rayleigh_optical_depth(555 * 10e-8, latitude=45, altitude=1500),

1542 0.093426777407767,

1543 atol=TOLERANCE_ABSOLUTE_TESTS,

1544 )

1545

1546 np.testing.assert_allclose(

1547 rayleigh_optical_depth(555 * 10e-8, latitude=48.8567, altitude=35),

1548 0.093350672894038,

1549 atol=TOLERANCE_ABSOLUTE_TESTS,

1550 )

1551

1552 def test_n_dimensional_rayleigh_optical_depth(self) -> None:

1553 """

1554 Test :func:`colour.phenomena.rayleigh.rayleigh_optical_depth`

1555 definition n-dimensional arrays support.

1556 """

1557

1558 wl = 360 * 10e-8

1559 T_R = rayleigh_optical_depth(wl)

1560

1561 T_R = np.tile(T_R, 6)

1562 np.testing.assert_allclose(

1563 rayleigh_optical_depth(wl), T_R, atol=TOLERANCE_ABSOLUTE_TESTS

1564 )

1565

1566 T_R = np.reshape(T_R, (2, 3))

1567 np.testing.assert_allclose(

1568 rayleigh_optical_depth(wl), T_R, atol=TOLERANCE_ABSOLUTE_TESTS

1569 )

1570

1571 T_R = np.reshape(T_R, (2, 3, 1))

1572 np.testing.assert_allclose(

1573 rayleigh_optical_depth(wl), T_R, atol=TOLERANCE_ABSOLUTE_TESTS

1574 )

1575

1576 @ignore_numpy_errors

1577 def test_nan_rayleigh_optical_depth(self) -> None:

1578 """

1579 Test :func:`colour.phenomena.rayleigh.rayleigh_optical_depth`

1580 definition nan support.

1581 """

1582

1583 cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]

1584 rayleigh_optical_depth(cases, cases, cases, cases, cases)

1585

1586

1587 class TestSdRayleighScattering:

1588 """

1589 Define :func:`colour.phenomena.rayleigh.sd_rayleigh_scattering`

1590 definition unit tests methods.

1591 """

1592

1593 def test_sd_rayleigh_scattering(self) -> None:

1594 """

1595 Test :func:`colour.phenomena.rayleigh.sd_rayleigh_scattering`

1596 definition.

1597 """

1598

1599 np.testing.assert_allclose(

1600 sd_rayleigh_scattering().values,

1601 DATA_SD_RAYLEIGH_SCATTERING,

1602 atol=TOLERANCE_ABSOLUTE_TESTS,

1603 )