Coder Social home page Coder Social logo

trackeddy's Introduction

TrackEddy (Eddy Identification Algorithm)

Travis CI (Python 3.6) Read the Docs Code Coverage
Build Status Documentation Status codecov

Supports Python 2.7 and Python 3 This code will let you identify and track any normal shape in a 2D space. The principal objective of this development is finding and tracking all the eddies in the ocean.

Alt Text

v1.0 Release:

The source code supports the extraction of eddies each time step and moving in vertical coordinate Z.

Alt Text

Installing TrackEddy

  1. Make a new directory where you want the repository.
  2. Clone the TrackEddy repository from Github. In the command prompt, type: git clone https://github.com/Josue-Martinez-Moreno/trackeddy.git
  3. Install the package globally: pip install -e . This make the package an editable install so that it can be updated with future additions to TrackEddy. To instead install the package locally: pip install --user .

Updating TrackEddy

  1. Move into your TrackEddy directory.
  2. Update your GitHub repository. git pull
  3. Edit your install of TrackEddy. pip install -e . or pip install --force-reinstall -e . or, for local installation: pip install --ignore-installed --user .

Read more about TrackEddy in

  • Martínez-Moreno, J., Hogg, A. McC., Kiss, A. E., Constantinou, N. C., and Morrison, A. K. (2019). Kinetic energy of eddy-like features from sea surface altimetry. Journal of Advances in Modeling Earth Systems, 11(10), 3090-3105. doi:10.1029/2019MS001769

References:

  • Faghmous, J. H., Frenger, I., Yao, Y., Warmka, R., Lindell, A., & Kumar, V. (2015). A daily global mesoscale ocean eddy dataset from satellite altimetry. Scientific Data, 2, 150028.
  • Chang, Y. L., & Oey, L. Y. (2014). Analysis of STCC eddies using the Okubo–Weiss parameter on model and satellite data. Ocean Dynamics, 64(2), 259-271.
  • Chelton, D. B., Schlax, M. G., Samelson, R. M., & de Szoeke, R. A. (2007). Global observations of large oceanic eddies. Geophysical Research Letters, 34(15), L15606.

trackeddy's People

Contributors

josuemtzmo avatar navidcy avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

trackeddy's Issues

AttributeError: module 'numpy' has no attribute 'float128'

sorry for opening another issue, I am using windows 10 and python 3.8

0% [==========>]100% | Elapsed Time: 0 s | Estimated Time: 0 s | Info: Init time |
0% [==========3]100% | Elapsed Time: 12 s | Estimated Time: 535 s | Info: # of E 2 |

AttributeError Traceback (most recent call last)
in
----> 1 negative_eddies=analyseddyzt(sla,lon,lat,0,1,1,levels,preferences=preferences
2 ,areamap=areamap,areaparms=checkarea,filters=filters
3 ,maskopt='contour',diagnostics=False,pprint=True)

