cerfacs-globc / icclim

icclim: Python library for climate indices and climate indicators calculation.
https://icclim.readthedocs.io/en/latest/
Apache License 2.0
80 stars 32 forks source link

ENH: large refactoring #303

Closed bzah closed 5 months ago

bzah commented 7 months ago

Pull Request to resolve #184

Describe the changes you made

Goal 1: Add DCSC indices

This pull request add the indices required for DRIAS in a new StandardIndexRegistry DcscIndexRegistry. Additionally, a new parameter offset has been added to Threshold class and build_threshold function. This allows to easily compute indices such as count days where tasmax is 5 deg_C above normal :

thresh = build_threshold(operator=">", value="normal_tasmax.nc", offset="5 delta_deg_C")
result = icclim.count_occurrences("tasmax.nc", threshold=thresh)

Todo:

icclim will perform a unit conversion if needed.

The following indices were added:

Goal 2: Refactor to improve maintainability

context: by adding the DCSC indices many issues within the code base were exposed thus this PR includes to improve this situation.

Issues
review-notebook-app[bot] commented 7 months ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

github-actions[bot] commented 6 months ago

Coverage

Report
FileStmtsMissCoverMissing
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/icclim
   logger.py862966%24, 44, 66, 71–96, 106, 112–143, 151–156
   main.py2703288%60–70, 131, 140, 491–492, 658–659, 727, 753–754, 756–757, 759, 761–762, 764–765, 789–796, 866–871
   rechunk.py90792%29–32, 126, 228–229, 233
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/icclim/_core
   climate_variable.py992080%31–42, 156–162, 264–265, 367–368, 377, 411, 421–422
   frequency.py1801393%39–41, 258–261, 449–453, 470, 553–557, 579, 584
   input_parsing.py2636376%28–37, 92–93, 97–98, 103–108, 140–141, 269, 274–278, 281, 301–305, 307–308, 349–350, 402–406, 409, 463, 534–539, 543, 545, 635, 686, 692–700, 731, 735–739, 754–758, 785, 799, 804–809, 816–821, 832–833, 837–844, 860
   utils.py14286%30–35
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/icclim/_core/generic
   functions.py3198374%54–63, 154, 238–239, 980–981, 987, 1021, 1027, 1081–1085, 1087–1088, 1106–1112, 1116, 1169, 1171, 1234–1235, 1244–1270, 1298–1318, 1334, 1342–1374, 1380–1383
   indicator.py1501789%36–41, 158–161, 165, 408, 416–420, 422–426, 461, 507–508, 530
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/icclim/_core/generic/threshold
   basic.py104892%31–34, 72, 172–173, 198, 324
   bounded.py551376%23–29, 54–56, 84–88, 92–96, 227
   percentile.py1341390%40–47, 215–216, 339–344, 458–460
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/icclim/_core/legacy/user_index
   model.py20200%3–43
   parse.py851582%21–26, 60–61, 79, 86, 90–94, 204, 229, 235–236
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/icclim/_core/model
   cf_calendar.py35197%63
   global_metadata.py660%3–23
   icclim_types.py14140%3–25
   in_file_dictionary.py990%3–46
   index_config.py31681%13–18
   indicator.py36878%10–11, 23, 28, 67, 72, 77, 82
   logical_link.py21195%14
   operator.py32391%13, 18–22
   standard_index.py36975%9–16, 68, 72, 77
   standard_variable.py48198%48
   threshold.py541081%15–25, 95, 100, 149
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/icclim/_generated
   _dcsc.py1015546%20–32, 136, 217, 298, 407, 527, 647, 767, 859, 943, 1027, 1111, 1195, 1413–1419, 1524–1530, 1635–1641, 1746–1752, 1834, 1918, 2002, 2083, 2167, 2248, 2332, 2416, 2500, 2612, 2733, 2854, 2975, 3083, 3193
   _ecad.py144894%19–31
   _generic.py591083%18–33
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/icclim/ecad
   binding.py58886%15–17, 45, 49, 86, 90, 127, 131
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/icclim/generic
   registry.py41490%39, 46–47, 69
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/icclim/threshold
   factory.py1691293%38, 177–178, 255, 279–280, 285, 355–356, 359–363, 403
TOTAL310150084% 

Test results

Tests Skipped Failures Errors Time
196 0 :zzz: 0 :x: 0 :fire: 2m 3s :stopwatch:
bzah commented 6 months ago

pre-commit.ci autofix