|
75 | 75 | "import iris.quickplot as qplt\n", |
76 | 76 | "import cartopy.crs as ccrs\n", |
77 | 77 | "from mpl_toolkits.axes_grid1 import AxesGrid\n", |
78 | | - "from cartopy.mpl.geoaxes import GeoAxes" |
| 78 | + "from cartopy.mpl.geoaxes import GeoAxes\n", |
| 79 | + "from utils import copy_s3_files, flush_data" |
79 | 80 | ] |
80 | 81 | }, |
81 | 82 | { |
|
104 | 105 | "Before running the code, take a look at it line-by-line to understand what steps are being taken. Then click in the box and press <kbd>ctrl</kbd> + <kbd>enter</kbd> to run the code." |
105 | 106 | ] |
106 | 107 | }, |
| 108 | + { |
| 109 | + "cell_type": "code", |
| 110 | + "execution_count": null, |
| 111 | + "metadata": {}, |
| 112 | + "outputs": [], |
| 113 | + "source": [ |
| 114 | + "# we first need to download APHRODITE data\n", |
| 115 | + "copy_s3_files('s3://ias-pyprecis/data/APHRODITE/*.nc', 'data/APHRODITE/')" |
| 116 | + ] |
| 117 | + }, |
107 | 118 | { |
108 | 119 | "cell_type": "code", |
109 | 120 | "execution_count": null, |
110 | 121 | "metadata": {}, |
111 | 122 | "outputs": [], |
112 | 123 | "source": [ |
113 | 124 | "# Provide the names of the directories where the netCDF model files are stored\n", |
114 | | - "DATADIR = '/project/ciid/projects/PRECIS/worksheets/data/'\n", |
| 125 | + "DATADIR = 'data/'\n", |
115 | 126 | "\n", |
116 | 127 | "# Load and print the HadCM3Q0 (cahpa) model cube data\n", |
117 | | - "infile = os.path.join(DATADIR, 'historical', 'cahpa.mon.1961_1990.pr.rr.nc')\n", |
| 128 | + "infile = os.path.join(DATADIR, 'cahpa.mon.1961_1990.pr.rr.nc')\n", |
118 | 129 | "cahpaData = iris.load_cube(infile)\n", |
119 | 130 | "\n", |
120 | 131 | "# Load and print the ECHAM5 (cahpb) model cube data\n", |
121 | | - "infile = os.path.join(DATADIR, 'historical', 'cahpb.mon.1961_1990.pr.rr.nc')\n", |
| 132 | + "infile = os.path.join(DATADIR, 'cahpb.mon.1961_1990.pr.rr.nc')\n", |
122 | 133 | "cahpbData = iris.load_cube(infile)\n", |
123 | 134 | "\n", |
124 | 135 | "# Load and print the APHRODITE observation cube data\n", |
|
309 | 320 | "cahpaData.remove_coord('forecast_period')\n", |
310 | 321 | "cahpaData.remove_coord('forecast_reference_time')\n", |
311 | 322 | "# Save the new cube as a new netCDF file\n", |
312 | | - "outfile = os.path.join(DATADIR, 'historical', 'cahpa.mon.1961_1990.pr.rr.mmday-1.nc')\n", |
| 323 | + "outfile = os.path.join(DATADIR, 'cahpa.mon.1961_1990.pr.rr.mmday-1.nc')\n", |
313 | 324 | "iris.save(cahpaData, outfile)" |
314 | 325 | ] |
315 | 326 | }, |
|
338 | 349 | "# Remove extraneous cube metadata. This helps make cube comparisons easier later.\n", |
339 | 350 | "\n", |
340 | 351 | "# Save the new cube as a new netCDF file using the `outfile` filename we've provided below!\n", |
341 | | - "outfile = os.path.join(DATADIR, 'historical', 'cahpb.mon.1961_1990.pr.rr.mmday-1.nc')\n", |
| 352 | + "outfile = os.path.join(DATADIR, 'cahpb.mon.1961_1990.pr.rr.mmday-1.nc')\n", |
342 | 353 | "\n" |
343 | 354 | ] |
344 | 355 | }, |
|
373 | 384 | "\n", |
374 | 385 | "# Loop through two model runs\n", |
375 | 386 | "for jobid in ['cahpa', 'cahpb']:\n", |
376 | | - " infile = os.path.join(DATADIR, 'historical', jobid + '.mon.1961_1990.pr.rr.mmday-1.nc')\n", |
| 387 | + " infile = os.path.join(DATADIR, jobid + '.mon.1961_1990.pr.rr.mmday-1.nc')\n", |
377 | 388 | "\n", |
378 | 389 | " # Load the data\n", |
379 | 390 | " data = iris.load_cube(infile)\n", |
|
437 | 448 | "Follow step d) and complete the code yourself. The file name to load is: `aphro.mon.1961_1990.nc`. We've given you the infile and outfile names to make sure you load and save it in the right place for later!" |
438 | 449 | ] |
439 | 450 | }, |
| 451 | + { |
| 452 | + "cell_type": "code", |
| 453 | + "execution_count": null, |
| 454 | + "metadata": {}, |
| 455 | + "outputs": [], |
| 456 | + "source": [ |
| 457 | + "# we first need to download APHRODITE data\n", |
| 458 | + "copy_s3_files('s3://ias-pyprecis/data/climatology/*.nc', 'data/climatology/')" |
| 459 | + ] |
| 460 | + }, |
440 | 461 | { |
441 | 462 | "cell_type": "code", |
442 | 463 | "execution_count": null, |
443 | 464 | "metadata": {}, |
444 | 465 | "outputs": [], |
445 | 466 | "source": [ |
446 | 467 | "# Directory names where data is read from and stored to\n", |
447 | | - "infile = os.path.join(DATADIR, 'APHRODITE', 'aphro.mon.1961_1990.nc')\n", |
| 468 | + "infile = os.path.join(DATADIR, 'climatology', 'aphro.mon.1961_1990.nc')\n", |
448 | 469 | "\n", |
449 | 470 | "\n", |
450 | 471 | "# Load the aphrodite data\n", |
|
460 | 481 | "\n", |
461 | 482 | "\n", |
462 | 483 | "# save the seasonal mean cube as a NetCDF file\n", |
463 | | - "outfile = os.path.join(DATADIR, 'climatology', 'aphro.OND.mean.1961_1990.pr.mmday-1.nc')\n", |
| 484 | + "outfile = os.path.join(DATADIR, 'aphro.OND.mean.1961_1990.pr.mmday-1.nc')\n", |
464 | 485 | "\n", |
465 | 486 | "\n", |
466 | 487 | "# print the APHRODITE seasonal mean cube\n", |
|
550 | 571 | "outputs": [], |
551 | 572 | "source": [ |
552 | 573 | "# Directory name where data is read from\n", |
553 | | - "indir = os.path.join(DATADIR, 'climatology')\n", |
| 574 | + "indir = DATADIR\n", |
554 | 575 | "\n", |
555 | 576 | "# load cahpa model data\n", |
556 | 577 | "infile = os.path.join(indir, 'cahpa.OND.mean.1961_1990.pr.mmday-1.nc')\n", |
|
663 | 684 | } |
664 | 685 | ], |
665 | 686 | "metadata": { |
| 687 | + "instance_type": "ml.t3.medium", |
666 | 688 | "kernelspec": { |
667 | | - "display_name": "pyprecis-environment", |
| 689 | + "display_name": "Python [conda env:pyprecis-environment] (arn:aws:sagemaker:eu-west-2:198477955030:image-version/abtraining/1)", |
668 | 690 | "language": "python", |
669 | | - "name": "pyprecis-environment" |
| 691 | + "name": "conda-env-pyprecis-environment-py__SAGEMAKER_INTERNAL__arn:aws:sagemaker:eu-west-2:198477955030:image-version/abtraining/1" |
670 | 692 | }, |
671 | 693 | "language_info": { |
672 | 694 | "codemirror_mode": { |
|
686 | 708 | } |
687 | 709 | }, |
688 | 710 | "nbformat": 4, |
689 | | - "nbformat_minor": 1 |
| 711 | + "nbformat_minor": 4 |
690 | 712 | } |
0 commit comments