|
17 | 17 |
|
18 | 18 | # %%
|
19 | 19 | # 2. Read the field in:
|
20 |
| -# Here I've used sample data ggap.nc (and later pressure=850), |
21 |
| -# but you could use tas_A1.nc (with time=15) |
22 | 20 | PATH = "~/git-repos/cf-plot/cfplot/test/cfplot_data"
|
23 | 21 | f = cf.read(f"{PATH}/ggap.nc")[0]
|
24 | 22 |
|
25 | 23 | # %%
|
26 |
| -# 3. Create the file with subplots: |
27 |
| -# If you are changing the number of subplots ensure the number of |
28 |
| -# rows * number of columns = the number of subplots/projections |
29 |
| -# Here we are doing 6 projections so 2x3 is fine |
| 24 | +# 3. Create the file with subplots. If changing the number of subplots, |
| 25 | +# ensure the number of rows * number of columns = the number of projections. |
| 26 | +# Here we are doing 6 projections so 2 x 3 is fine: |
30 | 27 | cfp.gopen(rows=2, columns=3, bottom=0.2, file="projections.png")
|
31 | 28 |
|
32 | 29 | # %%
|
33 |
| -# 4. List the projection types being used: |
34 |
| -# Here we are using Cylindrical/Default, North Pole Stereographic, |
35 |
| -# South Pole Stereographic, Mollweide, Cropped Lambert Conformal |
36 |
| -# and Robinson. |
37 |
| -# However you could also use other such as "rotated", "ortho" or |
38 |
| -# "merc", "ukcp", "osgb", or "EuroPP" |
39 |
| -# https://ncas-cms.github.io/cf-plot/build/user_guide.html#appendixc |
40 |
| -# TODO SB update second 'cyl' to 'lcc', replaced for now due to possible bug, |
41 |
| -# see: https://github.com/NCAS-CMS/cf-plot/issues/75 |
42 |
| -projtypes = ["cyl", "npstere", "spstere", "moll", "cyl", "robin"] |
| 30 | +# 4. List the projection types to use. Here we are using |
| 31 | +# Cylindrical/Default, North Pole Stereographic, South Pole Stereographic, |
| 32 | +# Mollweide, Mercator and Robinson. However there are several other choices |
| 33 | +# possible, see: |
| 34 | +# https://ncas-cms.github.io/cf-plot/build/user_guide.html#appendixc. Our |
| 35 | +# chosen list is: |
| 36 | +projtypes = ["cyl", "npstere", "spstere", "moll", "merc", "robin"] |
43 | 37 |
|
44 | 38 | # %%
|
45 |
| -# 5. We then use a for loop to cycle through all the different projection |
46 |
| -# types: |
47 |
| -# Only gpos has 1 added because it can only take 1 as its first value, |
48 |
| -# otherwise there are |
49 |
| -# errors. There are if statements for some projections (lcc, OSGB and |
50 |
| -# EuroPP) as they have |
51 |
| -# specific requirements for their contour. |
52 |
| -# However, OSGB and EuroPP will require very different data anyway. |
| 39 | +# 5. Loop through the list of projection types and plot each as a sub-plot: |
53 | 40 | for i, proj in enumerate(projtypes):
|
| 41 | + # gpos has 1 added to the index because it takes 1 as its first value |
54 | 42 | cfp.gpos(i + 1)
|
55 |
| - if proj == "lcc": |
56 |
| - cfp.mapset(proj="lcc", lonmin=-50, lonmax=50, latmin=20, latmax=85) |
57 |
| - if proj in ("OSGB", "EuroPP"): |
58 |
| - cfp.mapset(proj=proj, resolution="50m") |
59 |
| - else: |
60 |
| - cfp.mapset(proj=proj) |
| 43 | + cfp.mapset(proj=proj) |
| 44 | + |
| 45 | + # For the final plot only, add a colour bar to cover all the sub-plots |
61 | 46 | if i == len(projtypes) - 1:
|
62 | 47 | cfp.con(
|
63 | 48 | f.subspace(pressure=850),
|
|
66 | 51 | colorbar_position=[0.1, 0.1, 0.8, 0.02],
|
67 | 52 | colorbar_orientation="horizontal",
|
68 | 53 | )
|
69 |
| - # to see the marking lines need to be True, but this can be |
70 |
| - # hard to read so if not needed use False |
71 | 54 | else:
|
72 | 55 | cfp.con(
|
73 | 56 | f.subspace(pressure=850),
|
|
0 commit comments