Giter VIP home page Giter VIP logo

xgcm-examples's Introduction

xgcm: General Circulation Model Postprocessing with xarray

pypi package conda forge conda-forge GitHub Workflow CI Status code coverage documentation status DOI license Code style pre-commit.ci status

Binder Examples

Link Provider Description
Binder mybinder.org Basic self-contained example
PBinder Pangeo Binder More complex examples integrated with other Pangeo tools (dask, zarr, etc.)

Description

xgcm is a python package for working with the datasets produced by numerical General Circulation Models (GCMs) and similar gridded datasets that are amenable to finite volume analysis. In these datasets, different variables are located at different positions with respect to a volume or area element (e.g. cell center, cell face, etc.) xgcm solves the problem of how to interpolate and difference these variables from one position to another.

xgcm consumes and produces xarray data structures, which are coordinate and metadata-rich representations of multidimensional array data. xarray is ideal for analyzing GCM data in many ways, providing convenient indexing and grouping, coordinate-aware data transformations, and (via dask) parallel, out-of-core array computation. On top of this, xgcm adds an understanding of the finite volume Arakawa Grids commonly used in ocean and atmospheric models and differential and integral operators suited to these grids.

xgcm was motivated by the rapid growth in the numerical resolution of ocean, atmosphere, and climate models. While highly parallel supercomputers can now easily generate tera- and petascale datasets, common post-processing workflows struggle with these volumes. Furthermore, we believe that a flexible, evolving, open-source, python-based framework for GCM analysis will enhance the productivity of the field as a whole, accelerating the rate of discovery in climate science. xgcm is part of the Pangeo initiative.

Getting Started

To learn how to install and use xgcm for your dataset, visit the xgcm documentation.

xgcm-examples's People

Contributors

jbusecke avatar raphaeldussin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

xgcm-examples's Issues

Adjust thumbnail size

Currently we have too much whitespace in our thumbnail. I could just cut it (but that would contribute to the weird jagged layout of pangeo gallery. Not a priority, just pinning this here.

Mistake in computation horizontal divergence

First of all, thanks for making these tutorials! They've really helped me master xgcm, which I use almost daily now.

I spotted a mistake in the MITgcm example. The computation of the divergence is incorrect. The right MITgcm discrete form is found here. The difference is that there should be no multiplication by ds.drF (which in the link you currently include is present to correctly represent the z-derivative of the vertical velocity in the continuity equation), and that there should be an additional division by ds.hFacC. This also means that you may want to rename u/v_transport, since you don't need the transport after all.

I figured it's easiest for me to open an issue over a PR, since I don't know your specific workflow/integration for getting these examples on the xgcm website.

environment: importing from xgcm bad on sciserver

I'm trying to follow along from some of these sample notebooks but can't figure out the environment. I'm on sciserver. I have installed xgcm (it does appear in !conda list).
Can y'all help interpret this?

Traceback:

TypingErrorTraceback (most recent call last)
in
----> 1 from xgcm import Grid
2 from xgcm.autogenerate import generate_grid_ds

~/miniconda3/envs/py37/lib/python3.7/site-packages/xgcm/init.py in
4 version = "unknown"
5
----> 6 from .autogenerate import generate_grid_ds
7 from .grid import Axis, Grid

~/miniconda3/envs/py37/lib/python3.7/site-packages/xgcm/autogenerate.py in
1 import xarray as xr
2
----> 3 from xgcm.grid import Axis, raw_interp_function
4
5

~/miniconda3/envs/py37/lib/python3.7/site-packages/xgcm/grid.py in
15 import numba
16
---> 17 from .transform import conservative_interpolation, linear_interpolation
18 except ImportError:
19 numba = None

~/miniconda3/envs/py37/lib/python3.7/site-packages/xgcm/transform.py in
17 ],
18 "(n),(n),(m),(),()->(m)",
---> 19 nopython=True,
20 )
21 def _interp_1d_linear(

~/miniconda3/envs/py37/lib/python3.7/site-packages/numba/npyufunc/decorators.py in wrap(func)
177 guvec = GUVectorize(func, signature, **kws)
178 for fty in ftylist:
--> 179 guvec.add(fty)
180 return guvec.build_ufunc()
181

~/miniconda3/envs/py37/lib/python3.7/site-packages/numba/npyufunc/ufuncbuilder.py in add(self, sig)
194 targetoptions = self.nb_func.targetoptions
195 cres, args, return_type = _compile_element_wise_function(
--> 196 self.nb_func, targetoptions, sig)
197 sig = self._finalize_signature(cres, args, return_type)
198 self._sigs.append(sig)

~/miniconda3/envs/py37/lib/python3.7/site-packages/numba/npyufunc/ufuncbuilder.py in _compile_element_wise_function(nb_func, targetoptions, sig)
128 # Do compilation
129 # Return CompileResult to test
--> 130 cres = nb_func.compile(sig, **targetoptions)
131 args, return_type = sigutils.normalize_signature(sig)
132 return cres, args, return_type

~/miniconda3/envs/py37/lib/python3.7/site-packages/numba/npyufunc/ufuncbuilder.py in compile(self, sig, locals, **targetoptions)
77 flags.unset("enable_looplift")
78
---> 79 return self._compile_core(sig, flags, locals)
80
81 def _compile_core(self, sig, flags, locals):

~/miniconda3/envs/py37/lib/python3.7/site-packages/numba/npyufunc/ufuncbuilder.py in _compile_core(self, sig, flags, locals)
112 self.py_func, args=args,
113 return_type=return_type,
--> 114 flags=flags, locals=locals)
115
116 # cache lookup failed before so safe to save

