Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basemap deprecation #142

Merged
merged 3 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/tcrm-pylint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Pylint tests for TCRM
name: Pylint tests for TCRM

on:
on:
push:
branches: [ master, develop ]

Expand All @@ -12,17 +12,17 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up environment
uses: conda-incubator/setup-miniconda@v2.0.0
with:
python-version: 3.7
mamba-version: "*"
uses: conda-incubator/setup-miniconda@v2
with:
python-version: 3.9
miniforge-variant: Mambaforge
channels: conda-forge,defaults
channel-priority: true
activate-environment: tcrm
environment-file: tcrmenv.yml
auto-activate-base: false
use-only-tar-bz2: true

- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -32,7 +32,7 @@ jobs:
pylint --rcfile pylintrc --fail-under=7 `find -regextype egrep -regex '(.*.py)$'` |
tee pylint.txt
- name: Upload pylint.txt as artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: pylint report
path: pylint.txt
9 changes: 5 additions & 4 deletions .github/workflows/tcrm-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: ['3.9', '3.10']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up environment
uses: conda-incubator/setup-miniconda@v2.0.0
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: MambaForge
python-version: ${{ matrix.python-version }}
mamba-version: "*"
channels: conda-forge,defaults
channel-priority: true
activate-environment: tcrm
environment-file: tcrmenv.yml
auto-activate-base: false
use-only-tar-bz2: true


- name: Test with pytest
env:
PYTHONPATH: ~/tcrm;~/tcrm/Utilities
Expand Down
65 changes: 29 additions & 36 deletions Evaluate/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@

from matplotlib import pyplot, cm
from matplotlib.dates import date2num
from mpl_toolkits.basemap import Basemap
from cartopy import crs as ccrs
from cartopy import feature as cfeature
from scipy.stats import scoreatpercentile as percentile
from datetime import datetime

Expand Down Expand Up @@ -76,7 +77,7 @@
[ProcessMultipliers]
MaxWorkingThreads = 4
ProcessMultiVersion = 2
ProcessingSegmentSize = 256
ProcessingSegmentSize = 256
WarpMemoryLimit = 500

[Logging]
Expand Down Expand Up @@ -169,57 +170,49 @@ def plotDensity(x, y, data, llLon=None, llLat=None, urLon=None, urLat=None,
else:
urcrnrlat = y.max()

meridians = np.arange(dl * np.floor(llcrnrlon / dl),
dl * np.ceil(urcrnrlon / dl), dl)
parallels = np.arange(dl * np.floor(llcrnrlat / dl),
dl * np.ceil(urcrnrlat / dl), dl)

m = Basemap(projection='cyl',
resolution=res,
llcrnrlon=llcrnrlon,
urcrnrlon=urcrnrlon,
llcrnrlat=llcrnrlat,
urcrnrlat=urcrnrlat)

# Set the colour map:
if hasattr(cm, cmap):
cmap = getattr(cm, cmap)
else:
cmap = colours.colourMap(cmap, 'stretched')

if maskocean:
try:
from mpl_toolkits.basemap import maskoceans
except ImportError:
log.debug("Maskoceans module unavailable, skipping this command")
else:
datam = maskoceans(xx, yy, data, inlands=False)
m.pcolormesh(xx, yy, datam, edgecolors='None',
vmin=datarange[0], vmax=datarange[1],
cmap=cmap)
else:
m.pcolormesh(xx, yy, data, edgecolors='None',
vmin=datarange[0], vmax=datarange[1],
cmap=cmap)
ax = pyplot.axes(projection=ccrs.PlateCarree())
pyplot.pcolormesh(xx, yy, data, edgecolors='None',
vmin=datarange[0], vmax=datarange[1],
cmap=cmap, transfom=ccrs.PlateCarree())

m.drawcoastlines(linewidth=0.5)
if maskland:
m.fillcontinents(color='white')
ax.add_feature(cfeature.LAND, zorder=100, edgecolor='k')

if maskocean:
ax.add_feature(cfeature.OCEAN, zorder=100, edgecolor='k')

ax.coastlines(linewidth=0.5)
gl = ax.gridlines(draw_labels=True, crs=ccrs.PlateCarree(), linewidth=0.2)
gl.top_labels = False
gl.right_labels = False

ax.set_extent([llcrnrlon, urcrnrlon,
llcrnrlat, urcrnrlat])

cb = pyplot.colorbar(shrink=0.5, aspect=30,
orientation='horizontal',
extend='max', pad=0.1)

if cb.orientation == 'horizontal':
for t in cb.ax.get_xticklabels():
t.set_fontsize(8)

m.drawparallels(parallels, labels=[1, 0, 0, 0],
fontsize=7.5, linewidth=0.2)
m.drawmeridians(meridians, labels=[0, 0, 0, 1],
fontsize=7.5, linewidth=0.2)
if clabel:
cb.set_label(clabel)
if ylab:
pyplot.ylabel(ylab, fontsize=7.5)
if xlab:
pyplot.xlabel(xlab, fontsize=7.5)
if title:
pyplot.title(title)

pyplot.grid(True)
pyplot.tick_params(direction='out', right='off', top='off')

cb = pyplot.colorbar(shrink=0.5, aspect=30,
orientation='horizontal',
extend='max', pad=0.1)
Expand Down
6 changes: 3 additions & 3 deletions Evaluate/interpolateTracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def interpolate(track, delta, interpolation_type=None):
track.Minute)]
else:
day_ = track.Datetime

timestep = timedelta(delta/24.)
try:
time_ = np.array([d.toordinal() + (d.hour + d.minute/60.)/24.0
Expand Down Expand Up @@ -104,7 +104,7 @@ def interpolate(track, delta, interpolation_type=None):
idx[0] = 1
# TODO: Possibly could change `np.mean(dt)` to `dt`?
track.WindSpeed = maxWindSpeed(idx, np.mean(dt), track.Longitude,
track.Latitude, track.CentralPressure,
track.Latitude, track.CentralPressure,
track.EnvPressure)
# Find the indices of valid pressure observations:
validIdx = np.where(track.CentralPressure < sys.maxsize)[0]
Expand Down Expand Up @@ -182,7 +182,7 @@ def interpolate(track, delta, interpolation_type=None):
kind='linear')(newtime[firsttime:lasttime])

_nwSpd = interp1d(timestep[validIdx],
track.Speed[validIdx],
track.WindSpeed[validIdx],
kind='linear')(newtime[firsttime:lasttime])

npCentre[firsttime:lasttime] = _npCentre
Expand Down
4 changes: 1 addition & 3 deletions tcrmenv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ dependencies:
- numpy
- scipy
- matplotlib
- basemap
- shapely
- nose
- netcdf4
- cftime
Expand All @@ -23,7 +21,7 @@ dependencies:
- sqlite
- statsmodels
- configparser
- cartopy>=0.18.0
- cartopy
- affine
- tqdm
- xarray
Expand Down
70 changes: 0 additions & 70 deletions tests/kde/kde2.py

This file was deleted.

112 changes: 0 additions & 112 deletions tests/kde/kde3.py

This file was deleted.

Loading