|
1 |
| -def getmask(sector,lats,lons,lons_a,lons_p,land_mask): |
2 |
| - import MV2 as MV |
3 |
| -#Arctic Regions |
4 |
| -#Central Arctic |
5 |
| - if sector == 'ca': |
6 |
| - lat_bound1=MV.logical_and(MV.greater(lats,80.),MV.less_equal(lats,90.)) |
7 |
| - lat_bound2=MV.logical_and(MV.greater(lats,65.),MV.less_equal(lats,90.)) |
8 |
| - lon_bound1=MV.logical_and(MV.greater(lons_a,-120.),MV.less_equal(lons_a,90.)) |
9 |
| - lon_bound2=MV.logical_and(MV.greater(lons_p,90.),MV.less_equal(lons_p,240.)) |
10 |
| - reg1=MV.logical_and(lat_bound1,lon_bound1) |
11 |
| - reg2=MV.logical_and(lat_bound2,lon_bound2) |
12 |
| - mask=MV.where(MV.logical_or(reg1,reg2),1,0) |
13 |
| - mask=MV.where(MV.equal(land_mask,0),0,mask) # 0 - Land |
14 |
| - |
15 |
| -#NA region |
16 |
| - if sector == 'na': |
17 |
| - lat_bound=MV.logical_and(MV.greater(lats,45.),MV.less_equal(lats,80.)) |
18 |
| - lon_bound=MV.logical_and(MV.greater(lons_a,-120.),MV.less_equal(lons_a,90.)) |
19 |
| - lat_bound3=MV.logical_and(MV.greater(lats,45.),MV.less_equal(lats,50.)) |
20 |
| - lon_bound3=MV.logical_and(MV.greater(lons_a,30.),MV.less_equal(lons_a,60.)) |
21 |
| - reg3=MV.logical_and(lat_bound3,lon_bound3) |
22 |
| - |
23 |
| - mask=MV.where(MV.logical_and(lat_bound,lon_bound),1,0) |
24 |
| - mask=MV.where(MV.equal(reg3,True),0,mask) # Masking out the Black and Caspian Seas |
25 |
| - mask=MV.where(MV.equal(land_mask,True),0,mask) # 0 - Land |
26 |
| - mask=MV.where(MV.equal(land_mask,0),0,mask) # 0 - Land |
27 |
| - |
28 |
| -#NP region |
29 |
| - if sector == 'np': |
30 |
| - lat_bound=MV.logical_and(MV.greater(lats,45.),MV.less_equal(lats,65.)) |
31 |
| - lon_bound=MV.logical_and(MV.greater(lons_p,90.),MV.less_equal(lons_p,240.)) |
32 |
| - mask=MV.where(MV.logical_and(lat_bound,lon_bound),1,0) |
33 |
| - mask=MV.where(MV.equal(land_mask,0),0,mask) # 0 - Land |
34 |
| - |
35 |
| -#Antarctic Regions |
36 |
| - |
37 |
| -#SA region |
38 |
| - if sector == 'sa': |
39 |
| - lat_bound=MV.logical_and(MV.greater(lats,-90.),MV.less_equal(lats,-55.)) |
40 |
| - lon_bound=MV.logical_and(MV.greater(lons_a,-60.),MV.less_equal(lons_a,20.)) |
41 |
| - mask=MV.where(MV.logical_and(lat_bound,lon_bound),1,0) |
42 |
| - mask=MV.where(MV.equal(land_mask,0),0,mask) # 0 - Land |
43 |
| - |
44 |
| -#SP region |
45 |
| - if sector == 'sp': |
46 |
| - lat_bound=MV.logical_and(MV.greater(lats,-90.),MV.less_equal(lats,-55.)) |
47 |
| - lon_bound=MV.logical_and(MV.greater(lons_p,90.),MV.less_equal(lons_p,300.)) |
48 |
| - mask=MV.where(MV.logical_and(lat_bound,lon_bound),1,0) |
49 |
| - mask=MV.where(MV.equal(land_mask,0),0,mask) # 0 - Land |
50 |
| - |
51 |
| -#IO region |
52 |
| - if sector == 'io': |
53 |
| - lat_bound=MV.logical_and(MV.greater(lats,-90.),MV.less_equal(lats,-55.)) |
54 |
| - lon_bound=MV.logical_and(MV.greater(lons_p,20.),MV.less_equal(lons_p,90.)) |
55 |
| - mask=MV.where(MV.logical_and(lat_bound,lon_bound),1,0) |
56 |
| - mask=MV.where(MV.equal(land_mask,0),0,mask) # 0 - Land |
57 |
| - |
58 |
| - return mask |
| 1 | +def getmask(sector, lats, lons, lons_a, lons_p, land_mask): |
| 2 | + import MV2 as MV |
59 | 3 |
|
| 4 | + # Arctic Regions |
| 5 | + # Central Arctic |
| 6 | + if sector == "ca": |
| 7 | + lat_bound1 = MV.logical_and(MV.greater(lats, 80.0), MV.less_equal(lats, 90.0)) |
| 8 | + lat_bound2 = MV.logical_and(MV.greater(lats, 65.0), MV.less_equal(lats, 90.0)) |
| 9 | + lon_bound1 = MV.logical_and( |
| 10 | + MV.greater(lons_a, -120.0), MV.less_equal(lons_a, 90.0) |
| 11 | + ) |
| 12 | + lon_bound2 = MV.logical_and( |
| 13 | + MV.greater(lons_p, 90.0), MV.less_equal(lons_p, 240.0) |
| 14 | + ) |
| 15 | + reg1 = MV.logical_and(lat_bound1, lon_bound1) |
| 16 | + reg2 = MV.logical_and(lat_bound2, lon_bound2) |
| 17 | + mask = MV.where(MV.logical_or(reg1, reg2), 1, 0) |
| 18 | + mask = MV.where(MV.equal(land_mask, 0), 0, mask) # 0 - Land |
60 | 19 |
|
| 20 | + # NA region |
| 21 | + if sector == "na": |
| 22 | + lat_bound = MV.logical_and(MV.greater(lats, 45.0), MV.less_equal(lats, 80.0)) |
| 23 | + lon_bound = MV.logical_and( |
| 24 | + MV.greater(lons_a, -120.0), MV.less_equal(lons_a, 90.0) |
| 25 | + ) |
| 26 | + lat_bound3 = MV.logical_and(MV.greater(lats, 45.0), MV.less_equal(lats, 50.0)) |
| 27 | + lon_bound3 = MV.logical_and( |
| 28 | + MV.greater(lons_a, 30.0), MV.less_equal(lons_a, 60.0) |
| 29 | + ) |
| 30 | + reg3 = MV.logical_and(lat_bound3, lon_bound3) |
61 | 31 |
|
| 32 | + mask = MV.where(MV.logical_and(lat_bound, lon_bound), 1, 0) |
| 33 | + mask = MV.where( |
| 34 | + MV.equal(reg3, True), 0, mask |
| 35 | + ) # Masking out the Black and Caspian Seas |
| 36 | + mask = MV.where(MV.equal(land_mask, True), 0, mask) # 0 - Land |
| 37 | + mask = MV.where(MV.equal(land_mask, 0), 0, mask) # 0 - Land |
| 38 | + |
| 39 | + # NP region |
| 40 | + if sector == "np": |
| 41 | + lat_bound = MV.logical_and(MV.greater(lats, 45.0), MV.less_equal(lats, 65.0)) |
| 42 | + lon_bound = MV.logical_and( |
| 43 | + MV.greater(lons_p, 90.0), MV.less_equal(lons_p, 240.0) |
| 44 | + ) |
| 45 | + mask = MV.where(MV.logical_and(lat_bound, lon_bound), 1, 0) |
| 46 | + mask = MV.where(MV.equal(land_mask, 0), 0, mask) # 0 - Land |
| 47 | + |
| 48 | + # Antarctic Regions |
| 49 | + |
| 50 | + # SA region |
| 51 | + if sector == "sa": |
| 52 | + lat_bound = MV.logical_and(MV.greater(lats, -90.0), MV.less_equal(lats, -55.0)) |
| 53 | + lon_bound = MV.logical_and( |
| 54 | + MV.greater(lons_a, -60.0), MV.less_equal(lons_a, 20.0) |
| 55 | + ) |
| 56 | + mask = MV.where(MV.logical_and(lat_bound, lon_bound), 1, 0) |
| 57 | + mask = MV.where(MV.equal(land_mask, 0), 0, mask) # 0 - Land |
| 58 | + |
| 59 | + # SP region |
| 60 | + if sector == "sp": |
| 61 | + lat_bound = MV.logical_and(MV.greater(lats, -90.0), MV.less_equal(lats, -55.0)) |
| 62 | + lon_bound = MV.logical_and( |
| 63 | + MV.greater(lons_p, 90.0), MV.less_equal(lons_p, 300.0) |
| 64 | + ) |
| 65 | + mask = MV.where(MV.logical_and(lat_bound, lon_bound), 1, 0) |
| 66 | + mask = MV.where(MV.equal(land_mask, 0), 0, mask) # 0 - Land |
| 67 | + |
| 68 | + # IO region |
| 69 | + if sector == "io": |
| 70 | + lat_bound = MV.logical_and(MV.greater(lats, -90.0), MV.less_equal(lats, -55.0)) |
| 71 | + lon_bound = MV.logical_and( |
| 72 | + MV.greater(lons_p, 20.0), MV.less_equal(lons_p, 90.0) |
| 73 | + ) |
| 74 | + mask = MV.where(MV.logical_and(lat_bound, lon_bound), 1, 0) |
| 75 | + mask = MV.where(MV.equal(land_mask, 0), 0, mask) # 0 - Land |
| 76 | + |
| 77 | + return mask |
0 commit comments