Skip to content

Commit

Permalink
model_wetdays in correct place - period loop
Browse files Browse the repository at this point in the history
  • Loading branch information
rosannaamato committed Aug 5, 2022
1 parent ab0d48b commit 72fed13
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions notebooks/worksheet5.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,16 @@
"# To learn more about custom aggregators see\n",
"# https://scitools.org.uk/iris/docs/v2.4.0/examples/General/custom_aggregation.html#general-custom-aggregation \n",
"\n",
"# count wet days \n",
"model_wetdays = data.collapsed('time', iris.analysis.COUNT,\n",
" function=lambda values: values > 1)\n",
"\n",
"for gcmid in GCMIDS:\n",
" for period in TIME_PERIODS.keys():\n",
" # Get path to daily data\n",
" infile = os.path.join(DATADIR, period, gcmid + '.day.' + TIME_PERIODS[period] + '.GERICS-REMO2015.pr.*.nc')\n",
" data = iris.load_cube(infile)\n",
" # Select only wet days using our custom aggregator\n",
" model_wetdays = data.collapsed('time', count_nonzero)\n",
" \n",
" # Count wet days \n",
" model_wetdays = data.collapsed('time', iris.analysis.COUNT,\n",
" function=lambda values: values > 1)\n",
" model_wetdays.rename(f'{gcmid} number of wet days (>=1mm/day) {TIME_PERIODS[period]}')\n",
" # Save the file\n",
" outfile = os.path.join(CLIMDIR, gcmid + '.day.' + TIME_PERIODS[period] + '.GERICS-REMO2015.wetday.nc')\n",
Expand All @@ -166,7 +165,6 @@
" # Add metadata\n",
" model_pcent_wetdays.rename(f'{gcmid} percentage of wet days (>=1mm/day) {TIME_PERIODS[period]}')\n",
" model_pcent_wetdays.units = '%'\n",
"\n",
" # Save the file\n",
" outfile = os.path.join(CLIMDIR, gcmid + '.day.' + TIME_PERIODS[period] + '.GERICS-REMO2015.wetday.pcent.nc')\n",
" iris.save(model_pcent_wetdays, outfile)\n",
Expand Down

0 comments on commit 72fed13

Please sign in to comment.