NCAR / geocat-viz

GeoCAT-viz contains tools to help plot geoscience data, including convenience and plotting functions that are used to facilitate plotting geosciences data with Matplotlib, Cartopy, and other visualization packages.
https://geocat-viz.readthedocs.io
Other
48 stars 19 forks source link

Issue with gv.set_map_boundary() #231

Closed tingvan closed 7 months ago

tingvan commented 7 months ago

Describe the bug Im trying to reproduce the example 'NCL_polar_1.py' and I got this error when I run gv.set_map_boundary(ax, [-180, 180], [ -40, 90]). I also tried gv.util.set_map_boundary(ax, [-180, 180], [ -40, 90]), and it seems like this function has been removed (see attached screenshots).

Can someone help me? Appreciated!

To Reproduce

import geocat.viz as gv
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature

fig = plt.figure(figsize=(8.5,11))
projection = ccrs.NorthPolarStereo()
ax = plt.axes(projection=projection)
ax.add_feature(cfeature.LAND, color='silver',zorder=1)
gv.set_map_boundary(ax, [-180, 180], [ -40, 90])
plt.show()

Expected behavior AttributeError Traceback (most recent call last)

in 8 ax = plt.axes(projection=projection) 9 ax.add_feature(cfeature.LAND, color='silver',zorder=1) ---> 10 gv.set_map_boundary(ax, [-180, 180], [ -40, 90]) 11 plt.show() AttributeError: module 'geocat.viz' has no attribute 'set_map_boundary' **Screenshots** ![image](https://github.com/NCAR/geocat-viz/assets/56503442/5acdc03e-0d16-49ed-916a-8c92cbbb18aa) ![image](https://github.com/NCAR/geocat-viz/assets/56503442/fdb563c4-7809-469d-a4f7-0403d39cd897) **OS:** Windows 10 **Environment** packages in environment at B:\anaconda3\envs\geocat2: Name Version Build Channel anyio 4.3.0 pypi_0 pypi argon2-cffi 23.1.0 pypi_0 pypi argon2-cffi-bindings 21.2.0 pypi_0 pypi arrow 1.3.0 pypi_0 pypi asttokens 2.4.1 pypi_0 pypi async-lru 2.0.4 pypi_0 pypi attrs 23.2.0 pypi_0 pypi aws-c-auth 0.7.16 h7613915_8 conda-forge aws-c-cal 0.6.10 hf6fcf4e_2 conda-forge aws-c-common 0.9.14 hcfcfb64_0 conda-forge aws-c-compression 0.2.18 hf6fcf4e_2 conda-forge aws-c-event-stream 0.4.2 h3df98b0_6 conda-forge aws-c-http 0.8.1 h4e3df0f_7 conda-forge aws-c-io 0.14.6 hf0b8b6f_2 conda-forge aws-c-mqtt 0.10.3 h96fac68_2 conda-forge aws-c-s3 0.5.4 h08df315_0 conda-forge aws-c-sdkutils 0.1.15 hf6fcf4e_2 conda-forge aws-checksums 0.1.18 hf6fcf4e_2 conda-forge aws-crt-cpp 0.26.4 hbe739fa_2 conda-forge aws-sdk-cpp 1.11.267 hfaf0dd0_4 conda-forge babel 2.14.0 pypi_0 pypi beautifulsoup4 4.12.3 pypi_0 pypi bleach 6.1.0 pypi_0 pypi blosc 1.21.5 hdccc3a2_0 conda-forge bokeh 3.4.0 pyhd8ed1ab_0 conda-forge bottleneck 1.3.8 py310h3e78b6c_0 conda-forge brotli 1.1.0 hcfcfb64_1 conda-forge brotli-bin 1.1.0 hcfcfb64_1 conda-forge brotli-python 1.1.0 py310h00ffb61_1 conda-forge bzip2 1.0.8 hcfcfb64_5 conda-forge c-ares 1.27.0 hcfcfb64_0 conda-forge ca-certificates 2024.2.2 h56e8100_0 conda-forge cartopy 0.22.0 py310hecd3228_1 conda-forge certifi 2024.2.2 pyhd8ed1ab_0 conda-forge cf_xarray 0.9.0 pyhd8ed1ab_0 conda-forge cffi 1.16.0 pypi_0 pypi cftime 1.6.3 py310h3e78b6c_0 conda-forge charset-normalizer 3.3.2 pyhd8ed1ab_0 conda-forge click 8.1.3 py310h5588dad_1 conda-forge cloudpickle 3.0.0 pyhd8ed1ab_0 conda-forge cmaps 2.0.1 pyhd8ed1ab_0 conda-forge colorama 0.4.6 pyhd8ed1ab_0 conda-forge comm 0.2.2 pypi_0 pypi contourpy 1.2.0 py310h232114e_0 conda-forge cycler 0.12.1 pyhd8ed1ab_0 conda-forge cytoolz 0.12.3 py310h8d17308_0 conda-forge dask 2024.3.1 pyhd8ed1ab_0 conda-forge dask-core 2024.3.1 pyhd8ed1ab_0 conda-forge dask-expr 1.0.5 pyhd8ed1ab_0 conda-forge debugpy 1.8.1 pypi_0 pypi decorator 5.1.1 pypi_0 pypi defusedxml 0.7.1 pypi_0 pypi distributed 2024.3.1 pyhd8ed1ab_0 conda-forge eofs 1.4.1 pyhd8ed1ab_1 conda-forge et_xmlfile 1.1.0 pyhd8ed1ab_0 conda-forge exceptiongroup 1.2.0 pypi_0 pypi executing 2.0.1 pypi_0 pypi fastjsonschema 2.19.1 pypi_0 pypi fonttools 4.50.0 py310h8d17308_0 conda-forge fqdn 1.5.1 pypi_0 pypi freetype 2.12.1 hdaf720e_2 conda-forge fsspec 2024.3.1 pyhca7485f_0 conda-forge geocat-comp 2024.02.0 pyha770c72_0 conda-forge geocat-datafiles 2022.03.0 pyha770c72_0 conda-forge geocat-f2py 2023.3.0 pypi_0 pypi geocat-viz 2024.03.0 pyhd8ed1ab_0 conda-forge geos 3.12.1 h1537add_0 conda-forge gettext 0.21.1 h5728263_0 conda-forge glib 2.80.0 h39d0aa6_1 conda-forge glib-tools 2.80.0 h0a98069_1 conda-forge gst-plugins-base 1.22.9 h001b923_1 conda-forge gstreamer 1.22.9 hb4038d2_1 conda-forge h11 0.14.0 pypi_0 pypi hdf4 4.2.15 h5557f11_7 conda-forge hdf5 1.14.3 nompi_h73e8ff5_100 conda-forge httpcore 1.0.4 pypi_0 pypi httpx 0.27.0 pypi_0 pypi icu 73.2 h63175ca_0 conda-forge idna 3.6 pyhd8ed1ab_0 conda-forge importlib-metadata 7.1.0 pyha770c72_0 conda-forge importlib_metadata 7.1.0 hd8ed1ab_0 conda-forge intel-openmp 2024.0.0 h57928b3_49841 conda-forge ipykernel 6.29.3 pypi_0 pypi ipython 8.22.2 pypi_0 pypi ipywidgets 8.1.2 pypi_0 pypi isoduration 20.11.0 pypi_0 pypi jedi 0.19.1 pypi_0 pypi jinja2 3.1.3 pyhd8ed1ab_0 conda-forge joblib 1.3.2 pyhd8ed1ab_0 conda-forge json5 0.9.24 pypi_0 pypi jsonpointer 2.4 pypi_0 pypi jsonschema 4.21.1 pypi_0 pypi jsonschema-specifications 2023.12.1 pypi_0 pypi jupyter 1.0.0 pypi_0 pypi jupyter-client 8.6.1 pypi_0 pypi jupyter-console 6.6.3 pypi_0 pypi jupyter-core 5.7.2 pypi_0 pypi jupyter-events 0.10.0 pypi_0 pypi jupyter-lsp 2.2.4 pypi_0 pypi jupyter-server 2.13.0 pypi_0 pypi jupyter-server-terminals 0.5.3 pypi_0 pypi jupyterlab 4.1.5 pypi_0 pypi jupyterlab-pygments 0.3.0 pypi_0 pypi jupyterlab-server 2.25.4 pypi_0 pypi jupyterlab-widgets 3.0.10 pypi_0 pypi kiwisolver 1.4.5 py310h232114e_1 conda-forge krb5 1.21.2 heb0366b_0 conda-forge lcms2 2.16 h67d730c_0 conda-forge lerc 4.0.0 h63175ca_0 conda-forge libabseil 20240116.1 cxx17_h63175ca_2 conda-forge libaec 1.1.3 h63175ca_0 conda-forge libarrow 15.0.2 h878f99b_1_cpu conda-forge libarrow-acero 15.0.2 h63175ca_1_cpu conda-forge libarrow-dataset 15.0.2 h63175ca_1_cpu conda-forge libarrow-flight 15.0.2 h02312f3_1_cpu conda-forge libarrow-flight-sql 15.0.2 h55b4db4_1_cpu conda-forge libarrow-gandiva 15.0.2 h3f2ff47_1_cpu conda-forge libarrow-substrait 15.0.2 h89268de_1_cpu conda-forge libblas 3.9.0 21_win64_mkl conda-forge libbrotlicommon 1.1.0 hcfcfb64_1 conda-forge libbrotlidec 1.1.0 hcfcfb64_1 conda-forge libbrotlienc 1.1.0 hcfcfb64_1 conda-forge libcblas 3.9.0 21_win64_mkl conda-forge libclang13 18.1.2 default_hf64faad_1 conda-forge libcrc32c 1.1.2 h0e60522_0 conda-forge libcurl 8.6.0 hd5e4a3a_0 conda-forge libdeflate 1.20 hcfcfb64_0 conda-forge libevent 2.1.12 h3671451_1 conda-forge libffi 3.4.2 h8ffe710_5 conda-forge libglib 2.80.0 h39d0aa6_1 conda-forge libgoogle-cloud 2.22.0 h9cad5c0_1 conda-forge libgoogle-cloud-storage 2.22.0 hb581fae_1 conda-forge libgrpc 1.62.1 h5273850_0 conda-forge libhwloc 2.9.3 default_haede6df_1009 conda-forge libiconv 1.17 hcfcfb64_2 conda-forge libjpeg-turbo 3.0.0 hcfcfb64_1 conda-forge liblapack 3.9.0 21_win64_mkl conda-forge libnetcdf 4.9.2 nompi_h07c049d_113 conda-forge libogg 1.3.4 h8ffe710_1 conda-forge libparquet 15.0.2 h7ec3a38_1_cpu conda-forge libpng 1.6.43 h19919ed_0 conda-forge libprotobuf 4.25.3 h503648d_0 conda-forge libre2-11 2023.09.01 hf8d8778_2 conda-forge libsqlite 3.45.2 hcfcfb64_0 conda-forge libssh2 1.11.0 h7dfc565_0 conda-forge libthrift 0.19.0 ha2b3283_1 conda-forge libtiff 4.6.0 hddb2be6_3 conda-forge libutf8proc 2.8.0 h82a8f57_0 conda-forge libvorbis 1.3.7 h0e60522_0 conda-forge libwebp-base 1.3.2 hcfcfb64_0 conda-forge libxcb 1.15 hcd874cb_0 conda-forge libxml2 2.12.6 hc3477c8_1 conda-forge libzip 1.10.1 h1d365fa_3 conda-forge libzlib 1.2.13 hcfcfb64_5 conda-forge llvmlite 0.42.0 py310hb84602e_1 conda-forge locket 1.0.0 pyhd8ed1ab_0 conda-forge lz4 4.3.3 py310hbbb2075_0 conda-forge lz4-c 1.9.4 hcfcfb64_0 conda-forge m2w64-gcc-libgfortran 5.3.0 6 conda-forge m2w64-gcc-libs 5.3.0 7 conda-forge m2w64-gcc-libs-core 5.3.0 7 conda-forge m2w64-gmp 6.1.0 2 conda-forge m2w64-libwinpthread-git 5.0.0.4634.697f757 2 conda-forge markupsafe 2.1.5 py310h8d17308_0 conda-forge matplotlib 3.8.3 py310h5588dad_0 conda-forge matplotlib-base 3.8.3 py310hc9baf74_0 conda-forge matplotlib-inline 0.1.6 pypi_0 pypi metpy 1.6.1 pyhd8ed1ab_0 conda-forge mistune 3.0.2 pypi_0 pypi mkl 2024.0.0 h66d3029_49657 conda-forge msgpack-python 1.0.7 py310h232114e_0 conda-forge msys2-conda-epoch 20160418 1 conda-forge munkres 1.1.4 pyh9f0ad1d_0 conda-forge nbclient 0.10.0 pypi_0 pypi nbconvert 7.16.3 pypi_0 pypi nbformat 5.10.3 pypi_0 pypi nest-asyncio 1.6.0 pypi_0 pypi netcdf4 1.6.5 nompi_py310h6477780_100 conda-forge notebook 7.1.2 pypi_0 pypi notebook-shim 0.2.4 pypi_0 pypi numba 0.59.1 py310h9ccaf4f_0 conda-forge numpy 1.26.4 py310hf667824_0 conda-forge openjpeg 2.5.2 h3d672ee_0 conda-forge openpyxl 3.1.2 py310h8d17308_1 conda-forge openssl 3.2.1 hcfcfb64_1 conda-forge orc 2.0.0 heb0c069_0 conda-forge overrides 7.7.0 pypi_0 pypi packaging 24.0 pyhd8ed1ab_0 conda-forge pandas 2.2.1 py310hecd3228_0 conda-forge pandocfilters 1.5.1 pypi_0 pypi parso 0.8.3 pypi_0 pypi partd 1.4.1 pyhd8ed1ab_0 conda-forge patsy 0.5.6 pyhd8ed1ab_0 conda-forge pcre2 10.43 h17e33f8_0 conda-forge pillow 10.2.0 py310h1e6a543_0 conda-forge pint 0.23 pyhd8ed1ab_0 conda-forge pip 24.0 pyhd8ed1ab_0 conda-forge platformdirs 4.2.0 pyhd8ed1ab_0 conda-forge ply 3.11 py_1 conda-forge pooch 1.8.1 pyhd8ed1ab_0 conda-forge proj 9.3.1 he13c7e8_0 conda-forge prometheus-client 0.20.0 pypi_0 pypi prompt-toolkit 3.0.43 pypi_0 pypi properscoring 0.1 py_0 conda-forge psutil 5.9.8 py310h8d17308_0 conda-forge pthread-stubs 0.4 hcd874cb_1001 conda-forge pthreads-win32 2.9.1 hfa6e2cd_3 conda-forge pure-eval 0.2.2 pypi_0 pypi pyarrow 15.0.2 py310hd0bb7c2_1_cpu conda-forge pyarrow-hotfix 0.6 pyhd8ed1ab_0 conda-forge pycparser 2.21 pypi_0 pypi pygments 2.17.2 pypi_0 pypi pyparsing 3.1.2 pyhd8ed1ab_0 conda-forge pyproj 3.6.1 py310h05d47c7_5 conda-forge pyqt 5.15.9 py310h1fd54f2_5 conda-forge pyqt5-sip 12.12.2 py310h00ffb61_5 conda-forge pyshp 2.3.1 pyhd8ed1ab_0 conda-forge pysocks 1.7.1 py310h5588dad_5 conda-forge python 3.10.14 h4de0772_0_cpython conda-forge python-dateutil 2.9.0 pyhd8ed1ab_0 conda-forge python-json-logger 2.0.7 pypi_0 pypi python-tzdata 2024.1 pyhd8ed1ab_0 conda-forge python_abi 3.10 4_cp310 conda-forge pytz 2024.1 pyhd8ed1ab_0 conda-forge pywin32 306 pypi_0 pypi pywinpty 2.0.13 pypi_0 pypi pyyaml 6.0.1 py310h8d17308_1 conda-forge pyzmq 25.1.2 pypi_0 pypi qt-main 5.15.8 h9e85ed6_20 conda-forge qtconsole 5.5.1 pypi_0 pypi qtpy 2.4.1 pypi_0 pypi re2 2023.09.01 hd3b24a8_2 conda-forge referencing 0.34.0 pypi_0 pypi requests 2.31.0 pyhd8ed1ab_0 conda-forge rfc3339-validator 0.1.4 pypi_0 pypi rfc3986-validator 0.1.1 pypi_0 pypi rpds-py 0.18.0 pypi_0 pypi scikit-learn 1.4.1.post1 py310hfd2573f_0 conda-forge scipy 1.12.0 py310hf667824_2 conda-forge send2trash 1.8.2 pypi_0 pypi setuptools 69.2.0 pyhd8ed1ab_0 conda-forge shapely 2.0.3 py310hacc03b5_0 conda-forge sip 6.7.12 py310h00ffb61_0 conda-forge six 1.16.0 pyh6c4a22f_0 conda-forge snappy 1.1.10 hfb803bf_0 conda-forge sniffio 1.3.1 pypi_0 pypi sortedcontainers 2.4.0 pyhd8ed1ab_0 conda-forge soupsieve 2.5 pypi_0 pypi sqlite 3.45.2 hcfcfb64_0 conda-forge stack-data 0.6.3 pypi_0 pypi statsmodels 0.14.1 py310h3e78b6c_0 conda-forge tbb 2021.11.0 h91493d7_1 conda-forge tblib 3.0.0 pyhd8ed1ab_0 conda-forge terminado 0.18.1 pypi_0 pypi threadpoolctl 3.4.0 pyhc1e730c_0 conda-forge tinycss2 1.2.1 pypi_0 pypi tk 8.6.13 h5226925_1 conda-forge toml 0.10.2 pyhd8ed1ab_0 conda-forge tomli 2.0.1 pyhd8ed1ab_0 conda-forge toolz 0.12.1 pyhd8ed1ab_0 conda-forge tornado 6.4 py310h8d17308_0 conda-forge traitlets 5.14.2 pyhd8ed1ab_0 conda-forge types-python-dateutil 2.9.0.20240316 pypi_0 pypi typing_extensions 4.10.0 pyha770c72_0 conda-forge tzdata 2024a h0c530f3_0 conda-forge ucrt 10.0.22621.0 h57928b3_0 conda-forge unicodedata2 15.1.0 py310h8d17308_0 conda-forge uri-template 1.3.0 pypi_0 pypi urllib3 2.2.1 pyhd8ed1ab_0 conda-forge vc 14.3 hcf57466_18 conda-forge vc14_runtime 14.38.33130 h82b7239_18 conda-forge vs2015_runtime 14.38.33130 hcb4865c_18 conda-forge wcwidth 0.2.13 pypi_0 pypi webcolors 1.13 pypi_0 pypi webencodings 0.5.1 pypi_0 pypi websocket-client 1.7.0 pypi_0 pypi wheel 0.43.0 pyhd8ed1ab_0 conda-forge widgetsnbextension 4.0.10 pypi_0 pypi win_inet_pton 1.1.0 py310h5588dad_5 conda-forge wrapt 1.16.0 py310h8d17308_0 conda-forge wrf-python 1.3.4.1 py310he260135_3 conda-forge xarray 2024.2.0 pyhd8ed1ab_0 conda-forge xhistogram 0.3.2 pyhd8ed1ab_0 conda-forge xorg-libxau 1.0.11 hcd874cb_0 conda-forge xorg-libxdmcp 1.1.3 hcd874cb_0 conda-forge xskillscore 0.0.26 pyhd8ed1ab_0 conda-forge xyzservices 2023.10.1 pyhd8ed1ab_0 conda-forge xz 5.2.6 h8d14728_0 conda-forge yaml 0.2.5 h8ffe710_2 conda-forge zict 3.0.0 pyhd8ed1ab_0 conda-forge zipp 3.17.0 pyhd8ed1ab_0 conda-forge zlib 1.2.13 hcfcfb64_5 conda-forge zstd 1.5.5 h12be248_0 conda-forge
kafitzgerald commented 7 months ago

Thanks for the additional context here!

Unfortunately, I can't seem to replicate this on my end.

Could you print out the geocat-viz version from where you're working (i.e. using gv.__version__)? It looks like you might have a different (custom) version installed or some sort of namespace conflict.

tingvan commented 7 months ago

Hi, @kafitzgerald ,thanks for your reply!

My version of gv is 0.1. image

kafitzgerald commented 7 months ago

It looks like you have a much older version 0.1 of geocat-viz installed in the environment you're working in, which doesn't line up with the environment info you listed. You might double check the environment to make sure you're using the intended one.

If you'd like to keep working in the current environment, you could also try removing the older version of geocat-viz and reinstalling an updated version.

tingvan commented 7 months ago

I have solved this problem. I forgot to install the latest virtual environment into my ipykernel, thus I was using the old version of geocat-viz.

Thank you very much for your help, @kafitzgerald .

kafitzgerald commented 7 months ago

Glad you got things sorted out!