[Numpy-discussion] Array as Variable using "from cdms2 import MV2 as MV"

dileep kunjaai dileepkunjaai at gmail.com
Mon Apr 25 05:36:45 EDT 2011


Thank you sir .......thanks a lot
                                                      Keep in touch




On Mon, Apr 25, 2011 at 12:47 PM, <josef.pktd at gmail.com> wrote:

> On Mon, Apr 25, 2011 at 2:50 AM, dileep kunjaai <dileepkunjaai at gmail.com>
> wrote:
> > Dear sir,
> >
> >      I am have 2  mxn numpy array say "obs" & "fcst". I have to
> > calculate     sum of squre of (obs[i, j]-fcst[i, j]) using     from cdms2
> > import MV2 as MV   in CDAT without using "for"  loop.
> >
> > For example:
> > obs=
> > [0.6    1.1    0.02    0.2   0.2
> > 0.8    0.    0.    0.4   0.8
> > 0.5    5.5    1.5    0.5   1.5
> > 3.5    0.5    1.5    5.0   2.6
> > 5.1    4.1    3.2    2.3   1.5
> > 4.4    0.9    1.5    2.    2.3
> > 1.1    1.1    1.5    12.6  1.3
> > 2.2    12    1.7    1.6   15
> > 1.9    1.5    0.9    2.5   5.5 ]
> >
> >
> >
> > fcst=
> >
> > [0.7    0.1    0.2    0.2   0.2
> > 0.3    0.8    0.    0.    0.
> > 0.5    0.5    0.5    0.5   0.5
> > 0.7    1.     1.5    2.    2.6
> > 5.1    4.1    3.2    2.3   1.5
> > 0.7    1.    1.5    2.    2.3
> > 1.1    1.1    1.1    12.7  1.3
> > 2.2    2.    1.7    1.6   1.5
> > 1.9    1.5    0.9    0.5   7.5]
> >
> > here "obs" and "fcst" are numpy array
> > I give
> >
> > obs=MV.array(obs)
> > fcst=MV.array(fcst)
> >
> > Then it become
> >
> >
> > sbst=obs-fcst
> >
> >>> subst=
> > [[ -0.1    1.    -0.18   0.     0.  ]
> >  [  0.5   -0.8    0.     0.4    0.8 ]
> >  [  0.     5.     1.     0.     1.  ]
> >  [  2.8   -0.5    0.     3.     0.  ]
> >  [  0.     0.     0.     0.     0.  ]
> >  [  3.7   -0.1    0.     0.     0.  ]
> >  [  0.     0.     0.4   -0.1    0.  ]
> >  [  0.    10.     0.     0.    13.5 ]
> >  [  0.     0.     0.     2.    -2.  ]]
> >
> > But i dont know how to find sum of squre of each term....(Actually my aim
> is
> > to finding MEAN SQUARED ERROR)
>
> (sbst**2).sum()
>
> or with sum along columns
> (sbst**2).sum(0)
>
> explanation is in the documentation
>
> Josef
>
>
> >
> >
> >
> >
> > Thanking you...................
> >
> > --
> > DILEEPKUMAR. R
> > J R F, IIT DELHI
> >
> >
> > _______________________________________________
> > NumPy-Discussion mailing list
> > NumPy-Discussion at scipy.org
> > http://mail.scipy.org/mailman/listinfo/numpy-discussion
> >
> >
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



-- 
DILEEPKUMAR. R
J R F, IIT DELHI
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110425/37d8efb0/attachment.html>


More information about the NumPy-Discussion mailing list