c:\users\hafez\miniconda3\lib\site-packages\trackeddy-0.1-py3.8.egg\trackeddy\tracking.py in analyseddyzt(data, x, y, t0, t1, tstep, levels, areamap, mask, physics, eddycenter, preferences, checkgauss, areaparms, maskopt, mode, filters, timeanalysis, destdir, saveformat, diagnostics, plotdata, pprint, debug)
661 levels_scan = [levellist[ll], np.inf]
662
--> 663 eddies, check, numbereddies = scan_eddym(dataanomaly, x, y, levels_scan, ii
664 , areamap, mask=mask, destdir=destdir
665 , physics=physics, eddycenter=eddycenter, maskopt=maskopt \

c:\users\hafez\miniconda3\lib\site-packages\trackeddy-0.1-py3.8.egg\trackeddy\tracking.py in scan_eddym(data, lon, lat, levels, date, areamap, mask, destdir, physics, eddycenter, maskopt, preferences, mode, basemap, checkgauss, areaparms, usefullfit, diagnostics, plotdata, debug)
299 fixvalues = [lon_contour, lat_contour, extremvalue,
300 center_extrem[0], center_extrem[1]]
--> 301 gausssianfitp, R2 = fit2Dcurve(data_in_contour,
302 fixvalues,
303 level, initial_guess=initial_guess, date='', \

c:\users\hafez\miniconda3\lib\site-packages\trackeddy-0.1-py3.8.egg\trackeddy\geometryfunc.py in fit2Dcurve(var, values, level, initial_guess, date, mode, diagnostics)
520 #print("\n ----Fit----")
521 #pdb.set_trace()
--> 522 res = minimize(gaussian2Dresidual, initial_guess,args=(coords,varm),
523 method='SLSQP',options={'xtol': 1e-12, 'disp': False})
524 fitdict = res.x

c:\users\hafez\miniconda3\lib\site-packages\scipy\optimize_minimize.py in minimize(fun, x0, args, method, jac, hess, hessp, bounds, constraints, tol, callback, options)
623 return _minimize_cobyla(fun, x0, args, constraints, **options)
624 elif meth == 'slsqp':
--> 625 return _minimize_slsqp(fun, x0, args, jac, bounds,
626 constraints, callback=callback, **options)
627 elif meth == 'trust-constr':

c:\users\hafez\miniconda3\lib\site-packages\scipy\optimize\slsqp.py in _minimize_slsqp(func, x0, args, jac, bounds, constraints, maxiter, ftol, iprint, disp, eps, callback, finite_diff_rel_step, **unknown_options)
366
367 # ScalarFunction provides function and gradient evaluation
--> 368 sf = _prepare_scalar_function(func, x, jac=jac, args=args, epsilon=eps,
369 finite_diff_rel_step=finite_diff_rel_step,
370 bounds=new_bounds)

c:\users\hafez\miniconda3\lib\site-packages\scipy\optimize\optimize.py in _prepare_scalar_function(fun, x0, jac, args, bounds, epsilon, finite_diff_rel_step, hess)
259 # ScalarFunction caches. Reuse of fun(x) during grad
260 # calculation reduces overall function evaluations.
--> 261 sf = ScalarFunction(fun, x0, args, grad, hess,
262 finite_diff_rel_step, bounds, epsilon=epsilon)
263

c:\users\hafez\miniconda3\lib\site-packages\scipy\optimize_differentiable_functions.py in init(self, fun, x0, args, grad, hess, finite_diff_rel_step, finite_diff_bounds, epsilon)
74
75 self._update_fun_impl = update_fun
---> 76 self._update_fun()
77
78 # Gradient evaluation

c:\users\hafez\miniconda3\lib\site-packages\scipy\optimize_differentiable_functions.py in _update_fun(self)
164 def _update_fun(self):
165 if not self.f_updated:
--> 166 self._update_fun_impl()
167 self.f_updated = True
168

c:\users\hafez\miniconda3\lib\site-packages\scipy\optimize_differentiable_functions.py in update_fun()
71
72 def update_fun():
---> 73 self.f = fun_wrapped(self.x)
74
75 self._update_fun_impl = update_fun

c:\users\hafez\miniconda3\lib\site-packages\scipy\optimize_differentiable_functions.py in fun_wrapped(x)
68 def fun_wrapped(x):
69 self.nfev += 1
---> 70 return fun(x, *args)
71
72 def update_fun():

c:\users\hafez\miniconda3\lib\site-packages\trackeddy-0.1-py3.8.egg\trackeddy\geometryfunc.py in gaussian2Dresidual(popt, coords, varm)
459 def gaussian2Dresidual(popt, coords, varm):
460 g=twoD_Gaussian(coords,*popt).reshape(np.shape(varm))
--> 461 residual = np.exp(np.abs(np.float128(np.nanmean(abs(varm - g))))) - 1
462 #print('Residual:',np.nanmean(residual))
463 return residual

c:\users\hafez\miniconda3\lib\site-packages\numpy_init_.py in getattr(attr)
212 return Tester
213 else:
--> 214 raise AttributeError("module {!r} has no attribute "
215 "{!r}".format(name, attr))
216

AttributeError: module 'numpy' has no attribute 'float128'

Release v1.0

I suggest doing a release of v1.0 (which is the version used in the paper.

Screen Shot 2019-10-30 at 12 13 37 PM

Using SSH data to identify eddies

Hello!

If I want to use SSH data instead of SLA data to identify cold and warm eddies, how should I set the max and min values for my levels? In addition, could you please introduce the difference in identified eddies between SLA and SSH?

Here are the values for the SLA levels set:

positive_eddies: levels = {'max':sla[:,:,:].max(),'min':0.01,'step':0.03} negative_eddies: levels = {'max':sla[:,:,:].min(),'min':-0.01,'step':-0.03}

Thank you very much for your reply !!

scipy.ndimage.filter handles NaNs as zeros

Using scipy's ndimage filters, as for example in

nofilterdata = nofilterdata - ndimage.uniform_filter(nofilterdata, size = filters['spatial']['window'])

induces some errors as scipy.ndimage handles NaN (e.g., points which correspond to land) as zeros and this affects the average.

An alternative way that does not suffer from this is astropy.convolution.

Some problems regarding the examples, and how to proceed with the Trackeddy

Hello!

I am quite new in python and and absolutely new in Trackeddy. I have been trying to run How_Trackeddy_Works.ipynb and I have encountered some problems.

First is the trackeddy.init is not in the main package I have installed. I don't know if it is something I have to create myself or if it is included in another directory I have not installed. However if I remove that import line, it works, so I don't know how important that is.

Then another error appears, and it says "module 'time' has no attribute 'clock' " I don't know if I have to change the function to another one since in Stackoverflow it is mentioned that this function is no longer available in the latest python versions.

Sorry if these questions are a bit too basic or stupid. Hope you can help me.

Kind regards, Joan

how to track eddies and resquest for example/demo ?

I have already open two issues. I like to request demos on how to track eddies .would you add an example like basemap_mplot for positive and negative plots ? please. I have daily dataset from copernicus

I have tried but I am getting error
scan_eddym(sla,lon,lat,levels,0,areamap,maskopt='contour', preferences=None,plotdata=False)

TypeError Traceback (most recent call last)
in
----> 1 scan_eddym(sla,lon,lat,levels,0,areamap,maskopt='contour', preferences=None,plotdata=False)

c:\users\hafez\miniconda3\lib\site-packages\trackeddy-0.1-py3.8.egg\trackeddy\tracking.py in scan_eddym(data, lon, lat, levels, date, areamap, mask, destdir, physics, eddycenter, maskopt, preferences, mode, basemap, checkgauss, areaparms, usefullfit, diagnostics, plotdata, debug)
124 # Plot contours according to the data.
125 if len(shapedata) == 3:
--> 126 CS = plt.contourf(Lon[areamap[1, 0]:areamap[1, 1], areamap[0, 0]:areamap[0, 1]],
127 Lat[areamap[1, 0]:areamap[1, 1], areamap[0, 0]:areamap[0, 1]],
128 datanan[date, areamap[1, 0]:areamap[1, 1], areamap[0, 0]:areamap[0, 1]], \

c:\users\hafez\miniconda3\lib\site-packages\matplotlib\pyplot.py in contourf(data, *args, **kwargs)
2558 @_copy_docstring_and_deprecators(Axes.contourf)
2559 def contourf(*args, data=None, **kwargs):
-> 2560 __ret = gca().contourf(
2561 *args, **({"data": data} if data is not None else {}),
2562 **kwargs)

c:\users\hafez\miniconda3\lib\site-packages\matplotlib_init_.py in inner(ax, data, *args, **kwargs)
1429 def inner(ax, *args, data=None, **kwargs):
1430 if data is None:
-> 1431 return func(ax, *map(sanitize_sequence, args), **kwargs)
1432
1433 bound = new_sig.bind(ax, *args, **kwargs)

c:\users\hafez\miniconda3\lib\site-packages\matplotlib\axes_axes.py in contourf(self, *args, **kwargs)
6317 def contourf(self, *args, **kwargs):
6318 kwargs['filled'] = True
-> 6319 contours = mcontour.QuadContourSet(self, *args, **kwargs)
6320 self._request_autoscale_view()
6321 return contours

c:\users\hafez\miniconda3\lib\site-packages\matplotlib\contour.py in init(self, ax, levels, filled, linewidths, linestyles, hatches, alpha, origin, extent, cmap, colors, norm, vmin, vmax, extend, antialiased, nchunk, locator, transform, *args, **kwargs)
814 self._transform = transform
815
--> 816 kwargs = self._process_args(*args, **kwargs)
817 self._process_levels()
818

c:\users\hafez\miniconda3\lib\site-packages\matplotlib\contour.py in _process_args(self, corner_mask, *args, **kwargs)
1428 self._corner_mask = corner_mask
1429
-> 1430 x, y, z = self._contour_args(args, kwargs)
1431
1432 _mask = ma.getmask(z)

c:\users\hafez\miniconda3\lib\site-packages\matplotlib\contour.py in _contour_args(self, args, kwargs)
1499 'masked')
1500 self.zmin = float(z.min())
-> 1501 self._process_contour_level_args(args)
1502 return (x, y, z)
1503

c:\users\hafez\miniconda3\lib\site-packages\matplotlib\contour.py in _process_contour_level_args(self, args)
1156 self.levels = self._autolev(levels_arg)
1157 else:
-> 1158 self.levels = np.asarray(levels_arg).astype(np.float64)
1159
1160 if not self.filled:

TypeError: float() argument must be a string or a number, not 'dict'

Reported Bug #1 : Fake perturbations added.

If the field has positive and negative anomalies as shown in the top next figure, the algorithm performs properly.

time_012

However, if after a field like the presented before is a field with only one perturbation polarity, the reconstruction creates fake positive anomalies as shown in the next figure.

time_013

AttributeError: module 'time' has no attribute 'clock'

positive_eddies=analyseddyzt(sla,lon,lat,0,1,1,levels,preferences=preferences
,areamap=areamap,areaparms=checkarea,filters=filters
,maskopt='contour',diagnostics=False,pprint=True)
AttributeError Traceback (most recent call last)
in
----> 1 positive_eddies=analyseddyzt(sla,lon,lat,0,1,1,levels,preferences=preferences
2 ,areamap=areamap,areaparms=checkarea,filters=filters
3 ,maskopt='contour',diagnostics=False,pprint=True)

c:\users\hafez\miniconda3\lib\site-packages\trackeddy-0.1-py3.8.egg\trackeddy\tracking.py in analyseddyzt(data, x, y, t0, t1, tstep, levels, areamap, mask, physics, eddycenter, preferences, checkgauss, areaparms, maskopt, mode, filters, timeanalysis, destdir, saveformat, diagnostics, plotdata, pprint, debug)
508
509 if pprint == True:
--> 510 pp = Printer();
511 if len(np.shape(data)) < 3:
512 raise Exception('If you whant to analyze in time the data need to be 3d [i.e. data(t,x,y)]')

c:\users\hafez\miniconda3\lib\site-packages\trackeddy-0.1-py3.8.egg\trackeddy\printfunc.py in init(self)
10 """
11 def init(self):
---> 12 self.tic=time.clock()
13 sys.stdout.flush()
14 self.data=[]

AttributeError: module 'time' has no attribute 'clock'

local variable 'eddz' referenced before assignment

Hello

I have been trying to run the analyseddyzt function in order to detect the positive eddies on a SLA subset (55,70 N; 30,5 W) from the CMEMS_SEALEVEL_008_057 dataset. I have selected one year, so it has 365 timesteps. I have also set the time and spatial filters to None.

However when I run the function the same error always pops up "local variable 'eddz' referenced before assignment". So I don't know how to proceed since I don't detect what I can be doing wrong or if any step is missing in applying the routine.

positive_eddies=analyseddyzt(sla,lon,lat,0,364,365,levels,preferences=preferences
,areamap=areamap,areaparms=checkarea,filters=filters
,maskopt='contour',diagnostics=False,pprint=True)

This error is repeated if I only choose one timestep from my dataset and use the same configuration as the How_TrakcEddy_Works script.

I have tried to look into the function script in order to see the possible mistake from my side, however, I have not found the reason.

Also, I was wondering if there is any function that calculates EKE, TEKE and TRKE and TRKEc since I am mostly interested in these variables.

Kind regards, Joan

Reported Bug # 2 : Eddy dictionary

When the eddy dictionary only identifies an eddy for a particular timestep it removes a dimension.
The data should always look like:
array([[0],[1]])
however, if the eddy is only identified in one time step it produces:
array([0]).
This produces issues and exceptions when saving the data into NetCDF or hdf5 formats, as well as when handling the data.

Identify Eddies

Hi!

For TrackEddy,I don't know if I need to expand the vortex recognition results in order to ensure the correctness of the boundary value.If so, what are your recommended values for indenting for a region of 12°×12°? Thanks for your reply!

init.py not found

Hello,

I have been getting myself familiar with the structure of trackeddy and I still do not understand if I have to create the init.py file myself, or if it should be included in the trackeddy repository.

Also, has any of you also encountered the "clock" problem while running the examples?

kind regards, Joan

Question in eddy dicts

Hello, Prof !
I am new in eddy detection and I have some questions about eddy dicts.

1.The key of '2dgaussianfit' & ’area‘ both have three rows. What does each column mean?
2.The key of 'majoraxis' has two rows. What does each column mean?

If possible ,could you please release a variable user manual? Thanks for your reply!

positive_eddies=analyseddyzt(ssha[:,:,:],lon,lat,0,31,1,levels,preferences=preferences ,areamap=areamap,areaparms=checkarea,filters=filters ,maskopt='contour',diagnostics=False,pprint=True)

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.