MetOffice / PyPRECIS

PyPRECIS is the python based training environment for Met Office PRECIS training courses.
BSD 3-Clause "New" or "Revised" License
20 stars 2 forks source link

Wet days - using threshold of 0 not 1 -replace custom aggregator with count > 1 #140

Closed nhsavage closed 2 years ago

nhsavage commented 2 years ago

in the core EAS notebooks the example for how to calculate the number of wet days (worksheet 5, section 5.1) is wrong.

the aggregator used is:

count_nonzero = Aggregator('count', None,
                           units_func=lambda units: 1,
                           lazy_func=da.count_nonzero)

this counts the number of days when the rainfall is not zero. The correct definition is precipitation >=1 mm/day

the correct approach is shown on the AFR-22 version:

https://github.com/MetOffice/PyPRECIS/blob/new/afr_22/notebooks/AFR-22/worksheet5.ipynb

        # count wet days 
        model_wetdays = data.collapsed('time', iris.analysis.COUNT,
                               function=lambda values: values > 1)
rosannaamato commented 2 years ago

Updated EAS workbook5 wetday_count to >1mm threshold in 52fc291. Quick test of plot shows sensible looking output:

worksheet5_wetdays
rosannaamato commented 2 years ago

Wet day count also needed updating in 5.1b of notebooks/worksheet_solutions.ipynb 5.1e solutions was missing a line for pcent_bias_subset. Added. 847328d

nhsavage commented 2 years ago

closed by #143