~/miniconda3/envs/py37/lib/python3.7/site-packages/numba/compiler.py in compile_extra(typingctx, targetctx, func, args, return_type, flags, locals, library, pipeline_class)
970 pipeline = pipeline_class(typingctx, targetctx, library,
971 args, return_type, flags, locals)
--> 972 return pipeline.compile_extra(func)
973
974

~/miniconda3/envs/py37/lib/python3.7/site-packages/numba/compiler.py in compile_extra(self, func)
388 self.lifted = ()
389 self.lifted_from = None
--> 390 return self._compile_bytecode()
391
392 def compile_ir(self, func_ir, lifted=(), lifted_from=None):

~/miniconda3/envs/py37/lib/python3.7/site-packages/numba/compiler.py in _compile_bytecode(self)
901 """
902 assert self.func_ir is None
--> 903 return self._compile_core()
904
905 def _compile_ir(self):

~/miniconda3/envs/py37/lib/python3.7/site-packages/numba/compiler.py in _compile_core(self)
888 self.define_pipelines(pm)
889 pm.finalize()
--> 890 res = pm.run(self.status)
891 if res is not None:
892 # Early pipeline completion

~/miniconda3/envs/py37/lib/python3.7/site-packages/numba/compiler_lock.py in _acquire_compile_lock(*args, **kwargs)
30 def _acquire_compile_lock(*args, **kwargs):
31 with self:
---> 32 return func(*args, **kwargs)
33 return _acquire_compile_lock
34

~/miniconda3/envs/py37/lib/python3.7/site-packages/numba/compiler.py in run(self, status)
264 # No more fallback pipelines?
265 if is_final_pipeline:
--> 266 raise patched_exception
267 # Go to next fallback pipeline
268 else:

~/miniconda3/envs/py37/lib/python3.7/site-packages/numba/compiler.py in run(self, status)
255 try:
256 event("-- %s" % stage_name)
--> 257 stage()
258 except _EarlyPipelineCompletion as e:
259 return e.result

~/miniconda3/envs/py37/lib/python3.7/site-packages/numba/compiler.py in stage_nopython_frontend(self)
513 self.args,
514 self.return_type,
--> 515 self.locals)
516 self.typemap = typemap
517 self.return_type = return_type

~/miniconda3/envs/py37/lib/python3.7/site-packages/numba/compiler.py in type_inference_stage(typingctx, interp, args, return_type, locals)
1122
1123 infer.build_constraint()
-> 1124 infer.propagate()
1125 typemap, restype, calltypes = infer.unify()
1126

~/miniconda3/envs/py37/lib/python3.7/site-packages/numba/typeinfer.py in propagate(self, raise_errors)
925 if errors:
926 if raise_errors:
--> 927 raise errors[0]
928 else:
929 return errors

TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function(<function interp at 0x7f44f9406cb0>) with argument(s) of type(s): (array(float32, 1d, A), array(float32, 1d, A), array(float32, 1d, A))

  • parameterized
    In definition 0:
    TypingError: Failed in nopython mode pipeline (step: nopython frontend)
    Invalid use of Function(<function np_interp_impl_inner_factory..impl at 0x7f44f60215f0>) with argument(s) of type(s): (array(float32, 1d, A), array(float32, 1d, A), array(float32, 1d, A), dtype(float64))
  • parameterized
    In definition 0:
    TypingError: Failed in nopython mode pipeline (step: nopython frontend)
    Cannot unify array(float32, 1d, C) and array(float64, 1d, C) for 'slopes', defined at /home/idies/miniconda3/envs/py37/lib/python3.7/site-packages/numba/targets/arraymath.py (2120)

File "../../../../miniconda3/envs/py37/lib/python3.7/site-packages/numba/targets/arraymath.py", line 2120:
def impl(x, xp, fp, dtype):

if lenxp <= lenx:
slopes = (dy[1:] - dy[:-1]) / (dx[1:] - dx[:-1])
^

[1] During: typing of assignment at /home/idies/miniconda3/envs/py37/lib/python3.7/site-packages/numba/targets/arraymath.py (2122)

File "../../../../miniconda3/envs/py37/lib/python3.7/site-packages/numba/targets/arraymath.py", line 2122:
def impl(x, xp, fp, dtype):

else:
slopes = np.empty(0, dtype=dtype)
^

raised from /home/idies/miniconda3/envs/py37/lib/python3.7/site-packages/numba/typeinfer.py:927

In definition 1:
TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Cannot unify array(float32, 1d, C) and array(float64, 1d, C) for 'slopes', defined at /home/idies/miniconda3/envs/py37/lib/python3.7/site-packages/numba/targets/arraymath.py (2120)

File "../../../../miniconda3/envs/py37/lib/python3.7/site-packages/numba/targets/arraymath.py", line 2120:
def impl(x, xp, fp, dtype):

if lenxp <= lenx:
slopes = (dy[1:] - dy[:-1]) / (dx[1:] - dx[:-1])
^

[1] During: typing of assignment at /home/idies/miniconda3/envs/py37/lib/python3.7/site-packages/numba/targets/arraymath.py (2122)

File "../../../../miniconda3/envs/py37/lib/python3.7/site-packages/numba/targets/arraymath.py", line 2122:
def impl(x, xp, fp, dtype):

else:
slopes = np.empty(0, dtype=dtype)
^

raised from /home/idies/miniconda3/envs/py37/lib/python3.7/site-packages/numba/typeinfer.py:927

This error is usually caused by passing an argument of a type that is unsupported by the named function.
[1] During: resolving callee type: Function(<function np_interp_impl_inner_factory..impl at 0x7f44f60215f0>)
[2] During: typing of call at /home/idies/miniconda3/envs/py37/lib/python3.7/site-packages/numba/targets/arraymath.py (2237)

File "../../../../miniconda3/envs/py37/lib/python3.7/site-packages/numba/targets/arraymath.py", line 2237:
def np_interp_impl(x, xp, fp):
return inner(x, xp, fp, dtype)
^

raised from /home/idies/miniconda3/envs/py37/lib/python3.7/site-packages/numba/typeinfer.py:927

In definition 1:
TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function(<function np_interp_impl_inner_factory..impl at 0x7f44f60215f0>) with argument(s) of type(s): (array(float32, 1d, A), array(float32, 1d, A), array(float32, 1d, A), dtype(float64))

  • parameterized
    In definition 0:
    TypingError: Failed in nopython mode pipeline (step: nopython frontend)
    Cannot unify array(float32, 1d, C) and array(float64, 1d, C) for 'slopes', defined at /home/idies/miniconda3/envs/py37/lib/python3.7/site-packages/numba/targets/arraymath.py (2120)

File "../../../../miniconda3/envs/py37/lib/python3.7/site-packages/numba/targets/arraymath.py", line 2120:
def impl(x, xp, fp, dtype):

if lenxp <= lenx:
slopes = (dy[1:] - dy[:-1]) / (dx[1:] - dx[:-1])
^

[1] During: typing of assignment at /home/idies/miniconda3/envs/py37/lib/python3.7/site-packages/numba/targets/arraymath.py (2122)

File "../../../../miniconda3/envs/py37/lib/python3.7/site-packages/numba/targets/arraymath.py", line 2122:
def impl(x, xp, fp, dtype):

else:
slopes = np.empty(0, dtype=dtype)
^

raised from /home/idies/miniconda3/envs/py37/lib/python3.7/site-packages/numba/typeinfer.py:927

In definition 1:
TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Cannot unify array(float32, 1d, C) and array(float64, 1d, C) for 'slopes', defined at /home/idies/miniconda3/envs/py37/lib/python3.7/site-packages/numba/targets/arraymath.py (2120)

File "../../../../miniconda3/envs/py37/lib/python3.7/site-packages/numba/targets/arraymath.py", line 2120:
def impl(x, xp, fp, dtype):

if lenxp <= lenx:
slopes = (dy[1:] - dy[:-1]) / (dx[1:] - dx[:-1])
^

[1] During: typing of assignment at /home/idies/miniconda3/envs/py37/lib/python3.7/site-packages/numba/targets/arraymath.py (2122)

File "../../../../miniconda3/envs/py37/lib/python3.7/site-packages/numba/targets/arraymath.py", line 2122:
def impl(x, xp, fp, dtype):

else:
slopes = np.empty(0, dtype=dtype)
^

raised from /home/idies/miniconda3/envs/py37/lib/python3.7/site-packages/numba/typeinfer.py:927

This error is usually caused by passing an argument of a type that is unsupported by the named function.
[1] During: resolving callee type: Function(<function np_interp_impl_inner_factory..impl at 0x7f44f60215f0>)
[2] During: typing of call at /home/idies/miniconda3/envs/py37/lib/python3.7/site-packages/numba/targets/arraymath.py (2237)

File "../../../../miniconda3/envs/py37/lib/python3.7/site-packages/numba/targets/arraymath.py", line 2237:
def np_interp_impl(x, xp, fp):
return inner(x, xp, fp, dtype)
^

raised from /home/idies/miniconda3/envs/py37/lib/python3.7/site-packages/numba/typeinfer.py:927

This error is usually caused by passing an argument of a type that is unsupported by the named function.
[1] During: resolving callee type: Function(<function interp at 0x7f44f9406cb0>)
[2] During: typing of call at /home/idies/miniconda3/envs/py37/lib/python3.7/site-packages/xgcm/transform.py (31)

File "../../../../miniconda3/envs/py37/lib/python3.7/site-packages/xgcm/transform.py", line 31:
def _interp_1d_linear(

output[:] = np.interp(target_theta_levels, theta, phi)
^

Environment (anaconda, pipenv, virtual env) needed for the notebooks?

I wanted to rework the NEMO example (fix the typos, and reshape some stuff now that I am more confident with xgcm) and I am wondering, what environment should I use? Previously I used the environment.yml provided in xgcm (for readthedocs), is it still the same case now?
I feel lost between all the environments + the pangeo gallery.
Thanks!

Migrating notebooks

The mitgcm and MOM6 examples are both producing errors. Could the authors check on those?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.