Changeset 4037 for anuga_core/source/anuga/shallow_water/data_manager.py
- Timestamp:
- Nov 28, 2006, 11:54:54 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/data_manager.py
r4031 r4037 64 64 65 65 from Numeric import concatenate, array, Float, Int, Int32, resize, sometrue, \ 66 searchsorted, zeros, allclose, around, reshape, transpose 66 searchsorted, zeros, allclose, around, reshape, transpose, sort 67 67 from Scientific.IO.NetCDF import NetCDFFile 68 68 … … 2686 2686 jmax = searchsorted(times, maxt) 2687 2687 2688 #print "latitudes[:]",latitudes[:] 2689 #print "longitudes[:]",longitudes [:] 2688 2690 kmin, kmax, lmin, lmax = _get_min_max_indexes(latitudes[:], 2689 2691 longitudes[:], … … 2697 2699 longitudes = longitudes[lmin:lmax] 2698 2700 2701 #print "latitudes[:]",latitudes[:] 2702 #print "longitudes[:]",longitudes [:] 2699 2703 2700 2704 if verbose: print 'cropping' … … 3889 3893 outfile.close() 3890 3894 3891 def _get_min_max_indexes(latitudes ,longitudes,3895 def _get_min_max_indexes(latitudes_ref,longitudes_ref, 3892 3896 minlat=None, maxlat=None, 3893 3897 minlon=None, maxlon=None): … … 3901 3905 has a section outside of the latitudes/longitudes area.) 3902 3906 3903 ass ume latitudess &longitudes are sorted,3907 asset longitudes are sorted, 3904 3908 long - from low to high (west to east, eg 148 - 151) 3905 lat - from high to low (north to south, eg -35 - -38) 3906 """ 3907 3908 # reverse order of lat, so it's in ascending order 3909 try: 3910 latitudes = latitudes.tolist() 3911 except: 3912 pass 3909 assert latitudes are sorted, ascending or decending 3910 """ 3911 latitudes = latitudes_ref[:] 3912 longitudes = longitudes_ref[:] 3913 3914 latitudes = ensure_numeric(latitudes) 3915 longitudes = ensure_numeric(longitudes) 3913 3916 3914 latitudes.reverse() 3917 assert allclose(sort(longitudes), longitudes) 3918 3919 lat_ascending = True 3920 if not allclose(sort(latitudes), latitudes): 3921 lat_ascending = False 3922 # reverse order of lat, so it's in ascending order 3923 latitudes = latitudes[::-1] 3924 assert allclose(sort(latitudes), latitudes) 3925 #print "latitudes in funct", latitudes 3915 3926 3916 3927 largest_lat_index = len(latitudes)-1 … … 3943 3954 lon_max_index = searchsorted(longitudes, maxlon) 3944 3955 3945 # Take into account that the latitude list was reversed3946 latitudes.reverse() # Python passes by reference, need to swap back3947 lat_min_index, lat_max_index = largest_lat_index - lat_max_index , \3948 largest_lat_index - lat_min_index3956 # Reversing the indexes, if the lat array is decending 3957 if lat_ascending is False: 3958 lat_min_index, lat_max_index = largest_lat_index - lat_max_index , \ 3959 largest_lat_index - lat_min_index 3949 3960 lat_max_index = lat_max_index + 1 # taking into account how slicing works 3950 3961 lon_max_index = lon_max_index + 1 # taking into account how slicing works
Note: See TracChangeset
for help on using the changeset viewer.