Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 06 13:07
    PhilipeRLeal commented #490
  • Jul 05 18:31

    dopplershift on main

    docs: fix simple typo, noticabl… Merge pull request #2061 from t… (compare)

  • Jul 05 18:31
    dopplershift closed #2061
  • Jul 05 18:28
    dopplershift commented #490
  • Jul 05 09:02
    timgates42 opened #2061
  • Jul 04 12:13
    PhilipeRLeal commented #490
  • Jul 01 18:43
    lgarzio commented #2060
  • Jul 01 18:42
    lgarzio commented #2060
  • Jul 01 18:01
    greglucas commented #2060
  • Jul 01 17:44
    dopplershift commented #2060
  • Jul 01 17:33
    lgarzio opened #2060
  • Jul 01 12:54
    supershushu commented #1722
  • Jul 01 12:53
    supershushu commented #1722
  • Jul 01 12:53
    supershushu commented #1722
  • Jul 01 12:52
    supershushu commented #1722
  • Jul 01 01:43
    aluthfian commented #2048
  • Jul 01 01:42
    SciTools-assistant unlabeled #2048
  • Jul 01 01:42
    aluthfian synchronize #2048
  • Jun 30 19:00
    greglucas synchronize #1980
  • Jun 30 02:28
    greglucas synchronize #1980
Leonardo
@leonardojimenez1990

Hello. I would like to know how I can plot on a map the data from the variable "r" (relative humidity) of a NetCDF file with cartopy?

#

from netCDF4 import Dataset
import numpy as np
import xarray as xr
import cartopy.crs as ccrs
import matplotlib.pyplot as plt

leer el archive

ds=Dataset('relative_humidityEne_Dic2003_2020CMAS.nc', 'r')

print(ds)

mostar las variables del archive

print(ds.variables.keys())

accede a las variables

lon = ds.variables["longitude"]

print("longitude:===== ",lon)

lat = ds.variables["latitude"]

print("latitude:======= ",lat)

level = ds.variables["level"]

print("level:=========",level)

time = ds.variables["time"]

print("time:========= ",time)

r = ds.variables["r"]

print("humendad:===== ",r)

leer las dimenciones de las variables

print("las dimenciones variable r es: ", ds.variables['r'].dimensions)
print(r.shape)

dict_keys(['longitude', 'latitude', 'level', 'time', 'r'])
las dimenciones variable r es: ('time', 'level', 'latitude', 'longitude')
(53, 8, 241, 480)

crear la proyeccion con cartopy y matplotlib

ax = plt.axes(projection=ccrs.PlateCarree())

ax.coastlines()

plotear variables en el mapa

r_ds = ds.variables['r'][0, :, :, :]

print(r_ds)

plt.contourf(lon, lat, r_ds, transform=ccrs.PlateCarree())
ax.coastlines()
plt.show()

#

