Comments (5)
Hi, yes! These URLs are wrong and I haven't pushed those fixes here yet. NCEI changed the base URLs for model outputs to https://www.ncei.noaa.gov/thredds/model-<model>/
and made some other small changes. For historical NAM analysis, the base URL would include .../model-namanl-old/...
. So here, you'd have base_url = 'https://www.ncei.noaa.gov/thredds/dodsC/model-namanl-old/'
and it should work. We will be updating these URLs throughout the training hopefully as soon as we can focus some extra time on it.
from python-training.
Hi, yes! These URLs are wrong and I haven't pushed those fixes here yet. NCEI changed the base URLs for model outputs to https://www.ncei.noaa.gov/thredds/model-/ and made some other small changes. For historical NAM analysis, the base URL would include .../model-namanl-old/.... So here, you'd have base_url = 'https://www.ncei.noaa.gov/thredds/dodsC/model-namanl-old/' and it should work. We will be updating these URLs throughout the training hopefully as soon as we can focus some extra time on it.
I changed the URLS as above, but there is a mistake when I run the next code. Can you tell me wht's wrong with it?
from python-training.
The line data.x.values = data.x.values * 1000
is attempting to modify the values contained in the x
coordinate data variable of the data
dataset in-place, which xarray doesn't like. You can fix this by either assigning data.x.values * 1000
to a new python variable that you will then create the meshgrid from, or change the meshgrid generation to just x, y = np.meshgrid(data.x.values * 1000, data.y.values * 1000)
. Thanks for bringing this to my attention! I will mark this down and clean this up to run correctly when I go through to update the URLs.
from python-training.
The line data.x.values = data.x.values * 1000 is attempting to modify the values contained in the x coordinate data variable of the data dataset in-place, which xarray doesn't like. You can fix this by either assigning data.x.values * 1000 to a new python variable that you will then create the meshgrid from, or change the meshgrid generation to just x, y = np.meshgrid(data.x.values * 1000, data.y.values * 1000). Thanks for bringing this to my attention! I will mark this down and clean this up to run correctly when I go through to update the URLs.
I changed code as following, but when I plot the map, there is still mistake:
X, Y values are in units of km, need them in meters for plotting/calculations
#data.x.values = data.x.values * 1000.
#data.x.values = data.y.values * 1000.
Make them 2D for plotting/calculations
x, y = np.meshgrid(data.x.values * 1000, data.y.values * 1000)
mistake as following:
gaierror Traceback (most recent call last)
~\miniconda3\envs\unidata\lib\urllib\request.py in do_open(self, http_class, req, **http_conn_args)
1318 h.request(req.get_method(), req.selector, req.data, headers,
-> 1319 encode_chunked=req.has_header('Transfer-encoding'))
1320 except OSError as err: # timeout error
~\miniconda3\envs\unidata\lib\http\client.py in request(self, method, url, body, headers, encode_chunked)
1251 """Send a complete request to the server."""
-> 1252 self._send_request(method, url, body, headers, encode_chunked)
1253
~\miniconda3\envs\unidata\lib\http\client.py in _send_request(self, method, url, body, headers, encode_chunked)
1297 body = _encode(body, 'body')
-> 1298 self.endheaders(body, encode_chunked=encode_chunked)
1299
~\miniconda3\envs\unidata\lib\http\client.py in endheaders(self, message_body, encode_chunked)
1246 raise CannotSendHeader()
-> 1247 self._send_output(message_body, encode_chunked=encode_chunked)
1248
~\miniconda3\envs\unidata\lib\http\client.py in _send_output(self, message_body, encode_chunked)
1025 del self._buffer[:]
-> 1026 self.send(msg)
1027
~\miniconda3\envs\unidata\lib\http\client.py in send(self, data)
965 if self.auto_open:
--> 966 self.connect()
967 else:
~\miniconda3\envs\unidata\lib\http\client.py in connect(self)
937 self.sock = self._create_connection(
--> 938 (self.host,self.port), self.timeout, self.source_address)
939 self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
~\miniconda3\envs\unidata\lib\socket.py in create_connection(address, timeout, source_address)
706 err = None
--> 707 for res in getaddrinfo(host, port, 0, SOCK_STREAM):
708 af, socktype, proto, canonname, sa = res
~\miniconda3\envs\unidata\lib\socket.py in getaddrinfo(host, port, family, type, proto, flags)
751 addrlist = []
--> 752 for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
753 af, socktype, proto, canonname, sa = res
gaierror: [Errno 11002] getaddrinfo failed
During handling of the above exception, another exception occurred:
URLError Traceback (most recent call last)
~\miniconda3\envs\unidata\lib\site-packages\IPython\core\formatters.py in call(self, obj)
339 pass
340 else:
--> 341 return printer(obj)
342 # Finally look for special method names
343 method = get_real_method(obj, self.print_method)
~\miniconda3\envs\unidata\lib\site-packages\IPython\core\pylabtools.py in (fig)
246
247 if 'png' in formats:
--> 248 png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
249 if 'retina' in formats or 'png2x' in formats:
250 png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))
~\miniconda3\envs\unidata\lib\site-packages\IPython\core\pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs)
130 FigureCanvasBase(fig)
131
--> 132 fig.canvas.print_figure(bytes_io, **kw)
133 data = bytes_io.getvalue()
134 if fmt == 'svg':
~\miniconda3\envs\unidata\lib\site-packages\matplotlib\backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, **kwargs)
2077 print_method, dpi=dpi, orientation=orientation),
2078 draw_disabled=True)
-> 2079 self.figure.draw(renderer)
2080 bbox_artists = kwargs.pop("bbox_extra_artists", None)
2081 bbox_inches = self.figure.get_tightbbox(renderer,
~\miniconda3\envs\unidata\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
36 renderer.start_filter()
37
---> 38 return draw(artist, renderer, *args, **kwargs)
39 finally:
40 if artist.get_agg_filter() is not None:
~\miniconda3\envs\unidata\lib\site-packages\matplotlib\figure.py in draw(self, renderer)
1734 self.patch.draw(renderer)
1735 mimage._draw_list_compositing_images(
-> 1736 renderer, self, artists, self.suppressComposite)
1737
1738 renderer.close_group('figure')
~\miniconda3\envs\unidata\lib\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
135 if not_composite or not has_images:
136 for a in artists:
--> 137 a.draw(renderer)
138 else:
139 # Composite any adjacent images together
~\miniconda3\envs\unidata\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
36 renderer.start_filter()
37
---> 38 return draw(artist, renderer, *args, **kwargs)
39 finally:
40 if artist.get_agg_filter() is not None:
~\miniconda3\envs\unidata\lib\site-packages\cartopy\mpl\geoaxes.py in draw(self, renderer, inframe)
386
387 return matplotlib.axes.Axes.draw(self, renderer=renderer,
--> 388 inframe=inframe)
389
390 def str(self):
~\miniconda3\envs\unidata\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
36 renderer.start_filter()
37
---> 38 return draw(artist, renderer, *args, **kwargs)
39 finally:
40 if artist.get_agg_filter() is not None:
~\miniconda3\envs\unidata\lib\site-packages\matplotlib\axes_base.py in draw(self, renderer, inframe)
2628 renderer.stop_rasterizing()
2629
-> 2630 mimage._draw_list_compositing_images(renderer, self, artists)
2631
2632 renderer.close_group('axes')
~\miniconda3\envs\unidata\lib\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
135 if not_composite or not has_images:
136 for a in artists:
--> 137 a.draw(renderer)
138 else:
139 # Composite any adjacent images together
~\miniconda3\envs\unidata\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
36 renderer.start_filter()
37
---> 38 return draw(artist, renderer, *args, **kwargs)
39 finally:
40 if artist.get_agg_filter() is not None:
~\miniconda3\envs\unidata\lib\site-packages\cartopy\mpl\feature_artist.py in draw(self, renderer, *args, **kwargs)
162 except ValueError:
163 warnings.warn('Unable to determine extent. Defaulting to global.')
--> 164 geoms = self._feature.intersecting_geometries(extent)
165
166 # Combine all the keyword args in priority order.
~\miniconda3\envs\unidata\lib\site-packages\cartopy\feature_init_.py in intersecting_geometries(self, extent)
301 """
302 self.scaler.scale_from_extent(extent)
--> 303 return super(NaturalEarthFeature, self).intersecting_geometries(extent)
304
305 def with_scale(self, new_scale):
~\miniconda3\envs\unidata\lib\site-packages\cartopy\feature_init_.py in intersecting_geometries(self, extent)
118 extent_geom = sgeom.box(extent[0], extent[2],
119 extent[1], extent[3])
--> 120 return (geom for geom in self.geometries() if
121 geom is not None and extent_geom.intersects(geom))
122 else:
~\miniconda3\envs\unidata\lib\site-packages\cartopy\feature_init_.py in geometries(self)
285 path = shapereader.natural_earth(resolution=self.scale,
286 category=self.category,
--> 287 name=self.name)
288 geometries = tuple(shapereader.Reader(path).geometries())
289 _NATURAL_EARTH_GEOM_CACHE[key] = geometries
~\miniconda3\envs\unidata\lib\site-packages\cartopy\io\shapereader.py in natural_earth(resolution, category, name)
357 format_dict = {'config': config, 'category': category,
358 'name': name, 'resolution': resolution}
--> 359 return ne_downloader.path(format_dict)
360
361
~\miniconda3\envs\unidata\lib\site-packages\cartopy\io_init_.py in path(self, format_dict)
220 else:
221 # we need to download the file
--> 222 result_path = self.acquire_resource(target_path, format_dict)
223
224 return result_path
~\miniconda3\envs\unidata\lib\site-packages\cartopy\io\shapereader.py in acquire_resource(self, target_path, format_dict)
412 url = self.url(format_dict)
413
--> 414 shapefile_online = self._urlopen(url)
415
416 zfh = ZipFile(six.BytesIO(shapefile_online.read()), 'r')
~\miniconda3\envs\unidata\lib\site-packages\cartopy\io_init_.py in _urlopen(self, url)
259 """
260 warnings.warn('Downloading: {}'.format(url), DownloadWarning)
--> 261 return urlopen(url)
262
263 @staticmethod
~\miniconda3\envs\unidata\lib\urllib\request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
220 else:
221 opener = _opener
--> 222 return opener.open(url, data, timeout)
223
224 def install_opener(opener):
~\miniconda3\envs\unidata\lib\urllib\request.py in open(self, fullurl, data, timeout)
523 req = meth(req)
524
--> 525 response = self._open(req, data)
526
527 # post-process response
~\miniconda3\envs\unidata\lib\urllib\request.py in _open(self, req, data)
541 protocol = req.type
542 result = self._call_chain(self.handle_open, protocol, protocol +
--> 543 '_open', req)
544 if result:
545 return result
~\miniconda3\envs\unidata\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args)
501 for handler in handlers:
502 func = getattr(handler, meth_name)
--> 503 result = func(*args)
504 if result is not None:
505 return result
~\miniconda3\envs\unidata\lib\urllib\request.py in http_open(self, req)
1345
1346 def http_open(self, req):
-> 1347 return self.do_open(http.client.HTTPConnection, req)
1348
1349 http_request = AbstractHTTPHandler.do_request_
~\miniconda3\envs\unidata\lib\urllib\request.py in do_open(self, http_class, req, **http_conn_args)
1319 encode_chunked=req.has_header('Transfer-encoding'))
1320 except OSError as err: # timeout error
-> 1321 raise URLError(err)
1322 r = h.getresponse()
1323 except:
URLError: <urlopen error [Errno 11002] getaddrinfo failed>
from python-training.
We've fixed the issue in the notebooks you were having. Apologies for not getting back to you, but looks like you had trouble downloading the necessary cartopy features. If trying this again hasn't worked for you since, I can point you in the direction of this StackOverflow question that can help you manually download the features you may need if it isn't doing this automatically for you, or you may have DNS/proxy configuration issues. Closing this one but definitely reach out if there's any way I can still help!
from python-training.
Related Issues (20)
- Considerations for new infrastructure
- Probable link typo on Intro Python page
- NameError: name 'plt' is not defined HOT 1
- Ageostrophic_Wind_Example.ipynb reports error HOT 1
- Clarify iteration and indexing for catalog.datasets HOT 3
- UpperAir_Obs DataArray issues HOT 1
- Broken link
- More international examples
- Add pykdtree to python-training unidata environment
- Update advection API in QG analysis notebook
- extracting latitude from a string HOT 2
- Update MetPy Case Study to use MetPy v1.0 API and features HOT 1
- 250 hemispheric plot example updates
- Add materials about interpreting and fixing errors HOT 1
- Geomtrophic and Ageostrophic Wind problem in the HOT 2
- Add example of SPC reports and outlook
- Tie examples to data-access appendix
- "Downloading model fields with NCSS" needs an update
- Nice combo example HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-training.