| [183] | 1 | import PyNGL_numpy.Ngl as ngl |
|---|
| 2 | |
|---|
| 3 | def res_init(lat, lon, |
|---|
| 4 | lat_min=None, |
|---|
| 5 | lat_max=None, |
|---|
| 6 | lon_min=None, |
|---|
| 7 | lon_max=None): |
|---|
| 8 | """ |
|---|
| 9 | Assumes lat,lon are numpy arrays |
|---|
| 10 | """ |
|---|
| 11 | if not lat_min: |
|---|
| 12 | lat_min = lat.min() |
|---|
| 13 | if not lat_max: |
|---|
| 14 | lat_max = lat.max() |
|---|
| 15 | if not lon_min: |
|---|
| 16 | lon_min = lon.min() |
|---|
| 17 | if not lon_max: |
|---|
| 18 | lon_max = lon.max() |
|---|
| 19 | res = ngl.Resources() |
|---|
| 20 | res.mpProjection = 'Orthographic' |
|---|
| 21 | res.mpCenterLonF = lon_min + (lon_max-lon_min)/2. |
|---|
| 22 | res.mpCenterLatF = lat_min + (lat_max-lat_min)/2. |
|---|
| 23 | res.mpLimitMode = 'LatLon' |
|---|
| 24 | res.mpMinLatF = lat_min - 0.2 |
|---|
| 25 | res.mpMaxLatF = lat_max + 0.2 |
|---|
| 26 | res.mpMinLonF = lon_min - 0.2 |
|---|
| 27 | res.mpMaxLonF = lon_max + 0.2 |
|---|
| 28 | res.mpFillOn = True |
|---|
| 29 | res.mpGridSpacingF = 2. |
|---|
| 30 | res.vpXF = 0.1 |
|---|
| 31 | res.vpYF = 0.9 |
|---|
| 32 | res.vpWidthF = 0.7 |
|---|
| 33 | res.vpHeightF = 0.7 |
|---|
| 34 | return res |
|---|
| 35 | |
|---|
| 36 | def make_land_gray(wks,res): |
|---|
| 37 | ic = ngl.new_color(wks, 0.75, 0.75,0.75) |
|---|
| 38 | res.mpFillColors = [0,-1,ic,-1] |
|---|
| 39 | |
|---|
| 40 | def mslp_contour_levels(res): |
|---|
| 41 | mnlvl = 980 |
|---|
| 42 | mxlvl = 1024 |
|---|
| 43 | spcng = 2 |
|---|
| 44 | ncn = (mxlvl - mnlvl) / spcng + 1 |
|---|
| 45 | res.cnLevelSelectionMode = 'ManualLevels' |
|---|
| 46 | res.cnMinLevelValF = mnlvl |
|---|
| 47 | res.cnMaxLevelValF = mxlvl |
|---|
| 48 | res.cnLevelSpacingF = spcng |
|---|
| 49 | |
|---|
| 50 | def sfc_pres_contour_levels(res): |
|---|
| 51 | mnlvl = 840 |
|---|
| 52 | mxlvl = 1024 |
|---|
| 53 | spcng = 2 |
|---|
| 54 | ncn = (mxlvl - mnlvl) / spcng + 1 |
|---|
| 55 | res.cnLevelSelectionMode = 'ManualLevels' |
|---|
| 56 | res.cnMinLevelValF = mnlvl |
|---|
| 57 | res.cnMaxLevelValF = mxlvl |
|---|
| 58 | res.cnLevelSpacingF = spcng |
|---|
| 59 | |
|---|
| 60 | |
|---|