|  | 
| 39 | 39 | import matplotlib.dates as dt | 
| 40 | 40 | import matplotlib.path as path | 
| 41 | 41 | import matplotlib.patches as patch | 
| 42 |  | - | 
|  | 42 | +import mpl_toolkits.basemap.pyproj as pyproj | 
| 43 | 43 | import make_eddy_tracker_list_obj as eddy_tracker | 
| 44 | 44 | from py_eddy_tracker_property_classes import Amplitude, EddyProperty, interpolate | 
| 45 |  | -#import haversine_distmat as hav # needs compiling with f2py | 
| 46 | 45 | from haversine import haversine # needs compiling with f2py | 
| 47 | 46 | 
 | 
|  | 47 | + | 
| 48 | 48 | def datestr2datetime(datestr): | 
| 49 | 49 |     """ | 
| 50 | 50 |     Take strings with format YYYYMMDD and convert to datetime instance | 
| @@ -414,6 +414,7 @@ def get_uavg(Eddy, CS, collind, centlon_e, centlat_e, poly_eff, | 
| 414 | 414 | 
 | 
| 415 | 415 |     theseglon, theseglat = eddy_tracker.uniform_resample( | 
| 416 | 416 |         theseglon, theseglat, method='akima') | 
|  | 417 | +     | 
| 417 | 418 |     if 'RectBivariate' in Eddy.INTERP_METHOD: | 
| 418 | 419 |         uavg = Eddy.uspd_coeffs.ev(theseglat[1:], theseglon[1:]).mean() | 
| 419 | 420 | 
 | 
| @@ -499,9 +500,14 @@ def get_uavg(Eddy, CS, collind, centlon_e, centlat_e, poly_eff, | 
| 499 | 500 |         citer.iternext() | 
| 500 | 501 | 
 | 
| 501 | 502 |     if any_inner_contours:  # set speed based contour parameters | 
| 502 |  | -        cx, cy = Eddy.M(theseglon, theseglat) | 
|  | 503 | +        proj = pyproj.Proj('+proj=aeqd +lat_0=%s +lon_0=%s' | 
|  | 504 | +                           % (theseglat.mean(), theseglon.mean())) | 
|  | 505 | +        cx, cy = proj(theseglon, theseglat) | 
|  | 506 | +        #cx, cy = Eddy.M(theseglon, theseglat) | 
| 503 | 507 |         centx_s, centy_s, eddy_radius_s, junk = fit_circle(cx, cy) | 
| 504 |  | -        centlon_s, centlat_s = Eddy.M.projtran(centx_s, centy_s, inverse=True) | 
|  | 508 | +        centlon_s, centlat_s = proj(centx_s, centy_s, inverse=True) | 
|  | 509 | +        #print 'fffffffffff', centlon_s, centlat_s | 
|  | 510 | +        #centlon_s, centlat_s = Eddy.M.projtran(centx_s, centy_s, inverse=True) | 
| 505 | 511 | 
 | 
| 506 | 512 |     else:  # use the effective contour | 
| 507 | 513 |         centlon_s, centlat_s = centlon_e, centlat_e | 
| @@ -565,18 +571,35 @@ def collection_loop(CS, grd, rtime, A_list_obj, C_list_obj, | 
| 565 | 571 |                 properties = EddyProperty() | 
| 566 | 572 | 
 | 
| 567 | 573 |                 # Prepare for shape test and get eddy_radius_e | 
| 568 |  | -                cx, cy = Eddy.M(contlon_e, contlat_e) | 
|  | 574 | +                #cx, cy = Eddy.M(contlon_e, contlat_e) | 
|  | 575 | +                 | 
|  | 576 | +                ##################0 | 
|  | 577 | +                #proj = pyproj.Proj(proj='aeqd', lat_0=contlat_e.mean(), lon_0=contlon_e.mean())#, width=5.e2, height=5.e2) | 
|  | 578 | +                # http://www.geo.hunter.cuny.edu/~jochen/gtech201/lectures/lec6concepts/map%20coordinate%20systems/how%20to%20choose%20a%20projection.htm | 
|  | 579 | +                proj = pyproj.Proj('+proj=aeqd +lat_0=%s +lon_0=%s' | 
|  | 580 | +                                   % (contlat_e.mean(), contlon_e.mean())) | 
|  | 581 | +                cx, cy = proj(contlon_e, contlat_e) | 
| 569 | 582 |                 centlon_e, centlat_e, eddy_radius_e, aerr = fit_circle(cx, cy) | 
| 570 |  | - | 
|  | 583 | +                #print centlon_e, centlat_e, eddy_radius_e, aerr | 
|  | 584 | +                #print cxx, cyy | 
|  | 585 | +                ##################0 | 
|  | 586 | +                 | 
|  | 587 | +                #centlon_e, centlat_e, eddy_radius_e, aerr = fit_circle(cx, cy) | 
|  | 588 | +                #print centlon_e, centlat_e, eddy_radius_e, aerr | 
|  | 589 | +                #print cx, cy | 
|  | 590 | +                #print '-----------------------------------------------------' | 
|  | 591 | +                #aaaaaaaaaaaaaaaaa | 
|  | 592 | +                 | 
| 571 | 593 |                 aerr = np.atleast_1d(aerr) | 
| 572 | 594 | 
 | 
| 573 | 595 |                 # Filter for shape: >35% (>55%) is not an eddy for Q (SLA) | 
| 574 | 596 |                 if aerr >= 0. and aerr <= Eddy.SHAPE_ERROR[collind]: | 
| 575 | 597 | 
 | 
| 576 | 598 |                     # Get centroid in lon lat | 
| 577 |  | -                    centlon_e, centlat_e = Eddy.M.projtran(centlon_e, | 
| 578 |  | -                                                           centlat_e, | 
| 579 |  | -                                                           inverse=True) | 
|  | 599 | +                    centlon_e, centlat_e = proj(centlon_e, centlat_e, inverse=True) | 
|  | 600 | +                    #centlon_e, centlat_e = Eddy.M.projtran(centlon_e, | 
|  | 601 | +                                                           #centlat_e, | 
|  | 602 | +                                                           #inverse=True) | 
| 580 | 603 | 
 | 
| 581 | 604 |                     # For some reason centlat_e is transformed | 
| 582 | 605 |                     # by projtran to 'float'... | 
| @@ -648,8 +671,10 @@ def collection_loop(CS, grd, rtime, A_list_obj, C_list_obj, | 
| 648 | 671 |                             centx, centy = Eddy.M(centlon_e, centlat_e) | 
| 649 | 672 |                             circlon, circlat = get_circle(centx, centy, | 
| 650 | 673 |                                                           eddy_radius_e, 180) | 
| 651 |  | -                            circlon[:], circlat[:] = Eddy.M.projtran( | 
| 652 |  | -                                circlon, circlat, inverse=True) | 
|  | 674 | +                            #circlon[:], circlat[:] = Eddy.M.projtran( | 
|  | 675 | +                                #circlon, circlat, inverse=True) | 
|  | 676 | +                            circlon[:], circlat[:] = proj(circlon, circlat, | 
|  | 677 | +                                                          inverse=True) | 
| 653 | 678 |                             Eddy.circlon, Eddy.circlat = circlon, circlat | 
| 654 | 679 | 
 | 
| 655 | 680 |                             # Set masked points within bounding box around eddy | 
|  | 
0 commit comments