Marjolaine, Getting rid of rows/columns in your case might be a bit tricky, as there's nothing to ensure that your domain is actually square.
First, create your mask: lon_mask = (lon >= min_lon) & (lon <= max_lon) lat_mask = (lat >= min_lat) & (lat <= max_lat) glb_mask = lon_mask & lat_mask glb_mask is 2D, with True where the data is selected and False otherwise. Of course, that'll only work if the initial arrays have the same shape. Now, you can check whether all the rows are False (no data selected) row_clipper = glb_mask.any(axis=1) row_clipper is 1D, with the same length as glb_mask, and False where now data is selectd and True otherwise: we can use row_clipper to select only the rows that have at least one unmasked data: clipped_rows = original_array[row_clipper] Then, rinse and repeat, this time on the columns: col_clipper = glb_mask.any(axis=0) clipped_cols = clipped_rows.T[col_clipper].T Note the double .T. You can also decide to use .all instead of any, to select the rows/cols where all data are valid. Let us know how it works. P. On Friday 12 September 2008 10:02:56 Marjolaine Rouault wrote: > Hi, > > I was wondering if the matplotlib users would be able to help with a numpy > problem. > > I have 2 dimensional arrays of latitudes and longitude named lon and lat > and only want to extract lats and lons within a certain domain > It is easy to apply the mask > > lonMask = (lon >= minLon) & (lon <= maxLon) > latMask = (lat >= minLat) & (lat <= maxLat) > > MyNewArray = putmask(originalArray,lonMask*latMask) > > But I am not sure how to clip rows and column of mask data to reduce size > of resulting array. > > The compress, extract etc functions all seem to work with 1D arrays and I > don;t know how to get from my 1D array back to a 2D array. > > I hope this is making sense. > > Marjolaine. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users