Giter Club home page Giter Club logo

Comments (10)

miniufo avatar miniufo commented on July 28, 2024

Hi, thank you for your interests. This is due to the recent update of xgcm. A quick solution would be to use older version of xgcm (< 0.7). I have to see how to recover the original behavior using the newest 'xgcm'.

from xinvert.

silver-fox-9244 avatar silver-fox-9244 commented on July 28, 2024

Thank you for your swift response. Upon downgrading to xgcm v 0.6.1 I unfortunately get the following warnings and error:

ds, grid = add_latlon_metrics(dset, dims={'lev':'LEV', 'lat':'lat', 'lon':'lon'})
C:\Users\user-pc\miniconda3\Lib\site-packages\xinvert\tests\GeoApps\GridUtils.py:177: FutureWarning: xarray.ufuncs is deprecated. Instead, use numpy ufuncs directly.
dx = xr.ufuncs.cos(xr.ufuncs.deg2rad(lat))
C:\Users\user-pc\miniconda3\lib\site-packages\xarray\core\dataarray.py:3078: FutureWarning: xarray.ufuncs is deprecated. Instead, use numpy ufuncs directly.
da = self.array_wrap(f(self.variable.data, *args, **kwargs))
C:\Users\user-pc\miniconda3\Lib\site-packages\xinvert\tests\GeoApps\GridUtils.py:177: FutureWarning: xarray.ufuncs is deprecated. Instead, use numpy ufuncs directly.
dx = xr.ufuncs.cos(xr.ufuncs.deg2rad(lat))
C:\Users\user-pc\miniconda3\lib\site-packages\xarray\core\dataarray.py:3078: FutureWarning: xarray.ufuncs is deprecated. Instead, use numpy ufuncs directly.
da = self.array_wrap(f(self.variable.data, *args, **kwargs))
C:\Users\user-pc\miniconda3\Lib\site-packages\xinvert\tests\GeoApps\GridUtils.py:177: FutureWarning: xarray.ufuncs is deprecated. Instead, use numpy ufuncs directly.
dx = xr.ufuncs.cos(xr.ufuncs.deg2rad(lat))
C:\Users\user-pc\miniconda3\lib\site-packages\xarray\core\dataarray.py:3078: FutureWarning: xarray.ufuncs is deprecated. Instead, use numpy ufuncs directly.
da = self.array_wrap(f(self.variable.data, *args, **kwargs))
C:\Users\user-pc\miniconda3\Lib\site-packages\xinvert\tests\GeoApps\GridUtils.py:177: FutureWarning: xarray.ufuncs is deprecated. Instead, use numpy ufuncs directly.
dx = xr.ufuncs.cos(xr.ufuncs.deg2rad(lat))
C:\Users\user-pc\miniconda3\lib\site-packages\xarray\core\dataarray.py:3078: FutureWarning: xarray.ufuncs is deprecated. Instead, use numpy ufuncs directly.
da = self.array_wrap(f(self.variable.data, *args, **kwargs))
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\user-pc\miniconda3\Lib\site-packages\xinvert\tests\GeoApps\GridUtils.py", line 87, in add_latlon_metrics
grid._assign_metrics(metrics)
AttributeError: 'Grid' object has no attribute '_assign_metrics'

from xinvert.

miniufo avatar miniufo commented on July 28, 2024

Sorry for this inconvience. The dependence of xinvert on xgcm is to take advantage of its ability for finite difference, but since xgcm is still in heavy development, all the public apis can be changed at any time.

Could you please try 0.5.x of 'xgcm'? I write the codes using that version and I guess it should be OK.

from xinvert.

silver-fox-9244 avatar silver-fox-9244 commented on July 28, 2024

Ah...makes sense. Just downgraded to xgcm 0.5.0 and upon execution of the code this then comes up:

File "", line 1, in
File "", line 28, in
TypeError: init() got an unexpected keyword argument 'arakawa'

Is it because in the Dynamics class, the method init(self,dset,grid=None) doesn't take the grid type argument?

class Dynamics(Application):
"""
This class is designed for calculating the dynamical methods.
"""
def init(self, dset, grid=None):

from xinvert.

miniufo avatar miniufo commented on July 28, 2024

Oh, I notice that one may need GeoApps to do the tests of xinvert. You can clone it to your local path and import Dynamics from the updated GeoApps.

GeoApps is used for finite differences but it is not ready for release. I realize that xinvert has too many dependencies on those packages, and maybe it is time to make it standalone...

from xinvert.

silver-fox-9244 avatar silver-fox-9244 commented on July 28, 2024

I've just updated/cloned the GeoApps package into the tests folder, and again it throws the initial error I got before downgrading to an older xgcm version.

C:\Users\user-pc\miniconda3\lib\site-packages\scipy_init_.py:138: UserWarning: A NumPy version >=1.16.5 and <1.23.0 is required for this version of SciPy (detected version 1.23.1)
warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion} is required for this version of "
Traceback (most recent call last):
File "", line 1, in
File "", line 20, in
File "C:\Users\user-pc\miniconda3\Lib\site-packages\xinvert\tests\GeoApps\GridUtils.py", line 175, in add_latlon_metrics
grid.set_metrics(key, value)
AttributeError: 'Grid' object has no attribute 'set_metrics'

Could this be related to the scipy and numpy warnings issued?

from xinvert.

miniufo avatar miniufo commented on July 28, 2024

I'll give a try to run this example using the newest versions of packages, fix all the bugs, and let you know the results ASAP.

from xinvert.

silver-fox-9244 avatar silver-fox-9244 commented on July 28, 2024

Awesome!, thanks for your help and patience.

from xinvert.

miniufo avatar miniufo commented on July 28, 2024

I've updated the test codes of QG omega, with 0.7.0v of xgcm. Also, GeoApps is updated accordingly. You can try with them.

For inverting QG omega, one needs a 3D forcing function and a 3D stratification. But the calculations of the forcing and stratification are not the part of xinvert. There are two ways to do the calculation of forcings. One is to use GeoApps which is based on xgcm; the other is to use FiniteDiff in xinvert so that the package does not depend on other package (please see the cells in testOmegaEq.py). You can also write your own codes to do the calculation of forcings.

Note that there are NaN in the calculation, which is used to maskout the topography (kwarg undef=NaN). In this case, one need to change inf (the calculation of forcings usually brings up inf) to NaN explicitly so that inf do not propagate in the calculation.

Once the forcings are ready, inverting is much easier. Please tell me if you find other problems.

from xinvert.

miniufo avatar miniufo commented on July 28, 2024

Close this now. Feel free to re-open it in any case.

from xinvert.

Related Issues (20)

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.