|
From: Alex G. <ale...@co...> - 2014-02-24 01:29:02
|
Hi Fadzil, Ah sorry, I glossed over that part of your question. There are actually two solutions to this, one would be to actually find the indices where the latitudes and longitudes are within your desired bounds using numpy.where(). However I generally prefer to use numpy's built-in fancy indexing for this type of problem. For example: # lat and lon are extracted from the netcdf file, assumed to be 1D # Determine which latitudes are between 20S and 10N latidx = (lat >= -20) & (lat <= 10) # Determine which longitudes are between 130E and 170E. # The numbers here may differ depending on the longitude convention in your data. lonidx = (lon >= 130) & (lon <= 170) # Now we will actually subset the data. We need to subset lat too to make sure weights are consistent. sst = sstv[:] sst = sst[:, latidx][..., lonidx] lat = lat[latidx] Yes, the indexing does get a little tricky but it should work if you do it this way, then follow the same procedure outlined in the previous email. Thanks, Alex On Sun, Feb 23, 2014 at 6:02 PM, Fadzil Mnor <fad...@gm...> wrote: > Thanks Alex for the reply. > So, that script calculates the global SST. What if when we want to > calculate for only in specific box? For example, SST over this area only: > > ----------------------------------- 10 N > | | > | | > | | > | SST | > | | > | | > ----------------------------------- 20 S > 130 E 170E > > Thanks. > > Fadzil > -- Alex Goodman Graduate Research Assistant Department of Atmospheric Science Colorado State University |