Error message

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 3331, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-2-403ea023eab8>", line 1, in <module>
runfile('/home/leo/Documentos/Universidad/Trabajo_de_investigación/PerfilesVerticalesContaminantesAtmosfera/Datos/readNetdcf42003_2020CMAS.py', wdir='/home/leo/Documentos/Universidad/Trabajo_de_investigación/PerfilesVerticalesContaminantesAtmosfera/Datos')
File "/snap/pycharm-professional/230/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/snap/pycharm-professional/230/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File"/home/leo/Documentos/Universidad/Trabajo_de_investigación/PerfilesVerticalesContaminantesAtmosfera/Datos/readNetdcf42003_2020CMAS.py", line 65, in <module>
plt.contourf(lon, lat, r_ds, transform=ccrs.PlateCarree())
File "/home/leo/.local/lib/python3.8/site-packages/matplotlib/pyplot.py", line 2577, in contourf
ret = gca().contourf(
File "/home/leo/.local/lib/python3.8/site-packages/cartopy/mpl/geoaxes.py", line 321, in wrapper
return func(self, args, **kwargs)
File "/home/leo/.local/lib/python3.8/site-packages/cartopy/mpl/geoaxes.py", line 1586, in contourf
result = matplotlib.axes.Axes.contourf(self,
args, **kwargs)
File "/home/leo/.local/lib/python3.8/site-packages/matplotlib/
init.py", line 1447, in inner
return func(ax, map(sanitize_sequence, args), **kwargs)
File "/home/leo/.local/lib/python3.8/site-packages/matplotlib/axes/_axes.py", line 6335, in contourf
contours = mcontour.QuadContourSet(self,
args, **kwargs)
File "/home/leo/.local/lib/python3.8/site-packages/matplotlib/contour.py", line 816, in
init
kwargs = self._process_args(args, *kwargs)
File "/home/leo/.local/lib/python3.8/site-packages/matplotlib/contour.py", line 1430, in _process_args
x, y, z = self._contour_args(args, kwargs)
File "/home/leo/.local/lib/python3.8/site-packages/matplotlib/contour.py", line 1488, in _contour_args
x, y, z = self._check_xyz(args[:3], kwargs)
File "/home/leo/.local/lib/python3.8/site-packages/matplotlib/contour.py", line 1514, in _check_xyz
x = np.asarray(x, dtype=np.float64)
File "/usr/local/lib/python3.8/dist-packages/numpy/core/_asarray.py", line 102, in asarray
return array(a, dtype, copy=False, order=order)
TypeError:
array__() takes no arguments (1 given)

Rei 머호
@rei_wu:matrix.org
[m]

techprog:matrix.org

Elliott Sales de Andrade
@QuLogic
@leonardojimenez1990 it seems like that's a netcdf+matplotlib problem, and not specific to cartopy
Are you able to plot it in pure Matplotlib?
Greg Lucas
@greglucas
Anyone against me tagging a release candidate for 0.19? There hasn't been a whole lot of activity lately other than not being able to build with PROJ8 :( but I feel like that will be a bit of an overhaul to rework and probably better to do for another release rather than pushing this off longer. Thoughts/ping: @QuLogic or @dopplershift and any other maintainers
Elliott Sales de Andrade
@QuLogic
I'm trying to review my backlog of PRs
One thing that needs fixing is the tests with the latest mpl rc
but that doesn't hold up another rc
I think you had a list on the what's new PR, which I'll try to get to first
Greg Lucas
@greglucas
Ahh, I haven't run the latest mpl rc to see what is out there for those failing tests.
Elliott Sales de Andrade
@QuLogic
nothing major, just haven't gotten to it
it's some broken mocking, mostly
Ryan May
@dopplershift
No opposition here. I’ve been trying to get through a todo list and get back to prioritizing some time here. Getting there, but it’s a slog with more todo first.
Leonardo
@leonardojimenez1990
thanks @QuLogic .
tfardet
@tfardet:matrix.org
[m]
Hi there, I have a quick question: I made a (very) simple PR on GitHub, but as I tried to run the tests locally before submitting, I had to make a lot of ugly hacks (copy-pasting files) to get it to work. Is there a document explaining how to run the tests locally?
Greg Lucas
@greglucas
Sadly, no :( SciTools/cartopy#1371
You shouldn't have had to copy-paste things though...
Greg Lucas
@greglucas
OK, I tagged a release candidate and it looks like it uploaded the sdist: https://pypi.org/project/Cartopy/0.19.0rc1/
Of course, now I can't build it locally to make sure it is good. Let me know if I messed anything up in the branch/tag work.
pip install cartopy==0.19.0rc1
Greg Lucas
@greglucas
n/m I got it installed now (upgraded clang recently on my local system which messed it up) and that rc looks good to me for installation. Let us know if anyone runs into any issues with it!
tfardet
@tfardet:matrix.org
[m]
Ah, OK, thanks for the link.
I'm used to simply inputing pytest path/to/test and that was not working well because it was trying to make local imports and obviously all generated files where missing
Greg Lucas
@greglucas
Try that with an editable install pip install -e .?
Elliott Sales de Andrade
@QuLogic
@greglucas you did create a tag named list; you'll probably want to delete that from your copies
Greg Lucas
@greglucas
Hm... Sorry about that! I think I must have done a git tag list instead of git tag -l to see what the tags were and then pushed up two tags. Luckily it doesn't look like that one did anything though? I don't see it on GH now (I assume you deleted it?) and I deleted my local tag name. Thanks for pointing that out.
Elliott Sales de Andrade
@QuLogic
Yea, I deleted it; the upload only triggers for something like v[0-9].[0-9].[0-9]*
Greg Lucas
@greglucas
:+1: Thanks!
hayesla
@hayesla:matrix.org
[m]
hey! I'm currently moving from using basemap to cartopy and have a quick question about setting the resolution of great circle plot. I have two points that I'm plotting on a PlateCarree projection, and then plotting the great circle by using the transform=ccrs.Geodetic() keyword.
I'm wondering how I can increase the resolution of this blue line? Can someone help, or point me to the right direction within the source code or docs?
Greg Lucas
@greglucas
Looks like others have had the same request recently :) There is a workaround in this issue
SciTools/cartopy#8
I think the only way to do this currently is to modify the private threshold attribute before creating your axes.
pc = ccrs.PlateCarree()
pc._threshold = 0.1
ax = plt.axes(projection=pc)
hayesla
@hayesla:matrix.org
[m]
ah ok perfect, that worked! thank you!
jdnplanets
@jdnplanets
Hello! I currently make use of Basemap in my data reduction pipeline for images of Jupiter. A commonly-used coordinate system for Jupiter (and other planets) is left-handed, i.e. increases westward. Basemap has the celestial keyword, which enables this in its projections. I'd like to move to Cartopy, but I can't see how to enable this in Cartopy. Could anyone advise how to do this, or if there is a plan to add this as a feature? Thanks in advance.
Ryan May
@dopplershift
@jdnplanets I'm not aware of anyone working on this. I'm not sure how Basemap accomplishes this, but looking at their implementation might shed some light on it. Just as a guess here, I'd think we'd need this to be supported by PROJ, but again, not sure how Basemap does it.
Greg Lucas
@greglucas
There is this issue from a while ago doing somewhat similar things? SciTools/cartopy#1606
Greg Lucas
@greglucas
v0.19.0 is now out in the wild! Lets hope there aren't too many bad errors in this one ;)
Ryan May
@dopplershift
I'm waiting for the conda-forge bot to pick up the update
Greg Lucas
@greglucas
Did it get the pre-release?
Ryan May
@dopplershift
They don't normally
Greg Lucas
@greglucas
:+1:
Mark Wieczorek
@mark-wieczorek:matrix.org
[m]
Are there release notes for v0.19? Just curious if there is anything I need to know!
Greg Lucas
@greglucas
@mark-wieczorek:matrix.org, waiting for the docs to be merged on another repo still. Here is a link to the doc build from CI that shows the What's New https://2550-5282596-gh.circle-artifacts.com/0/docs/build/html/whats_new.html
Stephane Raynaud
@stefraynaud
@greglucas I saw your message. I'll try first to run successfully all the tests of master!
Greg Lucas
@greglucas
:+1:
Stephane Raynaud
@stefraynaud
All tests that plot labels (contour and gridliner) are failing with master
Greg Lucas
@greglucas
Hm... They are passing on CI's master. Are you grabbing matplotlib from the labels/testing conda-forge area? That has MPL with the specific freetype to help the image comparisons
Stephane Raynaud
@stefraynaud
Yep. I juste use python 3.8 because my old compiler fails with 3.9.
CHANNELS="-c conda-forge/label/testing -c conda-forge -c defaults"
PACKAGES_COMMON="flufl.lock owslib pep8 pillow pyepsg pyshp pytest"
PACKAGES_COMMON="$PACKAGES_COMMON pytest-xdist requests setuptools_scm"
PACKAGES_COMMON="$PACKAGES_COMMON setuptools_scm_git_archive shapely"
PACKAGES_LATEST="python=3.8 cython fiona matplotlib-base numpy proj<8 pykdtree scipy pytest-cov coveralls spyder=4"
Greg Lucas
@greglucas
:( Bummer... The CI systems list out what packages they installed and where they got them from conda list at the end of the "Install Dependencies" step. You can try to see if there is a difference between your local versions and those I guess? Here is the most recent one: https://github.com/SciTools/cartopy/runs/2413220331
Stephane Raynaud
@stefraynaud
Good idea
Leonardo
@leonardojimenez1990
Hello I would like to know how I can correctly plot the longitude on the map.
errorTrazarLongitudMap.png