Re: mask

From: Mary Haley (haley AT XXXXXX)
Date: Thu Aug 02 2001 - 14:47:21 MDT

  • Next message: Matt Fearon: "plotting wind vectors (v and w components) in height longitude x-sections"

    > Hi:
    >
    > A quick question about how to mask a 3d field (lat,lon,time) against a =
    > 2d field (lat,lon) without looping through each and every time element =
    > (I have 756 time periods).
    > At the moment my code loops through the 756 time periods and takes =
    > forever to complete.
    >
    > I have tried to use the following code with to no avail...
    >
    > sst3d = mask(data3d,(data2d.ne.0),True)
    >
    > I receive an error saying that parameters don't have the same dimension
    > size.
    >
    > Thanks for your suggestions!
    >
    > Maurice
    >

    Hi Maurice,

    The first input array ("data3d" in this case) must be a superset of
    the second input array ("data2d"). In the case of the mask function,
    this means that the dimensions of "data2d" must be equal to the
    rightmost dimensions of "data3d".

    You said that data3d was dimensioned (lat,lon,time) and data2d is
    (lat,lon), so data2d's dimensions are actually equal to the *leftmost*
    dimensions of data3d.

    To fix this, you need to swap the dimensions of data3d by first naming
    the dimensions of data3d, and then reordering them as follows:

         data3d!0 = "lat"
         data3d!1 = "lon"
         data3d!2 = "time"
         ...
         sst3d = mask(data3d(time|:,lat|:,lon|:),(data2d.ne.0),True)

    --Mary



    This archive was generated by hypermail 2b29 : Thu Aug 02 2001 - 14:48:04 MDT