|
1 | 1 | """
|
2 |
| -Plotting Contour Subplots with different Projections |
| 2 | +Plotting contour subplots with different projections |
3 | 3 | ====================================================
|
4 | 4 |
|
5 |
| -In this recipe, we will plot different projections for the same data to illustrate |
6 |
| -visually the ones available in order to more visually decide which is suitable. |
| 5 | +In this recipe, we will plot different projections for the same |
| 6 | +data to illustrate visually the ones available in order to more |
| 7 | +visually decide which is suitable. |
| 8 | +
|
7 | 9 | """
|
8 | 10 |
|
9 | 11 | # %%
|
10 | 12 | # 1. Import cf-python and cf-plot:
|
11 | 13 |
|
12 | 14 | import cfplot as cfp
|
| 15 | + |
13 | 16 | import cf
|
14 | 17 |
|
15 | 18 | # %%
|
16 | 19 | # 2. Read the field in:
|
17 | 20 | # Here I've used sample data ggap.nc (and later pressure=850),
|
18 | 21 | # but you could use tas_A1.nc (with time=15)
|
19 |
| - |
20 | 22 | f = cf.read("~/cfplot_data/ggap.nc")[0]
|
21 | 23 |
|
22 | 24 | # %%
|
23 | 25 | # 3. Create the file with subplots:
|
24 |
| -# If you are changing the number of subplots ensure the number of rows * number |
25 |
| -# of columns = the number of subplots/projections |
| 26 | +# If you are changing the number of subplots ensure the number of |
| 27 | +# rows * number of columns = the number of subplots/projections |
26 | 28 | # Here we are doing 6 projections so 2x3 is fine
|
27 |
| - |
28 | 29 | cfp.gopen(rows=2, columns=3, bottom=0.2, file="projections.png")
|
29 | 30 |
|
30 | 31 | # %%
|
31 | 32 | # 4. List the projection types being used:
|
32 | 33 | # Here we are using Cylindrical/Default, North Pole Stereographic,
|
33 |
| -# South Pole Stereographic, Mollweide, Cropped Lambert Conformal and Robinson |
| 34 | +# South Pole Stereographic, Mollweide, Cropped Lambert Conformal |
| 35 | +# and Robinson. |
34 | 36 | # However you could also use other such as "rotated", "ortho" or
|
35 | 37 | # "merc", "ukcp", "osgb", or "EuroPP"
|
36 | 38 | # https://ncas-cms.github.io/cf-plot/build/user_guide.html#appendixc
|
37 |
| - |
38 | 39 | projtypes = ["cyl", "npstere", "spstere", "moll", "lcc", "robin"]
|
39 | 40 |
|
40 | 41 | # %%
|
41 |
| -# 5. We then use a for loop to cycle through all the different projection types: |
42 |
| -# Only gpos has 1 added because it can only take 1 as its first value, otherwise there are |
43 |
| -# errors. There are if statements for some projections (lcc, OSGB and EuroPP) as they have |
| 42 | +# 5. We then use a for loop to cycle through all the different projection |
| 43 | +# types: |
| 44 | +# Only gpos has 1 added because it can only take 1 as its first value, |
| 45 | +# otherwise there are |
| 46 | +# errors. There are if statements for some projections (lcc, OSGB and |
| 47 | +# EuroPP) as they have |
44 | 48 | # specific requirements for their contour.
|
45 | 49 | # However, OSGB and EuroPP will require very different data anyway.
|
46 |
| - |
47 | 50 | for i, proj in enumerate(projtypes):
|
48 | 51 | cfp.gpos(i + 1)
|
49 | 52 | if projtypes[i] == "lcc":
|
|
59 | 62 | title=projtypes[i],
|
60 | 63 | colorbar_position=[0.1, 0.1, 0.8, 0.02],
|
61 | 64 | colorbar_orientation="horizontal",
|
62 |
| - ) # to see the marking lines need to be True, but this can be hard to read so if not needed use False |
| 65 | + ) |
| 66 | + # to see the marking lines need to be True, but this can be |
| 67 | + # hard to read so if not needed use False |
63 | 68 | else:
|
64 | 69 | cfp.con(
|
65 | 70 | f.subspace(pressure=850),
|
|
0 commit comments